From 52f245b47b7cce14673449791fa9ce69a45f74fb Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Tue, 6 Aug 2024 02:55:36 +1200 Subject: [PATCH] Regenerate dangling_indices namespace (#1124) * Rename genericArgs to typeParams Signed-off-by: Thomas Farr * Fix required path param handling Signed-off-by: Thomas Farr * Correctly generate AcknowledgedResponseBase Signed-off-by: Thomas Farr * Generate DeleteDanglingIndexRequest Signed-off-by: Thomas Farr * Correctly generate DeleteDanglingIndexResponse Signed-off-by: Thomas Farr * Generate import_dangling_index Signed-off-by: Thomas Farr * Generate ListDanglingIndicesRequest Signed-off-by: Thomas Farr * Generate ErrorCause Signed-off-by: Thomas Farr * Generate NodeStatistics Signed-off-by: Thomas Farr * Generate DanglingIndex Signed-off-by: Thomas Farr * Generate ListDanglingIndicesResponse Signed-off-by: Thomas Farr * Generate DanglingIndicesClient Signed-off-by: Thomas Farr * Fixes Signed-off-by: Thomas Farr * Changelog and Upgrading Signed-off-by: Thomas Farr * Fix javadoc Signed-off-by: Thomas Farr * Fix tests Signed-off-by: Thomas Farr --------- Signed-off-by: Thomas Farr (cherry picked from commit 324f90afa78fd4684d6a4589f4d8a17f0083d781) --- java-codegen/opensearch-openapi.yaml | 664 +++++++++++++++--- .../client/codegen/model/ArrayShape.java | 2 +- .../client/codegen/model/Field.java | 13 + .../client/codegen/model/HttpPath.java | 4 +- .../client/codegen/model/Namespace.java | 10 +- .../client/codegen/model/ObjectShape.java | 12 +- .../client/codegen/model/RequestShape.java | 9 + .../client/codegen/model/Shape.java | 4 + .../client/codegen/model/SpecTransformer.java | 32 +- .../codegen/model/TaggedUnionShape.java | 2 +- .../opensearch/client/codegen/model/Type.java | 32 +- .../client/codegen/model/Types.java | 20 +- .../codegen/openapi/OpenApiRefElement.java | 5 + .../client/codegen/openapi/OpenApiSchema.java | 98 ++- .../codegen/templates/ObjectShape.mustache | 2 + .../templates/ObjectShape/Builder.mustache | 59 +- .../ObjectShape/Constructor.mustache | 12 +- .../ObjectShape/Deserialize.mustache | 10 +- .../ObjectShape/FieldDoc/BasicInner.mustache | 7 +- .../ObjectShape/FieldDoc/ListAdd.mustache | 1 + .../ObjectShape/FieldDoc/ListAddAll.mustache | 1 + .../FieldDoc/ListAddBuilderFn.mustache | 1 + .../templates/ObjectShape/Serialize.mustache | 2 + .../Partials/ClassDeclaration.mustache | 2 +- .../codegen/templates/RequestShape.mustache | 8 +- .../templates/Type/deserializer.mustache | 6 +- 26 files changed, 835 insertions(+), 183 deletions(-) diff --git a/java-codegen/opensearch-openapi.yaml b/java-codegen/opensearch-openapi.yaml index 43c7dd003c..fb5695388c 100644 --- a/java-codegen/opensearch-openapi.yaml +++ b/java-codegen/opensearch-openapi.yaml @@ -64,7 +64,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::query.cluster_manager_timeout' - $ref: '#/components/parameters/indices.put_alias::query.master_timeout' @@ -128,7 +128,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::path.name' - $ref: '#/components/parameters/indices.put_alias::query.cluster_manager_timeout' @@ -150,7 +150,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::path.name' - $ref: '#/components/parameters/indices.put_alias::query.cluster_manager_timeout' @@ -173,7 +173,7 @@ paths: x-version-added: '1.0' description: Updates index aliases. externalDocs: - url: https://opensearch.org/docs/latest/api-reference/alias/ + url: https://opensearch.org/docs/latest/api-reference/index-apis/alias/ parameters: - $ref: '#/components/parameters/indices.update_aliases::query.cluster_manager_timeout' - $ref: '#/components/parameters/indices.update_aliases::query.master_timeout' @@ -195,7 +195,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::path.name' - $ref: '#/components/parameters/indices.put_alias::query.cluster_manager_timeout' @@ -217,7 +217,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::path.name' - $ref: '#/components/parameters/indices.put_alias::query.cluster_manager_timeout' @@ -5626,6 +5626,108 @@ paths: - $ref: '#/components/parameters/_global::query.error_trace' - $ref: '#/components/parameters/_global::query.source' - $ref: '#/components/parameters/_global::query.filter_path' + /_plugins/_sql: + post: + operationId: sql.query.0 + x-operation-group: sql.query + x-version-added: '1.0' + description: Send a SQL/PPL query to the SQL plugin. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/sql-ppl-api/ + parameters: + - $ref: '#/components/parameters/sql.query::query.format' + - $ref: '#/components/parameters/sql.query::query.sanitize' + - $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/sql.query' + responses: + '200': + $ref: '#/components/responses/sql.query@200' + /_plugins/_sql/_explain: + post: + operationId: sql.explain.0 + x-operation-group: sql.explain + x-version-added: '1.0' + description: Shows how a query is executed against OpenSearch. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/sql-ppl-api/ + parameters: + - $ref: '#/components/parameters/sql.explain::query.format' + - $ref: '#/components/parameters/sql.explain::query.sanitize' + - $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/sql.explain' + responses: + '200': + $ref: '#/components/responses/sql.explain@200' + /_plugins/_sql/close: + post: + operationId: sql.close.0 + x-operation-group: sql.close + x-version-added: '1.0' + description: Clear the cursor context. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/sql-ppl-api/ + parameters: + - $ref: '#/components/parameters/sql.close::query.format' + - $ref: '#/components/parameters/sql.close::query.sanitize' + - $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/sql.close' + responses: + '200': + $ref: '#/components/responses/sql.close@200' + /_plugins/_sql/stats: + get: + operationId: sql.get_stats.0 + x-operation-group: sql.get_stats + x-version-added: '1.0' + description: Collect metrics for the plugin within the interval. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/monitoring/ + parameters: + - $ref: '#/components/parameters/sql.get_stats::query.format' + - $ref: '#/components/parameters/sql.get_stats::query.sanitize' + - $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/sql.get_stats@200' + post: + operationId: sql.post_stats.1 + x-operation-group: sql.post_stats + x-version-added: '1.0' + description: By a stats endpoint, you are able to collect metrics for the plugin within the interval. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/monitoring/ + parameters: + - $ref: '#/components/parameters/sql.post_stats::query.format' + - $ref: '#/components/parameters/sql.post_stats::query.sanitize' + - $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/sql.post_stats' + responses: + '200': + $ref: '#/components/responses/sql.post_stats@200' /_plugins/_transform: get: operationId: transforms.search.0 @@ -7796,7 +7898,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::path.index' - $ref: '#/components/parameters/indices.put_alias::query.cluster_manager_timeout' @@ -7884,7 +7986,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::path.index' - $ref: '#/components/parameters/indices.put_alias::path.name' @@ -7907,7 +8009,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::path.index' - $ref: '#/components/parameters/indices.put_alias::path.name' @@ -7931,7 +8033,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::path.index' - $ref: '#/components/parameters/indices.put_alias::query.cluster_manager_timeout' @@ -7975,7 +8077,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::path.index' - $ref: '#/components/parameters/indices.put_alias::path.name' @@ -7998,7 +8100,7 @@ paths: x-version-added: '1.0' description: Creates or updates an alias. externalDocs: - url: https://opensearch.org/docs/latest/im-plugin/index-alias/#create-aliases + url: https://opensearch.org/docs/latest/api-reference/index-apis/update-alias/ parameters: - $ref: '#/components/parameters/indices.put_alias::path.index' - $ref: '#/components/parameters/indices.put_alias::path.name' @@ -11603,6 +11705,118 @@ paths: - $ref: '#/components/parameters/_global::query.filter_path' deprecated: true x-ignorable: true + /_opendistro/_sql: + post: + operationId: sql.query.0_superseded + x-operation-group: sql.query + x-version-added: '1.0' + description: Send a SQL/PPL query to the SQL plugin. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/sql-ppl-api/ + parameters: + - $ref: '#/components/parameters/sql.query::query.format' + - $ref: '#/components/parameters/sql.query::query.sanitize' + - $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/sql.query' + responses: + '200': + $ref: '#/components/responses/sql.query@200' + deprecated: true + x-ignorable: true + /_opendistro/_sql/_explain: + post: + operationId: sql.explain.0_superseded + x-operation-group: sql.explain + x-version-added: '1.0' + description: Shows how a query is executed against OpenSearch. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/sql-ppl-api/ + parameters: + - $ref: '#/components/parameters/sql.explain::query.format' + - $ref: '#/components/parameters/sql.explain::query.sanitize' + - $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/sql.explain' + responses: + '200': + $ref: '#/components/responses/sql.explain@200' + deprecated: true + x-ignorable: true + /_opendistro/_sql/close: + post: + operationId: sql.close.0_superseded + x-operation-group: sql.close + x-version-added: '1.0' + description: Clear the cursor context. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/sql-ppl-api/ + parameters: + - $ref: '#/components/parameters/sql.close::query.format' + - $ref: '#/components/parameters/sql.close::query.sanitize' + - $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/sql.close' + responses: + '200': + $ref: '#/components/responses/sql.close@200' + deprecated: true + x-ignorable: true + /_opendistro/_sql/stats: + get: + operationId: sql.get_stats.0_superseded + x-operation-group: sql.get_stats + x-version-added: '1.0' + description: Collect metrics for the plugin within the interval. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/monitoring/ + parameters: + - $ref: '#/components/parameters/sql.get_stats::query.format' + - $ref: '#/components/parameters/sql.get_stats::query.sanitize' + - $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/sql.get_stats@200' + deprecated: true + x-ignorable: true + post: + operationId: sql.post_stats.1_superseded + x-operation-group: sql.post_stats + x-version-added: '1.0' + description: By a stats endpoint, you are able to collect metrics for the plugin within the interval. + externalDocs: + url: https://opensearch.org/docs/latest/search-plugins/sql/monitoring/ + parameters: + - $ref: '#/components/parameters/sql.post_stats::query.format' + - $ref: '#/components/parameters/sql.post_stats::query.sanitize' + - $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/sql.post_stats' + responses: + '200': + $ref: '#/components/responses/sql.post_stats@200' + deprecated: true + x-ignorable: true components: parameters: _global::query.pretty: @@ -21070,6 +21284,81 @@ components: schema: $ref: '#/components/schemas/_common:Duration' style: form + sql.close::query.format: + name: format + in: query + description: A short version of the Accept header, e.g. json, yaml. + schema: + type: string + description: A short version of the Accept header, e.g. json, yaml. + sql.close::query.sanitize: + name: sanitize + in: query + description: Specifies whether to escape special characters in the results + schema: + type: boolean + default: true + description: Specifies whether to escape special characters in the results + sql.explain::query.format: + name: format + in: query + description: A short version of the Accept header, e.g. json, yaml. + schema: + type: string + description: A short version of the Accept header, e.g. json, yaml. + sql.explain::query.sanitize: + name: sanitize + in: query + description: Specifies whether to escape special characters in the results + schema: + type: boolean + default: true + description: Specifies whether to escape special characters in the results + sql.get_stats::query.format: + name: format + in: query + description: A short version of the Accept header, e.g. json, yaml. + schema: + type: string + description: A short version of the Accept header, e.g. json, yaml. + sql.get_stats::query.sanitize: + name: sanitize + in: query + description: Specifies whether to escape special characters in the results + schema: + type: boolean + default: true + description: Specifies whether to escape special characters in the results + sql.post_stats::query.format: + name: format + in: query + description: A short version of the Accept header, e.g. json, yaml. + schema: + type: string + description: A short version of the Accept header, e.g. json, yaml. + sql.post_stats::query.sanitize: + name: sanitize + in: query + description: Specifies whether to escape special characters in the results + schema: + type: boolean + default: true + description: Specifies whether to escape special characters in the results + sql.query::query.format: + name: format + in: query + description: A short version of the Accept header, e.g. json, yaml. + schema: + type: string + description: A short version of the Accept header, e.g. json, yaml. + sql.query::query.sanitize: + name: sanitize + in: query + description: Specifies whether to escape special characters in the results + schema: + type: boolean + default: true + description: Specifies whether to escape special characters in the results tasks.cancel::path.task_id: in: path name: task_id @@ -22521,18 +22810,7 @@ components: ml.search_models: content: application/json: - schema: - type: object - properties: - query: - type: object - description: The query. - size: - type: integer - description: The number of models to return. - required: - - query - - size + $ref: '#/components/schemas/ml._common:SearchModelsQuery' msearch: content: application/x-ndjson: @@ -23212,6 +23490,30 @@ components: rename_replacement: type: string description: Details of what to restore + sql.close: + content: + application/json: + schema: + $ref: '#/components/schemas/sql._common:SqlClose' + required: true + sql.explain: + content: + application/json: + schema: + $ref: '#/components/schemas/sql._common:SqlExplain' + required: true + sql.post_stats: + content: + application/json: + schema: + $ref: '#/components/schemas/sql._common:SqlStats' + required: true + sql.query: + content: + application/json: + schema: + $ref: '#/components/schemas/sql._common:SqlQuery' + required: true termvectors: content: application/json: @@ -24699,106 +25001,31 @@ components: ml.delete_model_group@200: content: application/json: - schema: - type: object + $ref: '#/components/schemas/ml._common:ModelGroup' ml.delete_model@200: content: application/json: - schema: - type: object + $ref: '#/components/schemas/ml._common:ModelGroup' ml.get_model_group@200: content: application/json: - schema: - type: object - properties: - name: - type: string - description: The model group name. - latest_version: - type: number - description: The latest version. - description: - type: string - description: The model group description. - access: - type: string - description: The model group access. - created_time: - type: integer - format: int64 - last_updated_time: - type: integer - format: int64 - required: - - access - - description - - latest_version - - name + $ref: '#/components/schemas/ml._common:ModelGroup' ml.get_task@200: content: application/json: - schema: - type: object - properties: - model_id: - type: string - description: The model ID. - state: - type: string - description: The state. - enum: - - CANCELLED - - COMPLETED - - COMPLETED_WITH_ERROR - - CREATED - - FAILED - - RUNNING - required: - - state + $ref: '#/components/schemas/ml._common:Task' ml.register_model_group@200: content: application/json: - schema: - type: object - properties: - model_group_id: - type: string - description: The model group ID. - status: - type: string - description: The status. - required: - - model_group_id - - status + $ref: '#/components/schemas/ml._common:ModelGroupRegistration' ml.register_model@200: content: application/json: - schema: - type: object - properties: - task_id: - type: string - description: The task ID. - model_id: - type: string - description: The model ID. - status: - type: string - description: The status. - required: - - status - - task_id + $ref: '#/components/schemas/ml._common:Task' ml.search_models@200: content: application/json: - schema: - type: object - properties: - hits: - $ref: '#/components/schemas/ml._common:SearchModelHits' - required: - - hits + $ref: '#/components/schemas/ml._common:SearchModelsResponse' msearch_template@200: description: '' content: @@ -25965,6 +26192,36 @@ components: $ref: '#/components/schemas/snapshot.verify_repository:CompactNodeInfo' required: - nodes + sql.close@200: + content: + application/json: + schema: + $ref: '#/components/schemas/sql._common:SqlCloseResponse' + required: true + sql.explain@200: + content: + application/json: + schema: + $ref: '#/components/schemas/sql._common:SqlExplainResponse' + required: true + sql.get_stats@200: + content: + text/plain: + schema: + type: string + required: true + sql.post_stats@200: + content: + text/plain: + schema: + type: string + required: true + sql.query@200: + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/sql._common:SqlQueryResponse' tasks.cancel@200: description: '' content: @@ -26449,6 +26706,9 @@ components: $ref: '#/components/schemas/_common:ErrorCause' required: - type + additionalProperties: + title: metadata + description: Additional details about the error _common:ErrorResponseBase: type: object properties: @@ -27531,8 +27791,7 @@ components: Specifies any named parameters that are passed into the script as variables. Use parameters instead of hard-coded values to decrease compile time. type: object - additionalProperties: - type: object + additionalProperties: true _common:ScriptField: type: object properties: @@ -28097,6 +28356,7 @@ components: _common:UnitMillis: description: Time unit for milliseconds type: number + format: int64 _common:UnitNanos: description: Time unit for nanoseconds type: number @@ -33841,8 +34101,8 @@ components: type: string enum: - 'false' - - runtime - strict + - strict_allow_templates - 'true' _common.mapping:DynamicProperty: allOf: @@ -36106,7 +36366,9 @@ components: To return a document, the query term must exactly match the queried field's value, including whitespace and capitalization. type: object additionalProperties: - $ref: '#/components/schemas/_common.query_dsl:TermQuery' + anyOf: + - $ref: '#/components/schemas/_common.query_dsl:TermQuery' + - $ref: '#/components/schemas/_common:FieldValue' minProperties: 1 maxProperties: 1 terms: @@ -41704,6 +41966,8 @@ components: type: string index_uuid: type: string + creation_date: + $ref: '#/components/schemas/_common:DateTime' creation_date_millis: $ref: '#/components/schemas/_common:EpochTimeUnitMillis' node_ids: @@ -44738,7 +45002,45 @@ components: required: - relation - value - ml._common:SearchModelHits: + ml._common:ModelGroup: + type: object + properties: + name: + type: string + description: The model group name. + latest_version: + type: number + description: The latest version. + description: + type: string + description: The model group description. + access: + type: string + description: The model group access. + created_time: + type: integer + format: int64 + last_updated_time: + type: integer + format: int64 + required: + - access + - description + - latest_version + - name + ml._common:ModelGroupRegistration: + type: object + properties: + model_group_id: + type: string + description: The model group ID. + status: + type: string + description: The status. + required: + - model_group_id + - status + ml._common:SearchModelsHits: type: object properties: total: @@ -44746,11 +45048,11 @@ components: hits: type: array items: - $ref: '#/components/schemas/ml._common:SearchModelHitsHit' + $ref: '#/components/schemas/ml._common:SearchModelsHitsHit' required: - hits - total - ml._common:SearchModelHitsHit: + ml._common:SearchModelsHitsHit: type: object properties: _index: @@ -44765,6 +45067,62 @@ components: required: - _id - model_id + ml._common:SearchModelsQuery: + type: object + properties: + query: + type: object + description: The query. + size: + type: integer + description: The number of models to return. + required: + - query + - size + ml._common:SearchModelsResponse: + type: object + properties: + hits: + $ref: '#/components/schemas/ml._common:SearchModelsHits' + required: + - hits + ml._common:Task: + type: object + properties: + model_id: + type: string + description: The model ID. + state: + type: string + description: The state. + enum: + - CANCELLED + - COMPLETED + - COMPLETED_WITH_ERROR + - CREATED + - FAILED + - RUNNING + task_type: + type: string + description: Task type. + enum: + - DEPLOY_MODEL + function_name: + type: string + worker_node: + type: array + items: + $ref: '#/components/schemas/_common:NodeIds' + create_time: + type: integer + format: int64 + last_update_time: + type: integer + format: int64 + is_async: + type: boolean + required: + - state nodes._common:AdaptiveSelection: type: object properties: @@ -48503,6 +48861,86 @@ components: $ref: '#/components/schemas/_common:Name' required: - name + sql._common:Explain: + type: object + properties: + name: + type: string + description: + type: object + children: + type: array + items: + $ref: '#/components/schemas/sql._common:Explain' + sql._common:SqlClose: + type: object + properties: + cursor: + type: string + sql._common:SqlCloseResponse: + type: object + properties: + succeeded: + type: boolean + sql._common:SqlExplain: + type: object + properties: + query: + type: string + filter: + type: object + fetch_size: + type: integer + sql._common:SqlExplainResponse: + type: object + properties: + root: + $ref: '#/components/schemas/sql._common:Explain' + sql._common:SqlQuery: + type: object + properties: + query: + type: string + filter: + type: object + fetch_size: + type: integer + sql._common:SqlQueryResponse: + type: object + properties: + schema: + type: array + items: + type: object + datarows: + type: array + items: + type: array + cursor: + type: string + total: + type: integer + size: + type: integer + status: + type: integer + sql._common:SqlStats: + type: object + properties: + start_time: + type: string + end_time: + type: object + cluster_name: + type: object + index: + type: object + query: + type: object + user: + type: object + execution_time: + type: object tasks._common:GroupBy: type: string enum: diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ArrayShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ArrayShape.java index 97540564eb..d04f66f6f7 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ArrayShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ArrayShape.java @@ -31,7 +31,7 @@ public Collection getAnnotations() { @Override public Collection getImplementsTypes() { - return List.of(Types.Client.Json.JsonpSerializable); + return List.of(Types.Client.Json.PlainJsonSerializable); } public Field getValueBodyField() { diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java index f2a95028d4..e4d1734572 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/Field.java @@ -24,6 +24,7 @@ public class Field { private final String description; @Nullable private final Deprecation deprecation; + private final boolean isAdditionalProperties; public Field( @Nonnull String wireName, @@ -31,12 +32,24 @@ public Field( boolean required, @Nullable String description, @Nullable Deprecation deprecation + ) { + this(wireName, type, required, description, deprecation, false); + } + + public Field( + @Nonnull String wireName, + @Nonnull Type type, + boolean required, + @Nullable String description, + @Nullable Deprecation deprecation, + boolean isAdditionalProperties ) { this.wireName = Strings.requireNonBlank(wireName, "wireName must not be null"); this.type = Objects.requireNonNull(type, "type must not be null"); this.required = required; this.description = description; this.deprecation = deprecation; + this.isAdditionalProperties = isAdditionalProperties; } @Nonnull diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/HttpPath.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/HttpPath.java index 8050fc21e6..36573e6e5e 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/HttpPath.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/HttpPath.java @@ -64,8 +64,8 @@ public List getParams() { return Lists.filterMap(parts, Part::isParameter, Part::getParameter); } - public Set getParamNameSet() { - return parts.stream().filter(Part::isParameter).map(p -> p.getParameter().getName()).collect(Collectors.toSet()); + public Set getParamWireNameSet() { + return parts.stream().filter(Part::isParameter).map(p -> p.getParameter().getWireName()).collect(Collectors.toSet()); } public Deprecation getDeprecation() { 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 3398b98583..1f455426a3 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 @@ -16,6 +16,7 @@ import java.util.TreeMap; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import org.apache.commons.lang3.builder.ToStringBuilder; import org.opensearch.client.codegen.exceptions.RenderException; import org.opensearch.client.codegen.utils.Lists; import org.opensearch.client.codegen.utils.Strings; @@ -96,7 +97,7 @@ private String getClientClassName(boolean async, boolean base) { private Type getClientType(boolean async, boolean base) { var type = Type.builder().pkg(getPackageName()).name(getClientClassName(async, base)); if (base) { - type.genericArgs(getClientType(async, false)); + type.typeParams(getClientType(async, false)); } return type.build(); } @@ -106,7 +107,7 @@ private static class Client extends Shape { private final Collection operations; private Client(Namespace parent, boolean async, Collection operations) { - super(parent, parent.getClientClassName(async, false), null, null); + super(parent, parent.getClientClassName(async, false), null, "Client for the " + parent.name + " namespace."); this.async = async; this.operations = operations; } @@ -137,6 +138,11 @@ public boolean isAsync() { return this.async; } + @Override + public String toString() { + return new ToStringBuilder(this).append("type", getType()).toString(); + } + private static class ClientRef { private final Type type; private final String name; diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java index 3dcbd1127a..39bb2e2e86 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/model/ObjectShape.java @@ -56,11 +56,19 @@ public Type getExtendsType() { return extendsType; } + public boolean extendsOtherShape() { + return extendsType != null; + } + + public boolean hasFieldsToSerialize() { + return !bodyFields.isEmpty() || additionalPropertiesField != null; + } + public Collection getImplementsTypes() { - return !bodyFields.isEmpty() ? List.of(Types.Client.Json.JsonpSerializable) : null; + return hasFieldsToSerialize() && !extendsOtherShape() ? List.of(Types.Client.Json.PlainJsonSerializable) : null; } public Collection getAnnotations() { - return !bodyFields.isEmpty() ? List.of(Types.Client.Json.JsonpDeserializable) : null; + return (hasFieldsToSerialize() || extendsOtherShape()) && !isAbstract() ? List.of(Types.Client.Json.JsonpDeserializable) : null; } } 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 b46ef19025..a2625fc7ce 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,6 +50,11 @@ 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 +149,10 @@ public boolean hasAnyRequiredFields() { return fields.values().stream().anyMatch(Field::isRequired); } + public Type getJsonEndpointType() { + return Types.Client.Transport.JsonEndpoint(getType(), getResponseType(), Types.Client.OpenSearch._Types.ErrorResponse); + } + @Nonnull private static String requestClassName(@Nonnull OperationGroup operationGroup) { Objects.requireNonNull(operationGroup, "operationGroup must not be null"); 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 9b24cac8d9..bd20d083c6 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 @@ -45,6 +45,10 @@ public JavaClassKind getClassKind() { return JavaClassKind.Class; } + public boolean isAbstract() { + return this.className.endsWith("Base"); + } + public String getTypedefName() { return this.typedefName; } 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 09f24a35e0..91af05c63f 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 @@ -28,11 +28,13 @@ import org.apache.logging.log4j.Logger; import org.opensearch.client.codegen.openapi.HttpStatusCode; import org.opensearch.client.codegen.openapi.In; +import org.opensearch.client.codegen.openapi.JsonPointer; import org.opensearch.client.codegen.openapi.MimeType; import org.opensearch.client.codegen.openapi.OpenApiMediaType; import org.opensearch.client.codegen.openapi.OpenApiOperation; import org.opensearch.client.codegen.openapi.OpenApiParameter; import org.opensearch.client.codegen.openapi.OpenApiPath; +import org.opensearch.client.codegen.openapi.OpenApiRefElement; import org.opensearch.client.codegen.openapi.OpenApiRequestBody; import org.opensearch.client.codegen.openapi.OpenApiResponse; import org.opensearch.client.codegen.openapi.OpenApiSchema; @@ -104,7 +106,16 @@ private void visit(@Nonnull OperationGroup group, @Nonnull List c.get(MimeType.Json)) .flatMap(OpenApiMediaType::getSchema) - .map(OpenApiSchema::resolve) + .map(s -> { + if (s.get$ref() + .map(OpenApiRefElement.RelativeRef::getPointer) + .flatMap(JsonPointer::getLastKey) + .map("_common:AcknowledgedResponseBase"::equals) + .orElse(false)) { + return OpenApiSchema.builder().withPointer(s.getPointer()).withAllOf(s, OpenApiSchema.ANONYMOUS_OBJECT).build(); + } + return s.resolve(); + }) .orElse(OpenApiSchema.ANONYMOUS_OBJECT); visit(parent, requestShape.getResponseType().getName(), group + ".Response", responseSchema); @@ -139,12 +150,12 @@ private RequestShape visit(@Nonnull Namespace parent, @Nonnull OperationGroup gr var httpPath = HttpPath.from(httpPathStr, variant, allPathParams); - (httpPath.getDeprecation() == null ? canonicalPaths : deprecatedPaths).put(httpPath.getParamNameSet(), httpPath); + (httpPath.getDeprecation() == null ? canonicalPaths : deprecatedPaths).put(httpPath.getParamWireNameSet(), httpPath); if (requiredPathParams != null) { - requiredPathParams.retainAll(httpPath.getParamNameSet()); + requiredPathParams.retainAll(httpPath.getParamWireNameSet()); } else { - requiredPathParams = new HashSet<>(httpPath.getParamNameSet()); + requiredPathParams = new HashSet<>(httpPath.getParamWireNameSet()); } } @@ -277,16 +288,17 @@ private void visitInto(OpenApiSchema schema, ObjectShape shape) { ) ); - var additionalProperties = schema.getAdditionalProperties(); - if (additionalProperties.isPresent()) { - var valueType = mapType(additionalProperties.get()); + var additionalProperties = schema.getAdditionalProperties().orElse(null); + if (additionalProperties != null) { + var valueType = mapType(additionalProperties); shape.setAdditionalPropertiesField( new Field( - "metadata", + additionalProperties.getTitle().orElseThrow(), Types.Java.Util.Map(Types.Java.Lang.String, valueType), false, - additionalProperties.get().getDescription().orElse(null), - null + additionalProperties.getDescription().orElse(null), + null, + true ) ); } 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 85e96761a0..36dc7e2f2a 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 @@ -41,7 +41,7 @@ public Collection getAnnotations() { public Collection getImplementsTypes() { return List.of( Types.Client.Util.TaggedUnion(getType().getNestedType("Kind"), Types.Java.Lang.Object), - Types.Client.Json.JsonpSerializable + Types.Client.Json.PlainJsonSerializable ); } 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 96ef37d344..ca4d27a0a3 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 @@ -45,26 +45,26 @@ public static Builder builder() { private final String pkg; private final String name; - private final Type[] genericArgs; + private final Type[] typeParams; private final boolean isEnum; private Type(Builder builder) { this.pkg = builder.pkg; this.name = builder.name; - this.genericArgs = builder.genericArgs; + this.typeParams = builder.typeParams; this.isEnum = builder.isEnum; } public Builder toBuilder() { - return new Builder().pkg(pkg).name(name).genericArgs(genericArgs).isEnum(isEnum); + return new Builder().pkg(pkg).name(name).typeParams(typeParams).isEnum(isEnum); } @Override public String toString() { String str = name; - if (genericArgs != null && genericArgs.length > 0) { + if (typeParams != null && typeParams.length > 0) { str += "<"; - str += Arrays.stream(genericArgs).map(Type::toString).collect(Collectors.joining(", ")); + str += Arrays.stream(typeParams).map(Type::toString).collect(Collectors.joining(", ")); str += ">"; } return str; @@ -104,19 +104,19 @@ public boolean isMap() { public Type getMapEntryType() { if (!isMap()) return null; - return Java.Util.MapEntry(this.genericArgs[0], this.genericArgs[1]); + return Java.Util.MapEntry(this.typeParams[0], this.typeParams[1]); } public Type getMapKeyType() { if (!isMap()) return null; - return this.genericArgs[0]; + return this.typeParams[0]; } public Type getMapValueType() { if (!isMap()) return null; - return this.genericArgs[1]; + return this.typeParams[1]; } public boolean isList() { @@ -126,7 +126,7 @@ public boolean isList() { public Type getListValueType() { if (!isList()) return null; - return this.genericArgs[0]; + return this.typeParams[0]; } public boolean isListOrMap() { @@ -186,15 +186,15 @@ public void getRequiredImports(Set imports, String currentPkg) { var dotIdx = name.indexOf('.'); imports.add(pkg + '.' + (dotIdx > 0 ? name.substring(0, dotIdx) : name)); } - if (genericArgs != null) { - for (Type arg : genericArgs) { + if (typeParams != null) { + for (Type arg : typeParams) { arg.getRequiredImports(imports, currentPkg); } } } - public Type withGenericArgs(Type... genericArgs) { - return toBuilder().genericArgs(genericArgs).build(); + public Type withTypeParams(Type... typeParams) { + return toBuilder().typeParams(typeParams).build(); } public Mustache.Lambda queryParamify() { @@ -204,7 +204,7 @@ public Mustache.Lambda queryParamify() { public static final class Builder { private String pkg; private String name; - private Type[] genericArgs; + private Type[] typeParams; private boolean isEnum; public Builder pkg(String pkg) { @@ -217,8 +217,8 @@ public Builder name(String name) { return this; } - public Builder genericArgs(Type... genericArgs) { - this.genericArgs = genericArgs; + public Builder typeParams(Type... typeParams) { + this.typeParams = typeParams; 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 7dc66ca479..1ce5a4806f 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 @@ -74,17 +74,17 @@ public static final class Util { public static final Type HashMap = Type.builder().pkg(PACKAGE).name("HashMap").build(); public static Type Map(Type keyType, Type valueType) { - return Map.withGenericArgs(keyType, valueType); + return Map.withTypeParams(keyType, valueType); } public static final Type Map = Type.builder().pkg(PACKAGE).name("Map").build(); public static Type MapEntry(Type keyType, Type valueType) { - return Type.builder().pkg(PACKAGE).name("Map.Entry").genericArgs(keyType, valueType).build(); + return Type.builder().pkg(PACKAGE).name("Map.Entry").typeParams(keyType, valueType).build(); } public static Type List(Type valueType) { - return Type.builder().pkg(PACKAGE).name("List").genericArgs(valueType).build(); + return Type.builder().pkg(PACKAGE).name("List").typeParams(valueType).build(); } public static final class Concurrent { @@ -96,7 +96,7 @@ public static final class Function { public static final String PACKAGE = Util.PACKAGE + ".function"; public static Type Function(Type argType, Type returnType) { - return Type.builder().pkg(PACKAGE).name("Function").genericArgs(argType, returnType).build(); + return Type.builder().pkg(PACKAGE).name("Function").typeParams(argType, returnType).build(); } } @@ -121,7 +121,7 @@ public static final class Client { public static final String PACKAGE = "org.opensearch.client"; public static Type ApiClient(Type transport, Type client) { - return ApiClient.withGenericArgs(transport, client); + return ApiClient.withTypeParams(transport, client); } public static final Type ApiClient = Type.builder().pkg(PACKAGE).name("ApiClient").build(); @@ -136,6 +136,7 @@ public static final class Json { public static final Type JsonpSerializable = Type.builder().pkg(PACKAGE).name("JsonpSerializable").build(); public static final Type ObjectBuilderDeserializer = Type.builder().pkg(PACKAGE).name("ObjectBuilderDeserializer").build(); public static final Type ObjectDeserializer = Type.builder().pkg(PACKAGE).name("ObjectDeserializer").build(); + public static final Type PlainJsonSerializable = Type.builder().pkg(PACKAGE).name("PlainJsonSerializable").build(); public static final Type UnionDeserializer = Type.builder().pkg(PACKAGE).name("UnionDeserializer").build(); } @@ -154,6 +155,11 @@ public static final class _Types { public static final class Transport { public static final String PACKAGE = Client.PACKAGE + ".transport"; public static final Type Endpoint = Type.builder().pkg(PACKAGE).name("Endpoint").build(); + + public static Type JsonEndpoint(Type requestType, Type responseType, Type errorType) { + return JsonEndpoint.withTypeParams(requestType, responseType, errorType); + } + public static final Type JsonEndpoint = Type.builder().pkg(PACKAGE).name("JsonEndpoint").build(); public static final Type OpenSearchTransport = Type.builder().pkg(PACKAGE).name("OpenSearchTransport").build(); public static final Type TransportOptions = Type.builder().pkg(PACKAGE).name("TransportOptions").build(); @@ -169,14 +175,14 @@ public static final class Util { public static final Type ApiTypeHelper = Type.builder().pkg(PACKAGE).name("ApiTypeHelper").build(); public static Type ObjectBuilder(Type type) { - return ObjectBuilder.withGenericArgs(type); + return ObjectBuilder.withTypeParams(type); } public static final Type ObjectBuilder = Type.builder().pkg(PACKAGE).name("ObjectBuilder").build(); public static final Type ObjectBuilderBase = Type.builder().pkg(PACKAGE).name("ObjectBuilderBase").build(); public static Type TaggedUnion(Type tagType, Type baseType) { - return TaggedUnion.withGenericArgs(tagType, baseType); + return TaggedUnion.withTypeParams(tagType, baseType); } public static final Type TaggedUnion = Type.builder().pkg(PACKAGE).name("TaggedUnion").build(); diff --git a/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiRefElement.java b/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiRefElement.java index 55f6829628..94328a7282 100644 --- a/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiRefElement.java +++ b/java-codegen/src/main/java/org/opensearch/client/codegen/openapi/OpenApiRefElement.java @@ -86,6 +86,11 @@ public > TElement resolveIn(OpenApiSpe return specification.getElement(pointer, clazz); } + @Nonnull + public JsonPointer getPointer() { + return pointer; + } + @Override public String toString() { return new ToStringBuilder(this).append("pointer", pointer).append("relativeLocation", relativeLocation).toString(); 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 ea9ab3a957..4d12ae2659 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 @@ -10,7 +10,6 @@ import static org.opensearch.client.codegen.utils.Functional.ifNonnull; -import io.swagger.v3.oas.models.media.ObjectSchema; import io.swagger.v3.oas.models.media.Schema; import java.util.HashSet; import java.util.List; @@ -28,7 +27,9 @@ public class OpenApiSchema extends OpenApiRefElement { private static final JsonPointer ANONYMOUS = JsonPointer.of(""); - public static final OpenApiSchema ANONYMOUS_OBJECT = new OpenApiSchema(null, ANONYMOUS.append("object"), new ObjectSchema()); + public static final OpenApiSchema ANONYMOUS_OBJECT = builder().withPointer(ANONYMOUS.append("object")) + .withTypes(OpenApiSchemaType.Object) + .build(); @Nullable private final String name; @@ -59,6 +60,24 @@ public class OpenApiSchema extends OpenApiRefElement { @Nullable private final String pattern; + private OpenApiSchema(@Nonnull Builder builder) { + super(builder.parent, Objects.requireNonNull(builder.pointer, "pointer must not be null"), builder.$ref, OpenApiSchema.class); + name = builder.name; + namespace = builder.namespace; + description = builder.description; + types = builder.types; + format = builder.format; + allOf = builder.allOf; + oneOf = builder.oneOf; + enums = builder.enums; + items = builder.items; + additionalProperties = builder.additionalProperties; + properties = builder.properties; + required = builder.required; + title = builder.title; + pattern = builder.pattern; + } + protected OpenApiSchema(@Nullable OpenApiElement parent, @Nonnull JsonPointer pointer, @Nonnull Schema schema) { super(parent, pointer, schema.get$ref(), OpenApiSchema.class); @@ -230,4 +249,79 @@ public Set determineTypes() { throw new IllegalStateException("Cannot determine type for schema: " + getPointer()); } + + @Nonnull + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + @Nullable + private OpenApiElement parent; + @Nullable + private JsonPointer pointer; + @Nullable + private String $ref; + @Nullable + private String name; + @Nullable + private String namespace; + @Nullable + private String description; + @Nullable + private Set types; + @Nullable + private OpenApiSchemaFormat format; + @Nullable + private List allOf; + @Nullable + private List oneOf; + @Nullable + private List enums; + @Nullable + private OpenApiSchema items; + @Nullable + private OpenApiSchema additionalProperties; + @Nullable + private Map properties; + @Nullable + private Set required; + @Nullable + private String title; + @Nullable + private String pattern; + + @Nonnull + public Builder withPointer(@Nonnull JsonPointer pointer) { + this.pointer = Objects.requireNonNull(pointer, "pointer must not be null"); + return this; + } + + @Nonnull + public Builder withTypes(OpenApiSchemaType... types) { + return withTypes(Set.of(types)); + } + + @Nonnull + public Builder withTypes(@Nullable Set types) { + this.types = types; + return this; + } + + @Nonnull + public Builder withAllOf(OpenApiSchema... allOf) { + return withAllOf(List.of(allOf)); + } + + @Nonnull + public Builder withAllOf(@Nullable List allOf) { + this.allOf = allOf; + return this; + } + + @Nonnull + public OpenApiSchema build() { + return new OpenApiSchema(this); + } + } } diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache index 3d4c1b94ce..627af1db03 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape.mustache @@ -7,8 +7,10 @@ {{>ObjectShape/Getters}} +{{#hasFieldsToSerialize}} {{>ObjectShape/Serialize}} +{{/hasFieldsToSerialize}} // --------------------------------------------------------------------------------------------- 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 47f7ce70dd..2ef354df7a 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,46 +1,64 @@ +{{^abstract}} /** * Builder for {@link {{className}}}. */ - public static class Builder extends {{TYPES.Client.Util.ObjectBuilderBase}} implements {{TYPES.Client.Util.ObjectBuilder}}<{{className}}> { - {{#fields}} + public static class Builder extends +{{#extendsOtherShape}} + {{extendsType}}.AbstractBuilder +{{/extendsOtherShape}} +{{^extendsOtherShape}} + {{TYPES.Client.Util.ObjectBuilderBase}} +{{/extendsOtherShape}} + implements {{TYPES.Client.Util.ObjectBuilder}}<{{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}} - {{#fields}} + {{#fields}} {{#type.isMap}} {{>ObjectShape/FieldDoc/Basic}} {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder {{name}}({{type}} map) { + public final Builder{{#abstract}}T{{/abstract}} {{name}}({{type}} map) { this.{{name}} = _mapPutAll(this.{{name}}, map); - return this; + return {{^abstract}}this{{/abstract}}{{#abstract}}self(){{/abstract}}; } {{>ObjectShape/FieldDoc/Basic}} {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder {{name}}({{type.mapKeyType}} key, {{type.mapValueType}} value) { + public final Builder{{#abstract}}T{{/abstract}} {{name}}({{type.mapKeyType}} key, {{type.mapValueType}} value) { this.{{name}} = _mapPut(this.{{name}}, key, value); - return this; + return {{^abstract}}this{{/abstract}}{{#abstract}}self(){{/abstract}}; } {{/type.isMap}} {{#type.isList}} {{>ObjectShape/FieldDoc/ListAddAll}} {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder {{name}}({{type}} list) { + public final Builder{{#abstract}}T{{/abstract}} {{name}}({{type}} list) { this.{{name}} = _listAddAll(this.{{name}}, list); - return this; + return {{^abstract}}this{{/abstract}}{{#abstract}}self(){{/abstract}}; } {{>ObjectShape/FieldDoc/ListAdd}} {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder {{name}}({{type.listValueType}} value, {{type.listValueType}}... values) { + public final Builder{{#abstract}}T{{/abstract}} {{name}}({{type.listValueType}} value, {{type.listValueType}}... values) { this.{{name}} = _listAdd(this.{{name}}, value, values); - return this; + return {{^abstract}}this{{/abstract}}{{#abstract}}self(){{/abstract}}; } {{#type.listValueType.hasBuilder}} {{>ObjectShape/FieldDoc/ListAddBuilderFn}} {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder {{name}}({{type.listValueType.builderFnType}} fn) { + public final Builder{{#abstract}}T{{/abstract}} {{name}}({{type.listValueType.builderFnType}} fn) { return {{name}}(fn.apply(new {{type.listValueType.builderType}}()).build()); } {{/type.listValueType.hasBuilder}} @@ -48,21 +66,22 @@ {{^type.isListOrMap}} {{>ObjectShape/FieldDoc/Basic}} {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder {{name}}({{^required}}@{{TYPES.Javax.Annotation.Nullable}} {{/required}}{{type}} value) { + public final Builder{{#abstract}}T{{/abstract}} {{name}}({{^required}}@{{TYPES.Javax.Annotation.Nullable}} {{/required}}{{type}} value) { this.{{name}} = value; - return this; + return {{^abstract}}this{{/abstract}}{{#abstract}}self(){{/abstract}}; } {{#type.hasBuilder}} {{>ObjectShape/FieldDoc/Basic}} {{#deprecation}}@Deprecated{{/deprecation}} - public final Builder {{name}}({{type.builderFnType}} fn) { - return this.{{name}}(fn.apply(new {{type.builderType}}()).build()); + public final Builder{{#abstract}}T{{/abstract}} {{name}}({{type.builderFnType}} fn) { + return {{name}}(fn.apply(new {{type.builderType}}()).build()); } {{/type.hasBuilder}} {{/type.isListOrMap}} - {{/fields}} + {{/fields}} + {{^abstract}} /** * Builds a {@link {{className}}}. * @@ -74,4 +93,8 @@ return new {{className}}(this); } + {{/abstract}} + {{#abstract}} + protected abstract BuilderT self(); + {{/abstract}} } \ 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 92995e9d00..d526639524 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,4 +1,12 @@ +{{^abstract}} private {{className}}(Builder builder) { +{{/abstract}} +{{#abstract}} + protected {{className}}(AbstractBuilder builder) { +{{/abstract}} +{{#extendsOtherShape}} + super(builder); +{{/extendsOtherShape}} {{#fields}} {{#type.isListOrMap}} {{#required}} @@ -18,7 +26,9 @@ {{/type.isListOrMap}} {{/fields}} } +{{^abstract}} public static {{className}} of({{type.builderFnType}} fn) { return fn.apply(new Builder()).build(); - } \ No newline at end of file + } +{{/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 42966164a4..366d666744 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 @@ -1,11 +1,19 @@ +{{^abstract}} /** * Json deserializer for {@link {{className}}} */ 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}} + protected static > void setup{{className}}Deserializer({{TYPES.Client.Json.ObjectDeserializer}} op) { +{{/abstract}} + {{#extendsOtherShape}} + {{extendsType}}.setup{{extendsType.name}}Deserializer(op); + {{/extendsOtherShape}} {{#bodyFields}} - op.add(Builder::{{name}}, {{#type}}{{>Type/deserializer}}{{/type}}, {{#quoted}}{{wireName}}{{/quoted}}); + op.add({{#abstract}}Abstract{{/abstract}}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/ObjectShape/FieldDoc/BasicInner.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/BasicInner.mustache index 332d7bfb4a..851ccc468e 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/BasicInner.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/BasicInner.mustache @@ -1 +1,6 @@ -* {{#required}}Required - {{/required}}{{#description}}{{.}}
{{/description}}API name: {@code {{wireName}}} \ No newline at end of file +{{^isAdditionalProperties}} +* {{#required}}Required - {{/required}}{{#description}}{{.}}

{{/description}}API name: {@code {{wireName}}}{{#description}}

{{/description}} +{{/isAdditionalProperties}} +{{#isAdditionalProperties}} +* {{description}} +{{/isAdditionalProperties}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAdd.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAdd.mustache index 65cb2a3aa7..d8720ba088 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAdd.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAdd.mustache @@ -1,4 +1,5 @@ /** {{>ObjectShape/FieldDoc/BasicInner}} + *

Adds one or more values to {{name}}.

*/ \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddAll.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddAll.mustache index 9f38e2fdba..2894d9549d 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddAll.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddAll.mustache @@ -1,4 +1,5 @@ /** {{>ObjectShape/FieldDoc/BasicInner}} + *

Adds all elements of list to {{name}}.

*/ \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddBuilderFn.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddBuilderFn.mustache index 72123b3e31..867d0eca28 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddBuilderFn.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/FieldDoc/ListAddBuilderFn.mustache @@ -1,4 +1,5 @@ /** {{>ObjectShape/FieldDoc/BasicInner}} + *

Adds a value to {{name}} using a builder lambda.

*/ \ No newline at end of file diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache index 2a2e1e914c..56e993fa67 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/ObjectShape/Serialize.mustache @@ -1,3 +1,4 @@ +{{^extendsOtherType}} /** * Serialize this object to JSON. */ @@ -8,6 +9,7 @@ generator.writeEnd(); } +{{/extendsOtherType}} protected void serializeInternal({{TYPES.Jakarta.Json.Stream.JsonGenerator}} generator, {{TYPES.Client.Json.JsonpMapper}} mapper) { {{#additionalPropertiesField}} {{#type.directSerializer}}this.{{name}}{{/type.directSerializer}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Partials/ClassDeclaration.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Partials/ClassDeclaration.mustache index ee29f712fb..fdb7a05eea 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Partials/ClassDeclaration.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Partials/ClassDeclaration.mustache @@ -11,4 +11,4 @@ @{{.}} {{/annotations}} @{{TYPES.Javax.Annotation.Generated}}("org.opensearch.client.codegen.CodeGenerator") -public {{classKind}} {{className}}{{#extendsType}} extends {{.}}{{/extendsType}}{{#implementsTypes}}{{#-first}} implements{{/-first}} {{.}}{{^-last}},{{/-last}}{{/implementsTypes}} +public {{#abstract}}abstract {{/abstract}}{{classKind}} {{className}}{{#extendsType}} extends {{.}}{{/extendsType}}{{#implementsTypes}}{{#-first}} implements{{/-first}} {{.}}{{^-last}},{{/-last}}{{/implementsTypes}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache index 99a3039a73..3b21b2216e 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/RequestShape.mustache @@ -77,16 +77,20 @@ {{#hasQueryParams}} request -> { {{TYPES.Java.Util.Map}} params = new {{TYPES.Java.Util.HashMap}}<>(); - {{#queryParams}} + {{#queryParams}} + {{^required}} {{#type.isListOrMap}} if ({{TYPES.Client.Util.ApiTypeHelper}}.isDefined(request.{{name}})) { {{/type.isListOrMap}} {{^type.isListOrMap}} if (request.{{name}} != null) { {{/type.isListOrMap}} + {{/required}} params.put({{#quoted}}{{wireName}}{{/quoted}}, {{#type.queryParamify}}request.{{name}}{{/type.queryParamify}}); + {{^required}} } - {{/queryParams}} + {{/required}} + {{/queryParams}} return params; }, {{/hasQueryParams}} diff --git a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/deserializer.mustache b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/deserializer.mustache index 52c4913328..61fb38b72b 100644 --- a/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/deserializer.mustache +++ b/java-codegen/src/main/resources/org/opensearch/client/codegen/templates/Type/deserializer.mustache @@ -1,12 +1,12 @@ {{#isPrimitive}} - JsonpDeserializer.{{#toLower}}{{boxed.name}}{{/toLower}}Deserializer() + {{TYPES.Client.Json.JsonpDeserializer}}.{{#toLower}}{{boxed.name}}{{/toLower}}Deserializer() {{/isPrimitive}} {{^isPrimitive}} {{#isList}} - JsonpDeserializer.arrayDeserializer({{#listValueType}}{{>Type/deserializer}}{{/listValueType}}) + {{TYPES.Client.Json.JsonpDeserializer}}.arrayDeserializer({{#listValueType}}{{>Type/deserializer}}{{/listValueType}}) {{/isList}} {{#isMap}} - JsonpDeserializer.stringMapDeserializer({{#mapValueType}}{{>Type/deserializer}}{{/mapValueType}}) + {{TYPES.Client.Json.JsonpDeserializer}}.stringMapDeserializer({{#mapValueType}}{{>Type/deserializer}}{{/mapValueType}}) {{/isMap}} {{^isListOrMap}} {{name}}._DESERIALIZER