From 9b3e2d0d58765a7de2ff758a4353084d29586974 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Wed, 23 Feb 2022 14:17:01 +0100 Subject: [PATCH 1/3] fix spec for one of --- specs/analytics/common/schemas/getTopHits.yml | 7 +- .../common/schemas/getTopSearches.yml | 7 +- specs/analytics/paths/search/getTopHits.yml | 4 +- .../analytics/paths/search/getTopSearches.yml | 4 +- specs/bundled/analytics.yml | 20 +-- specs/bundled/recommend.yml | 16 +-- specs/bundled/search.yml | 114 ++++++++++-------- specs/common/schemas/SearchParams.yml | 15 ++- specs/search/common/enums.yml | 5 + specs/search/paths/advanced/getLogs.yml | 5 +- .../paths/dictionaries/common/parameters.yml | 7 +- specs/search/paths/keys/common/schemas.yml | 35 +++--- specs/search/paths/objects/batch.yml | 2 +- specs/search/paths/objects/common/schemas.yml | 28 +++-- specs/search/paths/objects/multipleBatch.yml | 2 +- specs/search/paths/objects/partialUpdate.yml | 5 +- 16 files changed, 157 insertions(+), 119 deletions(-) diff --git a/specs/analytics/common/schemas/getTopHits.yml b/specs/analytics/common/schemas/getTopHits.yml index fd5e48396e..c45414aba1 100644 --- a/specs/analytics/common/schemas/getTopHits.yml +++ b/specs/analytics/common/schemas/getTopHits.yml @@ -1,4 +1,4 @@ -getTopHitsResponse: +getTopHitsResponseSimple: type: object additionalProperties: false required: @@ -54,3 +54,8 @@ getTopHitsResponseWithAnalytics: $ref: '../parameters.yml#/clickCount' conversionCount: $ref: '../parameters.yml#/conversionCount' + +getTopHitsResponse: + oneOf: + - $ref: '#/getTopHitsResponseSimple' + - $ref: '#/getTopHitsResponseWithAnalytics' diff --git a/specs/analytics/common/schemas/getTopSearches.yml b/specs/analytics/common/schemas/getTopSearches.yml index 24ede2268e..ac55d58047 100644 --- a/specs/analytics/common/schemas/getTopSearches.yml +++ b/specs/analytics/common/schemas/getTopSearches.yml @@ -1,4 +1,4 @@ -getTopSearchesResponse: +getTopSearchesResponseSimple: type: object additionalProperties: false required: @@ -63,3 +63,8 @@ getTopSearchesResponseWithAnalytics: $ref: '../parameters.yml#/conversionCount' nbHits: $ref: ../../../search/common/schemas/SearchResponse.yml#/nbHits + +getTopSearchesResponse: + oneOf: + - $ref: '#/getTopSearchesResponseSimple' + - $ref: '#/getTopSearchesResponseWithAnalytics' diff --git a/specs/analytics/paths/search/getTopHits.yml b/specs/analytics/paths/search/getTopHits.yml index 2373d2ea47..94a8da6e27 100644 --- a/specs/analytics/paths/search/getTopHits.yml +++ b/specs/analytics/paths/search/getTopHits.yml @@ -19,9 +19,7 @@ get: content: application/json: schema: - oneOf: - - $ref: '../../common/schemas/getTopHits.yml#/getTopHitsResponse' - - $ref: '../../common/schemas/getTopHits.yml#/getTopHitsResponseWithAnalytics' + $ref: '../../common/schemas/getTopHits.yml#/getTopHitsResponse' '400': $ref: ../../../common/responses/BadRequest.yml '402': diff --git a/specs/analytics/paths/search/getTopSearches.yml b/specs/analytics/paths/search/getTopSearches.yml index 64afb094f4..c6c2aa8cfe 100644 --- a/specs/analytics/paths/search/getTopSearches.yml +++ b/specs/analytics/paths/search/getTopSearches.yml @@ -20,9 +20,7 @@ get: content: application/json: schema: - oneOf: - - $ref: '../../common/schemas/getTopSearches.yml#/getTopSearchesResponse' - - $ref: '../../common/schemas/getTopSearches.yml#/getTopSearchesResponseWithAnalytics' + $ref: '../../common/schemas/getTopSearches.yml#/getTopSearchesResponse' '400': $ref: ../../../common/responses/BadRequest.yml '402': diff --git a/specs/bundled/analytics.yml b/specs/bundled/analytics.yml index ffdfbe25fc..a40ec0ed0f 100644 --- a/specs/bundled/analytics.yml +++ b/specs/bundled/analytics.yml @@ -118,7 +118,7 @@ components: type: integer description: Number of hits that the search query matched. example: 20 - getTopSearchesResponse: + getTopSearchesResponseSimple: type: object additionalProperties: false required: @@ -202,6 +202,10 @@ components: $ref: '#/components/schemas/conversionCount' nbHits: $ref: '#/components/schemas/nbHits' + getTopSearchesResponse: + oneOf: + - $ref: '#/components/schemas/getTopSearchesResponseSimple' + - $ref: '#/components/schemas/getTopSearchesResponseWithAnalytics' ErrorBase: description: Error. type: object @@ -216,7 +220,7 @@ components: hit: description: The hit. type: string - getTopHitsResponse: + getTopHitsResponseSimple: type: object additionalProperties: false required: @@ -271,6 +275,10 @@ components: $ref: '#/components/schemas/clickCount' conversionCount: $ref: '#/components/schemas/conversionCount' + getTopHitsResponse: + oneOf: + - $ref: '#/components/schemas/getTopHitsResponseSimple' + - $ref: '#/components/schemas/getTopHitsResponseWithAnalytics' attribute: description: The attribute. type: string @@ -439,9 +447,7 @@ paths: content: application/json: schema: - oneOf: - - $ref: '#/components/schemas/getTopSearchesResponse' - - $ref: '#/components/schemas/getTopSearchesResponseWithAnalytics' + $ref: '#/components/schemas/getTopSearchesResponse' '400': $ref: '#/components/responses/BadRequest' '402': @@ -765,9 +771,7 @@ paths: content: application/json: schema: - oneOf: - - $ref: '#/components/schemas/getTopHitsResponse' - - $ref: '#/components/schemas/getTopHitsResponseWithAnalytics' + $ref: '#/components/schemas/getTopHitsResponse' '400': $ref: '#/components/responses/BadRequest' '402': diff --git a/specs/bundled/recommend.yml b/specs/bundled/recommend.yml index 8119898e07..f8152ee1bf 100644 --- a/specs/bundled/recommend.yml +++ b/specs/bundled/recommend.yml @@ -25,6 +25,14 @@ components: type: integer description: Specify the page to retrieve. default: 0 + aroundRadius: + description: Define the maximum radius for a geo search (in meters). + oneOf: + - type: integer + minimum: 1 + - type: string + enum: + - all baseSearchParams: type: object additionalProperties: false @@ -115,13 +123,7 @@ components: from the requester's IP address. default: false aroundRadius: - description: Define the maximum radius for a geo search (in meters). - oneOf: - - type: integer - minimum: 1 - - type: string - enum: - - all + $ref: '#/components/schemas/aroundRadius' aroundPrecision: type: integer description: >- diff --git a/specs/bundled/search.yml b/specs/bundled/search.yml index 6a0734a7fb..c6b1d948b1 100644 --- a/specs/bundled/search.yml +++ b/specs/bundled/search.yml @@ -98,11 +98,7 @@ components: description: The dictionary to search in. required: true schema: - enum: - - plurals - - stopwords - - compounds - type: string + $ref: '#/components/schemas/dictionaryType' Page: in: query name: page @@ -145,6 +141,14 @@ components: type: integer description: Specify the page to retrieve. default: 0 + aroundRadius: + description: Define the maximum radius for a geo search (in meters). + oneOf: + - type: integer + minimum: 1 + - type: string + enum: + - all baseSearchParams: type: object additionalProperties: false @@ -235,13 +239,7 @@ components: from the requester's IP address. default: false aroundRadius: - description: Define the maximum radius for a geo search (in meters). - oneOf: - - type: integer - minimum: 1 - - type: string - enum: - - all + $ref: '#/components/schemas/aroundRadius' aroundPrecision: type: integer description: >- @@ -987,6 +985,17 @@ components: updatedAt: type: string description: Date of last update (ISO-8601 format). + builtInOperationType: + type: string + enum: + - Increment + - Decrement + - Add + - Remove + - AddUnique + - IncrementFrom + - IncrementSet + description: The operation to apply on the attribute. builtInOperation: type: object description: >- @@ -995,16 +1004,7 @@ components: additionalProperties: false properties: _operation: - type: string - enum: - - Increment - - Decrement - - Add - - Remove - - AddUnique - - IncrementFrom - - IncrementSet - description: The operation to apply on the attribute. + $ref: '#/components/schemas/builtInOperationType' value: type: string description: >- @@ -1013,6 +1013,10 @@ components: required: - _operation - value + attributeOrBuiltInOperation: + oneOf: + - $ref: '#/components/schemas/attribute' + - $ref: '#/components/schemas/builtInOperation' action: type: string enum: @@ -1183,6 +1187,23 @@ components: required: - hits - nbHits + acl: + type: string + enum: + - addObject + - analytics + - browse + - deleteObject + - deleteIndex + - editSettings + - listIndexes + - logs + - personalization + - recommendation + - search + - seeUnretrievableAttributes + - settings + - usage apiKey: type: object description: Api Key object. @@ -1193,22 +1214,7 @@ components: description: Set of permissions associated with the key. default: [] items: - type: string - enum: - - addObject - - analytics - - browse - - deleteObject - - deleteIndex - - editSettings - - listIndexes - - logs - - personalization - - recommendation - - search - - seeUnretrievableAttributes - - settings - - usage + $ref: '#/components/schemas/acl' description: type: string description: >- @@ -1501,6 +1507,12 @@ components: type: integer default: 20 description: Maximum number of hits in a page. Minimum is 1, maximum is 1000. + dictionaryType: + type: string + enum: + - plurals + - stopwords + - compounds dictionaryAction: type: string enum: @@ -1651,6 +1663,14 @@ components: type: array items: $ref: '#/components/schemas/source' + logType: + type: string + enum: + - all + - query + - build + - error + default: all operationType: type: string enum: @@ -2296,15 +2316,12 @@ paths: application/json: schema: type: array - additionalProperties: false items: type: object title: attributeToUpdate description: Attribute to update. additionalProperties: - oneOf: - - $ref: '#/components/schemas/attribute' - - $ref: '#/components/schemas/builtInOperation' + $ref: '#/components/schemas/attributeOrBuiltInOperation' responses: '200': $ref: '#/components/responses/UpdatedAtWithObjectId' @@ -2338,7 +2355,7 @@ paths: requests: type: array items: - title: operation + title: Operation type: object additionalProperties: false properties: @@ -2393,7 +2410,7 @@ paths: requests: type: array items: - title: Operation. + title: OperationIndexName type: object additionalProperties: false properties: @@ -3870,20 +3887,13 @@ paths: schema: type: string nullable: true - default: null - name: type in: query description: >- Type of log entries to retrieve. When omitted, all log entries are retrieved. schema: - type: string - enum: - - all - - query - - build - - error - default: all + $ref: '#/components/schemas/logType' responses: '200': description: OK diff --git a/specs/common/schemas/SearchParams.yml b/specs/common/schemas/SearchParams.yml index 77da247bd7..36adff4d76 100644 --- a/specs/common/schemas/SearchParams.yml +++ b/specs/common/schemas/SearchParams.yml @@ -96,12 +96,7 @@ baseSearchParams: description: Search for entries around a given location automatically computed from the requester's IP address. default: false aroundRadius: - description: Define the maximum radius for a geo search (in meters). - oneOf: - - type: integer - minimum: 1 - - type: string - enum: [all] + $ref: '#/aroundRadius' aroundPrecision: type: integer description: Precision of geo search (in meters), to add grouping by geo location to the ranking formula. @@ -196,3 +191,11 @@ cursor: type: string description: Cursor indicating the location to resume browsing from. Must match the value returned by the previous call. example: jMDY3M2MwM2QwMWUxMmQwYWI0ZTN + +aroundRadius: + description: Define the maximum radius for a geo search (in meters). + oneOf: + - type: integer + minimum: 1 + - type: string + enum: [all] diff --git a/specs/search/common/enums.yml b/specs/search/common/enums.yml index c90345a657..7c758d4f8d 100644 --- a/specs/search/common/enums.yml +++ b/specs/search/common/enums.yml @@ -27,3 +27,8 @@ dictionaryEntryState: enum: [enabled, disabled] default: enabled description: The state of the dictionary entry. + +logType: + type: string + enum: [all, query, build, error] + default: all diff --git a/specs/search/paths/advanced/getLogs.yml b/specs/search/paths/advanced/getLogs.yml index 0d6f7e4a9b..6d2dfe8489 100644 --- a/specs/search/paths/advanced/getLogs.yml +++ b/specs/search/paths/advanced/getLogs.yml @@ -24,14 +24,11 @@ get: schema: type: string nullable: true - default: null - name: type in: query description: Type of log entries to retrieve. When omitted, all log entries are retrieved. schema: - type: string - enum: [all, query, build, error] - default: all + $ref: ../../common/enums.yml#/logType responses: '200': description: OK diff --git a/specs/search/paths/dictionaries/common/parameters.yml b/specs/search/paths/dictionaries/common/parameters.yml index 626febc030..dba15e24ad 100644 --- a/specs/search/paths/dictionaries/common/parameters.yml +++ b/specs/search/paths/dictionaries/common/parameters.yml @@ -5,8 +5,11 @@ DictionaryName: description: The dictionary to search in. required: true schema: - enum: [plurals, stopwords, compounds] - type: string + $ref: '#/dictionaryType' + +dictionaryType: + type: string + enum: [plurals, stopwords, compounds] # misc language: diff --git a/specs/search/paths/keys/common/schemas.yml b/specs/search/paths/keys/common/schemas.yml index 50d93846e9..81f83d13c8 100644 --- a/specs/search/paths/keys/common/schemas.yml +++ b/specs/search/paths/keys/common/schemas.yml @@ -8,22 +8,7 @@ apiKey: description: Set of permissions associated with the key. default: [] items: - type: string - enum: - - addObject - - analytics - - browse - - deleteObject - - deleteIndex - - editSettings - - listIndexes - - logs - - personalization - - recommendation - - search - - seeUnretrievableAttributes - - settings - - usage + $ref: '#/acl' description: type: string @@ -88,3 +73,21 @@ addApiKeyResponse: required: - key - createdAt + +acl: + type: string + enum: + - addObject + - analytics + - browse + - deleteObject + - deleteIndex + - editSettings + - listIndexes + - logs + - personalization + - recommendation + - search + - seeUnretrievableAttributes + - settings + - usage diff --git a/specs/search/paths/objects/batch.yml b/specs/search/paths/objects/batch.yml index d892d04bb4..6ee69890be 100644 --- a/specs/search/paths/objects/batch.yml +++ b/specs/search/paths/objects/batch.yml @@ -19,7 +19,7 @@ post: requests: type: array items: - title: operation + title: Operation type: object additionalProperties: false properties: diff --git a/specs/search/paths/objects/common/schemas.yml b/specs/search/paths/objects/common/schemas.yml index 5a445300f3..89ec42b7ba 100644 --- a/specs/search/paths/objects/common/schemas.yml +++ b/specs/search/paths/objects/common/schemas.yml @@ -10,6 +10,18 @@ action: - clear description: type of operation. +builtInOperationType: + type: string + enum: + - Increment + - Decrement + - Add + - Remove + - AddUnique + - IncrementFrom + - IncrementSet + description: The operation to apply on the attribute. + attribute: type: string description: Value of the attribute to be updated. @@ -20,19 +32,15 @@ builtInOperation: additionalProperties: false properties: _operation: - type: string - enum: - - Increment - - Decrement - - Add - - Remove - - AddUnique - - IncrementFrom - - IncrementSet - description: The operation to apply on the attribute. + $ref: '#/builtInOperationType' value: type: string description: the right-hand side argument to the operation, for example, increment or decrement step, value to add or remove. required: - _operation - value + +attributeOrBuiltInOperation: + oneOf: + - $ref: '#/attribute' + - $ref: '#/builtInOperation' diff --git a/specs/search/paths/objects/multipleBatch.yml b/specs/search/paths/objects/multipleBatch.yml index 98f458a75e..e7d37b0d8f 100644 --- a/specs/search/paths/objects/multipleBatch.yml +++ b/specs/search/paths/objects/multipleBatch.yml @@ -17,7 +17,7 @@ post: requests: type: array items: - title: Operation. + title: OperationIndexName type: object additionalProperties: false properties: diff --git a/specs/search/paths/objects/partialUpdate.yml b/specs/search/paths/objects/partialUpdate.yml index 70ced042d7..4850f15156 100644 --- a/specs/search/paths/objects/partialUpdate.yml +++ b/specs/search/paths/objects/partialUpdate.yml @@ -27,15 +27,12 @@ post: application/json: schema: type: array - additionalProperties: false items: type: object title: attributeToUpdate description: Attribute to update. additionalProperties: - oneOf: - - $ref: 'common/schemas.yml#/attribute' - - $ref: 'common/schemas.yml#/builtInOperation' + $ref: 'common/schemas.yml#/attributeOrBuiltInOperation' responses: '200': $ref: ../../../common/responses/UpdatedAtWithObjectId.yml From 42f1e8fd40495fe2d08e69bb8a9435b75e773034 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Tue, 1 Mar 2022 13:02:42 +0100 Subject: [PATCH 2/3] review --- specs/analytics/common/schemas/getTopHits.yml | 8 ++++---- specs/analytics/common/schemas/getTopSearches.yml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/specs/analytics/common/schemas/getTopHits.yml b/specs/analytics/common/schemas/getTopHits.yml index c45414aba1..6214fc1f78 100644 --- a/specs/analytics/common/schemas/getTopHits.yml +++ b/specs/analytics/common/schemas/getTopHits.yml @@ -1,4 +1,4 @@ -getTopHitsResponseSimple: +topHitsResponse: type: object additionalProperties: false required: @@ -19,7 +19,7 @@ getTopHitsResponseSimple: count: $ref: ../../../common/parameters.yml#/count -getTopHitsResponseWithAnalytics: +topHitsResponseWithAnalytics: type: object additionalProperties: false required: @@ -57,5 +57,5 @@ getTopHitsResponseWithAnalytics: getTopHitsResponse: oneOf: - - $ref: '#/getTopHitsResponseSimple' - - $ref: '#/getTopHitsResponseWithAnalytics' + - $ref: '#/topHitsResponse' + - $ref: '#/topHitsResponseWithAnalytics' diff --git a/specs/analytics/common/schemas/getTopSearches.yml b/specs/analytics/common/schemas/getTopSearches.yml index ac55d58047..51270f3209 100644 --- a/specs/analytics/common/schemas/getTopSearches.yml +++ b/specs/analytics/common/schemas/getTopSearches.yml @@ -1,4 +1,4 @@ -getTopSearchesResponseSimple: +topSearchesResponse: type: object additionalProperties: false required: @@ -22,7 +22,7 @@ getTopSearchesResponseSimple: nbHits: $ref: ../../../search/common/schemas/SearchResponse.yml#/nbHits -getTopSearchesResponseWithAnalytics: +topSearchesResponseWithAnalytics: type: object additionalProperties: false required: @@ -66,5 +66,5 @@ getTopSearchesResponseWithAnalytics: getTopSearchesResponse: oneOf: - - $ref: '#/getTopSearchesResponseSimple' - - $ref: '#/getTopSearchesResponseWithAnalytics' + - $ref: '#/topSearchesResponse' + - $ref: '#/topSearchesResponseWithAnalytics' From 8e0c958b7cab60e8fb6d9b6aead504a5b0a54baf Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Thu, 3 Mar 2022 11:19:50 +0100 Subject: [PATCH 3/3] feat(java): custom generator APIC-300 (#180) --- .github/actions/cache/action.yml | 5 + .github/actions/setup/action.yml | 13 + .github/workflows/check.yml | 20 +- .prettierignore | 1 + Dockerfile | 3 + clients.config.json | 32 +- .../.openapi-generator-ignore | 1 - .../com/algolia/ApiClient.java | 39 +- .../algoliasearch-core/com/algolia/JSON.java | 315 +- .../model/BatchDictionaryEntriesParams.java | 113 - .../model/DictionarySettingsParams.java | 76 - .../model/SearchDictionaryEntriesParams.java | 146 - .../com/algolia/model/search/Acl.java | 78 + .../com/algolia/model/search/ApiKey.java | 86 +- .../algolia/model/search/AroundRadius.java | 71 + .../model/search/AroundRadiusOneOf.java | 55 + .../search/AttributeOrBuiltInOperation.java | 75 + .../model/search/BaseSearchParams.java | 10 +- .../model/search/BatchDictionaryEntries.java | 113 - .../com/algolia/model/search/BatchParams.java | 10 +- .../model/search/BuiltInOperation.java | 75 +- .../model/search/BuiltInOperationType.java | 67 + .../model/search/ConsequenceParams.java | 10 +- .../search/DictionarySettingsRequest.java | 76 - .../algolia/model/search/DictionaryType.java | 58 + .../com/algolia/model/search/Key.java | 86 +- .../com/algolia/model/search/LogType.java | 58 + .../model/search/OneOfintegerstring.java | 3 - .../search/OneOfstringbuiltInOperation.java | 20 - .../com/algolia/model/search/Operation.java | 31 +- .../model/search/OperationIndexName.java | 119 + .../model/search/SearchDictionaryEntries.java | 146 - .../algolia/model/search/SearchParams.java | 2914 +---------------- .../model/search/SearchParamsObject.java | 10 +- .../com/algolia/search/SearchApi.java | 246 +- .../com/algolia/utils/CompoundType.java | 5 + .../com/algolia/utils/echo/EchoResponse.java | 2161 ++++++------ .../model/getTopHitsResponse.ts | 10 +- .../model/getTopHitsResponseSimple.ts | 8 + .../model/getTopHitsResponseSimpleHits.ts | 10 + .../model/getTopSearchesResponse.ts | 12 +- .../model/getTopSearchesResponseSimple.ts | 8 + .../client-analytics/model/topHitsResponse.ts | 8 + ...ResponseHits.ts => topHitsResponseHits.ts} | 2 +- .../model/topHitsResponseWithAnalytics.ts | 8 + .../model/topHitsResponseWithAnalyticsHits.ts | 30 + .../model/topSearchesResponse.ts | 8 + .../model/topSearchesResponseWithAnalytics.ts | 8 + ...opSearchesResponseWithAnalyticsSearches.ts | 38 + .../client-analytics/src/analyticsApi.ts | 10 +- .../packages/client-search/model/acl.ts | 15 + .../packages/client-search/model/apiKey.ts | 20 +- .../client-search/model/aroundRadius.ts | 3 + .../client-search/model/aroundRadiusOneOf.ts | 1 + .../model/attributeOrBuiltInOperation.ts | 3 + .../client-search/model/baseSearchParams.ts | 7 +- .../client-search/model/batchParams.ts | 4 +- .../client-search/model/builtInOperation.ts | 16 +- .../model/builtInOperationType.ts | 12 + .../client-search/model/dictionaryType.ts | 1 + .../packages/client-search/model/logType.ts | 1 + .../packages/client-search/model/operation.ts | 4 - .../client-search/model/operationIndexName.ts | 13 + .../packages/client-search/src/searchApi.ts | 24 +- .../packages/recommend/model/aroundRadius.ts | 3 + .../recommend/model/aroundRadiusOneOf.ts | 1 + .../recommend/model/baseSearchParams.ts | 7 +- .../lib/Api/SearchApi.php | 24 +- config/base.tsconfig.json | 22 + config/clients.config.json | 19 + config/openapitools-java-cts.json | 9 + config/openapitools-java.json | 21 + .../release.config.json | 0 docs/CTS.md | 9 +- generators/build.gradle | 21 + generators/settings.gradle | 1 + .../algolia/codegen/AlgoliaJavaGenerator.java | 173 + .../algolia/codegen/GenerationException.java | 7 + .../codegen/cts/AlgoliaCtsGenerator.java | 172 + .../com/algolia/codegen/cts/CTSException.java | 7 + .../codegen/cts/EscapeQuotesLambda.java | 15 + .../codegen/cts/ParametersWithDataType.java | 326 ++ .../java/com/algolia/codegen/cts/Request.java | 67 + .../org.openapitools.codegen.CodegenConfig | 2 + .../gradle/wrapper/gradle-wrapper.properties | 2 +- .../main/java/com/algolia/playground/App.java | 6 +- playground/javascript/browser/tsconfig.json | 2 +- playground/javascript/node/tsconfig.json | 2 +- scripts/common.ts | 9 +- scripts/cts/generate.ts | 13 +- scripts/generate.ts | 24 +- scripts/post-gen/java.sh | 37 - scripts/pre-gen/java.sh | 15 - scripts/release/common.ts | 2 +- scripts/tsconfig.json | 2 +- specs/bundled/analytics.yml | 16 +- .../java/EchoResponse.mustache | 42 +- templates/java/JSON.mustache | 470 +-- .../libraries/okhttp-gson/ApiClient.mustache | 39 +- .../java/libraries/okhttp-gson/api.mustache | 4 +- templates/java/model.mustache | 4 - templates/java/oneof_interface.mustache | 56 +- templates/java/openapi.mustache | 1 - templates/java/pojo.mustache | 2 +- .../methods/requests/search/addApiKey.json | 1 - .../requests/search/addOrUpdateObject.json | 1 - .../methods/requests/search/appendSource.json | 1 - .../methods/requests/search/assignUserId.json | 1 - tests/CTS/methods/requests/search/batch.json | 14 +- .../requests/search/batchAssignUserIds.json | 1 - .../search/batchDictionaryEntries.json | 64 +- .../methods/requests/search/batchRules.json | 18 +- tests/CTS/methods/requests/search/browse.json | 1 - .../CTS/methods/requests/search/deleteBy.json | 1 - .../methods/requests/search/getObjects.json | 2 - .../requests/search/multipleBatch.json | 8 +- .../requests/search/multipleQueries.json | 12 +- .../requests/search/operationIndex.json | 6 +- .../requests/search/partialUpdateObject.json | 4 +- .../requests/search/replaceSources.json | 1 - .../methods/requests/search/saveObject.json | 1 - .../CTS/methods/requests/search/saveRule.json | 9 +- .../methods/requests/search/saveSynonym.json | 6 +- .../methods/requests/search/saveSynonyms.json | 12 +- tests/CTS/methods/requests/search/search.json | 1 - .../search/searchDictionaryEntries.json | 2 - .../requests/search/searchForFacetValues.json | 1 - .../methods/requests/search/searchRules.json | 1 - .../requests/search/searchUserIds.json | 1 - .../search/setDictionarySettings.json | 8 - .../methods/requests/search/setSettings.json | 1 - .../methods/requests/search/updateApiKey.json | 1 - .../templates/java/generateParams.mustache | 4 +- .../requests/templates/java/requests.mustache | 8 +- tests/output/java/.openapi-generator-ignore | 0 .../algolia/methods/requests/search.test.java | 1036 +++--- .../src/methods/requests/search.test.ts | 42 +- tests/output/javascript/tsconfig.json | 2 +- 138 files changed, 3913 insertions(+), 6644 deletions(-) delete mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchDictionaryEntriesParams.java delete mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/DictionarySettingsParams.java delete mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchDictionaryEntriesParams.java create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/Acl.java create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/AroundRadius.java create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/AroundRadiusOneOf.java create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/AttributeOrBuiltInOperation.java delete mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/BatchDictionaryEntries.java create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/BuiltInOperationType.java delete mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/DictionarySettingsRequest.java create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/DictionaryType.java create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/LogType.java delete mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/OneOfintegerstring.java delete mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/OneOfstringbuiltInOperation.java create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/OperationIndexName.java delete mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/SearchDictionaryEntries.java create mode 100644 clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/utils/CompoundType.java create mode 100644 clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopHitsResponseSimple.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopHitsResponseSimpleHits.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopSearchesResponseSimple.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-analytics/model/topHitsResponse.ts rename clients/algoliasearch-client-javascript/packages/client-analytics/model/{getTopHitsResponseHits.ts => topHitsResponseHits.ts} (72%) create mode 100644 clients/algoliasearch-client-javascript/packages/client-analytics/model/topHitsResponseWithAnalytics.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-analytics/model/topHitsResponseWithAnalyticsHits.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-analytics/model/topSearchesResponse.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-analytics/model/topSearchesResponseWithAnalytics.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-analytics/model/topSearchesResponseWithAnalyticsSearches.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/acl.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/aroundRadius.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/aroundRadiusOneOf.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/attributeOrBuiltInOperation.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/builtInOperationType.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/dictionaryType.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/logType.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-search/model/operationIndexName.ts create mode 100644 clients/algoliasearch-client-javascript/packages/recommend/model/aroundRadius.ts create mode 100644 clients/algoliasearch-client-javascript/packages/recommend/model/aroundRadiusOneOf.ts create mode 100644 config/base.tsconfig.json create mode 100644 config/clients.config.json create mode 100644 config/openapitools-java-cts.json create mode 100644 config/openapitools-java.json rename release.config.json => config/release.config.json (100%) create mode 100644 generators/build.gradle create mode 100644 generators/settings.gradle create mode 100644 generators/src/main/java/com/algolia/codegen/AlgoliaJavaGenerator.java create mode 100644 generators/src/main/java/com/algolia/codegen/GenerationException.java create mode 100644 generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java create mode 100644 generators/src/main/java/com/algolia/codegen/cts/CTSException.java create mode 100644 generators/src/main/java/com/algolia/codegen/cts/EscapeQuotesLambda.java create mode 100644 generators/src/main/java/com/algolia/codegen/cts/ParametersWithDataType.java create mode 100644 generators/src/main/java/com/algolia/codegen/cts/Request.java create mode 100644 generators/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig delete mode 100755 scripts/post-gen/java.sh delete mode 100755 scripts/pre-gen/java.sh rename scripts/post-gen/javaEchoResponse.mustache => templates/java/EchoResponse.mustache (50%) delete mode 100644 templates/java/openapi.mustache create mode 100644 tests/output/java/.openapi-generator-ignore diff --git a/.github/actions/cache/action.yml b/.github/actions/cache/action.yml index 66a1345811..010f5b46ea 100644 --- a/.github/actions/cache/action.yml +++ b/.github/actions/cache/action.yml @@ -134,3 +134,8 @@ runs: if: ${{ inputs.language == 'java' || inputs.job == 'cts' }} shell: bash run: curl -L "https://github.com/google/google-java-format/releases/download/v1.13.0/google-java-format-1.13.0-all-deps.jar" > /tmp/java-formatter.jar + + - name: Download openapi generator jar for java (TODO REMOVE) + if: ${{ inputs.language == 'java' || inputs.job == 'cts' }} + shell: bash + run: curl -L "https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.4.0/openapi-generator-cli-5.4.0.jar" > /tmp/openapi-generator-cli.jar diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 6a8a4e5b16..aece7c4b16 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -61,6 +61,9 @@ runs: run="true" fi + echo "Running spec matrix: $run" + echo "Spec matrix: $(echo $matrix | jq .)" + echo "::set-output name=MATRIX::$matrix" echo "::set-output name=RUN_SPECS::$run" @@ -78,10 +81,14 @@ runs: run="true" fi + echo "Running javascript matrix: $run" + echo "Javascript matrix: $(echo $matrix | jq .)" + echo "::set-output name=MATRIX::$matrix" echo "::set-output name=RUN_CLIENT::$run" if [[ $base_changed == 'true' || steps.diff.outputs.JS_COMMON_CHANGED > 0 ]]; then + echo "Running common javascript: true" echo "::set-output name=RUN_COMMON::true" fi @@ -99,6 +106,9 @@ runs: run="true" fi + echo "Running java matrix: $run" + echo "Java matrix: $(echo $matrix | jq .)" + echo "::set-output name=MATRIX::$matrix" echo "::set-output name=RUN_CLIENT::$run" @@ -116,6 +126,9 @@ runs: run="true" fi + echo "Running php matrix: $run" + echo "PHP matrix: $(echo $matrix | jq .)" + echo "::set-output name=MATRIX::$matrix" echo "::set-output name=RUN_CLIENT::$run" diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index c1fb46f3b7..6052f5e626 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -63,7 +63,9 @@ jobs: run: yarn cli build specs ${{ matrix.client }} - name: Check diff with pushed spec - run: exit $(git status --porcelain specs/bundled/${{ matrix.client }}.yml | wc -l) + run: | + git status + exit $(git status --porcelain specs/bundled/${{ matrix.client }}.yml | wc -l) client_javascript_common: timeout-minutes: 10 @@ -127,7 +129,9 @@ jobs: - name: Check diff with pushed client if: steps.cache.outputs.cache-hit != 'true' - run: exit $(git status --porcelain ${{ matrix.client.folder }} | wc -l) + run: | + git status + exit $(git status --porcelain ${{ matrix.client.folder }} | wc -l) - name: Build ${{ matrix.client.name }} client if: steps.cache.outputs.cache-hit != 'true' @@ -164,7 +168,9 @@ jobs: - name: Check diff with pushed client if: steps.cache.outputs.cache-hit != 'true' - run: exit $(git status --porcelain ${{ matrix.client.folder }} | wc -l) + run: | + git status + exit $(git status --porcelain ${{ matrix.client.folder }} | wc -l) - name: Build ${{ matrix.client.name }} client if: steps.cache.outputs.cache-hit != 'true' @@ -194,7 +200,9 @@ jobs: - name: Check diff with pushed client if: steps.cache.outputs.cache-hit != 'true' - run: exit $(git status --porcelain ${{ matrix.client.folder }} | wc -l) + run: | + git status + exit $(git status --porcelain ${{ matrix.client.folder }} | wc -l) - name: Build ${{ matrix.client.name }} client if: steps.cache.outputs.cache-hit != 'true' @@ -221,7 +229,9 @@ jobs: run: yarn cli cts generate - name: Check diff with pushed CTS - run: exit $(git status --porcelain ./tests/output | wc -l) + run: | + git status + exit $(git status --porcelain ./tests/output | wc -l) - name: Run CTS run: yarn cli cts run diff --git a/.prettierignore b/.prettierignore index 1521c8b765..de4d1f007d 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1 +1,2 @@ dist +node_modules diff --git a/Dockerfile b/Dockerfile index b567072464..de045f51b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,9 @@ ENV JAVA_HOME=/usr/lib/jvm/default-jvm # Java formatter ADD https://github.com/google/google-java-format/releases/download/v1.13.0/google-java-format-1.13.0-all-deps.jar /tmp/java-formatter.jar +# openapi generator jar (TODO: REMOVE) +ADD https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.4.0/openapi-generator-cli-5.4.0.jar /tmp/openapi-generator-cli.jar + # PHP dependencies RUN apk add -U composer php8 php8-tokenizer php8-dom php8-xml php8-xmlwriter diff --git a/clients.config.json b/clients.config.json index 817a6a11af..06e736304c 100644 --- a/clients.config.json +++ b/clients.config.json @@ -1,19 +1,19 @@ { - "java": { - "folder": "clients/algoliasearch-client-java-2", - "tests": { - "extension": ".test.java", - "outputFolder": "src/test/java/com/algolia" - } - }, - "javascript": { - "folder": "clients/algoliasearch-client-javascript", - "tests": { - "extension": ".test.ts", - "outputFolder": "src" - } - }, - "php": { - "folder": "clients/algoliasearch-client-php" + "java": { + "folder": "clients/algoliasearch-client-java-2", + "tests": { + "extension": ".test.java", + "outputFolder": "src/test/java/com/algolia" } + }, + "javascript": { + "folder": "clients/algoliasearch-client-javascript", + "tests": { + "extension": ".test.ts", + "outputFolder": "src" + } + }, + "php": { + "folder": "clients/algoliasearch-client-php" + } } diff --git a/clients/algoliasearch-client-java-2/.openapi-generator-ignore b/clients/algoliasearch-client-java-2/.openapi-generator-ignore index 7b4b7e7ffe..29cffb9f2d 100644 --- a/clients/algoliasearch-client-java-2/.openapi-generator-ignore +++ b/clients/algoliasearch-client-java-2/.openapi-generator-ignore @@ -5,7 +5,6 @@ # The patterns follow closely to .gitignore or .dockerignore. api/** -docs/** gradle/** src/** README.md diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ApiClient.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ApiClient.java index fe63fb8313..5380df5eec 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ApiClient.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ApiClient.java @@ -23,15 +23,12 @@ public class ApiClient { private DateFormat dateFormat; - private JSON json; - private Requester requester; /* * Constructor for ApiClient with custom Requester */ public ApiClient(String appId, String apiKey, Requester requester) { - json = new JSON(); setUserAgent("OpenAPI-Generator/0.1.0/java"); this.basePath = "https://" + appId + "-1.algolianet.com"; @@ -40,40 +37,10 @@ public ApiClient(String appId, String apiKey, Requester requester) { this.requester = requester; } - /** - * Get JSON - * - * @return JSON object - */ - public JSON getJSON() { - return json; - } - - /** - * Set JSON - * - * @param json JSON object - * @return Api client - */ - public ApiClient setJSON(JSON json) { - this.json = json; - return this; - } - public DateFormat getDateFormat() { return dateFormat; } - public ApiClient setDateFormat(DateFormat dateFormat) { - this.json.setDateFormat(dateFormat); - return this; - } - - public ApiClient setLenientOnJson(boolean lenientOnJson) { - this.json.setLenientOnJson(lenientOnJson); - return this; - } - /** * Set the User-Agent header's value (by adding to the default header map). * @@ -195,7 +162,7 @@ public String parameterToString(Object param) { param instanceof LocalDate ) { // Serialize to json string and remove the " enclosing characters - String jsonStr = json.serialize(param); + String jsonStr = JSON.serialize(param); return jsonStr.substring(1, jsonStr.length() - 1); } else if (param instanceof Collection) { StringBuilder b = new StringBuilder(); @@ -399,7 +366,7 @@ public T deserialize(Response response, Type returnType) contentType = "application/json"; } if (isJsonMime(contentType)) { - return json.deserialize(respBody, returnType); + return JSON.deserialize(respBody, returnType); } else if (returnType.equals(String.class)) { // Expecting string, return the raw response body. return (T) respBody; @@ -433,7 +400,7 @@ public RequestBody serialize(Object obj, String contentType) } else if (isJsonMime(contentType)) { String content; if (obj != null) { - content = json.serialize(obj); + content = JSON.serialize(obj); } else { content = null; } diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/JSON.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/JSON.java index 0bfbbc8762..dc22036834 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/JSON.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/JSON.java @@ -24,7 +24,6 @@ import com.google.gson.stream.JsonWriter; import io.gsonfire.GsonFireBuilder; import java.io.IOException; -import java.io.StringReader; import java.io.StringWriter; import java.lang.reflect.Field; import java.lang.reflect.Type; @@ -32,9 +31,6 @@ import java.text.DateFormat; import java.text.ParseException; import java.text.ParsePosition; -import java.time.LocalDate; -import java.time.OffsetDateTime; -import java.time.format.DateTimeFormatter; import java.util.Collections; import java.util.Date; import java.util.EnumMap; @@ -50,39 +46,31 @@ public class JSON { - private Gson gson; - private boolean isLenientOnJson = false; - private DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); - private SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); - private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); - private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); - private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); - private RetainFieldMapFactory mapAdapter = new RetainFieldMapFactory(); + private static Gson gson; + private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); + private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); + private static RetainFieldMapFactory mapAdapter = new RetainFieldMapFactory(); - public static GsonBuilder createGson() { - GsonFireBuilder fireBuilder = new GsonFireBuilder(); - GsonBuilder builder = fireBuilder.createGsonBuilder(); - return builder; - } - - public JSON() { + static { gson = createGson() .registerTypeAdapter(Date.class, dateTypeAdapter) - .registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter) - .registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter) - .registerTypeAdapter(LocalDate.class, localDateTypeAdapter) .registerTypeAdapter(byte[].class, byteArrayAdapter) .registerTypeAdapterFactory(mapAdapter) .create(); } + public static GsonBuilder createGson() { + GsonFireBuilder fireBuilder = new GsonFireBuilder(); + return fireBuilder.createGsonBuilder(); + } + /** * Get Gson. * * @return Gson */ - public Gson getGson() { + public static Gson getGson() { return gson; } @@ -92,14 +80,8 @@ public Gson getGson() { * @param gson Gson * @return JSON */ - public JSON setGson(Gson gson) { - this.gson = gson; - return this; - } - - public JSON setLenientOnJson(boolean lenientOnJson) { - isLenientOnJson = lenientOnJson; - return this; + public static void setGson(Gson gon) { + gson = gon; } /** @@ -108,7 +90,7 @@ public JSON setLenientOnJson(boolean lenientOnJson) { * @param obj Object * @return String representation of the JSON */ - public String serialize(Object obj) { + public static String serialize(Object obj) { return gson.toJson(obj); } @@ -120,21 +102,13 @@ public String serialize(Object obj) { * @param returnType The type to deserialize into * @return The deserialized Java object */ - public T deserialize(String body, Type returnType) { + public static T deserialize(String body, Type returnType) { try { - if (isLenientOnJson) { - JsonReader jsonReader = new JsonReader(new StringReader(body)); - // see - // https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean) - jsonReader.setLenient(true); - return gson.fromJson(jsonReader, returnType); - } else { - return gson.fromJson(body, returnType); - } + return gson.fromJson(body, returnType); } catch (JsonParseException e) { // Fallback processing when failed to parse JSON form response body: // return the response body string directly for the String return type; - if (returnType.equals(String.class)) { + if (returnType != null && returnType.equals(String.class)) { return (T) body; } else { throw (e); @@ -142,159 +116,72 @@ public T deserialize(String body, Type returnType) { } } - /** Gson TypeAdapter for Byte Array type */ - public class ByteArrayAdapter extends TypeAdapter { - - @Override - public void write(JsonWriter out, byte[] value) throws IOException { - if (value == null) { - out.nullValue(); - } else { - out.value(ByteString.of(value).base64()); - } - } - - @Override - public byte[] read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String bytesAsBase64 = in.nextString(); - ByteString byteString = ByteString.decodeBase64(bytesAsBase64); - return byteString.toByteArray(); - } - } + public static void setDateFormat(DateFormat dateFormat) { + dateTypeAdapter.setFormat(dateFormat); } +} - /** Gson TypeAdapter for JSR310 OffsetDateTime type */ - public static class OffsetDateTimeTypeAdapter - extends TypeAdapter { - - private DateTimeFormatter formatter; - - public OffsetDateTimeTypeAdapter() { - this(DateTimeFormatter.ISO_OFFSET_DATE_TIME); - } - - public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { - this.formatter = formatter; - } - - public void setFormat(DateTimeFormatter dateFormat) { - this.formatter = dateFormat; - } - - @Override - public void write(JsonWriter out, OffsetDateTime date) throws IOException { - if (date == null) { - out.nullValue(); - } else { - out.value(formatter.format(date)); - } - } +/** Gson TypeAdapter for Byte Array type */ +class ByteArrayAdapter extends TypeAdapter { - @Override - public OffsetDateTime read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - if (date.endsWith("+0000")) { - date = date.substring(0, date.length() - 5) + "Z"; - } - return OffsetDateTime.parse(date, formatter); - } + @Override + public void write(JsonWriter out, byte[] value) throws IOException { + if (value == null) { + out.nullValue(); + } else { + out.value(ByteString.of(value).base64()); } } - /** Gson TypeAdapter for JSR310 LocalDate type */ - public class LocalDateTypeAdapter extends TypeAdapter { - - private DateTimeFormatter formatter; - - public LocalDateTypeAdapter() { - this(DateTimeFormatter.ISO_LOCAL_DATE); - } - - public LocalDateTypeAdapter(DateTimeFormatter formatter) { - this.formatter = formatter; + @Override + public byte[] read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String bytesAsBase64 = in.nextString(); + ByteString byteString = ByteString.decodeBase64(bytesAsBase64); + return byteString.toByteArray(); } + } +} - public void setFormat(DateTimeFormatter dateFormat) { - this.formatter = dateFormat; - } +/** + * Gson TypeAdapter for java.util.Date type If the dateFormat is null, ISO8601Utils will be used. + */ +class DateTypeAdapter extends TypeAdapter { - @Override - public void write(JsonWriter out, LocalDate date) throws IOException { - if (date == null) { - out.nullValue(); - } else { - out.value(formatter.format(date)); - } - } + private DateFormat dateFormat; - @Override - public LocalDate read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - return LocalDate.parse(date, formatter); - } - } - } + public DateTypeAdapter() {} - public JSON setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { - offsetDateTimeTypeAdapter.setFormat(dateFormat); - return this; + public DateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; } - public JSON setLocalDateFormat(DateTimeFormatter dateFormat) { - localDateTypeAdapter.setFormat(dateFormat); - return this; + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; } - /** - * Gson TypeAdapter for java.sql.Date type If the dateFormat is null, a simple "yyyy-MM-dd" format - * will be used (more efficient than SimpleDateFormat). - */ - public static class SqlDateTypeAdapter extends TypeAdapter { - - private DateFormat dateFormat; - - public SqlDateTypeAdapter() {} - - public SqlDateTypeAdapter(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } - - public void setFormat(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } - - @Override - public void write(JsonWriter out, java.sql.Date date) throws IOException { - if (date == null) { - out.nullValue(); + @Override + public void write(JsonWriter out, Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); } else { - String value; - if (dateFormat != null) { - value = dateFormat.format(date); - } else { - value = date.toString(); - } - out.value(value); + value = ISO8601Utils.format(date, true); } + out.value(value); } + } - @Override - public java.sql.Date read(JsonReader in) throws IOException { + @Override + public Date read(JsonReader in) throws IOException { + try { switch (in.peek()) { case NULL: in.nextNull(); @@ -303,83 +190,17 @@ public java.sql.Date read(JsonReader in) throws IOException { String date = in.nextString(); try { if (dateFormat != null) { - return new java.sql.Date(dateFormat.parse(date).getTime()); + return dateFormat.parse(date); } - return new java.sql.Date( - ISO8601Utils.parse(date, new ParsePosition(0)).getTime() - ); + return ISO8601Utils.parse(date, new ParsePosition(0)); } catch (ParseException e) { throw new JsonParseException(e); } } + } catch (IllegalArgumentException e) { + throw new JsonParseException(e); } } - - /** - * Gson TypeAdapter for java.util.Date type If the dateFormat is null, ISO8601Utils will be used. - */ - public static class DateTypeAdapter extends TypeAdapter { - - private DateFormat dateFormat; - - public DateTypeAdapter() {} - - public DateTypeAdapter(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } - - public void setFormat(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } - - @Override - public void write(JsonWriter out, Date date) throws IOException { - if (date == null) { - out.nullValue(); - } else { - String value; - if (dateFormat != null) { - value = dateFormat.format(date); - } else { - value = ISO8601Utils.format(date, true); - } - out.value(value); - } - } - - @Override - public Date read(JsonReader in) throws IOException { - try { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - try { - if (dateFormat != null) { - return dateFormat.parse(date); - } - return ISO8601Utils.parse(date, new ParsePosition(0)); - } catch (ParseException e) { - throw new JsonParseException(e); - } - } - } catch (IllegalArgumentException e) { - throw new JsonParseException(e); - } - } - } - - public JSON setDateFormat(DateFormat dateFormat) { - dateTypeAdapter.setFormat(dateFormat); - return this; - } - - public JSON setSqlDateFormat(DateFormat dateFormat) { - sqlDateTypeAdapter.setFormat(dateFormat); - return this; - } } // https://stackoverflow.com/questions/21458468/gson-wont-properly-serialise-a-class-that-extends-hashmap diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchDictionaryEntriesParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchDictionaryEntriesParams.java deleted file mode 100644 index 7ae9e55e18..0000000000 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchDictionaryEntriesParams.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.algolia.model.search; - -import com.google.gson.annotations.SerializedName; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -/** The `batchDictionaryEntries` parameters. */ -public class BatchDictionaryEntriesParams { - - @SerializedName("clearExistingDictionaryEntries") - private Boolean clearExistingDictionaryEntries = false; - - @SerializedName("requests") - private List requests = new ArrayList<>(); - - public BatchDictionaryEntriesParams clearExistingDictionaryEntries( - Boolean clearExistingDictionaryEntries - ) { - this.clearExistingDictionaryEntries = clearExistingDictionaryEntries; - return this; - } - - /** - * When `true`, start the batch by removing all the custom entries from the dictionary. - * - * @return clearExistingDictionaryEntries - */ - @javax.annotation.Nullable - public Boolean getClearExistingDictionaryEntries() { - return clearExistingDictionaryEntries; - } - - public void setClearExistingDictionaryEntries( - Boolean clearExistingDictionaryEntries - ) { - this.clearExistingDictionaryEntries = clearExistingDictionaryEntries; - } - - public BatchDictionaryEntriesParams requests( - List requests - ) { - this.requests = requests; - return this; - } - - public BatchDictionaryEntriesParams addRequestsItem( - BatchDictionaryEntriesRequest requestsItem - ) { - this.requests.add(requestsItem); - return this; - } - - /** - * List of operations to batch. Each operation is described by an `action` and a `body`. - * - * @return requests - */ - @javax.annotation.Nonnull - public List getRequests() { - return requests; - } - - public void setRequests(List requests) { - this.requests = requests; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - BatchDictionaryEntriesParams batchDictionaryEntriesParams = (BatchDictionaryEntriesParams) o; - return ( - Objects.equals( - this.clearExistingDictionaryEntries, - batchDictionaryEntriesParams.clearExistingDictionaryEntries - ) && - Objects.equals(this.requests, batchDictionaryEntriesParams.requests) - ); - } - - @Override - public int hashCode() { - return Objects.hash(clearExistingDictionaryEntries, requests); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class BatchDictionaryEntriesParams {\n"); - sb - .append(" clearExistingDictionaryEntries: ") - .append(toIndentedString(clearExistingDictionaryEntries)) - .append("\n"); - sb.append(" requests: ").append(toIndentedString(requests)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/DictionarySettingsParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/DictionarySettingsParams.java deleted file mode 100644 index f825ad4dbc..0000000000 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/DictionarySettingsParams.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.algolia.model.search; - -import com.google.gson.annotations.SerializedName; -import java.util.Objects; - -/** Disable the builtin Algolia entries for a type of dictionary per language. */ -public class DictionarySettingsParams { - - @SerializedName("disableStandardEntries") - private StandardEntries disableStandardEntries; - - public DictionarySettingsParams disableStandardEntries( - StandardEntries disableStandardEntries - ) { - this.disableStandardEntries = disableStandardEntries; - return this; - } - - /** - * Get disableStandardEntries - * - * @return disableStandardEntries - */ - @javax.annotation.Nonnull - public StandardEntries getDisableStandardEntries() { - return disableStandardEntries; - } - - public void setDisableStandardEntries( - StandardEntries disableStandardEntries - ) { - this.disableStandardEntries = disableStandardEntries; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - DictionarySettingsParams dictionarySettingsParams = (DictionarySettingsParams) o; - return Objects.equals( - this.disableStandardEntries, - dictionarySettingsParams.disableStandardEntries - ); - } - - @Override - public int hashCode() { - return Objects.hash(disableStandardEntries); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class DictionarySettingsParams {\n"); - sb - .append(" disableStandardEntries: ") - .append(toIndentedString(disableStandardEntries)) - .append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchDictionaryEntriesParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchDictionaryEntriesParams.java deleted file mode 100644 index 3aee13fa8a..0000000000 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchDictionaryEntriesParams.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.algolia.model.search; - -import com.google.gson.annotations.SerializedName; -import java.util.Objects; - -/** The `searchDictionaryEntries` parameters. */ -public class SearchDictionaryEntriesParams { - - @SerializedName("query") - private String query = ""; - - @SerializedName("page") - private Integer page = 0; - - @SerializedName("hitsPerPage") - private Integer hitsPerPage = 20; - - @SerializedName("language") - private String language; - - public SearchDictionaryEntriesParams query(String query) { - this.query = query; - return this; - } - - /** - * The text to search in the index. - * - * @return query - */ - @javax.annotation.Nonnull - public String getQuery() { - return query; - } - - public void setQuery(String query) { - this.query = query; - } - - public SearchDictionaryEntriesParams page(Integer page) { - this.page = page; - return this; - } - - /** - * Specify the page to retrieve. - * - * @return page - */ - @javax.annotation.Nullable - public Integer getPage() { - return page; - } - - public void setPage(Integer page) { - this.page = page; - } - - public SearchDictionaryEntriesParams hitsPerPage(Integer hitsPerPage) { - this.hitsPerPage = hitsPerPage; - return this; - } - - /** - * Set the number of hits per page. - * - * @return hitsPerPage - */ - @javax.annotation.Nullable - public Integer getHitsPerPage() { - return hitsPerPage; - } - - public void setHitsPerPage(Integer hitsPerPage) { - this.hitsPerPage = hitsPerPage; - } - - public SearchDictionaryEntriesParams language(String language) { - this.language = language; - return this; - } - - /** - * Language ISO code supported by the dictionary (e.g., \"en\" for English). - * - * @return language - */ - @javax.annotation.Nullable - public String getLanguage() { - return language; - } - - public void setLanguage(String language) { - this.language = language; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - SearchDictionaryEntriesParams searchDictionaryEntriesParams = (SearchDictionaryEntriesParams) o; - return ( - Objects.equals(this.query, searchDictionaryEntriesParams.query) && - Objects.equals(this.page, searchDictionaryEntriesParams.page) && - Objects.equals( - this.hitsPerPage, - searchDictionaryEntriesParams.hitsPerPage - ) && - Objects.equals(this.language, searchDictionaryEntriesParams.language) - ); - } - - @Override - public int hashCode() { - return Objects.hash(query, page, hitsPerPage, language); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class SearchDictionaryEntriesParams {\n"); - sb.append(" query: ").append(toIndentedString(query)).append("\n"); - sb.append(" page: ").append(toIndentedString(page)).append("\n"); - sb - .append(" hitsPerPage: ") - .append(toIndentedString(hitsPerPage)) - .append("\n"); - sb.append(" language: ").append(toIndentedString(language)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/Acl.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/Acl.java new file mode 100644 index 0000000000..72da04d5af --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/Acl.java @@ -0,0 +1,78 @@ +package com.algolia.model.search; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +/** Gets or Sets acl */ +@JsonAdapter(Acl.Adapter.class) +public enum Acl { + ADDOBJECT("addObject"), + + ANALYTICS("analytics"), + + BROWSE("browse"), + + DELETEOBJECT("deleteObject"), + + DELETEINDEX("deleteIndex"), + + EDITSETTINGS("editSettings"), + + LISTINDEXES("listIndexes"), + + LOGS("logs"), + + PERSONALIZATION("personalization"), + + RECOMMENDATION("recommendation"), + + SEARCH("search"), + + SEEUNRETRIEVABLEATTRIBUTES("seeUnretrievableAttributes"), + + SETTINGS("settings"), + + USAGE("usage"); + + private String value; + + Acl(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static Acl fromValue(String value) { + for (Acl b : Acl.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write(final JsonWriter jsonWriter, final Acl enumeration) + throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public Acl read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return Acl.fromValue(value); + } + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/ApiKey.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/ApiKey.java index 8e649db35d..4a460828f4 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/ApiKey.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/ApiKey.java @@ -1,11 +1,6 @@ package com.algolia.model.search; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -13,79 +8,8 @@ /** Api Key object. */ public class ApiKey { - /** Gets or Sets acl */ - @JsonAdapter(AclEnum.Adapter.class) - public enum AclEnum { - ADDOBJECT("addObject"), - - ANALYTICS("analytics"), - - BROWSE("browse"), - - DELETEOBJECT("deleteObject"), - - DELETEINDEX("deleteIndex"), - - EDITSETTINGS("editSettings"), - - LISTINDEXES("listIndexes"), - - LOGS("logs"), - - PERSONALIZATION("personalization"), - - RECOMMENDATION("recommendation"), - - SEARCH("search"), - - SEEUNRETRIEVABLEATTRIBUTES("seeUnretrievableAttributes"), - - SETTINGS("settings"), - - USAGE("usage"); - - private String value; - - AclEnum(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static AclEnum fromValue(String value) { - for (AclEnum b : AclEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter extends TypeAdapter { - - @Override - public void write(final JsonWriter jsonWriter, final AclEnum enumeration) - throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public AclEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return AclEnum.fromValue(value); - } - } - } - @SerializedName("acl") - private List acl = new ArrayList<>(); + private List acl = new ArrayList<>(); @SerializedName("description") private String description = ""; @@ -108,12 +32,12 @@ public AclEnum read(final JsonReader jsonReader) throws IOException { @SerializedName("validity") private Integer validity = 0; - public ApiKey acl(List acl) { + public ApiKey acl(List acl) { this.acl = acl; return this; } - public ApiKey addAclItem(AclEnum aclItem) { + public ApiKey addAclItem(Acl aclItem) { this.acl.add(aclItem); return this; } @@ -124,11 +48,11 @@ public ApiKey addAclItem(AclEnum aclItem) { * @return acl */ @javax.annotation.Nonnull - public List getAcl() { + public List getAcl() { return acl; } - public void setAcl(List acl) { + public void setAcl(List acl) { this.acl = acl; } diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/AroundRadius.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/AroundRadius.java new file mode 100644 index 0000000000..1ed44ea4e1 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/AroundRadius.java @@ -0,0 +1,71 @@ +package com.algolia.model.search; + +import com.algolia.JSON; +import com.algolia.utils.CompoundType; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +@JsonAdapter(AroundRadius.Adapter.class) +public abstract class AroundRadius implements CompoundType { + + public static AroundRadius of(AroundRadiusOneOf inside) { + return new AroundRadiusAroundRadiusOneOf(inside); + } + + public static AroundRadius of(Integer inside) { + return new AroundRadiusInteger(inside); + } + + public abstract Object getInsideValue(); + + public static class Adapter extends TypeAdapter { + + @Override + public void write(final JsonWriter out, final AroundRadius oneOf) + throws IOException { + TypeAdapter runtimeTypeAdapter = (TypeAdapter) JSON + .getGson() + .getAdapter(TypeToken.get(oneOf.getInsideValue().getClass())); + runtimeTypeAdapter.write(out, oneOf.getInsideValue()); + } + + @Override + public AroundRadius read(final JsonReader jsonReader) throws IOException { + return null; + } + } +} + +@JsonAdapter(AroundRadius.Adapter.class) +class AroundRadiusAroundRadiusOneOf extends AroundRadius { + + private final AroundRadiusOneOf insideValue; + + AroundRadiusAroundRadiusOneOf(AroundRadiusOneOf insideValue) { + this.insideValue = insideValue; + } + + @Override + public AroundRadiusOneOf getInsideValue() { + return insideValue; + } +} + +@JsonAdapter(AroundRadius.Adapter.class) +class AroundRadiusInteger extends AroundRadius { + + private final Integer insideValue; + + AroundRadiusInteger(Integer insideValue) { + this.insideValue = insideValue; + } + + @Override + public Integer getInsideValue() { + return insideValue; + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/AroundRadiusOneOf.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/AroundRadiusOneOf.java new file mode 100644 index 0000000000..caab5fafb0 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/AroundRadiusOneOf.java @@ -0,0 +1,55 @@ +package com.algolia.model.search; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +/** Gets or Sets aroundRadius_oneOf */ +@JsonAdapter(AroundRadiusOneOf.Adapter.class) +public enum AroundRadiusOneOf { + ALL("all"); + + private String value; + + AroundRadiusOneOf(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static AroundRadiusOneOf fromValue(String value) { + for (AroundRadiusOneOf b : AroundRadiusOneOf.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final AroundRadiusOneOf enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public AroundRadiusOneOf read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return AroundRadiusOneOf.fromValue(value); + } + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/AttributeOrBuiltInOperation.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/AttributeOrBuiltInOperation.java new file mode 100644 index 0000000000..15161aa58b --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/AttributeOrBuiltInOperation.java @@ -0,0 +1,75 @@ +package com.algolia.model.search; + +import com.algolia.JSON; +import com.algolia.utils.CompoundType; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +@JsonAdapter(AttributeOrBuiltInOperation.Adapter.class) +public abstract class AttributeOrBuiltInOperation implements CompoundType { + + public static AttributeOrBuiltInOperation of(BuiltInOperation inside) { + return new AttributeOrBuiltInOperationBuiltInOperation(inside); + } + + public static AttributeOrBuiltInOperation of(String inside) { + return new AttributeOrBuiltInOperationString(inside); + } + + public abstract Object getInsideValue(); + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter out, + final AttributeOrBuiltInOperation oneOf + ) throws IOException { + TypeAdapter runtimeTypeAdapter = (TypeAdapter) JSON + .getGson() + .getAdapter(TypeToken.get(oneOf.getInsideValue().getClass())); + runtimeTypeAdapter.write(out, oneOf.getInsideValue()); + } + + @Override + public AttributeOrBuiltInOperation read(final JsonReader jsonReader) + throws IOException { + return null; + } + } +} + +@JsonAdapter(AttributeOrBuiltInOperation.Adapter.class) +class AttributeOrBuiltInOperationBuiltInOperation + extends AttributeOrBuiltInOperation { + + private final BuiltInOperation insideValue; + + AttributeOrBuiltInOperationBuiltInOperation(BuiltInOperation insideValue) { + this.insideValue = insideValue; + } + + @Override + public BuiltInOperation getInsideValue() { + return insideValue; + } +} + +@JsonAdapter(AttributeOrBuiltInOperation.Adapter.class) +class AttributeOrBuiltInOperationString extends AttributeOrBuiltInOperation { + + private final String insideValue; + + AttributeOrBuiltInOperationString(String insideValue) { + this.insideValue = insideValue; + } + + @Override + public String getInsideValue() { + return insideValue; + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/BaseSearchParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/BaseSearchParams.java index add358c4a8..4c254e5948 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/BaseSearchParams.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/BaseSearchParams.java @@ -58,7 +58,7 @@ public class BaseSearchParams { private Boolean aroundLatLngViaIP = false; @SerializedName("aroundRadius") - private OneOfintegerstring aroundRadius; + private AroundRadius aroundRadius; @SerializedName("aroundPrecision") private Integer aroundPrecision = 10; @@ -452,22 +452,22 @@ public void setAroundLatLngViaIP(Boolean aroundLatLngViaIP) { this.aroundLatLngViaIP = aroundLatLngViaIP; } - public BaseSearchParams aroundRadius(OneOfintegerstring aroundRadius) { + public BaseSearchParams aroundRadius(AroundRadius aroundRadius) { this.aroundRadius = aroundRadius; return this; } /** - * Define the maximum radius for a geo search (in meters). + * Get aroundRadius * * @return aroundRadius */ @javax.annotation.Nullable - public OneOfintegerstring getAroundRadius() { + public AroundRadius getAroundRadius() { return aroundRadius; } - public void setAroundRadius(OneOfintegerstring aroundRadius) { + public void setAroundRadius(AroundRadius aroundRadius) { this.aroundRadius = aroundRadius; } diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/BatchDictionaryEntries.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/BatchDictionaryEntries.java deleted file mode 100644 index 7ae9e55e18..0000000000 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/BatchDictionaryEntries.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.algolia.model.search; - -import com.google.gson.annotations.SerializedName; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -/** The `batchDictionaryEntries` parameters. */ -public class BatchDictionaryEntriesParams { - - @SerializedName("clearExistingDictionaryEntries") - private Boolean clearExistingDictionaryEntries = false; - - @SerializedName("requests") - private List requests = new ArrayList<>(); - - public BatchDictionaryEntriesParams clearExistingDictionaryEntries( - Boolean clearExistingDictionaryEntries - ) { - this.clearExistingDictionaryEntries = clearExistingDictionaryEntries; - return this; - } - - /** - * When `true`, start the batch by removing all the custom entries from the dictionary. - * - * @return clearExistingDictionaryEntries - */ - @javax.annotation.Nullable - public Boolean getClearExistingDictionaryEntries() { - return clearExistingDictionaryEntries; - } - - public void setClearExistingDictionaryEntries( - Boolean clearExistingDictionaryEntries - ) { - this.clearExistingDictionaryEntries = clearExistingDictionaryEntries; - } - - public BatchDictionaryEntriesParams requests( - List requests - ) { - this.requests = requests; - return this; - } - - public BatchDictionaryEntriesParams addRequestsItem( - BatchDictionaryEntriesRequest requestsItem - ) { - this.requests.add(requestsItem); - return this; - } - - /** - * List of operations to batch. Each operation is described by an `action` and a `body`. - * - * @return requests - */ - @javax.annotation.Nonnull - public List getRequests() { - return requests; - } - - public void setRequests(List requests) { - this.requests = requests; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - BatchDictionaryEntriesParams batchDictionaryEntriesParams = (BatchDictionaryEntriesParams) o; - return ( - Objects.equals( - this.clearExistingDictionaryEntries, - batchDictionaryEntriesParams.clearExistingDictionaryEntries - ) && - Objects.equals(this.requests, batchDictionaryEntriesParams.requests) - ); - } - - @Override - public int hashCode() { - return Objects.hash(clearExistingDictionaryEntries, requests); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class BatchDictionaryEntriesParams {\n"); - sb - .append(" clearExistingDictionaryEntries: ") - .append(toIndentedString(clearExistingDictionaryEntries)) - .append("\n"); - sb.append(" requests: ").append(toIndentedString(requests)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/BatchParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/BatchParams.java index 631f95af7d..5e499cd894 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/BatchParams.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/BatchParams.java @@ -9,14 +9,14 @@ public class BatchParams { @SerializedName("requests") - private List requests = null; + private List requests = null; - public BatchParams requests(List requests) { + public BatchParams requests(List requests) { this.requests = requests; return this; } - public BatchParams addRequestsItem(Operation requestsItem) { + public BatchParams addRequestsItem(OperationIndexName requestsItem) { if (this.requests == null) { this.requests = new ArrayList<>(); } @@ -30,11 +30,11 @@ public BatchParams addRequestsItem(Operation requestsItem) { * @return requests */ @javax.annotation.Nullable - public List getRequests() { + public List getRequests() { return requests; } - public void setRequests(List requests) { + public void setRequests(List requests) { this.requests = requests; } diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/BuiltInOperation.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/BuiltInOperation.java index 0c59fc0ef6..b81e35f8c0 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/BuiltInOperation.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/BuiltInOperation.java @@ -1,11 +1,6 @@ package com.algolia.model.search; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; import java.util.Objects; /** @@ -13,88 +8,28 @@ */ public class BuiltInOperation { - /** The operation to apply on the attribute. */ - @JsonAdapter(OperationEnum.Adapter.class) - public enum OperationEnum { - INCREMENT("Increment"), - - DECREMENT("Decrement"), - - ADD("Add"), - - REMOVE("Remove"), - - ADDUNIQUE("AddUnique"), - - INCREMENTFROM("IncrementFrom"), - - INCREMENTSET("IncrementSet"); - - private String value; - - OperationEnum(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static OperationEnum fromValue(String value) { - for (OperationEnum b : OperationEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter extends TypeAdapter { - - @Override - public void write( - final JsonWriter jsonWriter, - final OperationEnum enumeration - ) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public OperationEnum read(final JsonReader jsonReader) - throws IOException { - String value = jsonReader.nextString(); - return OperationEnum.fromValue(value); - } - } - } - @SerializedName("_operation") - private OperationEnum operation; + private BuiltInOperationType operation; @SerializedName("value") private String value; - public BuiltInOperation operation(OperationEnum operation) { + public BuiltInOperation operation(BuiltInOperationType operation) { this.operation = operation; return this; } /** - * The operation to apply on the attribute. + * Get operation * * @return operation */ @javax.annotation.Nonnull - public OperationEnum getOperation() { + public BuiltInOperationType getOperation() { return operation; } - public void setOperation(OperationEnum operation) { + public void setOperation(BuiltInOperationType operation) { this.operation = operation; } diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/BuiltInOperationType.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/BuiltInOperationType.java new file mode 100644 index 0000000000..3e4cf35099 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/BuiltInOperationType.java @@ -0,0 +1,67 @@ +package com.algolia.model.search; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +/** The operation to apply on the attribute. */ +@JsonAdapter(BuiltInOperationType.Adapter.class) +public enum BuiltInOperationType { + INCREMENT("Increment"), + + DECREMENT("Decrement"), + + ADD("Add"), + + REMOVE("Remove"), + + ADDUNIQUE("AddUnique"), + + INCREMENTFROM("IncrementFrom"), + + INCREMENTSET("IncrementSet"); + + private String value; + + BuiltInOperationType(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static BuiltInOperationType fromValue(String value) { + for (BuiltInOperationType b : BuiltInOperationType.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final BuiltInOperationType enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public BuiltInOperationType read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return BuiltInOperationType.fromValue(value); + } + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/ConsequenceParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/ConsequenceParams.java index 3241c7516e..fd40be3b14 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/ConsequenceParams.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/ConsequenceParams.java @@ -72,7 +72,7 @@ public class ConsequenceParams { private Boolean aroundLatLngViaIP = false; @SerializedName("aroundRadius") - private OneOfintegerstring aroundRadius; + private AroundRadius aroundRadius; @SerializedName("aroundPrecision") private Integer aroundPrecision = 10; @@ -1005,22 +1005,22 @@ public void setAroundLatLngViaIP(Boolean aroundLatLngViaIP) { this.aroundLatLngViaIP = aroundLatLngViaIP; } - public ConsequenceParams aroundRadius(OneOfintegerstring aroundRadius) { + public ConsequenceParams aroundRadius(AroundRadius aroundRadius) { this.aroundRadius = aroundRadius; return this; } /** - * Define the maximum radius for a geo search (in meters). + * Get aroundRadius * * @return aroundRadius */ @javax.annotation.Nullable - public OneOfintegerstring getAroundRadius() { + public AroundRadius getAroundRadius() { return aroundRadius; } - public void setAroundRadius(OneOfintegerstring aroundRadius) { + public void setAroundRadius(AroundRadius aroundRadius) { this.aroundRadius = aroundRadius; } diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/DictionarySettingsRequest.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/DictionarySettingsRequest.java deleted file mode 100644 index f825ad4dbc..0000000000 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/DictionarySettingsRequest.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.algolia.model.search; - -import com.google.gson.annotations.SerializedName; -import java.util.Objects; - -/** Disable the builtin Algolia entries for a type of dictionary per language. */ -public class DictionarySettingsParams { - - @SerializedName("disableStandardEntries") - private StandardEntries disableStandardEntries; - - public DictionarySettingsParams disableStandardEntries( - StandardEntries disableStandardEntries - ) { - this.disableStandardEntries = disableStandardEntries; - return this; - } - - /** - * Get disableStandardEntries - * - * @return disableStandardEntries - */ - @javax.annotation.Nonnull - public StandardEntries getDisableStandardEntries() { - return disableStandardEntries; - } - - public void setDisableStandardEntries( - StandardEntries disableStandardEntries - ) { - this.disableStandardEntries = disableStandardEntries; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - DictionarySettingsParams dictionarySettingsParams = (DictionarySettingsParams) o; - return Objects.equals( - this.disableStandardEntries, - dictionarySettingsParams.disableStandardEntries - ); - } - - @Override - public int hashCode() { - return Objects.hash(disableStandardEntries); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class DictionarySettingsParams {\n"); - sb - .append(" disableStandardEntries: ") - .append(toIndentedString(disableStandardEntries)) - .append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/DictionaryType.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/DictionaryType.java new file mode 100644 index 0000000000..08d9ce4d48 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/DictionaryType.java @@ -0,0 +1,58 @@ +package com.algolia.model.search; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +/** Gets or Sets dictionaryType */ +@JsonAdapter(DictionaryType.Adapter.class) +public enum DictionaryType { + PLURALS("plurals"), + + STOPWORDS("stopwords"), + + COMPOUNDS("compounds"); + + private String value; + + DictionaryType(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static DictionaryType fromValue(String value) { + for (DictionaryType b : DictionaryType.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final DictionaryType enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public DictionaryType read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return DictionaryType.fromValue(value); + } + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/Key.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/Key.java index 8e2d8da338..508663e5be 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/Key.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/Key.java @@ -1,11 +1,6 @@ package com.algolia.model.search; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -13,79 +8,8 @@ /** Key */ public class Key { - /** Gets or Sets acl */ - @JsonAdapter(AclEnum.Adapter.class) - public enum AclEnum { - ADDOBJECT("addObject"), - - ANALYTICS("analytics"), - - BROWSE("browse"), - - DELETEOBJECT("deleteObject"), - - DELETEINDEX("deleteIndex"), - - EDITSETTINGS("editSettings"), - - LISTINDEXES("listIndexes"), - - LOGS("logs"), - - PERSONALIZATION("personalization"), - - RECOMMENDATION("recommendation"), - - SEARCH("search"), - - SEEUNRETRIEVABLEATTRIBUTES("seeUnretrievableAttributes"), - - SETTINGS("settings"), - - USAGE("usage"); - - private String value; - - AclEnum(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static AclEnum fromValue(String value) { - for (AclEnum b : AclEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter extends TypeAdapter { - - @Override - public void write(final JsonWriter jsonWriter, final AclEnum enumeration) - throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public AclEnum read(final JsonReader jsonReader) throws IOException { - String value = jsonReader.nextString(); - return AclEnum.fromValue(value); - } - } - } - @SerializedName("acl") - private List acl = new ArrayList<>(); + private List acl = new ArrayList<>(); @SerializedName("description") private String description = ""; @@ -111,12 +35,12 @@ public AclEnum read(final JsonReader jsonReader) throws IOException { @SerializedName("createdAt") private String createdAt; - public Key acl(List acl) { + public Key acl(List acl) { this.acl = acl; return this; } - public Key addAclItem(AclEnum aclItem) { + public Key addAclItem(Acl aclItem) { this.acl.add(aclItem); return this; } @@ -127,11 +51,11 @@ public Key addAclItem(AclEnum aclItem) { * @return acl */ @javax.annotation.Nonnull - public List getAcl() { + public List getAcl() { return acl; } - public void setAcl(List acl) { + public void setAcl(List acl) { this.acl = acl; } diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/LogType.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/LogType.java new file mode 100644 index 0000000000..96fe00f6c6 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/LogType.java @@ -0,0 +1,58 @@ +package com.algolia.model.search; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +/** Gets or Sets logType */ +@JsonAdapter(LogType.Adapter.class) +public enum LogType { + ALL("all"), + + QUERY("query"), + + BUILD("build"), + + ERROR("error"); + + private String value; + + LogType(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static LogType fromValue(String value) { + for (LogType b : LogType.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write(final JsonWriter jsonWriter, final LogType enumeration) + throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public LogType read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return LogType.fromValue(value); + } + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/OneOfintegerstring.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/OneOfintegerstring.java deleted file mode 100644 index 00156b3140..0000000000 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/OneOfintegerstring.java +++ /dev/null @@ -1,3 +0,0 @@ -package com.algolia.model; - -public class OneOfintegerstring {} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/OneOfstringbuiltInOperation.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/OneOfstringbuiltInOperation.java deleted file mode 100644 index 8ac01fc739..0000000000 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/OneOfstringbuiltInOperation.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.algolia.model; - -import com.google.gson.annotations.SerializedName; - -public class OneOfstringbuiltInOperation { - - @SerializedName("_operation") - private String _operation; - - @SerializedName("value") - private String value; - - public void set_operation(String op) { - _operation = op; - } - - public void setValue(String value) { - this.value = value; - } -} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/Operation.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/Operation.java index 440277f23c..cecab2f4b4 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/Operation.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/Operation.java @@ -12,9 +12,6 @@ public class Operation { @SerializedName("body") private Object body; - @SerializedName("indexName") - private String indexName; - public Operation action(Action action) { this.action = action; return this; @@ -53,25 +50,6 @@ public void setBody(Object body) { this.body = body; } - public Operation indexName(String indexName) { - this.indexName = indexName; - return this; - } - - /** - * Index to target for this operation. - * - * @return indexName - */ - @javax.annotation.Nullable - public String getIndexName() { - return indexName; - } - - public void setIndexName(String indexName) { - this.indexName = indexName; - } - @Override public boolean equals(Object o) { if (this == o) { @@ -83,14 +61,13 @@ public boolean equals(Object o) { Operation operation = (Operation) o; return ( Objects.equals(this.action, operation.action) && - Objects.equals(this.body, operation.body) && - Objects.equals(this.indexName, operation.indexName) + Objects.equals(this.body, operation.body) ); } @Override public int hashCode() { - return Objects.hash(action, body, indexName); + return Objects.hash(action, body); } @Override @@ -99,10 +76,6 @@ public String toString() { sb.append("class Operation {\n"); sb.append(" action: ").append(toIndentedString(action)).append("\n"); sb.append(" body: ").append(toIndentedString(body)).append("\n"); - sb - .append(" indexName: ") - .append(toIndentedString(indexName)) - .append("\n"); sb.append("}"); return sb.toString(); } diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/OperationIndexName.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/OperationIndexName.java new file mode 100644 index 0000000000..686a38508d --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/OperationIndexName.java @@ -0,0 +1,119 @@ +package com.algolia.model.search; + +import com.google.gson.annotations.SerializedName; +import java.util.Objects; + +/** OperationIndexName */ +public class OperationIndexName { + + @SerializedName("action") + private Action action; + + @SerializedName("body") + private Object body; + + @SerializedName("indexName") + private String indexName; + + public OperationIndexName action(Action action) { + this.action = action; + return this; + } + + /** + * Get action + * + * @return action + */ + @javax.annotation.Nullable + public Action getAction() { + return action; + } + + public void setAction(Action action) { + this.action = action; + } + + public OperationIndexName body(Object body) { + this.body = body; + return this; + } + + /** + * arguments to the operation (depends on the type of the operation). + * + * @return body + */ + @javax.annotation.Nullable + public Object getBody() { + return body; + } + + public void setBody(Object body) { + this.body = body; + } + + public OperationIndexName indexName(String indexName) { + this.indexName = indexName; + return this; + } + + /** + * Index to target for this operation. + * + * @return indexName + */ + @javax.annotation.Nullable + public String getIndexName() { + return indexName; + } + + public void setIndexName(String indexName) { + this.indexName = indexName; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OperationIndexName operationIndexName = (OperationIndexName) o; + return ( + Objects.equals(this.action, operationIndexName.action) && + Objects.equals(this.body, operationIndexName.body) && + Objects.equals(this.indexName, operationIndexName.indexName) + ); + } + + @Override + public int hashCode() { + return Objects.hash(action, body, indexName); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OperationIndexName {\n"); + sb.append(" action: ").append(toIndentedString(action)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb + .append(" indexName: ") + .append(toIndentedString(indexName)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/SearchDictionaryEntries.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/SearchDictionaryEntries.java deleted file mode 100644 index 3aee13fa8a..0000000000 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/SearchDictionaryEntries.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.algolia.model.search; - -import com.google.gson.annotations.SerializedName; -import java.util.Objects; - -/** The `searchDictionaryEntries` parameters. */ -public class SearchDictionaryEntriesParams { - - @SerializedName("query") - private String query = ""; - - @SerializedName("page") - private Integer page = 0; - - @SerializedName("hitsPerPage") - private Integer hitsPerPage = 20; - - @SerializedName("language") - private String language; - - public SearchDictionaryEntriesParams query(String query) { - this.query = query; - return this; - } - - /** - * The text to search in the index. - * - * @return query - */ - @javax.annotation.Nonnull - public String getQuery() { - return query; - } - - public void setQuery(String query) { - this.query = query; - } - - public SearchDictionaryEntriesParams page(Integer page) { - this.page = page; - return this; - } - - /** - * Specify the page to retrieve. - * - * @return page - */ - @javax.annotation.Nullable - public Integer getPage() { - return page; - } - - public void setPage(Integer page) { - this.page = page; - } - - public SearchDictionaryEntriesParams hitsPerPage(Integer hitsPerPage) { - this.hitsPerPage = hitsPerPage; - return this; - } - - /** - * Set the number of hits per page. - * - * @return hitsPerPage - */ - @javax.annotation.Nullable - public Integer getHitsPerPage() { - return hitsPerPage; - } - - public void setHitsPerPage(Integer hitsPerPage) { - this.hitsPerPage = hitsPerPage; - } - - public SearchDictionaryEntriesParams language(String language) { - this.language = language; - return this; - } - - /** - * Language ISO code supported by the dictionary (e.g., \"en\" for English). - * - * @return language - */ - @javax.annotation.Nullable - public String getLanguage() { - return language; - } - - public void setLanguage(String language) { - this.language = language; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - SearchDictionaryEntriesParams searchDictionaryEntriesParams = (SearchDictionaryEntriesParams) o; - return ( - Objects.equals(this.query, searchDictionaryEntriesParams.query) && - Objects.equals(this.page, searchDictionaryEntriesParams.page) && - Objects.equals( - this.hitsPerPage, - searchDictionaryEntriesParams.hitsPerPage - ) && - Objects.equals(this.language, searchDictionaryEntriesParams.language) - ); - } - - @Override - public int hashCode() { - return Objects.hash(query, page, hitsPerPage, language); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class SearchDictionaryEntriesParams {\n"); - sb.append(" query: ").append(toIndentedString(query)).append("\n"); - sb.append(" page: ").append(toIndentedString(page)).append("\n"); - sb - .append(" hitsPerPage: ") - .append(toIndentedString(hitsPerPage)) - .append("\n"); - sb.append(" language: ").append(toIndentedString(language)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/SearchParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/SearchParams.java index 76be07a03c..148231ce59 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/SearchParams.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/SearchParams.java @@ -1,2913 +1,71 @@ package com.algolia.model.search; +import com.algolia.JSON; +import com.algolia.utils.CompoundType; import com.google.gson.TypeAdapter; import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -/** SearchParams */ -public class SearchParams { +@JsonAdapter(SearchParams.Adapter.class) +public abstract class SearchParams implements CompoundType { - @SerializedName("params") - private String params = ""; - - @SerializedName("similarQuery") - private String similarQuery = ""; - - @SerializedName("filters") - private String filters = ""; - - @SerializedName("facetFilters") - private List facetFilters = null; - - @SerializedName("optionalFilters") - private List optionalFilters = null; - - @SerializedName("numericFilters") - private List numericFilters = null; - - @SerializedName("tagFilters") - private List tagFilters = null; - - @SerializedName("sumOrFiltersScores") - private Boolean sumOrFiltersScores = false; - - @SerializedName("facets") - private List facets = null; - - @SerializedName("maxValuesPerFacet") - private Integer maxValuesPerFacet = 100; - - @SerializedName("facetingAfterDistinct") - private Boolean facetingAfterDistinct = false; - - @SerializedName("sortFacetValuesBy") - private String sortFacetValuesBy = "count"; - - @SerializedName("page") - private Integer page = 0; - - @SerializedName("offset") - private Integer offset; - - @SerializedName("length") - private Integer length; - - @SerializedName("aroundLatLng") - private String aroundLatLng = ""; - - @SerializedName("aroundLatLngViaIP") - private Boolean aroundLatLngViaIP = false; - - @SerializedName("aroundRadius") - private OneOfintegerstring aroundRadius; - - @SerializedName("aroundPrecision") - private Integer aroundPrecision = 10; - - @SerializedName("minimumAroundRadius") - private Integer minimumAroundRadius; - - @SerializedName("insideBoundingBox") - private List insideBoundingBox = null; - - @SerializedName("insidePolygon") - private List insidePolygon = null; - - @SerializedName("naturalLanguages") - private List naturalLanguages = null; - - @SerializedName("ruleContexts") - private List ruleContexts = null; - - @SerializedName("personalizationImpact") - private Integer personalizationImpact = 100; - - @SerializedName("userToken") - private String userToken; - - @SerializedName("getRankingInfo") - private Boolean getRankingInfo = false; - - @SerializedName("clickAnalytics") - private Boolean clickAnalytics = false; - - @SerializedName("analytics") - private Boolean analytics = true; - - @SerializedName("analyticsTags") - private List analyticsTags = null; - - @SerializedName("percentileComputation") - private Boolean percentileComputation = true; - - @SerializedName("enableABTest") - private Boolean enableABTest = true; - - @SerializedName("enableReRanking") - private Boolean enableReRanking = true; - - @SerializedName("query") - private String query = ""; - - @SerializedName("searchableAttributes") - private List searchableAttributes = null; - - @SerializedName("attributesForFaceting") - private List attributesForFaceting = null; - - @SerializedName("unretrievableAttributes") - private List unretrievableAttributes = null; - - @SerializedName("attributesToRetrieve") - private List attributesToRetrieve = null; - - @SerializedName("restrictSearchableAttributes") - private List restrictSearchableAttributes = null; - - @SerializedName("ranking") - private List ranking = null; - - @SerializedName("customRanking") - private List customRanking = null; - - @SerializedName("relevancyStrictness") - private Integer relevancyStrictness = 100; - - @SerializedName("attributesToHighlight") - private List attributesToHighlight = null; - - @SerializedName("attributesToSnippet") - private List attributesToSnippet = null; - - @SerializedName("highlightPreTag") - private String highlightPreTag = ""; - - @SerializedName("highlightPostTag") - private String highlightPostTag = ""; - - @SerializedName("snippetEllipsisText") - private String snippetEllipsisText = "…"; - - @SerializedName("restrictHighlightAndSnippetArrays") - private Boolean restrictHighlightAndSnippetArrays = false; - - @SerializedName("hitsPerPage") - private Integer hitsPerPage = 20; - - @SerializedName("minWordSizefor1Typo") - private Integer minWordSizefor1Typo = 4; - - @SerializedName("minWordSizefor2Typos") - private Integer minWordSizefor2Typos = 8; - - /** Controls whether typo tolerance is enabled and how it is applied. */ - @JsonAdapter(TypoToleranceEnum.Adapter.class) - public enum TypoToleranceEnum { - TRUE("true"), - - FALSE("false"), - - MIN("min"), - - STRICT("strict"); - - private String value; - - TypoToleranceEnum(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static TypoToleranceEnum fromValue(String value) { - for (TypoToleranceEnum b : TypoToleranceEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter extends TypeAdapter { - - @Override - public void write( - final JsonWriter jsonWriter, - final TypoToleranceEnum enumeration - ) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public TypoToleranceEnum read(final JsonReader jsonReader) - throws IOException { - String value = jsonReader.nextString(); - return TypoToleranceEnum.fromValue(value); - } - } - } - - @SerializedName("typoTolerance") - private TypoToleranceEnum typoTolerance = TypoToleranceEnum.TRUE; - - @SerializedName("allowTyposOnNumericTokens") - private Boolean allowTyposOnNumericTokens = true; - - @SerializedName("disableTypoToleranceOnAttributes") - private List disableTypoToleranceOnAttributes = null; - - @SerializedName("separatorsToIndex") - private String separatorsToIndex = ""; - - @SerializedName("ignorePlurals") - private String ignorePlurals = "false"; - - @SerializedName("removeStopWords") - private String removeStopWords = "false"; - - @SerializedName("keepDiacriticsOnCharacters") - private String keepDiacriticsOnCharacters = ""; - - @SerializedName("queryLanguages") - private List queryLanguages = null; - - @SerializedName("decompoundQuery") - private Boolean decompoundQuery = true; - - @SerializedName("enableRules") - private Boolean enableRules = true; - - @SerializedName("enablePersonalization") - private Boolean enablePersonalization = false; - - /** Controls if and how query words are interpreted as prefixes. */ - @JsonAdapter(QueryTypeEnum.Adapter.class) - public enum QueryTypeEnum { - PREFIXLAST("prefixLast"), - - PREFIXALL("prefixAll"), - - PREFIXNONE("prefixNone"); - - private String value; - - QueryTypeEnum(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static QueryTypeEnum fromValue(String value) { - for (QueryTypeEnum b : QueryTypeEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter extends TypeAdapter { - - @Override - public void write( - final JsonWriter jsonWriter, - final QueryTypeEnum enumeration - ) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public QueryTypeEnum read(final JsonReader jsonReader) - throws IOException { - String value = jsonReader.nextString(); - return QueryTypeEnum.fromValue(value); - } - } - } - - @SerializedName("queryType") - private QueryTypeEnum queryType = QueryTypeEnum.PREFIXLAST; - - /** Selects a strategy to remove words from the query when it doesn't match any hits. */ - @JsonAdapter(RemoveWordsIfNoResultsEnum.Adapter.class) - public enum RemoveWordsIfNoResultsEnum { - NONE("none"), - - LASTWORDS("lastWords"), - - FIRSTWORDS("firstWords"), - - ALLOPTIONAL("allOptional"); - - private String value; - - RemoveWordsIfNoResultsEnum(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static RemoveWordsIfNoResultsEnum fromValue(String value) { - for (RemoveWordsIfNoResultsEnum b : RemoveWordsIfNoResultsEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter - extends TypeAdapter { - - @Override - public void write( - final JsonWriter jsonWriter, - final RemoveWordsIfNoResultsEnum enumeration - ) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public RemoveWordsIfNoResultsEnum read(final JsonReader jsonReader) - throws IOException { - String value = jsonReader.nextString(); - return RemoveWordsIfNoResultsEnum.fromValue(value); - } - } + public static SearchParams of(SearchParamsObject inside) { + return new SearchParamsSearchParamsObject(inside); } - @SerializedName("removeWordsIfNoResults") - private RemoveWordsIfNoResultsEnum removeWordsIfNoResults = - RemoveWordsIfNoResultsEnum.NONE; - - @SerializedName("advancedSyntax") - private Boolean advancedSyntax = false; - - @SerializedName("optionalWords") - private List optionalWords = null; - - @SerializedName("disableExactOnAttributes") - private List disableExactOnAttributes = null; - - /** Controls how the exact ranking criterion is computed when the query contains only one word. */ - @JsonAdapter(ExactOnSingleWordQueryEnum.Adapter.class) - public enum ExactOnSingleWordQueryEnum { - ATTRIBUTE("attribute"), - - NONE("none"), - - WORD("word"); - - private String value; - - ExactOnSingleWordQueryEnum(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - public static ExactOnSingleWordQueryEnum fromValue(String value) { - for (ExactOnSingleWordQueryEnum b : ExactOnSingleWordQueryEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter - extends TypeAdapter { - - @Override - public void write( - final JsonWriter jsonWriter, - final ExactOnSingleWordQueryEnum enumeration - ) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public ExactOnSingleWordQueryEnum read(final JsonReader jsonReader) - throws IOException { - String value = jsonReader.nextString(); - return ExactOnSingleWordQueryEnum.fromValue(value); - } - } + public static SearchParams of(SearchParamsString inside) { + return new SearchParamsSearchParamsString(inside); } - @SerializedName("exactOnSingleWordQuery") - private ExactOnSingleWordQueryEnum exactOnSingleWordQuery = - ExactOnSingleWordQueryEnum.ATTRIBUTE; - - /** Gets or Sets alternativesAsExact */ - @JsonAdapter(AlternativesAsExactEnum.Adapter.class) - public enum AlternativesAsExactEnum { - IGNOREPLURALS("ignorePlurals"), - - SINGLEWORDSYNONYM("singleWordSynonym"), - - MULTIWORDSSYNONYM("multiWordsSynonym"); + public abstract Object getInsideValue(); - private String value; - - AlternativesAsExactEnum(String value) { - this.value = value; - } - - public String getValue() { - return value; - } + public static class Adapter extends TypeAdapter { @Override - public String toString() { - return String.valueOf(value); - } - - public static AlternativesAsExactEnum fromValue(String value) { - for (AlternativesAsExactEnum b : AlternativesAsExactEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter extends TypeAdapter { - - @Override - public void write( - final JsonWriter jsonWriter, - final AlternativesAsExactEnum enumeration - ) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public AlternativesAsExactEnum read(final JsonReader jsonReader) - throws IOException { - String value = jsonReader.nextString(); - return AlternativesAsExactEnum.fromValue(value); - } - } - } - - @SerializedName("alternativesAsExact") - private List alternativesAsExact = null; - - /** Gets or Sets advancedSyntaxFeatures */ - @JsonAdapter(AdvancedSyntaxFeaturesEnum.Adapter.class) - public enum AdvancedSyntaxFeaturesEnum { - EXACTPHRASE("exactPhrase"), - - EXCLUDEWORDS("excludeWords"); - - private String value; - - AdvancedSyntaxFeaturesEnum(String value) { - this.value = value; - } - - public String getValue() { - return value; + public void write(final JsonWriter out, final SearchParams oneOf) + throws IOException { + TypeAdapter runtimeTypeAdapter = (TypeAdapter) JSON + .getGson() + .getAdapter(TypeToken.get(oneOf.getInsideValue().getClass())); + runtimeTypeAdapter.write(out, oneOf.getInsideValue()); } @Override - public String toString() { - return String.valueOf(value); - } - - public static AdvancedSyntaxFeaturesEnum fromValue(String value) { - for (AdvancedSyntaxFeaturesEnum b : AdvancedSyntaxFeaturesEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - throw new IllegalArgumentException("Unexpected value '" + value + "'"); - } - - public static class Adapter - extends TypeAdapter { - - @Override - public void write( - final JsonWriter jsonWriter, - final AdvancedSyntaxFeaturesEnum enumeration - ) throws IOException { - jsonWriter.value(enumeration.getValue()); - } - - @Override - public AdvancedSyntaxFeaturesEnum read(final JsonReader jsonReader) - throws IOException { - String value = jsonReader.nextString(); - return AdvancedSyntaxFeaturesEnum.fromValue(value); - } - } - } - - @SerializedName("advancedSyntaxFeatures") - private List advancedSyntaxFeatures = null; - - @SerializedName("distinct") - private Integer distinct = 0; - - @SerializedName("synonyms") - private Boolean synonyms = true; - - @SerializedName("replaceSynonymsInHighlight") - private Boolean replaceSynonymsInHighlight = false; - - @SerializedName("minProximity") - private Integer minProximity = 1; - - @SerializedName("responseFields") - private List responseFields = null; - - @SerializedName("maxFacetHits") - private Integer maxFacetHits = 10; - - @SerializedName("attributeCriteriaComputedByMinProximity") - private Boolean attributeCriteriaComputedByMinProximity = false; - - @SerializedName("renderingContent") - private Object renderingContent = new Object(); - - public SearchParams params(String params) { - this.params = params; - return this; - } - - /** - * Search parameters as URL-encoded query string. - * - * @return params - */ - @javax.annotation.Nullable - public String getParams() { - return params; - } - - public void setParams(String params) { - this.params = params; - } - - public SearchParams similarQuery(String similarQuery) { - this.similarQuery = similarQuery; - return this; - } - - /** - * Overrides the query parameter and performs a more generic search that can be used to find - * \"similar\" results. - * - * @return similarQuery - */ - @javax.annotation.Nullable - public String getSimilarQuery() { - return similarQuery; - } - - public void setSimilarQuery(String similarQuery) { - this.similarQuery = similarQuery; - } - - public SearchParams filters(String filters) { - this.filters = filters; - return this; - } - - /** - * Filter the query with numeric, facet and/or tag filters. - * - * @return filters - */ - @javax.annotation.Nullable - public String getFilters() { - return filters; - } - - public void setFilters(String filters) { - this.filters = filters; - } - - public SearchParams facetFilters(List facetFilters) { - this.facetFilters = facetFilters; - return this; - } - - public SearchParams addFacetFiltersItem(String facetFiltersItem) { - if (this.facetFilters == null) { - this.facetFilters = new ArrayList<>(); - } - this.facetFilters.add(facetFiltersItem); - return this; - } - - /** - * Filter hits by facet value. - * - * @return facetFilters - */ - @javax.annotation.Nullable - public List getFacetFilters() { - return facetFilters; - } - - public void setFacetFilters(List facetFilters) { - this.facetFilters = facetFilters; - } - - public SearchParams optionalFilters(List optionalFilters) { - this.optionalFilters = optionalFilters; - return this; - } - - public SearchParams addOptionalFiltersItem(String optionalFiltersItem) { - if (this.optionalFilters == null) { - this.optionalFilters = new ArrayList<>(); - } - this.optionalFilters.add(optionalFiltersItem); - return this; - } - - /** - * Create filters for ranking purposes, where records that match the filter are ranked higher, or - * lower in the case of a negative optional filter. - * - * @return optionalFilters - */ - @javax.annotation.Nullable - public List getOptionalFilters() { - return optionalFilters; - } - - public void setOptionalFilters(List optionalFilters) { - this.optionalFilters = optionalFilters; - } - - public SearchParams numericFilters(List numericFilters) { - this.numericFilters = numericFilters; - return this; - } - - public SearchParams addNumericFiltersItem(String numericFiltersItem) { - if (this.numericFilters == null) { - this.numericFilters = new ArrayList<>(); - } - this.numericFilters.add(numericFiltersItem); - return this; - } - - /** - * Filter on numeric attributes. - * - * @return numericFilters - */ - @javax.annotation.Nullable - public List getNumericFilters() { - return numericFilters; - } - - public void setNumericFilters(List numericFilters) { - this.numericFilters = numericFilters; - } - - public SearchParams tagFilters(List tagFilters) { - this.tagFilters = tagFilters; - return this; - } - - public SearchParams addTagFiltersItem(String tagFiltersItem) { - if (this.tagFilters == null) { - this.tagFilters = new ArrayList<>(); + public SearchParams read(final JsonReader jsonReader) throws IOException { + return null; } - this.tagFilters.add(tagFiltersItem); - return this; - } - - /** - * Filter hits by tags. - * - * @return tagFilters - */ - @javax.annotation.Nullable - public List getTagFilters() { - return tagFilters; - } - - public void setTagFilters(List tagFilters) { - this.tagFilters = tagFilters; - } - - public SearchParams sumOrFiltersScores(Boolean sumOrFiltersScores) { - this.sumOrFiltersScores = sumOrFiltersScores; - return this; - } - - /** - * Determines how to calculate the total score for filtering. - * - * @return sumOrFiltersScores - */ - @javax.annotation.Nullable - public Boolean getSumOrFiltersScores() { - return sumOrFiltersScores; - } - - public void setSumOrFiltersScores(Boolean sumOrFiltersScores) { - this.sumOrFiltersScores = sumOrFiltersScores; - } - - public SearchParams facets(List facets) { - this.facets = facets; - return this; - } - - public SearchParams addFacetsItem(String facetsItem) { - if (this.facets == null) { - this.facets = new ArrayList<>(); - } - this.facets.add(facetsItem); - return this; - } - - /** - * Retrieve facets and their facet values. - * - * @return facets - */ - @javax.annotation.Nullable - public List getFacets() { - return facets; - } - - public void setFacets(List facets) { - this.facets = facets; - } - - public SearchParams maxValuesPerFacet(Integer maxValuesPerFacet) { - this.maxValuesPerFacet = maxValuesPerFacet; - return this; - } - - /** - * Maximum number of facet values to return for each facet during a regular search. - * - * @return maxValuesPerFacet - */ - @javax.annotation.Nullable - public Integer getMaxValuesPerFacet() { - return maxValuesPerFacet; - } - - public void setMaxValuesPerFacet(Integer maxValuesPerFacet) { - this.maxValuesPerFacet = maxValuesPerFacet; } +} - public SearchParams facetingAfterDistinct(Boolean facetingAfterDistinct) { - this.facetingAfterDistinct = facetingAfterDistinct; - return this; - } +@JsonAdapter(SearchParams.Adapter.class) +class SearchParamsSearchParamsObject extends SearchParams { - /** - * Force faceting to be applied after de-duplication (via the Distinct setting). - * - * @return facetingAfterDistinct - */ - @javax.annotation.Nullable - public Boolean getFacetingAfterDistinct() { - return facetingAfterDistinct; - } + private final SearchParamsObject insideValue; - public void setFacetingAfterDistinct(Boolean facetingAfterDistinct) { - this.facetingAfterDistinct = facetingAfterDistinct; + SearchParamsSearchParamsObject(SearchParamsObject insideValue) { + this.insideValue = insideValue; } - public SearchParams sortFacetValuesBy(String sortFacetValuesBy) { - this.sortFacetValuesBy = sortFacetValuesBy; - return this; + @Override + public SearchParamsObject getInsideValue() { + return insideValue; } +} - /** - * Controls how facet values are fetched. - * - * @return sortFacetValuesBy - */ - @javax.annotation.Nullable - public String getSortFacetValuesBy() { - return sortFacetValuesBy; - } +@JsonAdapter(SearchParams.Adapter.class) +class SearchParamsSearchParamsString extends SearchParams { - public void setSortFacetValuesBy(String sortFacetValuesBy) { - this.sortFacetValuesBy = sortFacetValuesBy; - } + private final SearchParamsString insideValue; - public SearchParams page(Integer page) { - this.page = page; - return this; - } - - /** - * Specify the page to retrieve. - * - * @return page - */ - @javax.annotation.Nullable - public Integer getPage() { - return page; - } - - public void setPage(Integer page) { - this.page = page; - } - - public SearchParams offset(Integer offset) { - this.offset = offset; - return this; - } - - /** - * Specify the offset of the first hit to return. - * - * @return offset - */ - @javax.annotation.Nullable - public Integer getOffset() { - return offset; - } - - public void setOffset(Integer offset) { - this.offset = offset; - } - - public SearchParams length(Integer length) { - this.length = length; - return this; - } - - /** - * Set the number of hits to retrieve (used only with offset). minimum: 1 maximum: 1000 - * - * @return length - */ - @javax.annotation.Nullable - public Integer getLength() { - return length; - } - - public void setLength(Integer length) { - this.length = length; - } - - public SearchParams aroundLatLng(String aroundLatLng) { - this.aroundLatLng = aroundLatLng; - return this; - } - - /** - * Search for entries around a central geolocation, enabling a geo search within a circular area. - * - * @return aroundLatLng - */ - @javax.annotation.Nullable - public String getAroundLatLng() { - return aroundLatLng; - } - - public void setAroundLatLng(String aroundLatLng) { - this.aroundLatLng = aroundLatLng; - } - - public SearchParams aroundLatLngViaIP(Boolean aroundLatLngViaIP) { - this.aroundLatLngViaIP = aroundLatLngViaIP; - return this; - } - - /** - * Search for entries around a given location automatically computed from the requester's IP - * address. - * - * @return aroundLatLngViaIP - */ - @javax.annotation.Nullable - public Boolean getAroundLatLngViaIP() { - return aroundLatLngViaIP; - } - - public void setAroundLatLngViaIP(Boolean aroundLatLngViaIP) { - this.aroundLatLngViaIP = aroundLatLngViaIP; - } - - public SearchParams aroundRadius(OneOfintegerstring aroundRadius) { - this.aroundRadius = aroundRadius; - return this; - } - - /** - * Define the maximum radius for a geo search (in meters). - * - * @return aroundRadius - */ - @javax.annotation.Nullable - public OneOfintegerstring getAroundRadius() { - return aroundRadius; - } - - public void setAroundRadius(OneOfintegerstring aroundRadius) { - this.aroundRadius = aroundRadius; - } - - public SearchParams aroundPrecision(Integer aroundPrecision) { - this.aroundPrecision = aroundPrecision; - return this; - } - - /** - * Precision of geo search (in meters), to add grouping by geo location to the ranking formula. - * - * @return aroundPrecision - */ - @javax.annotation.Nullable - public Integer getAroundPrecision() { - return aroundPrecision; - } - - public void setAroundPrecision(Integer aroundPrecision) { - this.aroundPrecision = aroundPrecision; - } - - public SearchParams minimumAroundRadius(Integer minimumAroundRadius) { - this.minimumAroundRadius = minimumAroundRadius; - return this; - } - - /** - * Minimum radius (in meters) used for a geo search when aroundRadius is not set. minimum: 1 - * - * @return minimumAroundRadius - */ - @javax.annotation.Nullable - public Integer getMinimumAroundRadius() { - return minimumAroundRadius; - } - - public void setMinimumAroundRadius(Integer minimumAroundRadius) { - this.minimumAroundRadius = minimumAroundRadius; - } - - public SearchParams insideBoundingBox(List insideBoundingBox) { - this.insideBoundingBox = insideBoundingBox; - return this; - } - - public SearchParams addInsideBoundingBoxItem( - BigDecimal insideBoundingBoxItem - ) { - if (this.insideBoundingBox == null) { - this.insideBoundingBox = new ArrayList<>(); - } - this.insideBoundingBox.add(insideBoundingBoxItem); - return this; - } - - /** - * Search inside a rectangular area (in geo coordinates). - * - * @return insideBoundingBox - */ - @javax.annotation.Nullable - public List getInsideBoundingBox() { - return insideBoundingBox; - } - - public void setInsideBoundingBox(List insideBoundingBox) { - this.insideBoundingBox = insideBoundingBox; - } - - public SearchParams insidePolygon(List insidePolygon) { - this.insidePolygon = insidePolygon; - return this; - } - - public SearchParams addInsidePolygonItem(BigDecimal insidePolygonItem) { - if (this.insidePolygon == null) { - this.insidePolygon = new ArrayList<>(); - } - this.insidePolygon.add(insidePolygonItem); - return this; - } - - /** - * Search inside a polygon (in geo coordinates). - * - * @return insidePolygon - */ - @javax.annotation.Nullable - public List getInsidePolygon() { - return insidePolygon; - } - - public void setInsidePolygon(List insidePolygon) { - this.insidePolygon = insidePolygon; - } - - public SearchParams naturalLanguages(List naturalLanguages) { - this.naturalLanguages = naturalLanguages; - return this; - } - - public SearchParams addNaturalLanguagesItem(String naturalLanguagesItem) { - if (this.naturalLanguages == null) { - this.naturalLanguages = new ArrayList<>(); - } - this.naturalLanguages.add(naturalLanguagesItem); - return this; - } - - /** - * This parameter changes the default values of certain parameters and settings that work best for - * a natural language query, such as ignorePlurals, removeStopWords, removeWordsIfNoResults, - * analyticsTags and ruleContexts. These parameters and settings work well together when the query - * is formatted in natural language instead of keywords, for example when your user performs a - * voice search. - * - * @return naturalLanguages - */ - @javax.annotation.Nullable - public List getNaturalLanguages() { - return naturalLanguages; - } - - public void setNaturalLanguages(List naturalLanguages) { - this.naturalLanguages = naturalLanguages; - } - - public SearchParams ruleContexts(List ruleContexts) { - this.ruleContexts = ruleContexts; - return this; - } - - public SearchParams addRuleContextsItem(String ruleContextsItem) { - if (this.ruleContexts == null) { - this.ruleContexts = new ArrayList<>(); - } - this.ruleContexts.add(ruleContextsItem); - return this; - } - - /** - * Enables contextual rules. - * - * @return ruleContexts - */ - @javax.annotation.Nullable - public List getRuleContexts() { - return ruleContexts; - } - - public void setRuleContexts(List ruleContexts) { - this.ruleContexts = ruleContexts; - } - - public SearchParams personalizationImpact(Integer personalizationImpact) { - this.personalizationImpact = personalizationImpact; - return this; - } - - /** - * Define the impact of the Personalization feature. - * - * @return personalizationImpact - */ - @javax.annotation.Nullable - public Integer getPersonalizationImpact() { - return personalizationImpact; - } - - public void setPersonalizationImpact(Integer personalizationImpact) { - this.personalizationImpact = personalizationImpact; - } - - public SearchParams userToken(String userToken) { - this.userToken = userToken; - return this; - } - - /** - * Associates a certain user token with the current search. - * - * @return userToken - */ - @javax.annotation.Nullable - public String getUserToken() { - return userToken; - } - - public void setUserToken(String userToken) { - this.userToken = userToken; - } - - public SearchParams getRankingInfo(Boolean getRankingInfo) { - this.getRankingInfo = getRankingInfo; - return this; - } - - /** - * Retrieve detailed ranking information. - * - * @return getRankingInfo - */ - @javax.annotation.Nullable - public Boolean getGetRankingInfo() { - return getRankingInfo; - } - - public void setGetRankingInfo(Boolean getRankingInfo) { - this.getRankingInfo = getRankingInfo; - } - - public SearchParams clickAnalytics(Boolean clickAnalytics) { - this.clickAnalytics = clickAnalytics; - return this; - } - - /** - * Enable the Click Analytics feature. - * - * @return clickAnalytics - */ - @javax.annotation.Nullable - public Boolean getClickAnalytics() { - return clickAnalytics; - } - - public void setClickAnalytics(Boolean clickAnalytics) { - this.clickAnalytics = clickAnalytics; - } - - public SearchParams analytics(Boolean analytics) { - this.analytics = analytics; - return this; - } - - /** - * Whether the current query will be taken into account in the Analytics. - * - * @return analytics - */ - @javax.annotation.Nullable - public Boolean getAnalytics() { - return analytics; - } - - public void setAnalytics(Boolean analytics) { - this.analytics = analytics; - } - - public SearchParams analyticsTags(List analyticsTags) { - this.analyticsTags = analyticsTags; - return this; - } - - public SearchParams addAnalyticsTagsItem(String analyticsTagsItem) { - if (this.analyticsTags == null) { - this.analyticsTags = new ArrayList<>(); - } - this.analyticsTags.add(analyticsTagsItem); - return this; - } - - /** - * List of tags to apply to the query for analytics purposes. - * - * @return analyticsTags - */ - @javax.annotation.Nullable - public List getAnalyticsTags() { - return analyticsTags; - } - - public void setAnalyticsTags(List analyticsTags) { - this.analyticsTags = analyticsTags; - } - - public SearchParams percentileComputation(Boolean percentileComputation) { - this.percentileComputation = percentileComputation; - return this; - } - - /** - * Whether to include or exclude a query from the processing-time percentile computation. - * - * @return percentileComputation - */ - @javax.annotation.Nullable - public Boolean getPercentileComputation() { - return percentileComputation; - } - - public void setPercentileComputation(Boolean percentileComputation) { - this.percentileComputation = percentileComputation; - } - - public SearchParams enableABTest(Boolean enableABTest) { - this.enableABTest = enableABTest; - return this; - } - - /** - * Whether this search should participate in running AB tests. - * - * @return enableABTest - */ - @javax.annotation.Nullable - public Boolean getEnableABTest() { - return enableABTest; - } - - public void setEnableABTest(Boolean enableABTest) { - this.enableABTest = enableABTest; - } - - public SearchParams enableReRanking(Boolean enableReRanking) { - this.enableReRanking = enableReRanking; - return this; - } - - /** - * Whether this search should use AI Re-Ranking. - * - * @return enableReRanking - */ - @javax.annotation.Nullable - public Boolean getEnableReRanking() { - return enableReRanking; - } - - public void setEnableReRanking(Boolean enableReRanking) { - this.enableReRanking = enableReRanking; - } - - public SearchParams query(String query) { - this.query = query; - return this; - } - - /** - * The text to search in the index. - * - * @return query - */ - @javax.annotation.Nonnull - public String getQuery() { - return query; - } - - public void setQuery(String query) { - this.query = query; - } - - public SearchParams searchableAttributes(List searchableAttributes) { - this.searchableAttributes = searchableAttributes; - return this; - } - - public SearchParams addSearchableAttributesItem( - String searchableAttributesItem - ) { - if (this.searchableAttributes == null) { - this.searchableAttributes = new ArrayList<>(); - } - this.searchableAttributes.add(searchableAttributesItem); - return this; - } - - /** - * The complete list of attributes used for searching. - * - * @return searchableAttributes - */ - @javax.annotation.Nullable - public List getSearchableAttributes() { - return searchableAttributes; - } - - public void setSearchableAttributes(List searchableAttributes) { - this.searchableAttributes = searchableAttributes; - } - - public SearchParams attributesForFaceting( - List attributesForFaceting - ) { - this.attributesForFaceting = attributesForFaceting; - return this; - } - - public SearchParams addAttributesForFacetingItem( - String attributesForFacetingItem - ) { - if (this.attributesForFaceting == null) { - this.attributesForFaceting = new ArrayList<>(); - } - this.attributesForFaceting.add(attributesForFacetingItem); - return this; - } - - /** - * The complete list of attributes that will be used for faceting. - * - * @return attributesForFaceting - */ - @javax.annotation.Nullable - public List getAttributesForFaceting() { - return attributesForFaceting; - } - - public void setAttributesForFaceting(List attributesForFaceting) { - this.attributesForFaceting = attributesForFaceting; - } - - public SearchParams unretrievableAttributes( - List unretrievableAttributes - ) { - this.unretrievableAttributes = unretrievableAttributes; - return this; - } - - public SearchParams addUnretrievableAttributesItem( - String unretrievableAttributesItem - ) { - if (this.unretrievableAttributes == null) { - this.unretrievableAttributes = new ArrayList<>(); - } - this.unretrievableAttributes.add(unretrievableAttributesItem); - return this; - } - - /** - * List of attributes that can't be retrieved at query time. - * - * @return unretrievableAttributes - */ - @javax.annotation.Nullable - public List getUnretrievableAttributes() { - return unretrievableAttributes; - } - - public void setUnretrievableAttributes(List unretrievableAttributes) { - this.unretrievableAttributes = unretrievableAttributes; - } - - public SearchParams attributesToRetrieve(List attributesToRetrieve) { - this.attributesToRetrieve = attributesToRetrieve; - return this; - } - - public SearchParams addAttributesToRetrieveItem( - String attributesToRetrieveItem - ) { - if (this.attributesToRetrieve == null) { - this.attributesToRetrieve = new ArrayList<>(); - } - this.attributesToRetrieve.add(attributesToRetrieveItem); - return this; - } - - /** - * This parameter controls which attributes to retrieve and which not to retrieve. - * - * @return attributesToRetrieve - */ - @javax.annotation.Nullable - public List getAttributesToRetrieve() { - return attributesToRetrieve; - } - - public void setAttributesToRetrieve(List attributesToRetrieve) { - this.attributesToRetrieve = attributesToRetrieve; - } - - public SearchParams restrictSearchableAttributes( - List restrictSearchableAttributes - ) { - this.restrictSearchableAttributes = restrictSearchableAttributes; - return this; - } - - public SearchParams addRestrictSearchableAttributesItem( - String restrictSearchableAttributesItem - ) { - if (this.restrictSearchableAttributes == null) { - this.restrictSearchableAttributes = new ArrayList<>(); - } - this.restrictSearchableAttributes.add(restrictSearchableAttributesItem); - return this; - } - - /** - * Restricts a given query to look in only a subset of your searchable attributes. - * - * @return restrictSearchableAttributes - */ - @javax.annotation.Nullable - public List getRestrictSearchableAttributes() { - return restrictSearchableAttributes; - } - - public void setRestrictSearchableAttributes( - List restrictSearchableAttributes - ) { - this.restrictSearchableAttributes = restrictSearchableAttributes; - } - - public SearchParams ranking(List ranking) { - this.ranking = ranking; - return this; - } - - public SearchParams addRankingItem(String rankingItem) { - if (this.ranking == null) { - this.ranking = new ArrayList<>(); - } - this.ranking.add(rankingItem); - return this; - } - - /** - * Controls how Algolia should sort your results. - * - * @return ranking - */ - @javax.annotation.Nullable - public List getRanking() { - return ranking; - } - - public void setRanking(List ranking) { - this.ranking = ranking; - } - - public SearchParams customRanking(List customRanking) { - this.customRanking = customRanking; - return this; - } - - public SearchParams addCustomRankingItem(String customRankingItem) { - if (this.customRanking == null) { - this.customRanking = new ArrayList<>(); - } - this.customRanking.add(customRankingItem); - return this; - } - - /** - * Specifies the custom ranking criterion. - * - * @return customRanking - */ - @javax.annotation.Nullable - public List getCustomRanking() { - return customRanking; - } - - public void setCustomRanking(List customRanking) { - this.customRanking = customRanking; - } - - public SearchParams relevancyStrictness(Integer relevancyStrictness) { - this.relevancyStrictness = relevancyStrictness; - return this; - } - - /** - * Controls the relevancy threshold below which less relevant results aren't included in the - * results. - * - * @return relevancyStrictness - */ - @javax.annotation.Nullable - public Integer getRelevancyStrictness() { - return relevancyStrictness; - } - - public void setRelevancyStrictness(Integer relevancyStrictness) { - this.relevancyStrictness = relevancyStrictness; - } - - public SearchParams attributesToHighlight( - List attributesToHighlight - ) { - this.attributesToHighlight = attributesToHighlight; - return this; - } - - public SearchParams addAttributesToHighlightItem( - String attributesToHighlightItem - ) { - if (this.attributesToHighlight == null) { - this.attributesToHighlight = new ArrayList<>(); - } - this.attributesToHighlight.add(attributesToHighlightItem); - return this; - } - - /** - * List of attributes to highlight. - * - * @return attributesToHighlight - */ - @javax.annotation.Nullable - public List getAttributesToHighlight() { - return attributesToHighlight; - } - - public void setAttributesToHighlight(List attributesToHighlight) { - this.attributesToHighlight = attributesToHighlight; - } - - public SearchParams attributesToSnippet(List attributesToSnippet) { - this.attributesToSnippet = attributesToSnippet; - return this; - } - - public SearchParams addAttributesToSnippetItem( - String attributesToSnippetItem - ) { - if (this.attributesToSnippet == null) { - this.attributesToSnippet = new ArrayList<>(); - } - this.attributesToSnippet.add(attributesToSnippetItem); - return this; - } - - /** - * List of attributes to snippet, with an optional maximum number of words to snippet. - * - * @return attributesToSnippet - */ - @javax.annotation.Nullable - public List getAttributesToSnippet() { - return attributesToSnippet; - } - - public void setAttributesToSnippet(List attributesToSnippet) { - this.attributesToSnippet = attributesToSnippet; - } - - public SearchParams highlightPreTag(String highlightPreTag) { - this.highlightPreTag = highlightPreTag; - return this; - } - - /** - * The HTML string to insert before the highlighted parts in all highlight and snippet results. - * - * @return highlightPreTag - */ - @javax.annotation.Nullable - public String getHighlightPreTag() { - return highlightPreTag; - } - - public void setHighlightPreTag(String highlightPreTag) { - this.highlightPreTag = highlightPreTag; - } - - public SearchParams highlightPostTag(String highlightPostTag) { - this.highlightPostTag = highlightPostTag; - return this; - } - - /** - * The HTML string to insert after the highlighted parts in all highlight and snippet results. - * - * @return highlightPostTag - */ - @javax.annotation.Nullable - public String getHighlightPostTag() { - return highlightPostTag; - } - - public void setHighlightPostTag(String highlightPostTag) { - this.highlightPostTag = highlightPostTag; - } - - public SearchParams snippetEllipsisText(String snippetEllipsisText) { - this.snippetEllipsisText = snippetEllipsisText; - return this; - } - - /** - * String used as an ellipsis indicator when a snippet is truncated. - * - * @return snippetEllipsisText - */ - @javax.annotation.Nullable - public String getSnippetEllipsisText() { - return snippetEllipsisText; - } - - public void setSnippetEllipsisText(String snippetEllipsisText) { - this.snippetEllipsisText = snippetEllipsisText; - } - - public SearchParams restrictHighlightAndSnippetArrays( - Boolean restrictHighlightAndSnippetArrays - ) { - this.restrictHighlightAndSnippetArrays = restrictHighlightAndSnippetArrays; - return this; - } - - /** - * Restrict highlighting and snippeting to items that matched the query. - * - * @return restrictHighlightAndSnippetArrays - */ - @javax.annotation.Nullable - public Boolean getRestrictHighlightAndSnippetArrays() { - return restrictHighlightAndSnippetArrays; - } - - public void setRestrictHighlightAndSnippetArrays( - Boolean restrictHighlightAndSnippetArrays - ) { - this.restrictHighlightAndSnippetArrays = restrictHighlightAndSnippetArrays; - } - - public SearchParams hitsPerPage(Integer hitsPerPage) { - this.hitsPerPage = hitsPerPage; - return this; - } - - /** - * Set the number of hits per page. - * - * @return hitsPerPage - */ - @javax.annotation.Nullable - public Integer getHitsPerPage() { - return hitsPerPage; - } - - public void setHitsPerPage(Integer hitsPerPage) { - this.hitsPerPage = hitsPerPage; - } - - public SearchParams minWordSizefor1Typo(Integer minWordSizefor1Typo) { - this.minWordSizefor1Typo = minWordSizefor1Typo; - return this; - } - - /** - * Minimum number of characters a word in the query string must contain to accept matches with 1 - * typo. - * - * @return minWordSizefor1Typo - */ - @javax.annotation.Nullable - public Integer getMinWordSizefor1Typo() { - return minWordSizefor1Typo; - } - - public void setMinWordSizefor1Typo(Integer minWordSizefor1Typo) { - this.minWordSizefor1Typo = minWordSizefor1Typo; - } - - public SearchParams minWordSizefor2Typos(Integer minWordSizefor2Typos) { - this.minWordSizefor2Typos = minWordSizefor2Typos; - return this; - } - - /** - * Minimum number of characters a word in the query string must contain to accept matches with 2 - * typos. - * - * @return minWordSizefor2Typos - */ - @javax.annotation.Nullable - public Integer getMinWordSizefor2Typos() { - return minWordSizefor2Typos; - } - - public void setMinWordSizefor2Typos(Integer minWordSizefor2Typos) { - this.minWordSizefor2Typos = minWordSizefor2Typos; - } - - public SearchParams typoTolerance(TypoToleranceEnum typoTolerance) { - this.typoTolerance = typoTolerance; - return this; - } - - /** - * Controls whether typo tolerance is enabled and how it is applied. - * - * @return typoTolerance - */ - @javax.annotation.Nullable - public TypoToleranceEnum getTypoTolerance() { - return typoTolerance; - } - - public void setTypoTolerance(TypoToleranceEnum typoTolerance) { - this.typoTolerance = typoTolerance; - } - - public SearchParams allowTyposOnNumericTokens( - Boolean allowTyposOnNumericTokens - ) { - this.allowTyposOnNumericTokens = allowTyposOnNumericTokens; - return this; - } - - /** - * Whether to allow typos on numbers (\"numeric tokens\") in the query string. - * - * @return allowTyposOnNumericTokens - */ - @javax.annotation.Nullable - public Boolean getAllowTyposOnNumericTokens() { - return allowTyposOnNumericTokens; - } - - public void setAllowTyposOnNumericTokens(Boolean allowTyposOnNumericTokens) { - this.allowTyposOnNumericTokens = allowTyposOnNumericTokens; - } - - public SearchParams disableTypoToleranceOnAttributes( - List disableTypoToleranceOnAttributes - ) { - this.disableTypoToleranceOnAttributes = disableTypoToleranceOnAttributes; - return this; - } - - public SearchParams addDisableTypoToleranceOnAttributesItem( - String disableTypoToleranceOnAttributesItem - ) { - if (this.disableTypoToleranceOnAttributes == null) { - this.disableTypoToleranceOnAttributes = new ArrayList<>(); - } - this.disableTypoToleranceOnAttributes.add( - disableTypoToleranceOnAttributesItem - ); - return this; - } - - /** - * List of attributes on which you want to disable typo tolerance. - * - * @return disableTypoToleranceOnAttributes - */ - @javax.annotation.Nullable - public List getDisableTypoToleranceOnAttributes() { - return disableTypoToleranceOnAttributes; - } - - public void setDisableTypoToleranceOnAttributes( - List disableTypoToleranceOnAttributes - ) { - this.disableTypoToleranceOnAttributes = disableTypoToleranceOnAttributes; - } - - public SearchParams separatorsToIndex(String separatorsToIndex) { - this.separatorsToIndex = separatorsToIndex; - return this; - } - - /** - * Control which separators are indexed. - * - * @return separatorsToIndex - */ - @javax.annotation.Nullable - public String getSeparatorsToIndex() { - return separatorsToIndex; - } - - public void setSeparatorsToIndex(String separatorsToIndex) { - this.separatorsToIndex = separatorsToIndex; - } - - public SearchParams ignorePlurals(String ignorePlurals) { - this.ignorePlurals = ignorePlurals; - return this; - } - - /** - * Treats singular, plurals, and other forms of declensions as matching terms. - * - * @return ignorePlurals - */ - @javax.annotation.Nullable - public String getIgnorePlurals() { - return ignorePlurals; - } - - public void setIgnorePlurals(String ignorePlurals) { - this.ignorePlurals = ignorePlurals; - } - - public SearchParams removeStopWords(String removeStopWords) { - this.removeStopWords = removeStopWords; - return this; - } - - /** - * Removes stop (common) words from the query before executing it. - * - * @return removeStopWords - */ - @javax.annotation.Nullable - public String getRemoveStopWords() { - return removeStopWords; - } - - public void setRemoveStopWords(String removeStopWords) { - this.removeStopWords = removeStopWords; - } - - public SearchParams keepDiacriticsOnCharacters( - String keepDiacriticsOnCharacters - ) { - this.keepDiacriticsOnCharacters = keepDiacriticsOnCharacters; - return this; - } - - /** - * List of characters that the engine shouldn't automatically normalize. - * - * @return keepDiacriticsOnCharacters - */ - @javax.annotation.Nullable - public String getKeepDiacriticsOnCharacters() { - return keepDiacriticsOnCharacters; - } - - public void setKeepDiacriticsOnCharacters(String keepDiacriticsOnCharacters) { - this.keepDiacriticsOnCharacters = keepDiacriticsOnCharacters; - } - - public SearchParams queryLanguages(List queryLanguages) { - this.queryLanguages = queryLanguages; - return this; - } - - public SearchParams addQueryLanguagesItem(String queryLanguagesItem) { - if (this.queryLanguages == null) { - this.queryLanguages = new ArrayList<>(); - } - this.queryLanguages.add(queryLanguagesItem); - return this; - } - - /** - * Sets the languages to be used by language-specific settings and functionalities such as - * ignorePlurals, removeStopWords, and CJK word-detection. - * - * @return queryLanguages - */ - @javax.annotation.Nullable - public List getQueryLanguages() { - return queryLanguages; - } - - public void setQueryLanguages(List queryLanguages) { - this.queryLanguages = queryLanguages; - } - - public SearchParams decompoundQuery(Boolean decompoundQuery) { - this.decompoundQuery = decompoundQuery; - return this; - } - - /** - * Splits compound words into their composing atoms in the query. - * - * @return decompoundQuery - */ - @javax.annotation.Nullable - public Boolean getDecompoundQuery() { - return decompoundQuery; - } - - public void setDecompoundQuery(Boolean decompoundQuery) { - this.decompoundQuery = decompoundQuery; - } - - public SearchParams enableRules(Boolean enableRules) { - this.enableRules = enableRules; - return this; - } - - /** - * Whether Rules should be globally enabled. - * - * @return enableRules - */ - @javax.annotation.Nullable - public Boolean getEnableRules() { - return enableRules; - } - - public void setEnableRules(Boolean enableRules) { - this.enableRules = enableRules; - } - - public SearchParams enablePersonalization(Boolean enablePersonalization) { - this.enablePersonalization = enablePersonalization; - return this; - } - - /** - * Enable the Personalization feature. - * - * @return enablePersonalization - */ - @javax.annotation.Nullable - public Boolean getEnablePersonalization() { - return enablePersonalization; - } - - public void setEnablePersonalization(Boolean enablePersonalization) { - this.enablePersonalization = enablePersonalization; - } - - public SearchParams queryType(QueryTypeEnum queryType) { - this.queryType = queryType; - return this; - } - - /** - * Controls if and how query words are interpreted as prefixes. - * - * @return queryType - */ - @javax.annotation.Nullable - public QueryTypeEnum getQueryType() { - return queryType; - } - - public void setQueryType(QueryTypeEnum queryType) { - this.queryType = queryType; - } - - public SearchParams removeWordsIfNoResults( - RemoveWordsIfNoResultsEnum removeWordsIfNoResults - ) { - this.removeWordsIfNoResults = removeWordsIfNoResults; - return this; - } - - /** - * Selects a strategy to remove words from the query when it doesn't match any hits. - * - * @return removeWordsIfNoResults - */ - @javax.annotation.Nullable - public RemoveWordsIfNoResultsEnum getRemoveWordsIfNoResults() { - return removeWordsIfNoResults; - } - - public void setRemoveWordsIfNoResults( - RemoveWordsIfNoResultsEnum removeWordsIfNoResults - ) { - this.removeWordsIfNoResults = removeWordsIfNoResults; - } - - public SearchParams advancedSyntax(Boolean advancedSyntax) { - this.advancedSyntax = advancedSyntax; - return this; - } - - /** - * Enables the advanced query syntax. - * - * @return advancedSyntax - */ - @javax.annotation.Nullable - public Boolean getAdvancedSyntax() { - return advancedSyntax; - } - - public void setAdvancedSyntax(Boolean advancedSyntax) { - this.advancedSyntax = advancedSyntax; - } - - public SearchParams optionalWords(List optionalWords) { - this.optionalWords = optionalWords; - return this; - } - - public SearchParams addOptionalWordsItem(String optionalWordsItem) { - if (this.optionalWords == null) { - this.optionalWords = new ArrayList<>(); - } - this.optionalWords.add(optionalWordsItem); - return this; - } - - /** - * A list of words that should be considered as optional when found in the query. - * - * @return optionalWords - */ - @javax.annotation.Nullable - public List getOptionalWords() { - return optionalWords; - } - - public void setOptionalWords(List optionalWords) { - this.optionalWords = optionalWords; - } - - public SearchParams disableExactOnAttributes( - List disableExactOnAttributes - ) { - this.disableExactOnAttributes = disableExactOnAttributes; - return this; - } - - public SearchParams addDisableExactOnAttributesItem( - String disableExactOnAttributesItem - ) { - if (this.disableExactOnAttributes == null) { - this.disableExactOnAttributes = new ArrayList<>(); - } - this.disableExactOnAttributes.add(disableExactOnAttributesItem); - return this; - } - - /** - * List of attributes on which you want to disable the exact ranking criterion. - * - * @return disableExactOnAttributes - */ - @javax.annotation.Nullable - public List getDisableExactOnAttributes() { - return disableExactOnAttributes; - } - - public void setDisableExactOnAttributes( - List disableExactOnAttributes - ) { - this.disableExactOnAttributes = disableExactOnAttributes; - } - - public SearchParams exactOnSingleWordQuery( - ExactOnSingleWordQueryEnum exactOnSingleWordQuery - ) { - this.exactOnSingleWordQuery = exactOnSingleWordQuery; - return this; - } - - /** - * Controls how the exact ranking criterion is computed when the query contains only one word. - * - * @return exactOnSingleWordQuery - */ - @javax.annotation.Nullable - public ExactOnSingleWordQueryEnum getExactOnSingleWordQuery() { - return exactOnSingleWordQuery; - } - - public void setExactOnSingleWordQuery( - ExactOnSingleWordQueryEnum exactOnSingleWordQuery - ) { - this.exactOnSingleWordQuery = exactOnSingleWordQuery; - } - - public SearchParams alternativesAsExact( - List alternativesAsExact - ) { - this.alternativesAsExact = alternativesAsExact; - return this; - } - - public SearchParams addAlternativesAsExactItem( - AlternativesAsExactEnum alternativesAsExactItem - ) { - if (this.alternativesAsExact == null) { - this.alternativesAsExact = new ArrayList<>(); - } - this.alternativesAsExact.add(alternativesAsExactItem); - return this; - } - - /** - * List of alternatives that should be considered an exact match by the exact ranking criterion. - * - * @return alternativesAsExact - */ - @javax.annotation.Nullable - public List getAlternativesAsExact() { - return alternativesAsExact; - } - - public void setAlternativesAsExact( - List alternativesAsExact - ) { - this.alternativesAsExact = alternativesAsExact; - } - - public SearchParams advancedSyntaxFeatures( - List advancedSyntaxFeatures - ) { - this.advancedSyntaxFeatures = advancedSyntaxFeatures; - return this; - } - - public SearchParams addAdvancedSyntaxFeaturesItem( - AdvancedSyntaxFeaturesEnum advancedSyntaxFeaturesItem - ) { - if (this.advancedSyntaxFeatures == null) { - this.advancedSyntaxFeatures = new ArrayList<>(); - } - this.advancedSyntaxFeatures.add(advancedSyntaxFeaturesItem); - return this; - } - - /** - * Allows you to specify which advanced syntax features are active when ‘advancedSyntax' is - * enabled. - * - * @return advancedSyntaxFeatures - */ - @javax.annotation.Nullable - public List getAdvancedSyntaxFeatures() { - return advancedSyntaxFeatures; - } - - public void setAdvancedSyntaxFeatures( - List advancedSyntaxFeatures - ) { - this.advancedSyntaxFeatures = advancedSyntaxFeatures; - } - - public SearchParams distinct(Integer distinct) { - this.distinct = distinct; - return this; - } - - /** - * Enables de-duplication or grouping of results. minimum: 0 maximum: 4 - * - * @return distinct - */ - @javax.annotation.Nullable - public Integer getDistinct() { - return distinct; - } - - public void setDistinct(Integer distinct) { - this.distinct = distinct; - } - - public SearchParams synonyms(Boolean synonyms) { - this.synonyms = synonyms; - return this; - } - - /** - * Whether to take into account an index's synonyms for a particular search. - * - * @return synonyms - */ - @javax.annotation.Nullable - public Boolean getSynonyms() { - return synonyms; - } - - public void setSynonyms(Boolean synonyms) { - this.synonyms = synonyms; - } - - public SearchParams replaceSynonymsInHighlight( - Boolean replaceSynonymsInHighlight - ) { - this.replaceSynonymsInHighlight = replaceSynonymsInHighlight; - return this; - } - - /** - * Whether to highlight and snippet the original word that matches the synonym or the synonym - * itself. - * - * @return replaceSynonymsInHighlight - */ - @javax.annotation.Nullable - public Boolean getReplaceSynonymsInHighlight() { - return replaceSynonymsInHighlight; - } - - public void setReplaceSynonymsInHighlight( - Boolean replaceSynonymsInHighlight - ) { - this.replaceSynonymsInHighlight = replaceSynonymsInHighlight; - } - - public SearchParams minProximity(Integer minProximity) { - this.minProximity = minProximity; - return this; - } - - /** - * Precision of the proximity ranking criterion. minimum: 1 maximum: 7 - * - * @return minProximity - */ - @javax.annotation.Nullable - public Integer getMinProximity() { - return minProximity; - } - - public void setMinProximity(Integer minProximity) { - this.minProximity = minProximity; - } - - public SearchParams responseFields(List responseFields) { - this.responseFields = responseFields; - return this; - } - - public SearchParams addResponseFieldsItem(String responseFieldsItem) { - if (this.responseFields == null) { - this.responseFields = new ArrayList<>(); - } - this.responseFields.add(responseFieldsItem); - return this; - } - - /** - * Choose which fields to return in the API response. This parameters applies to search and browse - * queries. - * - * @return responseFields - */ - @javax.annotation.Nullable - public List getResponseFields() { - return responseFields; - } - - public void setResponseFields(List responseFields) { - this.responseFields = responseFields; - } - - public SearchParams maxFacetHits(Integer maxFacetHits) { - this.maxFacetHits = maxFacetHits; - return this; - } - - /** - * Maximum number of facet hits to return during a search for facet values. For performance - * reasons, the maximum allowed number of returned values is 100. maximum: 100 - * - * @return maxFacetHits - */ - @javax.annotation.Nullable - public Integer getMaxFacetHits() { - return maxFacetHits; - } - - public void setMaxFacetHits(Integer maxFacetHits) { - this.maxFacetHits = maxFacetHits; - } - - public SearchParams attributeCriteriaComputedByMinProximity( - Boolean attributeCriteriaComputedByMinProximity - ) { - this.attributeCriteriaComputedByMinProximity = - attributeCriteriaComputedByMinProximity; - return this; - } - - /** - * When attribute is ranked above proximity in your ranking formula, proximity is used to select - * which searchable attribute is matched in the attribute ranking stage. - * - * @return attributeCriteriaComputedByMinProximity - */ - @javax.annotation.Nullable - public Boolean getAttributeCriteriaComputedByMinProximity() { - return attributeCriteriaComputedByMinProximity; - } - - public void setAttributeCriteriaComputedByMinProximity( - Boolean attributeCriteriaComputedByMinProximity - ) { - this.attributeCriteriaComputedByMinProximity = - attributeCriteriaComputedByMinProximity; - } - - public SearchParams renderingContent(Object renderingContent) { - this.renderingContent = renderingContent; - return this; - } - - /** - * Content defining how the search interface should be rendered. Can be set via the settings for a - * default value and can be overridden via rules. - * - * @return renderingContent - */ - @javax.annotation.Nullable - public Object getRenderingContent() { - return renderingContent; - } - - public void setRenderingContent(Object renderingContent) { - this.renderingContent = renderingContent; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - SearchParams searchParams = (SearchParams) o; - return ( - Objects.equals(this.params, searchParams.params) && - Objects.equals(this.similarQuery, searchParams.similarQuery) && - Objects.equals(this.filters, searchParams.filters) && - Objects.equals(this.facetFilters, searchParams.facetFilters) && - Objects.equals(this.optionalFilters, searchParams.optionalFilters) && - Objects.equals(this.numericFilters, searchParams.numericFilters) && - Objects.equals(this.tagFilters, searchParams.tagFilters) && - Objects.equals( - this.sumOrFiltersScores, - searchParams.sumOrFiltersScores - ) && - Objects.equals(this.facets, searchParams.facets) && - Objects.equals(this.maxValuesPerFacet, searchParams.maxValuesPerFacet) && - Objects.equals( - this.facetingAfterDistinct, - searchParams.facetingAfterDistinct - ) && - Objects.equals(this.sortFacetValuesBy, searchParams.sortFacetValuesBy) && - Objects.equals(this.page, searchParams.page) && - Objects.equals(this.offset, searchParams.offset) && - Objects.equals(this.length, searchParams.length) && - Objects.equals(this.aroundLatLng, searchParams.aroundLatLng) && - Objects.equals(this.aroundLatLngViaIP, searchParams.aroundLatLngViaIP) && - Objects.equals(this.aroundRadius, searchParams.aroundRadius) && - Objects.equals(this.aroundPrecision, searchParams.aroundPrecision) && - Objects.equals( - this.minimumAroundRadius, - searchParams.minimumAroundRadius - ) && - Objects.equals(this.insideBoundingBox, searchParams.insideBoundingBox) && - Objects.equals(this.insidePolygon, searchParams.insidePolygon) && - Objects.equals(this.naturalLanguages, searchParams.naturalLanguages) && - Objects.equals(this.ruleContexts, searchParams.ruleContexts) && - Objects.equals( - this.personalizationImpact, - searchParams.personalizationImpact - ) && - Objects.equals(this.userToken, searchParams.userToken) && - Objects.equals(this.getRankingInfo, searchParams.getRankingInfo) && - Objects.equals(this.clickAnalytics, searchParams.clickAnalytics) && - Objects.equals(this.analytics, searchParams.analytics) && - Objects.equals(this.analyticsTags, searchParams.analyticsTags) && - Objects.equals( - this.percentileComputation, - searchParams.percentileComputation - ) && - Objects.equals(this.enableABTest, searchParams.enableABTest) && - Objects.equals(this.enableReRanking, searchParams.enableReRanking) && - Objects.equals(this.query, searchParams.query) && - Objects.equals( - this.searchableAttributes, - searchParams.searchableAttributes - ) && - Objects.equals( - this.attributesForFaceting, - searchParams.attributesForFaceting - ) && - Objects.equals( - this.unretrievableAttributes, - searchParams.unretrievableAttributes - ) && - Objects.equals( - this.attributesToRetrieve, - searchParams.attributesToRetrieve - ) && - Objects.equals( - this.restrictSearchableAttributes, - searchParams.restrictSearchableAttributes - ) && - Objects.equals(this.ranking, searchParams.ranking) && - Objects.equals(this.customRanking, searchParams.customRanking) && - Objects.equals( - this.relevancyStrictness, - searchParams.relevancyStrictness - ) && - Objects.equals( - this.attributesToHighlight, - searchParams.attributesToHighlight - ) && - Objects.equals( - this.attributesToSnippet, - searchParams.attributesToSnippet - ) && - Objects.equals(this.highlightPreTag, searchParams.highlightPreTag) && - Objects.equals(this.highlightPostTag, searchParams.highlightPostTag) && - Objects.equals( - this.snippetEllipsisText, - searchParams.snippetEllipsisText - ) && - Objects.equals( - this.restrictHighlightAndSnippetArrays, - searchParams.restrictHighlightAndSnippetArrays - ) && - Objects.equals(this.hitsPerPage, searchParams.hitsPerPage) && - Objects.equals( - this.minWordSizefor1Typo, - searchParams.minWordSizefor1Typo - ) && - Objects.equals( - this.minWordSizefor2Typos, - searchParams.minWordSizefor2Typos - ) && - Objects.equals(this.typoTolerance, searchParams.typoTolerance) && - Objects.equals( - this.allowTyposOnNumericTokens, - searchParams.allowTyposOnNumericTokens - ) && - Objects.equals( - this.disableTypoToleranceOnAttributes, - searchParams.disableTypoToleranceOnAttributes - ) && - Objects.equals(this.separatorsToIndex, searchParams.separatorsToIndex) && - Objects.equals(this.ignorePlurals, searchParams.ignorePlurals) && - Objects.equals(this.removeStopWords, searchParams.removeStopWords) && - Objects.equals( - this.keepDiacriticsOnCharacters, - searchParams.keepDiacriticsOnCharacters - ) && - Objects.equals(this.queryLanguages, searchParams.queryLanguages) && - Objects.equals(this.decompoundQuery, searchParams.decompoundQuery) && - Objects.equals(this.enableRules, searchParams.enableRules) && - Objects.equals( - this.enablePersonalization, - searchParams.enablePersonalization - ) && - Objects.equals(this.queryType, searchParams.queryType) && - Objects.equals( - this.removeWordsIfNoResults, - searchParams.removeWordsIfNoResults - ) && - Objects.equals(this.advancedSyntax, searchParams.advancedSyntax) && - Objects.equals(this.optionalWords, searchParams.optionalWords) && - Objects.equals( - this.disableExactOnAttributes, - searchParams.disableExactOnAttributes - ) && - Objects.equals( - this.exactOnSingleWordQuery, - searchParams.exactOnSingleWordQuery - ) && - Objects.equals( - this.alternativesAsExact, - searchParams.alternativesAsExact - ) && - Objects.equals( - this.advancedSyntaxFeatures, - searchParams.advancedSyntaxFeatures - ) && - Objects.equals(this.distinct, searchParams.distinct) && - Objects.equals(this.synonyms, searchParams.synonyms) && - Objects.equals( - this.replaceSynonymsInHighlight, - searchParams.replaceSynonymsInHighlight - ) && - Objects.equals(this.minProximity, searchParams.minProximity) && - Objects.equals(this.responseFields, searchParams.responseFields) && - Objects.equals(this.maxFacetHits, searchParams.maxFacetHits) && - Objects.equals( - this.attributeCriteriaComputedByMinProximity, - searchParams.attributeCriteriaComputedByMinProximity - ) && - Objects.equals(this.renderingContent, searchParams.renderingContent) - ); - } - - @Override - public int hashCode() { - return Objects.hash( - params, - similarQuery, - filters, - facetFilters, - optionalFilters, - numericFilters, - tagFilters, - sumOrFiltersScores, - facets, - maxValuesPerFacet, - facetingAfterDistinct, - sortFacetValuesBy, - page, - offset, - length, - aroundLatLng, - aroundLatLngViaIP, - aroundRadius, - aroundPrecision, - minimumAroundRadius, - insideBoundingBox, - insidePolygon, - naturalLanguages, - ruleContexts, - personalizationImpact, - userToken, - getRankingInfo, - clickAnalytics, - analytics, - analyticsTags, - percentileComputation, - enableABTest, - enableReRanking, - query, - searchableAttributes, - attributesForFaceting, - unretrievableAttributes, - attributesToRetrieve, - restrictSearchableAttributes, - ranking, - customRanking, - relevancyStrictness, - attributesToHighlight, - attributesToSnippet, - highlightPreTag, - highlightPostTag, - snippetEllipsisText, - restrictHighlightAndSnippetArrays, - hitsPerPage, - minWordSizefor1Typo, - minWordSizefor2Typos, - typoTolerance, - allowTyposOnNumericTokens, - disableTypoToleranceOnAttributes, - separatorsToIndex, - ignorePlurals, - removeStopWords, - keepDiacriticsOnCharacters, - queryLanguages, - decompoundQuery, - enableRules, - enablePersonalization, - queryType, - removeWordsIfNoResults, - advancedSyntax, - optionalWords, - disableExactOnAttributes, - exactOnSingleWordQuery, - alternativesAsExact, - advancedSyntaxFeatures, - distinct, - synonyms, - replaceSynonymsInHighlight, - minProximity, - responseFields, - maxFacetHits, - attributeCriteriaComputedByMinProximity, - renderingContent - ); + SearchParamsSearchParamsString(SearchParamsString insideValue) { + this.insideValue = insideValue; } @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class SearchParams {\n"); - sb.append(" params: ").append(toIndentedString(params)).append("\n"); - sb - .append(" similarQuery: ") - .append(toIndentedString(similarQuery)) - .append("\n"); - sb.append(" filters: ").append(toIndentedString(filters)).append("\n"); - sb - .append(" facetFilters: ") - .append(toIndentedString(facetFilters)) - .append("\n"); - sb - .append(" optionalFilters: ") - .append(toIndentedString(optionalFilters)) - .append("\n"); - sb - .append(" numericFilters: ") - .append(toIndentedString(numericFilters)) - .append("\n"); - sb - .append(" tagFilters: ") - .append(toIndentedString(tagFilters)) - .append("\n"); - sb - .append(" sumOrFiltersScores: ") - .append(toIndentedString(sumOrFiltersScores)) - .append("\n"); - sb.append(" facets: ").append(toIndentedString(facets)).append("\n"); - sb - .append(" maxValuesPerFacet: ") - .append(toIndentedString(maxValuesPerFacet)) - .append("\n"); - sb - .append(" facetingAfterDistinct: ") - .append(toIndentedString(facetingAfterDistinct)) - .append("\n"); - sb - .append(" sortFacetValuesBy: ") - .append(toIndentedString(sortFacetValuesBy)) - .append("\n"); - sb.append(" page: ").append(toIndentedString(page)).append("\n"); - sb.append(" offset: ").append(toIndentedString(offset)).append("\n"); - sb.append(" length: ").append(toIndentedString(length)).append("\n"); - sb - .append(" aroundLatLng: ") - .append(toIndentedString(aroundLatLng)) - .append("\n"); - sb - .append(" aroundLatLngViaIP: ") - .append(toIndentedString(aroundLatLngViaIP)) - .append("\n"); - sb - .append(" aroundRadius: ") - .append(toIndentedString(aroundRadius)) - .append("\n"); - sb - .append(" aroundPrecision: ") - .append(toIndentedString(aroundPrecision)) - .append("\n"); - sb - .append(" minimumAroundRadius: ") - .append(toIndentedString(minimumAroundRadius)) - .append("\n"); - sb - .append(" insideBoundingBox: ") - .append(toIndentedString(insideBoundingBox)) - .append("\n"); - sb - .append(" insidePolygon: ") - .append(toIndentedString(insidePolygon)) - .append("\n"); - sb - .append(" naturalLanguages: ") - .append(toIndentedString(naturalLanguages)) - .append("\n"); - sb - .append(" ruleContexts: ") - .append(toIndentedString(ruleContexts)) - .append("\n"); - sb - .append(" personalizationImpact: ") - .append(toIndentedString(personalizationImpact)) - .append("\n"); - sb - .append(" userToken: ") - .append(toIndentedString(userToken)) - .append("\n"); - sb - .append(" getRankingInfo: ") - .append(toIndentedString(getRankingInfo)) - .append("\n"); - sb - .append(" clickAnalytics: ") - .append(toIndentedString(clickAnalytics)) - .append("\n"); - sb - .append(" analytics: ") - .append(toIndentedString(analytics)) - .append("\n"); - sb - .append(" analyticsTags: ") - .append(toIndentedString(analyticsTags)) - .append("\n"); - sb - .append(" percentileComputation: ") - .append(toIndentedString(percentileComputation)) - .append("\n"); - sb - .append(" enableABTest: ") - .append(toIndentedString(enableABTest)) - .append("\n"); - sb - .append(" enableReRanking: ") - .append(toIndentedString(enableReRanking)) - .append("\n"); - sb.append(" query: ").append(toIndentedString(query)).append("\n"); - sb - .append(" searchableAttributes: ") - .append(toIndentedString(searchableAttributes)) - .append("\n"); - sb - .append(" attributesForFaceting: ") - .append(toIndentedString(attributesForFaceting)) - .append("\n"); - sb - .append(" unretrievableAttributes: ") - .append(toIndentedString(unretrievableAttributes)) - .append("\n"); - sb - .append(" attributesToRetrieve: ") - .append(toIndentedString(attributesToRetrieve)) - .append("\n"); - sb - .append(" restrictSearchableAttributes: ") - .append(toIndentedString(restrictSearchableAttributes)) - .append("\n"); - sb.append(" ranking: ").append(toIndentedString(ranking)).append("\n"); - sb - .append(" customRanking: ") - .append(toIndentedString(customRanking)) - .append("\n"); - sb - .append(" relevancyStrictness: ") - .append(toIndentedString(relevancyStrictness)) - .append("\n"); - sb - .append(" attributesToHighlight: ") - .append(toIndentedString(attributesToHighlight)) - .append("\n"); - sb - .append(" attributesToSnippet: ") - .append(toIndentedString(attributesToSnippet)) - .append("\n"); - sb - .append(" highlightPreTag: ") - .append(toIndentedString(highlightPreTag)) - .append("\n"); - sb - .append(" highlightPostTag: ") - .append(toIndentedString(highlightPostTag)) - .append("\n"); - sb - .append(" snippetEllipsisText: ") - .append(toIndentedString(snippetEllipsisText)) - .append("\n"); - sb - .append(" restrictHighlightAndSnippetArrays: ") - .append(toIndentedString(restrictHighlightAndSnippetArrays)) - .append("\n"); - sb - .append(" hitsPerPage: ") - .append(toIndentedString(hitsPerPage)) - .append("\n"); - sb - .append(" minWordSizefor1Typo: ") - .append(toIndentedString(minWordSizefor1Typo)) - .append("\n"); - sb - .append(" minWordSizefor2Typos: ") - .append(toIndentedString(minWordSizefor2Typos)) - .append("\n"); - sb - .append(" typoTolerance: ") - .append(toIndentedString(typoTolerance)) - .append("\n"); - sb - .append(" allowTyposOnNumericTokens: ") - .append(toIndentedString(allowTyposOnNumericTokens)) - .append("\n"); - sb - .append(" disableTypoToleranceOnAttributes: ") - .append(toIndentedString(disableTypoToleranceOnAttributes)) - .append("\n"); - sb - .append(" separatorsToIndex: ") - .append(toIndentedString(separatorsToIndex)) - .append("\n"); - sb - .append(" ignorePlurals: ") - .append(toIndentedString(ignorePlurals)) - .append("\n"); - sb - .append(" removeStopWords: ") - .append(toIndentedString(removeStopWords)) - .append("\n"); - sb - .append(" keepDiacriticsOnCharacters: ") - .append(toIndentedString(keepDiacriticsOnCharacters)) - .append("\n"); - sb - .append(" queryLanguages: ") - .append(toIndentedString(queryLanguages)) - .append("\n"); - sb - .append(" decompoundQuery: ") - .append(toIndentedString(decompoundQuery)) - .append("\n"); - sb - .append(" enableRules: ") - .append(toIndentedString(enableRules)) - .append("\n"); - sb - .append(" enablePersonalization: ") - .append(toIndentedString(enablePersonalization)) - .append("\n"); - sb - .append(" queryType: ") - .append(toIndentedString(queryType)) - .append("\n"); - sb - .append(" removeWordsIfNoResults: ") - .append(toIndentedString(removeWordsIfNoResults)) - .append("\n"); - sb - .append(" advancedSyntax: ") - .append(toIndentedString(advancedSyntax)) - .append("\n"); - sb - .append(" optionalWords: ") - .append(toIndentedString(optionalWords)) - .append("\n"); - sb - .append(" disableExactOnAttributes: ") - .append(toIndentedString(disableExactOnAttributes)) - .append("\n"); - sb - .append(" exactOnSingleWordQuery: ") - .append(toIndentedString(exactOnSingleWordQuery)) - .append("\n"); - sb - .append(" alternativesAsExact: ") - .append(toIndentedString(alternativesAsExact)) - .append("\n"); - sb - .append(" advancedSyntaxFeatures: ") - .append(toIndentedString(advancedSyntaxFeatures)) - .append("\n"); - sb.append(" distinct: ").append(toIndentedString(distinct)).append("\n"); - sb.append(" synonyms: ").append(toIndentedString(synonyms)).append("\n"); - sb - .append(" replaceSynonymsInHighlight: ") - .append(toIndentedString(replaceSynonymsInHighlight)) - .append("\n"); - sb - .append(" minProximity: ") - .append(toIndentedString(minProximity)) - .append("\n"); - sb - .append(" responseFields: ") - .append(toIndentedString(responseFields)) - .append("\n"); - sb - .append(" maxFacetHits: ") - .append(toIndentedString(maxFacetHits)) - .append("\n"); - sb - .append(" attributeCriteriaComputedByMinProximity: ") - .append(toIndentedString(attributeCriteriaComputedByMinProximity)) - .append("\n"); - sb - .append(" renderingContent: ") - .append(toIndentedString(renderingContent)) - .append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + public SearchParamsString getInsideValue() { + return insideValue; } } diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/SearchParamsObject.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/SearchParamsObject.java index dcd3f08252..1e47d48f10 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/SearchParamsObject.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/search/SearchParamsObject.java @@ -63,7 +63,7 @@ public class SearchParamsObject { private Boolean aroundLatLngViaIP = false; @SerializedName("aroundRadius") - private OneOfintegerstring aroundRadius; + private AroundRadius aroundRadius; @SerializedName("aroundPrecision") private Integer aroundPrecision = 10; @@ -913,22 +913,22 @@ public void setAroundLatLngViaIP(Boolean aroundLatLngViaIP) { this.aroundLatLngViaIP = aroundLatLngViaIP; } - public SearchParamsObject aroundRadius(OneOfintegerstring aroundRadius) { + public SearchParamsObject aroundRadius(AroundRadius aroundRadius) { this.aroundRadius = aroundRadius; return this; } /** - * Define the maximum radius for a geo search (in meters). + * Get aroundRadius * * @return aroundRadius */ @javax.annotation.Nullable - public OneOfintegerstring getAroundRadius() { + public AroundRadius getAroundRadius() { return aroundRadius; } - public void setAroundRadius(OneOfintegerstring aroundRadius) { + public void setAroundRadius(AroundRadius aroundRadius) { this.aroundRadius = aroundRadius; } diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java index 04ef04f457..6e79c4de10 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java @@ -83,7 +83,7 @@ private Call addApiKeyValidateBeforeCall( public AddApiKeyResponse addApiKey(ApiKey apiKey) throws ApiException { Call req = addApiKeyValidateBeforeCall(apiKey, null); if (req instanceof CallEcho) { - return new EchoResponse.AddApiKey(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.AddApiKey(((CallEcho) req).request()); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -204,7 +204,9 @@ public UpdatedAtWithObjectIdResponse addOrUpdateObject( null ); if (req instanceof CallEcho) { - return new EchoResponse.AddOrUpdateObject(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.AddOrUpdateObject( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {} @@ -300,7 +302,9 @@ private Call appendSourceValidateBeforeCall( public CreatedAtResponse appendSource(Source source) throws ApiException { Call req = appendSourceValidateBeforeCall(source, null); if (req instanceof CallEcho) { - return new EchoResponse.AppendSource(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.AppendSource( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -409,7 +413,9 @@ public CreatedAtResponse assignUserId( null ); if (req instanceof CallEcho) { - return new EchoResponse.AssignUserId(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.AssignUserId( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -518,7 +524,7 @@ public BatchResponse batch( ) throws ApiException { Call req = batchValidateBeforeCall(indexName, batchWriteParams, null); if (req instanceof CallEcho) { - return new EchoResponse.Batch(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.Batch(((CallEcho) req).request()); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -633,7 +639,9 @@ public CreatedAtResponse batchAssignUserIds( null ); if (req instanceof CallEcho) { - return new EchoResponse.BatchAssignUserIds(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.BatchAssignUserIds( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -675,7 +683,7 @@ public Call batchAssignUserIdsAsync( * @throws ApiException If fail to serialize the request body object */ private Call batchDictionaryEntriesCall( - String dictionaryName, + DictionaryType dictionaryName, BatchDictionaryEntriesParams batchDictionaryEntriesParams, final ApiCallback _callback ) throws ApiException { @@ -705,7 +713,7 @@ private Call batchDictionaryEntriesCall( } private Call batchDictionaryEntriesValidateBeforeCall( - String dictionaryName, + DictionaryType dictionaryName, BatchDictionaryEntriesParams batchDictionaryEntriesParams, final ApiCallback _callback ) throws ApiException { @@ -742,7 +750,7 @@ private Call batchDictionaryEntriesValidateBeforeCall( * response body */ public UpdatedAtResponse batchDictionaryEntries( - String dictionaryName, + DictionaryType dictionaryName, BatchDictionaryEntriesParams batchDictionaryEntriesParams ) throws ApiException { Call req = batchDictionaryEntriesValidateBeforeCall( @@ -751,7 +759,7 @@ public UpdatedAtResponse batchDictionaryEntries( null ); if (req instanceof CallEcho) { - return new EchoResponse.BatchDictionaryEntries( + return new EchoResponse.SearchEcho.BatchDictionaryEntries( ((CallEcho) req).request() ); } @@ -771,7 +779,7 @@ public UpdatedAtResponse batchDictionaryEntries( * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call batchDictionaryEntriesAsync( - String dictionaryName, + DictionaryType dictionaryName, BatchDictionaryEntriesParams batchDictionaryEntriesParams, final ApiCallback _callback ) throws ApiException { @@ -893,7 +901,7 @@ public UpdatedAtResponse batchRules( null ); if (req instanceof CallEcho) { - return new EchoResponse.BatchRules(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.BatchRules(((CallEcho) req).request()); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -1008,7 +1016,7 @@ public BrowseResponse browse(String indexName, BrowseRequest browseRequest) throws ApiException { Call req = browseValidateBeforeCall(indexName, browseRequest, null); if (req instanceof CallEcho) { - return new EchoResponse.Browse(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.Browse(((CallEcho) req).request()); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -1124,7 +1132,9 @@ public UpdatedAtResponse clearAllSynonyms( null ); if (req instanceof CallEcho) { - return new EchoResponse.ClearAllSynonyms(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.ClearAllSynonyms( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -1223,7 +1233,9 @@ private Call clearObjectsValidateBeforeCall( public UpdatedAtResponse clearObjects(String indexName) throws ApiException { Call req = clearObjectsValidateBeforeCall(indexName, null); if (req instanceof CallEcho) { - return new EchoResponse.ClearObjects(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.ClearObjects( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -1324,7 +1336,7 @@ public UpdatedAtResponse clearRules( ) throws ApiException { Call req = clearRulesValidateBeforeCall(indexName, forwardToReplicas, null); if (req instanceof CallEcho) { - return new EchoResponse.ClearRules(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.ClearRules(((CallEcho) req).request()); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -1422,7 +1434,9 @@ private Call deleteApiKeyValidateBeforeCall( public DeleteApiKeyResponse deleteApiKey(String key) throws ApiException { Call req = deleteApiKeyValidateBeforeCall(key, null); if (req instanceof CallEcho) { - return new EchoResponse.DeleteApiKey(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.DeleteApiKey( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -1524,7 +1538,7 @@ public DeletedAtResponse deleteBy( ) throws ApiException { Call req = deleteByValidateBeforeCall(indexName, searchParams, null); if (req instanceof CallEcho) { - return new EchoResponse.DeleteBy(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.DeleteBy(((CallEcho) req).request()); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -1615,7 +1629,9 @@ private Call deleteIndexValidateBeforeCall( public DeletedAtResponse deleteIndex(String indexName) throws ApiException { Call req = deleteIndexValidateBeforeCall(indexName, null); if (req instanceof CallEcho) { - return new EchoResponse.DeleteIndex(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.DeleteIndex( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -1717,7 +1733,9 @@ public DeletedAtResponse deleteObject(String indexName, String objectID) throws ApiException { Call req = deleteObjectValidateBeforeCall(indexName, objectID, null); if (req instanceof CallEcho) { - return new EchoResponse.DeleteObject(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.DeleteObject( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -1839,7 +1857,7 @@ public UpdatedAtResponse deleteRule( null ); if (req instanceof CallEcho) { - return new EchoResponse.DeleteRule(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.DeleteRule(((CallEcho) req).request()); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -1941,7 +1959,9 @@ private Call deleteSourceValidateBeforeCall( public DeleteSourceResponse deleteSource(String source) throws ApiException { Call req = deleteSourceValidateBeforeCall(source, null); if (req instanceof CallEcho) { - return new EchoResponse.DeleteSource(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.DeleteSource( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -2061,7 +2081,9 @@ public DeletedAtResponse deleteSynonym( null ); if (req instanceof CallEcho) { - return new EchoResponse.DeleteSynonym(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.DeleteSynonym( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -2161,7 +2183,7 @@ private Call getApiKeyValidateBeforeCall( public Key getApiKey(String key) throws ApiException { Call req = getApiKeyValidateBeforeCall(key, null); if (req instanceof CallEcho) { - return new EchoResponse.GetApiKey(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.GetApiKey(((CallEcho) req).request()); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -2232,7 +2254,7 @@ private Call getDictionaryLanguagesValidateBeforeCall( public Map getDictionaryLanguages() throws ApiException { Call req = getDictionaryLanguagesValidateBeforeCall(null); if (req instanceof CallEcho) { - return new EchoResponse.GetDictionaryLanguages( + return new EchoResponse.SearchEcho.GetDictionaryLanguages( ((CallEcho) req).request() ); } @@ -2306,7 +2328,9 @@ public GetDictionarySettingsResponse getDictionarySettings() throws ApiException { Call req = getDictionarySettingsValidateBeforeCall(null); if (req instanceof CallEcho) { - return new EchoResponse.GetDictionarySettings(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.GetDictionarySettings( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {} @@ -2344,7 +2368,7 @@ private Call getLogsCall( Integer offset, Integer length, String indexName, - String type, + LogType type, final ApiCallback _callback ) throws ApiException { Object bodyObj = null; @@ -2388,7 +2412,7 @@ private Call getLogsValidateBeforeCall( Integer offset, Integer length, String indexName, - String type, + LogType type, final ApiCallback _callback ) throws ApiException { return getLogsCall(offset, length, indexName, type, _callback); @@ -2402,7 +2426,7 @@ private Call getLogsValidateBeforeCall( * @param length Maximum number of entries to retrieve. The maximum allowed value is 1000. * (optional, default to 10) * @param indexName Index for which log entries should be retrieved. When omitted, log entries are - * retrieved across all indices. (optional, default to null) + * retrieved across all indices. (optional) * @param type Type of log entries to retrieve. When omitted, all log entries are retrieved. * (optional, default to all) * @return GetLogsResponse @@ -2413,11 +2437,11 @@ public GetLogsResponse getLogs( Integer offset, Integer length, String indexName, - String type + LogType type ) throws ApiException { Call req = getLogsValidateBeforeCall(offset, length, indexName, type, null); if (req instanceof CallEcho) { - return new EchoResponse.GetLogs(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.GetLogs(((CallEcho) req).request()); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -2426,7 +2450,7 @@ public GetLogsResponse getLogs( } public GetLogsResponse getLogs() throws ApiException { - return this.getLogs(0, 10, "null", "all"); + return this.getLogs(0, 10, null, LogType.ALL); } /** @@ -2437,7 +2461,7 @@ public GetLogsResponse getLogs() throws ApiException { * @param length Maximum number of entries to retrieve. The maximum allowed value is 1000. * (optional, default to 10) * @param indexName Index for which log entries should be retrieved. When omitted, log entries are - * retrieved across all indices. (optional, default to null) + * retrieved across all indices. (optional) * @param type Type of log entries to retrieve. When omitted, all log entries are retrieved. * (optional, default to all) * @param _callback The callback to be executed when the API call finishes @@ -2448,7 +2472,7 @@ public Call getLogsAsync( Integer offset, Integer length, String indexName, - String type, + LogType type, final ApiCallback _callback ) throws ApiException { Call call = getLogsValidateBeforeCall( @@ -2557,7 +2581,7 @@ public Map getObject( null ); if (req instanceof CallEcho) { - return new EchoResponse.GetObject(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.GetObject(((CallEcho) req).request()); } Call call = (Call) req; Type returnType = new TypeToken>() {}.getType(); @@ -2567,7 +2591,7 @@ public Map getObject( public Map getObject(String indexName, String objectID) throws ApiException { - return this.getObject(indexName, objectID, null); + return this.getObject(indexName, objectID, new ArrayList<>()); } /** @@ -2656,7 +2680,7 @@ public GetObjectsResponse getObjects(GetObjectsParams getObjectsParams) throws ApiException { Call req = getObjectsValidateBeforeCall(getObjectsParams, null); if (req instanceof CallEcho) { - return new EchoResponse.GetObjects(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.GetObjects(((CallEcho) req).request()); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -2758,7 +2782,7 @@ private Call getRuleValidateBeforeCall( public Rule getRule(String indexName, String objectID) throws ApiException { Call req = getRuleValidateBeforeCall(indexName, objectID, null); if (req instanceof CallEcho) { - return new EchoResponse.GetRule(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.GetRule(((CallEcho) req).request()); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -2847,7 +2871,9 @@ private Call getSettingsValidateBeforeCall( public IndexSettings getSettings(String indexName) throws ApiException { Call req = getSettingsValidateBeforeCall(indexName, null); if (req instanceof CallEcho) { - return new EchoResponse.GetSettings(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.GetSettings( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -2919,7 +2945,7 @@ private Call getSourcesValidateBeforeCall( public List getSources() throws ApiException { Call req = getSourcesValidateBeforeCall(null); if (req instanceof CallEcho) { - return new EchoResponse.GetSources(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.GetSources(((CallEcho) req).request()); } Call call = (Call) req; Type returnType = new TypeToken>() {}.getType(); @@ -3018,7 +3044,7 @@ public SynonymHit getSynonym(String indexName, String objectID) throws ApiException { Call req = getSynonymValidateBeforeCall(indexName, objectID, null); if (req instanceof CallEcho) { - return new EchoResponse.GetSynonym(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.GetSynonym(((CallEcho) req).request()); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -3122,7 +3148,7 @@ public GetTaskResponse getTask(String indexName, Integer taskID) throws ApiException { Call req = getTaskValidateBeforeCall(indexName, taskID, null); if (req instanceof CallEcho) { - return new EchoResponse.GetTask(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.GetTask(((CallEcho) req).request()); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -3200,7 +3226,9 @@ private Call getTopUserIdsValidateBeforeCall( public GetTopUserIdsResponse getTopUserIds() throws ApiException { Call req = getTopUserIdsValidateBeforeCall(null); if (req instanceof CallEcho) { - return new EchoResponse.GetTopUserIds(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.GetTopUserIds( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -3291,7 +3319,7 @@ private Call getUserIdValidateBeforeCall( public UserId getUserId(String userID) throws ApiException { Call req = getUserIdValidateBeforeCall(userID, null); if (req instanceof CallEcho) { - return new EchoResponse.GetUserId(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.GetUserId(((CallEcho) req).request()); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -3379,7 +3407,9 @@ public CreatedAtResponse hasPendingMappings(Boolean getClusters) throws ApiException { Call req = hasPendingMappingsValidateBeforeCall(getClusters, null); if (req instanceof CallEcho) { - return new EchoResponse.HasPendingMappings(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.HasPendingMappings( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -3460,7 +3490,9 @@ private Call listApiKeysValidateBeforeCall( public ListApiKeysResponse listApiKeys() throws ApiException { Call req = listApiKeysValidateBeforeCall(null); if (req instanceof CallEcho) { - return new EchoResponse.ListApiKeys(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.ListApiKeys( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -3532,7 +3564,9 @@ private Call listClustersValidateBeforeCall( public ListClustersResponse listClusters() throws ApiException { Call req = listClustersValidateBeforeCall(null); if (req instanceof CallEcho) { - return new EchoResponse.ListClusters(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.ListClusters( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -3613,7 +3647,9 @@ private Call listIndicesValidateBeforeCall( public ListIndicesResponse listIndices(Integer page) throws ApiException { Call req = listIndicesValidateBeforeCall(page, null); if (req instanceof CallEcho) { - return new EchoResponse.ListIndices(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.ListIndices( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -3712,7 +3748,9 @@ public ListUserIdsResponse listUserIds(Integer page, Integer hitsPerPage) throws ApiException { Call req = listUserIdsValidateBeforeCall(page, hitsPerPage, null); if (req instanceof CallEcho) { - return new EchoResponse.ListUserIds(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.ListUserIds( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -3808,7 +3846,9 @@ public MultipleBatchResponse multipleBatch(BatchParams batchParams) throws ApiException { Call req = multipleBatchValidateBeforeCall(batchParams, null); if (req instanceof CallEcho) { - return new EchoResponse.MultipleBatch(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.MultipleBatch( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -3895,7 +3935,9 @@ public MultipleQueriesResponse multipleQueries( ) throws ApiException { Call req = multipleQueriesValidateBeforeCall(multipleQueriesParams, null); if (req instanceof CallEcho) { - return new EchoResponse.MultipleQueries(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.MultipleQueries( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -4003,7 +4045,9 @@ public UpdatedAtResponse operationIndex( null ); if (req instanceof CallEcho) { - return new EchoResponse.OperationIndex(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.OperationIndex( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -4045,11 +4089,11 @@ public Call operationIndexAsync( private Call partialUpdateObjectCall( String indexName, String objectID, - List> oneOfstringbuiltInOperation, + List> attributeOrBuiltInOperation, Boolean createIfNotExists, final ApiCallback _callback ) throws ApiException { - Object bodyObj = oneOfstringbuiltInOperation; + Object bodyObj = attributeOrBuiltInOperation; // create path and map variables String path = @@ -4087,7 +4131,7 @@ private Call partialUpdateObjectCall( private Call partialUpdateObjectValidateBeforeCall( String indexName, String objectID, - List> oneOfstringbuiltInOperation, + List> attributeOrBuiltInOperation, Boolean createIfNotExists, final ApiCallback _callback ) throws ApiException { @@ -4105,10 +4149,10 @@ private Call partialUpdateObjectValidateBeforeCall( ); } - // verify the required parameter 'oneOfstringbuiltInOperation' is set - if (oneOfstringbuiltInOperation == null) { + // verify the required parameter 'attributeOrBuiltInOperation' is set + if (attributeOrBuiltInOperation == null) { throw new ApiException( - "Missing the required parameter 'oneOfstringbuiltInOperation' when calling" + + "Missing the required parameter 'attributeOrBuiltInOperation' when calling" + " partialUpdateObject(Async)" ); } @@ -4116,7 +4160,7 @@ private Call partialUpdateObjectValidateBeforeCall( return partialUpdateObjectCall( indexName, objectID, - oneOfstringbuiltInOperation, + attributeOrBuiltInOperation, createIfNotExists, _callback ); @@ -4130,7 +4174,7 @@ private Call partialUpdateObjectValidateBeforeCall( * * @param indexName The index in which to perform the request. (required) * @param objectID Unique identifier of an object. (required) - * @param oneOfstringbuiltInOperation List of attributes to update. (required) + * @param attributeOrBuiltInOperation List of attributes to update. (required) * @param createIfNotExists Creates the record if it does not exist yet. (optional, default to * true) * @return UpdatedAtWithObjectIdResponse @@ -4140,18 +4184,20 @@ private Call partialUpdateObjectValidateBeforeCall( public UpdatedAtWithObjectIdResponse partialUpdateObject( String indexName, String objectID, - List> oneOfstringbuiltInOperation, + List> attributeOrBuiltInOperation, Boolean createIfNotExists ) throws ApiException { Call req = partialUpdateObjectValidateBeforeCall( indexName, objectID, - oneOfstringbuiltInOperation, + attributeOrBuiltInOperation, createIfNotExists, null ); if (req instanceof CallEcho) { - return new EchoResponse.PartialUpdateObject(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.PartialUpdateObject( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {} @@ -4164,12 +4210,12 @@ public UpdatedAtWithObjectIdResponse partialUpdateObject( public UpdatedAtWithObjectIdResponse partialUpdateObject( String indexName, String objectID, - List> oneOfstringbuiltInOperation + List> attributeOrBuiltInOperation ) throws ApiException { return this.partialUpdateObject( indexName, objectID, - oneOfstringbuiltInOperation, + attributeOrBuiltInOperation, true ); } @@ -4182,7 +4228,7 @@ public UpdatedAtWithObjectIdResponse partialUpdateObject( * * @param indexName The index in which to perform the request. (required) * @param objectID Unique identifier of an object. (required) - * @param oneOfstringbuiltInOperation List of attributes to update. (required) + * @param attributeOrBuiltInOperation List of attributes to update. (required) * @param createIfNotExists Creates the record if it does not exist yet. (optional, default to * true) * @param _callback The callback to be executed when the API call finishes @@ -4192,14 +4238,14 @@ public UpdatedAtWithObjectIdResponse partialUpdateObject( public Call partialUpdateObjectAsync( String indexName, String objectID, - List> oneOfstringbuiltInOperation, + List> attributeOrBuiltInOperation, Boolean createIfNotExists, final ApiCallback _callback ) throws ApiException { Call call = partialUpdateObjectValidateBeforeCall( indexName, objectID, - oneOfstringbuiltInOperation, + attributeOrBuiltInOperation, createIfNotExists, _callback ); @@ -4271,7 +4317,9 @@ private Call removeUserIdValidateBeforeCall( public RemoveUserIdResponse removeUserId(String userID) throws ApiException { Call req = removeUserIdValidateBeforeCall(userID, null); if (req instanceof CallEcho) { - return new EchoResponse.RemoveUserId(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.RemoveUserId( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -4356,7 +4404,9 @@ public ReplaceSourceResponse replaceSources(List source) throws ApiException { Call req = replaceSourcesValidateBeforeCall(source, null); if (req instanceof CallEcho) { - return new EchoResponse.ReplaceSources(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.ReplaceSources( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -4443,7 +4493,9 @@ private Call restoreApiKeyValidateBeforeCall( public AddApiKeyResponse restoreApiKey(String key) throws ApiException { Call req = restoreApiKeyValidateBeforeCall(key, null); if (req instanceof CallEcho) { - return new EchoResponse.RestoreApiKey(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.RestoreApiKey( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -4541,7 +4593,7 @@ public SaveObjectResponse saveObject(String indexName, Object body) throws ApiException { Call req = saveObjectValidateBeforeCall(indexName, body, null); if (req instanceof CallEcho) { - return new EchoResponse.SaveObject(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.SaveObject(((CallEcho) req).request()); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -4681,7 +4733,7 @@ public UpdatedRuleResponse saveRule( null ); if (req instanceof CallEcho) { - return new EchoResponse.SaveRule(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.SaveRule(((CallEcho) req).request()); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -4840,7 +4892,9 @@ public SaveSynonymResponse saveSynonym( null ); if (req instanceof CallEcho) { - return new EchoResponse.SaveSynonym(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.SaveSynonym( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -4997,7 +5051,9 @@ public UpdatedAtResponse saveSynonyms( null ); if (req instanceof CallEcho) { - return new EchoResponse.SaveSynonyms(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.SaveSynonyms( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -5117,7 +5173,7 @@ public SearchResponse search(String indexName, SearchParams searchParams) throws ApiException { Call req = searchValidateBeforeCall(indexName, searchParams, null); if (req instanceof CallEcho) { - return new EchoResponse.Search(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.Search(((CallEcho) req).request()); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -5153,7 +5209,7 @@ public Call searchAsync( * @throws ApiException If fail to serialize the request body object */ private Call searchDictionaryEntriesCall( - String dictionaryName, + DictionaryType dictionaryName, SearchDictionaryEntriesParams searchDictionaryEntriesParams, final ApiCallback _callback ) throws ApiException { @@ -5183,7 +5239,7 @@ private Call searchDictionaryEntriesCall( } private Call searchDictionaryEntriesValidateBeforeCall( - String dictionaryName, + DictionaryType dictionaryName, SearchDictionaryEntriesParams searchDictionaryEntriesParams, final ApiCallback _callback ) throws ApiException { @@ -5220,7 +5276,7 @@ private Call searchDictionaryEntriesValidateBeforeCall( * response body */ public UpdatedAtResponse searchDictionaryEntries( - String dictionaryName, + DictionaryType dictionaryName, SearchDictionaryEntriesParams searchDictionaryEntriesParams ) throws ApiException { Call req = searchDictionaryEntriesValidateBeforeCall( @@ -5229,7 +5285,7 @@ public UpdatedAtResponse searchDictionaryEntries( null ); if (req instanceof CallEcho) { - return new EchoResponse.SearchDictionaryEntries( + return new EchoResponse.SearchEcho.SearchDictionaryEntries( ((CallEcho) req).request() ); } @@ -5249,7 +5305,7 @@ public UpdatedAtResponse searchDictionaryEntries( * @throws ApiException If fail to process the API call, e.g. serializing the request body object */ public Call searchDictionaryEntriesAsync( - String dictionaryName, + DictionaryType dictionaryName, SearchDictionaryEntriesParams searchDictionaryEntriesParams, final ApiCallback _callback ) throws ApiException { @@ -5356,7 +5412,9 @@ public SearchForFacetValuesResponse searchForFacetValues( null ); if (req instanceof CallEcho) { - return new EchoResponse.SearchForFacetValues(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.SearchForFacetValues( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {} @@ -5480,7 +5538,9 @@ public SearchRulesResponse searchRules( null ); if (req instanceof CallEcho) { - return new EchoResponse.SearchRules(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.SearchRules( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -5623,7 +5683,9 @@ public SearchSynonymsResponse searchSynonyms( null ); if (req instanceof CallEcho) { - return new EchoResponse.SearchSynonyms(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.SearchSynonyms( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -5736,7 +5798,9 @@ public SearchUserIdsResponse searchUserIds( ) throws ApiException { Call req = searchUserIdsValidateBeforeCall(searchUserIdsParams, null); if (req instanceof CallEcho) { - return new EchoResponse.SearchUserIds(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.SearchUserIds( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -5831,7 +5895,9 @@ public UpdatedAtResponse setDictionarySettings( null ); if (req instanceof CallEcho) { - return new EchoResponse.SetDictionarySettings(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.SetDictionarySettings( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -5956,7 +6022,9 @@ public UpdatedAtResponse setSettings( null ); if (req instanceof CallEcho) { - return new EchoResponse.SetSettings(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.SetSettings( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); @@ -6073,7 +6141,9 @@ public UpdateApiKeyResponse updateApiKey(String key, ApiKey apiKey) throws ApiException { Call req = updateApiKeyValidateBeforeCall(key, apiKey, null); if (req instanceof CallEcho) { - return new EchoResponse.UpdateApiKey(((CallEcho) req).request()); + return new EchoResponse.SearchEcho.UpdateApiKey( + ((CallEcho) req).request() + ); } Call call = (Call) req; Type returnType = new TypeToken() {}.getType(); diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/utils/CompoundType.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/utils/CompoundType.java new file mode 100644 index 0000000000..9a64ddd3c2 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/utils/CompoundType.java @@ -0,0 +1,5 @@ +package com.algolia.utils; + +public interface CompoundType { + Object getInsideValue(); +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/utils/echo/EchoResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/utils/echo/EchoResponse.java index c9e9b4e64e..ed6db20a02 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/utils/echo/EchoResponse.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/utils/echo/EchoResponse.java @@ -1,7 +1,7 @@ package com.algolia.utils.echo; import com.algolia.Pair; -import com.algolia.model.*; +import com.algolia.model.search.*; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -34,1538 +34,1541 @@ private static List buildQueryParams(Request req) { return params; } - public static class AddApiKey - extends AddApiKeyResponse - implements EchoResponseInterface { + public static class SearchEcho { - private Request request; + public static class AddApiKey + extends AddApiKeyResponse + implements EchoResponseInterface { - public AddApiKey(Request request) { - this.request = request; - } + private Request request; - public String getPath() { - return request.url().encodedPath(); - } + public AddApiKey(Request request) { + this.request = request; + } - public String getMethod() { - return request.method(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getMethod() { + return request.method(); + } - public List getQueryParams() { - return buildQueryParams(request); + public String getBody() { + return parseRequestBody(request); + } + + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class AddOrUpdateObject - extends UpdatedAtWithObjectIdResponse - implements EchoResponseInterface { + public static class AddOrUpdateObject + extends UpdatedAtWithObjectIdResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public AddOrUpdateObject(Request request) { - this.request = request; - } + public AddOrUpdateObject(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class AppendSource - extends CreatedAtResponse - implements EchoResponseInterface { + public static class AppendSource + extends CreatedAtResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public AppendSource(Request request) { - this.request = request; - } + public AppendSource(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class AssignUserId - extends CreatedAtResponse - implements EchoResponseInterface { + public static class AssignUserId + extends CreatedAtResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public AssignUserId(Request request) { - this.request = request; - } + public AssignUserId(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class Batch - extends BatchResponse - implements EchoResponseInterface { + public static class Batch + extends BatchResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public Batch(Request request) { - this.request = request; - } + public Batch(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class BatchAssignUserIds - extends CreatedAtResponse - implements EchoResponseInterface { + public static class BatchAssignUserIds + extends CreatedAtResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public BatchAssignUserIds(Request request) { - this.request = request; - } + public BatchAssignUserIds(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class BatchDictionaryEntries - extends UpdatedAtResponse - implements EchoResponseInterface { + public static class BatchDictionaryEntries + extends UpdatedAtResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public BatchDictionaryEntries(Request request) { - this.request = request; - } + public BatchDictionaryEntries(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class BatchRules - extends UpdatedAtResponse - implements EchoResponseInterface { + public static class BatchRules + extends UpdatedAtResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public BatchRules(Request request) { - this.request = request; - } + public BatchRules(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class Browse - extends BrowseResponse - implements EchoResponseInterface { + public static class Browse + extends BrowseResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public Browse(Request request) { - this.request = request; - } + public Browse(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class ClearAllSynonyms - extends UpdatedAtResponse - implements EchoResponseInterface { + public static class ClearAllSynonyms + extends UpdatedAtResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public ClearAllSynonyms(Request request) { - this.request = request; - } + public ClearAllSynonyms(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class ClearObjects - extends UpdatedAtResponse - implements EchoResponseInterface { + public static class ClearObjects + extends UpdatedAtResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public ClearObjects(Request request) { - this.request = request; - } + public ClearObjects(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class ClearRules - extends UpdatedAtResponse - implements EchoResponseInterface { + public static class ClearRules + extends UpdatedAtResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public ClearRules(Request request) { - this.request = request; - } + public ClearRules(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class DeleteApiKey - extends DeleteApiKeyResponse - implements EchoResponseInterface { + public static class DeleteApiKey + extends DeleteApiKeyResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public DeleteApiKey(Request request) { - this.request = request; - } + public DeleteApiKey(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class DeleteBy - extends DeletedAtResponse - implements EchoResponseInterface { + public static class DeleteBy + extends DeletedAtResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public DeleteBy(Request request) { - this.request = request; - } + public DeleteBy(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class DeleteIndex - extends DeletedAtResponse - implements EchoResponseInterface { + public static class DeleteIndex + extends DeletedAtResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public DeleteIndex(Request request) { - this.request = request; - } + public DeleteIndex(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class DeleteObject - extends DeletedAtResponse - implements EchoResponseInterface { + public static class DeleteObject + extends DeletedAtResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public DeleteObject(Request request) { - this.request = request; - } + public DeleteObject(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class DeleteRule - extends UpdatedAtResponse - implements EchoResponseInterface { + public static class DeleteRule + extends UpdatedAtResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public DeleteRule(Request request) { - this.request = request; - } + public DeleteRule(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class DeleteSource - extends DeleteSourceResponse - implements EchoResponseInterface { + public static class DeleteSource + extends DeleteSourceResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public DeleteSource(Request request) { - this.request = request; - } + public DeleteSource(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class DeleteSynonym - extends DeletedAtResponse - implements EchoResponseInterface { + public static class DeleteSynonym + extends DeletedAtResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public DeleteSynonym(Request request) { - this.request = request; - } + public DeleteSynonym(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class GetApiKey extends Key implements EchoResponseInterface { + public static class GetApiKey extends Key implements EchoResponseInterface { - private Request request; + private Request request; - public GetApiKey(Request request) { - this.request = request; - } + public GetApiKey(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class GetDictionaryLanguages - extends HashMap - implements EchoResponseInterface { + public static class GetDictionaryLanguages + extends HashMap + implements EchoResponseInterface { - private Request request; + private Request request; - public GetDictionaryLanguages(Request request) { - this.request = request; - } + public GetDictionaryLanguages(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class GetDictionarySettings - extends GetDictionarySettingsResponse - implements EchoResponseInterface { + public static class GetDictionarySettings + extends GetDictionarySettingsResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public GetDictionarySettings(Request request) { - this.request = request; - } + public GetDictionarySettings(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class GetLogs - extends GetLogsResponse - implements EchoResponseInterface { + public static class GetLogs + extends GetLogsResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public GetLogs(Request request) { - this.request = request; - } + public GetLogs(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class GetObject - extends HashMap - implements EchoResponseInterface { + public static class GetObject + extends HashMap + implements EchoResponseInterface { - private Request request; + private Request request; - public GetObject(Request request) { - this.request = request; - } + public GetObject(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class GetObjects - extends GetObjectsResponse - implements EchoResponseInterface { + public static class GetObjects + extends GetObjectsResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public GetObjects(Request request) { - this.request = request; - } + public GetObjects(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class GetRule extends Rule implements EchoResponseInterface { + public static class GetRule extends Rule implements EchoResponseInterface { - private Request request; + private Request request; - public GetRule(Request request) { - this.request = request; - } + public GetRule(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class GetSettings - extends IndexSettings - implements EchoResponseInterface { + public static class GetSettings + extends IndexSettings + implements EchoResponseInterface { - private Request request; + private Request request; - public GetSettings(Request request) { - this.request = request; - } + public GetSettings(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class GetSources - extends ArrayList - implements EchoResponseInterface { + public static class GetSources + extends ArrayList + implements EchoResponseInterface { - private Request request; + private Request request; - public GetSources(Request request) { - this.request = request; - } + public GetSources(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class GetSynonym - extends SynonymHit - implements EchoResponseInterface { + public static class GetSynonym + extends SynonymHit + implements EchoResponseInterface { - private Request request; + private Request request; - public GetSynonym(Request request) { - this.request = request; - } + public GetSynonym(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class GetTask - extends GetTaskResponse - implements EchoResponseInterface { + public static class GetTask + extends GetTaskResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public GetTask(Request request) { - this.request = request; - } + public GetTask(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class GetTopUserIds - extends GetTopUserIdsResponse - implements EchoResponseInterface { + public static class GetTopUserIds + extends GetTopUserIdsResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public GetTopUserIds(Request request) { - this.request = request; - } + public GetTopUserIds(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class GetUserId - extends UserId - implements EchoResponseInterface { + public static class GetUserId + extends UserId + implements EchoResponseInterface { - private Request request; + private Request request; - public GetUserId(Request request) { - this.request = request; - } + public GetUserId(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class HasPendingMappings - extends CreatedAtResponse - implements EchoResponseInterface { + public static class HasPendingMappings + extends CreatedAtResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public HasPendingMappings(Request request) { - this.request = request; - } + public HasPendingMappings(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class ListApiKeys - extends ListApiKeysResponse - implements EchoResponseInterface { + public static class ListApiKeys + extends ListApiKeysResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public ListApiKeys(Request request) { - this.request = request; - } + public ListApiKeys(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class ListClusters - extends ListClustersResponse - implements EchoResponseInterface { + public static class ListClusters + extends ListClustersResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public ListClusters(Request request) { - this.request = request; - } + public ListClusters(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class ListIndices - extends ListIndicesResponse - implements EchoResponseInterface { + public static class ListIndices + extends ListIndicesResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public ListIndices(Request request) { - this.request = request; - } + public ListIndices(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class ListUserIds - extends ListUserIdsResponse - implements EchoResponseInterface { + public static class ListUserIds + extends ListUserIdsResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public ListUserIds(Request request) { - this.request = request; - } + public ListUserIds(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class MultipleBatch - extends MultipleBatchResponse - implements EchoResponseInterface { + public static class MultipleBatch + extends MultipleBatchResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public MultipleBatch(Request request) { - this.request = request; - } + public MultipleBatch(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class MultipleQueries - extends MultipleQueriesResponse - implements EchoResponseInterface { + public static class MultipleQueries + extends MultipleQueriesResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public MultipleQueries(Request request) { - this.request = request; - } + public MultipleQueries(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class OperationIndex - extends UpdatedAtResponse - implements EchoResponseInterface { + public static class OperationIndex + extends UpdatedAtResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public OperationIndex(Request request) { - this.request = request; - } + public OperationIndex(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class PartialUpdateObject - extends UpdatedAtWithObjectIdResponse - implements EchoResponseInterface { + public static class PartialUpdateObject + extends UpdatedAtWithObjectIdResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public PartialUpdateObject(Request request) { - this.request = request; - } + public PartialUpdateObject(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class RemoveUserId - extends RemoveUserIdResponse - implements EchoResponseInterface { + public static class RemoveUserId + extends RemoveUserIdResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public RemoveUserId(Request request) { - this.request = request; - } + public RemoveUserId(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class ReplaceSources - extends ReplaceSourceResponse - implements EchoResponseInterface { + public static class ReplaceSources + extends ReplaceSourceResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public ReplaceSources(Request request) { - this.request = request; - } + public ReplaceSources(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class RestoreApiKey - extends AddApiKeyResponse - implements EchoResponseInterface { + public static class RestoreApiKey + extends AddApiKeyResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public RestoreApiKey(Request request) { - this.request = request; - } + public RestoreApiKey(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class SaveObject - extends SaveObjectResponse - implements EchoResponseInterface { + public static class SaveObject + extends SaveObjectResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public SaveObject(Request request) { - this.request = request; - } + public SaveObject(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class SaveRule - extends UpdatedRuleResponse - implements EchoResponseInterface { + public static class SaveRule + extends UpdatedRuleResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public SaveRule(Request request) { - this.request = request; - } + public SaveRule(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class SaveSynonym - extends SaveSynonymResponse - implements EchoResponseInterface { + public static class SaveSynonym + extends SaveSynonymResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public SaveSynonym(Request request) { - this.request = request; - } + public SaveSynonym(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class SaveSynonyms - extends UpdatedAtResponse - implements EchoResponseInterface { + public static class SaveSynonyms + extends UpdatedAtResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public SaveSynonyms(Request request) { - this.request = request; - } + public SaveSynonyms(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class Search - extends SearchResponse - implements EchoResponseInterface { + public static class Search + extends SearchResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public Search(Request request) { - this.request = request; - } + public Search(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class SearchDictionaryEntries - extends UpdatedAtResponse - implements EchoResponseInterface { + public static class SearchDictionaryEntries + extends UpdatedAtResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public SearchDictionaryEntries(Request request) { - this.request = request; - } + public SearchDictionaryEntries(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class SearchForFacetValues - extends SearchForFacetValuesResponse - implements EchoResponseInterface { + public static class SearchForFacetValues + extends SearchForFacetValuesResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public SearchForFacetValues(Request request) { - this.request = request; - } + public SearchForFacetValues(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class SearchRules - extends SearchRulesResponse - implements EchoResponseInterface { + public static class SearchRules + extends SearchRulesResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public SearchRules(Request request) { - this.request = request; - } + public SearchRules(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class SearchSynonyms - extends SearchSynonymsResponse - implements EchoResponseInterface { + public static class SearchSynonyms + extends SearchSynonymsResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public SearchSynonyms(Request request) { - this.request = request; - } + public SearchSynonyms(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class SearchUserIds - extends SearchUserIdsResponse - implements EchoResponseInterface { + public static class SearchUserIds + extends SearchUserIdsResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public SearchUserIds(Request request) { - this.request = request; - } + public SearchUserIds(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class SetDictionarySettings - extends UpdatedAtResponse - implements EchoResponseInterface { + public static class SetDictionarySettings + extends UpdatedAtResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public SetDictionarySettings(Request request) { - this.request = request; - } + public SetDictionarySettings(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class SetSettings - extends UpdatedAtResponse - implements EchoResponseInterface { + public static class SetSettings + extends UpdatedAtResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public SetSettings(Request request) { - this.request = request; - } + public SetSettings(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } - } - public static class UpdateApiKey - extends UpdateApiKeyResponse - implements EchoResponseInterface { + public static class UpdateApiKey + extends UpdateApiKeyResponse + implements EchoResponseInterface { - private Request request; + private Request request; - public UpdateApiKey(Request request) { - this.request = request; - } + public UpdateApiKey(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } } } diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopHitsResponse.ts b/clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopHitsResponse.ts index 454261b174..a3ea005704 100644 --- a/clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopHitsResponse.ts +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopHitsResponse.ts @@ -1,8 +1,4 @@ -import type { GetTopHitsResponseHits } from './getTopHitsResponseHits'; +import type { TopHitsResponse } from './topHitsResponse'; +import type { TopHitsResponseWithAnalytics } from './topHitsResponseWithAnalytics'; -export type GetTopHitsResponse = { - /** - * A list of top hits with their count. - */ - hits: GetTopHitsResponseHits[]; -}; +export type GetTopHitsResponse = TopHitsResponse | TopHitsResponseWithAnalytics; diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopHitsResponseSimple.ts b/clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopHitsResponseSimple.ts new file mode 100644 index 0000000000..b6c7bbdff5 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopHitsResponseSimple.ts @@ -0,0 +1,8 @@ +import type { GetTopHitsResponseSimpleHits } from './getTopHitsResponseSimpleHits'; + +export type GetTopHitsResponseSimple = { + /** + * A list of top hits with their count. + */ + hits: GetTopHitsResponseSimpleHits[]; +}; diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopHitsResponseSimpleHits.ts b/clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopHitsResponseSimpleHits.ts new file mode 100644 index 0000000000..a2fd274ddd --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopHitsResponseSimpleHits.ts @@ -0,0 +1,10 @@ +export type GetTopHitsResponseSimpleHits = { + /** + * The hit. + */ + hit: string; + /** + * The number of occurrences. + */ + count: number; +}; diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopSearchesResponse.ts b/clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopSearchesResponse.ts index cc805fa4e6..f82c1126eb 100644 --- a/clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopSearchesResponse.ts +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopSearchesResponse.ts @@ -1,8 +1,6 @@ -import type { GetSearchesNoResultsResponseSearches } from './getSearchesNoResultsResponseSearches'; +import type { TopSearchesResponse } from './topSearchesResponse'; +import type { TopSearchesResponseWithAnalytics } from './topSearchesResponseWithAnalytics'; -export type GetTopSearchesResponse = { - /** - * A list of top searches with their count. - */ - searches: GetSearchesNoResultsResponseSearches[]; -}; +export type GetTopSearchesResponse = + | TopSearchesResponse + | TopSearchesResponseWithAnalytics; diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopSearchesResponseSimple.ts b/clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopSearchesResponseSimple.ts new file mode 100644 index 0000000000..7d7cd3ea28 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopSearchesResponseSimple.ts @@ -0,0 +1,8 @@ +import type { GetSearchesNoResultsResponseSearches } from './getSearchesNoResultsResponseSearches'; + +export type GetTopSearchesResponseSimple = { + /** + * A list of top searches with their count. + */ + searches: GetSearchesNoResultsResponseSearches[]; +}; diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/model/topHitsResponse.ts b/clients/algoliasearch-client-javascript/packages/client-analytics/model/topHitsResponse.ts new file mode 100644 index 0000000000..4b724b0012 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/model/topHitsResponse.ts @@ -0,0 +1,8 @@ +import type { TopHitsResponseHits } from './topHitsResponseHits'; + +export type TopHitsResponse = { + /** + * A list of top hits with their count. + */ + hits: TopHitsResponseHits[]; +}; diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopHitsResponseHits.ts b/clients/algoliasearch-client-javascript/packages/client-analytics/model/topHitsResponseHits.ts similarity index 72% rename from clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopHitsResponseHits.ts rename to clients/algoliasearch-client-javascript/packages/client-analytics/model/topHitsResponseHits.ts index 4a24c30a21..148da97c02 100644 --- a/clients/algoliasearch-client-javascript/packages/client-analytics/model/getTopHitsResponseHits.ts +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/model/topHitsResponseHits.ts @@ -1,4 +1,4 @@ -export type GetTopHitsResponseHits = { +export type TopHitsResponseHits = { /** * The hit. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/model/topHitsResponseWithAnalytics.ts b/clients/algoliasearch-client-javascript/packages/client-analytics/model/topHitsResponseWithAnalytics.ts new file mode 100644 index 0000000000..fb2b5d3db9 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/model/topHitsResponseWithAnalytics.ts @@ -0,0 +1,8 @@ +import type { TopHitsResponseWithAnalyticsHits } from './topHitsResponseWithAnalyticsHits'; + +export type TopHitsResponseWithAnalytics = { + /** + * A list of top hits with their count and analytics. + */ + hits: TopHitsResponseWithAnalyticsHits[]; +}; diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/model/topHitsResponseWithAnalyticsHits.ts b/clients/algoliasearch-client-javascript/packages/client-analytics/model/topHitsResponseWithAnalyticsHits.ts new file mode 100644 index 0000000000..ce8afdbb2a --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/model/topHitsResponseWithAnalyticsHits.ts @@ -0,0 +1,30 @@ +export type TopHitsResponseWithAnalyticsHits = { + /** + * The hit. + */ + hit: string; + /** + * The number of occurrences. + */ + count: number; + /** + * The click-through rate. + */ + clickThroughRate: number; + /** + * The conversion rate. + */ + conversionRate: number; + /** + * The number of tracked search click. + */ + trackedSearchCount: number; + /** + * The number of click event. + */ + clickCount: number; + /** + * The number of converted clicks. + */ + conversionCount: number; +}; diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/model/topSearchesResponse.ts b/clients/algoliasearch-client-javascript/packages/client-analytics/model/topSearchesResponse.ts new file mode 100644 index 0000000000..2dabac55c6 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/model/topSearchesResponse.ts @@ -0,0 +1,8 @@ +import type { GetSearchesNoResultsResponseSearches } from './getSearchesNoResultsResponseSearches'; + +export type TopSearchesResponse = { + /** + * A list of top searches with their count. + */ + searches: GetSearchesNoResultsResponseSearches[]; +}; diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/model/topSearchesResponseWithAnalytics.ts b/clients/algoliasearch-client-javascript/packages/client-analytics/model/topSearchesResponseWithAnalytics.ts new file mode 100644 index 0000000000..1a58b7a9d8 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/model/topSearchesResponseWithAnalytics.ts @@ -0,0 +1,8 @@ +import type { TopSearchesResponseWithAnalyticsSearches } from './topSearchesResponseWithAnalyticsSearches'; + +export type TopSearchesResponseWithAnalytics = { + /** + * A list of top searches with their count and analytics. + */ + searches: TopSearchesResponseWithAnalyticsSearches[]; +}; diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/model/topSearchesResponseWithAnalyticsSearches.ts b/clients/algoliasearch-client-javascript/packages/client-analytics/model/topSearchesResponseWithAnalyticsSearches.ts new file mode 100644 index 0000000000..af52de5a07 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/model/topSearchesResponseWithAnalyticsSearches.ts @@ -0,0 +1,38 @@ +export type TopSearchesResponseWithAnalyticsSearches = { + /** + * The search query. + */ + search: string; + /** + * The number of occurrences. + */ + count: number; + /** + * The click-through rate. + */ + clickThroughRate: number; + /** + * The average position of all the click count event. + */ + averageClickPosition: number; + /** + * The conversion rate. + */ + conversionRate: number; + /** + * The number of tracked search click. + */ + trackedSearchCount: number; + /** + * The number of click event. + */ + clickCount: number; + /** + * The number of converted clicks. + */ + conversionCount: number; + /** + * Number of hits that the search query matched. + */ + nbHits: number; +}; diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts b/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts index 7486b001f1..1c8db3dc0f 100644 --- a/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts @@ -26,9 +26,7 @@ import type { GetTopFilterAttributesResponse } from '../model/getTopFilterAttrib import type { GetTopFilterForAttributeResponse } from '../model/getTopFilterForAttributeResponse'; import type { GetTopFiltersNoResultsResponse } from '../model/getTopFiltersNoResultsResponse'; import type { GetTopHitsResponse } from '../model/getTopHitsResponse'; -import type { GetTopHitsResponseWithAnalytics } from '../model/getTopHitsResponseWithAnalytics'; import type { GetTopSearchesResponse } from '../model/getTopSearchesResponse'; -import type { GetTopSearchesResponseWithAnalytics } from '../model/getTopSearchesResponseWithAnalytics'; import type { GetUsersCountResponse } from '../model/getUsersCountResponse'; export const apiClientVersion = '5.0.0'; @@ -919,9 +917,7 @@ export function createAnalyticsApi( limit, offset, tags, - }: GetTopHitsProps): Promise< - GetTopHitsResponse | GetTopHitsResponseWithAnalytics - > { + }: GetTopHitsProps): Promise { const path = '/2/hits'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; @@ -1000,9 +996,7 @@ export function createAnalyticsApi( limit, offset, tags, - }: GetTopSearchesProps): Promise< - GetTopSearchesResponse | GetTopSearchesResponseWithAnalytics - > { + }: GetTopSearchesProps): Promise { const path = '/2/searches'; const headers: Headers = { Accept: 'application/json' }; const queryParameters: Record = {}; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/acl.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/acl.ts new file mode 100644 index 0000000000..f1cf7fd90d --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/acl.ts @@ -0,0 +1,15 @@ +export type Acl = + | 'addObject' + | 'analytics' + | 'browse' + | 'deleteIndex' + | 'deleteObject' + | 'editSettings' + | 'listIndexes' + | 'logs' + | 'personalization' + | 'recommendation' + | 'search' + | 'seeUnretrievableAttributes' + | 'settings' + | 'usage'; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/apiKey.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/apiKey.ts index 4dff62ed0e..5ad4a42d1d 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/apiKey.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/apiKey.ts @@ -1,3 +1,5 @@ +import type { Acl } from './acl'; + /** * Api Key object. */ @@ -5,7 +7,7 @@ export type ApiKey = { /** * Set of permissions associated with the key. */ - acl: ApiKeyAcl[]; + acl: Acl[]; /** * A comment used to identify a key more easily in the dashboard. It is not interpreted by the API. */ @@ -35,19 +37,3 @@ export type ApiKey = { */ validity?: number; }; - -export type ApiKeyAcl = - | 'addObject' - | 'analytics' - | 'browse' - | 'deleteIndex' - | 'deleteObject' - | 'editSettings' - | 'listIndexes' - | 'logs' - | 'personalization' - | 'recommendation' - | 'search' - | 'seeUnretrievableAttributes' - | 'settings' - | 'usage'; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/aroundRadius.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/aroundRadius.ts new file mode 100644 index 0000000000..929d3c0fba --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/aroundRadius.ts @@ -0,0 +1,3 @@ +import type { AroundRadiusOneOf } from './aroundRadiusOneOf'; + +export type AroundRadius = AroundRadiusOneOf | number; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/aroundRadiusOneOf.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/aroundRadiusOneOf.ts new file mode 100644 index 0000000000..b737491ab2 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/aroundRadiusOneOf.ts @@ -0,0 +1 @@ +export type AroundRadiusOneOf = 'all'; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/attributeOrBuiltInOperation.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/attributeOrBuiltInOperation.ts new file mode 100644 index 0000000000..77a50a18bd --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/attributeOrBuiltInOperation.ts @@ -0,0 +1,3 @@ +import type { BuiltInOperation } from './builtInOperation'; + +export type AttributeOrBuiltInOperation = BuiltInOperation | string; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/baseSearchParams.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/baseSearchParams.ts index 8bf1730be7..77631535de 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/baseSearchParams.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/baseSearchParams.ts @@ -1,3 +1,5 @@ +import type { AroundRadius } from './aroundRadius'; + export type BaseSearchParams = { /** * Overrides the query parameter and performs a more generic search that can be used to find \"similar\" results. @@ -63,10 +65,7 @@ export type BaseSearchParams = { * Search for entries around a given location automatically computed from the requester\'s IP address. */ aroundLatLngViaIP?: boolean; - /** - * Define the maximum radius for a geo search (in meters). - */ - aroundRadius?: number | string | null; + aroundRadius?: AroundRadius; /** * Precision of geo search (in meters), to add grouping by geo location to the ranking formula. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/batchParams.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/batchParams.ts index c0c9a64003..7bb0bc2604 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/batchParams.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/batchParams.ts @@ -1,8 +1,8 @@ -import type { Operation } from './operation'; +import type { OperationIndexName } from './operationIndexName'; /** * The `multipleBatch` parameters. */ export type BatchParams = { - requests?: Operation[]; + requests?: OperationIndexName[]; }; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/builtInOperation.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/builtInOperation.ts index 58bb215b56..a65f72e536 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/builtInOperation.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/builtInOperation.ts @@ -1,22 +1,12 @@ +import type { BuiltInOperationType } from './builtInOperationType'; + /** * To update an attribute without pushing the entire record, you can use these built-in operations. */ export type BuiltInOperation = { - /** - * The operation to apply on the attribute. - */ - _operation: BuiltInOperationOperation; + _operation: BuiltInOperationType; /** * The right-hand side argument to the operation, for example, increment or decrement step, value to add or remove. */ value: string; }; - -export type BuiltInOperationOperation = - | 'Add' - | 'AddUnique' - | 'Decrement' - | 'Increment' - | 'IncrementFrom' - | 'IncrementSet' - | 'Remove'; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/builtInOperationType.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/builtInOperationType.ts new file mode 100644 index 0000000000..19fa4de4db --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/builtInOperationType.ts @@ -0,0 +1,12 @@ +/** + * The operation to apply on the attribute. + */ + +export type BuiltInOperationType = + | 'Add' + | 'AddUnique' + | 'Decrement' + | 'Increment' + | 'IncrementFrom' + | 'IncrementSet' + | 'Remove'; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/dictionaryType.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/dictionaryType.ts new file mode 100644 index 0000000000..04ec8ba25c --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/dictionaryType.ts @@ -0,0 +1 @@ +export type DictionaryType = 'compounds' | 'plurals' | 'stopwords'; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/logType.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/logType.ts new file mode 100644 index 0000000000..e2520137ce --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/logType.ts @@ -0,0 +1 @@ +export type LogType = 'all' | 'build' | 'error' | 'query'; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/operation.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/operation.ts index bc80b8fbbd..e91c6b8852 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/model/operation.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/operation.ts @@ -6,8 +6,4 @@ export type Operation = { * Arguments to the operation (depends on the type of the operation). */ body?: Record; - /** - * Index to target for this operation. - */ - indexName?: string; }; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/model/operationIndexName.ts b/clients/algoliasearch-client-javascript/packages/client-search/model/operationIndexName.ts new file mode 100644 index 0000000000..42af0bf2c5 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-search/model/operationIndexName.ts @@ -0,0 +1,13 @@ +import type { Action } from './action'; + +export type OperationIndexName = { + action?: Action; + /** + * Arguments to the operation (depends on the type of the operation). + */ + body?: Record; + /** + * Index to target for this operation. + */ + indexName?: string; +}; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts b/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts index b99e6a7f89..474cbbd063 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts @@ -15,6 +15,7 @@ import type { import type { AddApiKeyResponse } from '../model/addApiKeyResponse'; import type { ApiKey } from '../model/apiKey'; import type { AssignUserIdParams } from '../model/assignUserIdParams'; +import type { AttributeOrBuiltInOperation } from '../model/attributeOrBuiltInOperation'; import type { BatchAssignUserIdsParams } from '../model/batchAssignUserIdsParams'; import type { BatchDictionaryEntriesParams } from '../model/batchDictionaryEntriesParams'; import type { BatchParams } from '../model/batchParams'; @@ -22,12 +23,12 @@ import type { BatchResponse } from '../model/batchResponse'; import type { BatchWriteParams } from '../model/batchWriteParams'; import type { BrowseRequest } from '../model/browseRequest'; import type { BrowseResponse } from '../model/browseResponse'; -import type { BuiltInOperation } from '../model/builtInOperation'; import type { CreatedAtResponse } from '../model/createdAtResponse'; import type { DeleteApiKeyResponse } from '../model/deleteApiKeyResponse'; import type { DeleteSourceResponse } from '../model/deleteSourceResponse'; import type { DeletedAtResponse } from '../model/deletedAtResponse'; import type { DictionarySettingsParams } from '../model/dictionarySettingsParams'; +import type { DictionaryType } from '../model/dictionaryType'; import type { GetDictionarySettingsResponse } from '../model/getDictionarySettingsResponse'; import type { GetLogsResponse } from '../model/getLogsResponse'; import type { GetObjectsParams } from '../model/getObjectsParams'; @@ -41,6 +42,7 @@ import type { ListApiKeysResponse } from '../model/listApiKeysResponse'; import type { ListClustersResponse } from '../model/listClustersResponse'; import type { ListIndicesResponse } from '../model/listIndicesResponse'; import type { ListUserIdsResponse } from '../model/listUserIdsResponse'; +import type { LogType } from '../model/logType'; import type { MultipleBatchResponse } from '../model/multipleBatchResponse'; import type { MultipleQueriesParams } from '../model/multipleQueriesParams'; import type { MultipleQueriesResponse } from '../model/multipleQueriesResponse'; @@ -1614,13 +1616,13 @@ export function createSearchApi(options: CreateClientOptions) { * @param partialUpdateObject - The partialUpdateObject object. * @param partialUpdateObject.indexName - The index in which to perform the request. * @param partialUpdateObject.objectID - Unique identifier of an object. - * @param partialUpdateObject.stringBuiltInOperation - List of attributes to update. + * @param partialUpdateObject.attributeOrBuiltInOperation - List of attributes to update. * @param partialUpdateObject.createIfNotExists - Creates the record if it does not exist yet. */ function partialUpdateObject({ indexName, objectID, - stringBuiltInOperation, + attributeOrBuiltInOperation, createIfNotExists, }: PartialUpdateObjectProps): Promise { const path = '/1/indexes/{indexName}/{objectID}/partial' @@ -1641,9 +1643,9 @@ export function createSearchApi(options: CreateClientOptions) { ); } - if (!stringBuiltInOperation) { + if (!attributeOrBuiltInOperation) { throw new Error( - 'Parameter `stringBuiltInOperation` is required when calling `partialUpdateObject`.' + 'Parameter `attributeOrBuiltInOperation` is required when calling `partialUpdateObject`.' ); } @@ -1654,7 +1656,7 @@ export function createSearchApi(options: CreateClientOptions) { const request: Request = { method: 'POST', path, - data: stringBuiltInOperation, + data: attributeOrBuiltInOperation, }; return transporter.request(request, { @@ -2505,7 +2507,7 @@ export type BatchDictionaryEntriesProps = { /** * The dictionary to search in. */ - dictionaryName: 'compounds' | 'plurals' | 'stopwords'; + dictionaryName: DictionaryType; batchDictionaryEntriesParams: BatchDictionaryEntriesParams; }; @@ -2655,7 +2657,7 @@ export type GetLogsProps = { /** * Type of log entries to retrieve. When omitted, all log entries are retrieved. */ - type?: 'all' | 'build' | 'error' | 'query'; + type?: LogType; }; export type GetObjectProps = { @@ -2765,7 +2767,9 @@ export type PartialUpdateObjectProps = { /** * List of attributes to update. */ - stringBuiltInOperation: Array<{ [key: string]: BuiltInOperation | string }>; + attributeOrBuiltInOperation: Array<{ + [key: string]: AttributeOrBuiltInOperation; + }>; /** * Creates the record if it does not exist yet. */ @@ -2864,7 +2868,7 @@ export type SearchDictionaryEntriesProps = { /** * The dictionary to search in. */ - dictionaryName: 'compounds' | 'plurals' | 'stopwords'; + dictionaryName: DictionaryType; searchDictionaryEntriesParams: SearchDictionaryEntriesParams; }; diff --git a/clients/algoliasearch-client-javascript/packages/recommend/model/aroundRadius.ts b/clients/algoliasearch-client-javascript/packages/recommend/model/aroundRadius.ts new file mode 100644 index 0000000000..929d3c0fba --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/recommend/model/aroundRadius.ts @@ -0,0 +1,3 @@ +import type { AroundRadiusOneOf } from './aroundRadiusOneOf'; + +export type AroundRadius = AroundRadiusOneOf | number; diff --git a/clients/algoliasearch-client-javascript/packages/recommend/model/aroundRadiusOneOf.ts b/clients/algoliasearch-client-javascript/packages/recommend/model/aroundRadiusOneOf.ts new file mode 100644 index 0000000000..b737491ab2 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/recommend/model/aroundRadiusOneOf.ts @@ -0,0 +1 @@ +export type AroundRadiusOneOf = 'all'; diff --git a/clients/algoliasearch-client-javascript/packages/recommend/model/baseSearchParams.ts b/clients/algoliasearch-client-javascript/packages/recommend/model/baseSearchParams.ts index 8bf1730be7..77631535de 100644 --- a/clients/algoliasearch-client-javascript/packages/recommend/model/baseSearchParams.ts +++ b/clients/algoliasearch-client-javascript/packages/recommend/model/baseSearchParams.ts @@ -1,3 +1,5 @@ +import type { AroundRadius } from './aroundRadius'; + export type BaseSearchParams = { /** * Overrides the query parameter and performs a more generic search that can be used to find \"similar\" results. @@ -63,10 +65,7 @@ export type BaseSearchParams = { * Search for entries around a given location automatically computed from the requester\'s IP address. */ aroundLatLngViaIP?: boolean; - /** - * Define the maximum radius for a geo search (in meters). - */ - aroundRadius?: number | string | null; + aroundRadius?: AroundRadius; /** * Precision of geo search (in meters), to add grouping by geo location to the ranking formula. */ diff --git a/clients/algoliasearch-client-php/lib/Api/SearchApi.php b/clients/algoliasearch-client-php/lib/Api/SearchApi.php index 4049e0dbef..06b5f4f3ac 100644 --- a/clients/algoliasearch-client-php/lib/Api/SearchApi.php +++ b/clients/algoliasearch-client-php/lib/Api/SearchApi.php @@ -339,7 +339,7 @@ public function batchAssignUserIds($xAlgoliaUserID, $batchAssignUserIdsParams) /** * Send a batch of dictionary entries. * - * @param string $dictionaryName The dictionary to search in. (required) + * @param array $dictionaryName The dictionary to search in. (required) * @param array $batchDictionaryEntriesParams batchDictionaryEntriesParams (required) * * @return array @@ -954,12 +954,12 @@ public function getDictionarySettings() * * @param int $offset First entry to retrieve (zero-based). Log entries are sorted by decreasing date, therefore 0 designates the most recent log entry. (optional, default to 0) * @param int $length Maximum number of entries to retrieve. The maximum allowed value is 1000. (optional, default to 10) - * @param string $indexName Index for which log entries should be retrieved. When omitted, log entries are retrieved across all indices. (optional, default to 'null') - * @param string $type Type of log entries to retrieve. When omitted, all log entries are retrieved. (optional, default to 'all') + * @param string $indexName Index for which log entries should be retrieved. When omitted, log entries are retrieved across all indices. (optional) + * @param array $type Type of log entries to retrieve. When omitted, all log entries are retrieved. (optional) * * @return array */ - public function getLogs($offset = 0, $length = 10, $indexName = 'null', $type = 'all') + public function getLogs($offset = 0, $length = 10, $indexName = null, $type = null) { if ($length !== null && $length > 1000) { throw new \InvalidArgumentException('invalid value for "$length" when calling SearchApi.getLogs, must be smaller than or equal to 1000.'); @@ -1549,12 +1549,12 @@ public function operationIndex($indexName, $operationIndexParams) * * @param string $indexName The index in which to perform the request. (required) * @param string $objectID Unique identifier of an object. (required) - * @param array $oneOfStringBuiltInOperation List of attributes to update. (required) + * @param array $attributeOrBuiltInOperation List of attributes to update. (required) * @param array $createIfNotExists Creates the record if it does not exist yet. (optional, default to true) * * @return array */ - public function partialUpdateObject($indexName, $objectID, $oneOfStringBuiltInOperation, $createIfNotExists = true) + public function partialUpdateObject($indexName, $objectID, $attributeOrBuiltInOperation, $createIfNotExists = true) { // verify the required parameter 'indexName' is set if ($indexName === null || (is_array($indexName) && count($indexName) === 0)) { @@ -1568,10 +1568,10 @@ public function partialUpdateObject($indexName, $objectID, $oneOfStringBuiltInOp 'Missing the required parameter $objectID when calling partialUpdateObject' ); } - // verify the required parameter 'oneOfStringBuiltInOperation' is set - if ($oneOfStringBuiltInOperation === null || (is_array($oneOfStringBuiltInOperation) && count($oneOfStringBuiltInOperation) === 0)) { + // verify the required parameter 'attributeOrBuiltInOperation' is set + if ($attributeOrBuiltInOperation === null || (is_array($attributeOrBuiltInOperation) && count($attributeOrBuiltInOperation) === 0)) { throw new \InvalidArgumentException( - 'Missing the required parameter $oneOfStringBuiltInOperation when calling partialUpdateObject' + 'Missing the required parameter $attributeOrBuiltInOperation when calling partialUpdateObject' ); } @@ -1605,8 +1605,8 @@ public function partialUpdateObject($indexName, $objectID, $oneOfStringBuiltInOp ); } - if (isset($oneOfStringBuiltInOperation)) { - $httpBody = $oneOfStringBuiltInOperation; + if (isset($attributeOrBuiltInOperation)) { + $httpBody = $attributeOrBuiltInOperation; } return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody); @@ -1991,7 +1991,7 @@ public function search($indexName, $searchParams) /** * Search the dictionary entries. * - * @param string $dictionaryName The dictionary to search in. (required) + * @param array $dictionaryName The dictionary to search in. (required) * @param array $searchDictionaryEntriesParams searchDictionaryEntriesParams (required) * * @return array diff --git a/config/base.tsconfig.json b/config/base.tsconfig.json new file mode 100644 index 0000000000..4d0d503a84 --- /dev/null +++ b/config/base.tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "noImplicitAny": false, + "suppressImplicitAnyIndexErrors": true, + "target": "esnext", + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "strict": true, + "moduleResolution": "node", + "removeComments": true, + "sourceMap": true, + "noLib": false, + "declaration": true, + "lib": ["ESNext"], + "outDir": "dist", + "typeRoots": ["node_modules/@types"], + "types": ["node"], + "resolveJsonModule": true + }, + "exclude": ["node_modules"] +} diff --git a/config/clients.config.json b/config/clients.config.json new file mode 100644 index 0000000000..817a6a11af --- /dev/null +++ b/config/clients.config.json @@ -0,0 +1,19 @@ +{ + "java": { + "folder": "clients/algoliasearch-client-java-2", + "tests": { + "extension": ".test.java", + "outputFolder": "src/test/java/com/algolia" + } + }, + "javascript": { + "folder": "clients/algoliasearch-client-javascript", + "tests": { + "extension": ".test.ts", + "outputFolder": "src" + } + }, + "php": { + "folder": "clients/algoliasearch-client-php" + } +} diff --git a/config/openapitools-java-cts.json b/config/openapitools-java-cts.json new file mode 100644 index 0000000000..7ae7f413b1 --- /dev/null +++ b/config/openapitools-java-cts.json @@ -0,0 +1,9 @@ +{ + "generatorName": "algolia-cts", + "templateDir": "tests/CTS/methods/requests/templates/java", + "outputDir": "tests/output/java", + "artifactId": "java-tests", + "groupId": "com.algolia", + "invokerPackage": "com.algolia", + "inputSpec": "specs/bundled/search.yml" +} diff --git a/config/openapitools-java.json b/config/openapitools-java.json new file mode 100644 index 0000000000..d3537b05b6 --- /dev/null +++ b/config/openapitools-java.json @@ -0,0 +1,21 @@ +{ + "generatorName": "algolia-java", + "templateDir": "templates/java/", + "outputDir": "clients/algoliasearch-client-java-2", + "artifactId": "algoliasearch-client-java-2", + "groupId": "com.algolia", + "apiPackage": "com.algolia.search", + "invokerPackage": "com.algolia", + "modelPackage": "com.algolia.model.search", + "library": "okhttp-gson", + "inputSpec": "specs/bundled/search.yml", + "gitHost": "algolia", + "gitUserId": "algolia", + "gitRepoId": "algoliasearch-client-java-2", + "additionalProperties": { + "sourceFolder": "algoliasearch-core", + "java8": true, + "dateLibrary": "java8", + "packageName": "algoliasearch-client-java-2" + } +} diff --git a/release.config.json b/config/release.config.json similarity index 100% rename from release.config.json rename to config/release.config.json diff --git a/docs/CTS.md b/docs/CTS.md index 3b3023a427..565ff72085 100644 --- a/docs/CTS.md +++ b/docs/CTS.md @@ -44,12 +44,7 @@ The test generation script requires a JSON file name from the `operationId` (e.g "parameters": { "indexName": "testIndex", "searchParam": { - "$objectName": "the name of the object for strongly type language, should be on every 'object' type (can be 'Object' if free-form)", - "query": "the string to search", - "acl": { - "$enumType": "the name of the enum object if marked as enum in the spec", - "value": "the string value of the enum" - } + "query": "the string to search" } }, "request": { @@ -62,8 +57,6 @@ The test generation script requires a JSON file name from the `operationId` (e.g ``` And that's it! If the name of the file matches a real `operationId` in the spec, then a test will be generated. -Don't forget to add `$objectName` and `$enumType` when necessary, otherwise typed language will fail to generate tests. - ## How to add a new language - Create a template in `test/CTS/templates//requests.mustache` that parses an array of tests into the test framework of choice diff --git a/generators/build.gradle b/generators/build.gradle new file mode 100644 index 0000000000..795d70a9c7 --- /dev/null +++ b/generators/build.gradle @@ -0,0 +1,21 @@ +plugins { + id 'java' +} + +group = 'org.openapitools' +version = '1.0.0' +description = 'algolia-java-openapi-generator' +java.sourceCompatibility = JavaVersion.VERSION_1_8 + +repositories { + mavenCentral() +} + +dependencies { + compileOnly 'org.openapitools:openapi-generator:5.4.0' + compileOnly 'org.yaml:snakeyaml:1.19' +} + +tasks.withType(JavaCompile) { + options.encoding = 'UTF-8' +} diff --git a/generators/settings.gradle b/generators/settings.gradle new file mode 100644 index 0000000000..22f1bf52de --- /dev/null +++ b/generators/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'algolia-java-openapi-generator' diff --git a/generators/src/main/java/com/algolia/codegen/AlgoliaJavaGenerator.java b/generators/src/main/java/com/algolia/codegen/AlgoliaJavaGenerator.java new file mode 100644 index 0000000000..406084ae20 --- /dev/null +++ b/generators/src/main/java/com/algolia/codegen/AlgoliaJavaGenerator.java @@ -0,0 +1,173 @@ +package com.algolia.codegen; + +import org.openapitools.codegen.*; +import org.openapitools.codegen.languages.JavaClientCodegen; +import org.openapitools.codegen.utils.ModelUtils; +import org.yaml.snakeyaml.Yaml; + +import java.util.*; +import java.util.Map.Entry; +import java.io.FileInputStream; +import java.net.URL; + +import io.swagger.v3.oas.models.media.Schema; + +@SuppressWarnings("unchecked") +public class AlgoliaJavaGenerator extends JavaClientCodegen { + /** + * Configures a friendly name for the generator. This will be used by the + * generator + * to select the library with the -g flag. + * + * @return the friendly name for the generator + */ + @Override + public String getName() { + return "algolia-java"; + } + + /** + * Inject server info into the client to generate the right URL + */ + private void generateServer(Map client) { + String clientName = (String) client.get("pathPrefix"); + Yaml yaml = new Yaml(); + try { + Map spec = yaml.load(new FileInputStream("specs/" + clientName + "/spec.yml")); + List> servers = (List>) spec.get("servers"); + + boolean hasRegionalHost = false; + boolean fallbackToAliasHost = false; + + boolean isEuHost = false; + boolean isDeHost = false; + String host = ""; + String topLevelDomain = ""; + + for (Map server : servers) { + if (!server.containsKey("url")) { + throw new GenerationException("Invalid server, does not contains 'url'"); + } + + if (!server.containsKey("variables")) { + continue; + } + + Map> variables = (Map>) server.get("variables"); + + if (!variables.containsKey("region") || !variables.get("region").containsKey("enum")) { + continue; + } + ArrayList enums = (ArrayList) variables.get("region").get("enum"); + hasRegionalHost = true; + + URL url = new URL((String) server.get("url")); + + if (!fallbackToAliasHost) { + // Determine if the current URL with `region` also have an alias without + // variables. + fallbackToAliasHost = true; + } + + if (enums.contains("eu")) { + isEuHost = true; + } + + if (enums.contains("de")) { + isDeHost = true; + } + + // This is used for hosts like `insights` that uses `.io` + String[] hostParts = url.getHost().split("\\."); + host = hostParts[0]; + topLevelDomain = hostParts[hostParts.length - 1]; + } + client.put("hasRegionalHost", hasRegionalHost); + client.put("fallbackToAliasHost", fallbackToAliasHost); + client.put("isEuHost", isEuHost); + client.put("isDeHost", isDeHost); + client.put("host", host); + client.put("topLevelDomain", topLevelDomain); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Provides an opportunity to inspect and modify operation data before the code + * is generated. + */ + @Override + public Map postProcessOperationsWithModels(Map objs, List allModels) { + Map results = super.postProcessOperationsWithModels(objs, allModels); + Map client = (Map) results.get("operations"); + + generateServer(client); + + return results; + } + + @Override + public Map postProcessAllModels(Map objs) { + Map models = super.postProcessAllModels(objs); + + for (Object modelContainer : models.values()) { + CodegenModel model = ((Map>>) modelContainer).get("models").get(0) + .get("model"); + if (!model.oneOf.isEmpty()) { + model.vendorExtensions.put("x-is-one-of-interface", true); + } + } + + return models; + } + + @Override + public Map postProcessSupportingFileData(Map objs) { + Map bundle = super.postProcessSupportingFileData(objs); + List> apis = ((Map>>) bundle.get("apiInfo")).get("apis"); + for (Map api : apis) { + List operations = ((Map>) api.get("operations")) + .get("operation"); + + for (CodegenOperation ope : operations) { + ope.returnType = ope.returnType.replace("Map<", "HashMap<").replace("List<", "ArrayList<"); + } + } + return bundle; + } + + /** + * Returns human-friendly help for the generator. Provide the consumer with help + * tips, parameters here + * + * @return A string value for the help message + */ + @Override + public String getHelp() { + return "Generates an algolia-java client library."; + } + + public AlgoliaJavaGenerator() { + super(); + + supportingFiles.add(new SupportingFile("EchoResponse.mustache", + "algoliasearch-core/com/algolia/utils/echo", + "EchoResponse.java")); + + // Prevent all useless file to generate + apiTestTemplateFiles.clear(); + modelTestTemplateFiles.clear(); + apiDocTemplateFiles.clear(); + modelDocTemplateFiles.clear(); + } + + @Override + public String toDefaultValue(Schema schema) { + // Replace the {} from openapi with new Object() + if (ModelUtils.isObjectSchema(schema) && schema.getDefault() != null) { + return "new Object()"; + } + return super.toDefaultValue(schema); + } +} diff --git a/generators/src/main/java/com/algolia/codegen/GenerationException.java b/generators/src/main/java/com/algolia/codegen/GenerationException.java new file mode 100644 index 0000000000..52d34b335c --- /dev/null +++ b/generators/src/main/java/com/algolia/codegen/GenerationException.java @@ -0,0 +1,7 @@ +package com.algolia.codegen; + +public class GenerationException extends Exception { + public GenerationException(String message) { + super(message); + } +} diff --git a/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java b/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java new file mode 100644 index 0000000000..fc2ad5cfc1 --- /dev/null +++ b/generators/src/main/java/com/algolia/codegen/cts/AlgoliaCtsGenerator.java @@ -0,0 +1,172 @@ +package com.algolia.codegen.cts; + +import org.openapitools.codegen.*; + +import java.util.*; +import java.util.Map.Entry; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.google.common.collect.ImmutableMap.Builder; +import com.samskivert.mustache.Mustache.Lambda; + +import java.io.File; +import java.io.IOException; + +import io.swagger.v3.core.util.Json; + +@SuppressWarnings("unchecked") +public class AlgoliaCtsGenerator extends DefaultCodegen { + // cache the models + private final Map models = new HashMap<>(); + + /** + * Configures the type of generator. + * + * @return the CodegenType for this generator + * @see org.openapitools.codegen.CodegenType + */ + @Override + public CodegenType getTag() { + return CodegenType.OTHER; + } + + /** + * Configures a friendly name for the generator. This will be used by the + * generator + * to select the library with the -g flag. + * + * @return the friendly name for the generator + */ + @Override + public String getName() { + return "algolia-cts"; + } + + /** + * Returns human-friendly help for the generator. Provide the consumer with help + * tips, parameters here + * + * @return A string value for the help message + */ + public String getHelp() { + return "Generates the CTS"; + } + + @Override + public Map postProcessAllModels(Map objs) { + Map mod = super.postProcessAllModels(objs); + for (Entry entry : mod.entrySet()) { + List innerModel = ((Map>) entry.getValue()).get("models"); + if (!innerModel.isEmpty()) { + models.put(entry.getKey(), (CodegenModel) ((Map) innerModel.get(0)).get("model")); + } + } + return mod; + } + + public AlgoliaCtsGenerator() { + super(); + supportingFiles + .add(new SupportingFile("requests.mustache", "src/test/java/com/algolia/methods/requests", "search.test.java")); + } + + @Override + protected Builder addMustacheLambdas() { + Builder lambdas = super.addMustacheLambdas(); + + lambdas.put("escapequotes", new EscapeQuotesLambda()); + return lambdas; + } + + @Override + public Map postProcessSupportingFileData(Map objs) { + Map cts = null; + try { + cts = loadCTS(); + + Map operations = buildOperations(objs).get("Search"); + + Map bundle = super.postProcessSupportingFileData(objs); + + // We can put whatever we want in the bundle, and it will be accessible in the + // template + bundle.put("client", "SearchApi"); + + List blocks = new ArrayList<>(); + ParametersWithDataType paramsType = new ParametersWithDataType(models); + + for (Entry entry : cts.entrySet()) { + if (!operations.containsKey(entry.getKey())) { + throw new CTSException("operationId " + entry.getKey() + " does not exist in the spec"); + } + CodegenOperation op = operations.get(entry.getKey()); + + List tests = new ArrayList<>(); + for (int i = 0; i < entry.getValue().length; i++) { + Map test = paramsType.buildJSONForRequest(entry.getValue()[i], op, i); + tests.add(test); + } + Map testObj = new HashMap<>(); + testObj.put("tests", tests); + blocks.add(testObj); + } + bundle.put("blocks", blocks); + + return bundle; + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + return null; + } + + private Map loadCTS() throws JsonParseException, JsonMappingException, IOException { + TreeMap cts = new TreeMap<>(); + File dir = new File("tests/CTS/methods/requests/search"); + for (File f : dir.listFiles()) { + cts.put(f.getName().replace(".json", ""), Json.mapper().readValue(f, Request[].class)); + } + return cts; + } + + // Client -> operationId -> CodegenOperation + private HashMap> buildOperations(Map objs) { + HashMap> result = new HashMap<>(); + List> apis = ((Map>>) objs.get("apiInfo")).get("apis"); + for (Map api : apis) { + String apiName = (String) api.get("baseName"); + List operations = ((Map>) api.get("operations")) + .get("operation"); + + HashMap allOp = new HashMap<>(); + for (CodegenOperation ope : operations) { + allOp.put(ope.operationId, ope); + } + result.put(apiName, allOp); + } + return result; + } + + /** + * override with any special text escaping logic to handle unsafe + * characters so as to avoid code injection + * + * @param input String to be cleaned up + * @return string with unsafe characters removed or escaped + */ + @Override + public String escapeUnsafeCharacters(String input) { + return input; + } + + /** + * Escape single and/or double quote to avoid code injection + * + * @param input String to be cleaned up + * @return string with quotation mark removed or escaped + */ + public String escapeQuotationMark(String input) { + return input.replace("\"", "\\\""); + } +} diff --git a/generators/src/main/java/com/algolia/codegen/cts/CTSException.java b/generators/src/main/java/com/algolia/codegen/cts/CTSException.java new file mode 100644 index 0000000000..ba3765a6ff --- /dev/null +++ b/generators/src/main/java/com/algolia/codegen/cts/CTSException.java @@ -0,0 +1,7 @@ +package com.algolia.codegen.cts; + +public class CTSException extends Exception { + public CTSException(String message) { + super(message); + } +} diff --git a/generators/src/main/java/com/algolia/codegen/cts/EscapeQuotesLambda.java b/generators/src/main/java/com/algolia/codegen/cts/EscapeQuotesLambda.java new file mode 100644 index 0000000000..a66dfa10e8 --- /dev/null +++ b/generators/src/main/java/com/algolia/codegen/cts/EscapeQuotesLambda.java @@ -0,0 +1,15 @@ +package com.algolia.codegen.cts; + +import java.io.IOException; +import java.io.Writer; + +import com.samskivert.mustache.Mustache; +import com.samskivert.mustache.Template; + +public class EscapeQuotesLambda implements Mustache.Lambda { + @Override + public void execute(Template.Fragment fragment, Writer writer) throws IOException { + String text = fragment.execute(); + writer.write(text.replace("\"", "\\\"")); + } +} diff --git a/generators/src/main/java/com/algolia/codegen/cts/ParametersWithDataType.java b/generators/src/main/java/com/algolia/codegen/cts/ParametersWithDataType.java new file mode 100644 index 0000000000..7f5d717511 --- /dev/null +++ b/generators/src/main/java/com/algolia/codegen/cts/ParametersWithDataType.java @@ -0,0 +1,326 @@ +package com.algolia.codegen.cts; + +import java.util.*; +import java.util.Map.Entry; + +import org.openapitools.codegen.CodegenModel; +import org.openapitools.codegen.CodegenOperation; +import org.openapitools.codegen.CodegenParameter; +import org.openapitools.codegen.CodegenProperty; +import org.openapitools.codegen.CodegenResponse; +import org.openapitools.codegen.IJsonSchemaValidationProperties; + +import io.swagger.v3.core.util.Json; + +@SuppressWarnings("unchecked") +public class ParametersWithDataType { + private final Map models; + + public ParametersWithDataType(Map models) { + this.models = models; + } + + public Map buildJSONForRequest(Request req, CodegenOperation ope, int testIndex) + throws CTSException { + Map test = new HashMap<>(); + test.put("method", req.method); + test.put("testName", req.testName == null ? req.method : req.testName); + test.put("testIndex", testIndex); + test.put("request", req.request); + + List parametersWithDataType = new ArrayList<>(); + + // special case if there is only bodyParam which is not an array + if (ope.allParams.size() == 1 && ope.bodyParams.size() == 1 && !ope.bodyParam.isArray) { + parametersWithDataType.add(traverseParams(ope.bodyParam.paramName, req.parameters, ope.bodyParam, "", 0)); + } else { + for (Entry param : req.parameters.entrySet()) { + CodegenParameter specParam = null; + for (CodegenParameter sp : ope.allParams) { + if (sp.paramName.equals(param.getKey())) { + specParam = sp; + break; + } + } + if (specParam == null) { + throw new CTSException("Parameter " + param.getKey() + " not found in the root parameter"); + } + parametersWithDataType.add(traverseParams(param.getKey(), param.getValue(), specParam, "", 0)); + } + } + + test.put("parametersWithDataType", parametersWithDataType); + return test; + } + + private Map traverseParams(String paramName, Object param, IJsonSchemaValidationProperties spec, + String parent, int suffix) + throws CTSException { + String baseType = getTypeName(spec); + if (baseType == null) { + throw new CTSException("Cannot determine type of " + paramName + " (value: " + param + ")"); + } + + boolean isCodegenModel = spec instanceof CodegenModel; + + if (!isCodegenModel) { + // don't overwrite it if it's already a model + // sometimes it's in lowercase for some reason + String lowerBaseType = baseType.substring(0, 1).toLowerCase() + baseType.substring(1); + if (models.containsKey(baseType)) { + // get the real model if possible + spec = models.get(baseType); + } else if (models.containsKey(lowerBaseType)) { + spec = models.get(lowerBaseType); + } + isCodegenModel = spec instanceof CodegenModel; + } + + String finalParamName = paramName; + if (paramName.startsWith("_")) { + finalParamName = paramName.substring(1); + } + + Map testOutput = createDefaultOutput(); + testOutput.put("key", finalParamName); + testOutput.put("parentSuffix", suffix - 1); + testOutput.put("suffix", suffix); + testOutput.put("parent", parent); + testOutput.put("objectName", baseType.substring(0, 1).toUpperCase() + baseType.substring(1)); + + if (spec.getIsArray()) { + handleArray(paramName, param, testOutput, spec, suffix); + } else if (isEnum(spec)) { + handleEnum(param, testOutput); + } else if (spec.getIsModel() || isCodegenModel) { + // recursive object + handleModel(paramName, param, testOutput, spec, baseType, parent, suffix); + } else if (baseType.equals("Object")) { + // not var, no item, pure free form + handleObject(paramName, param, testOutput, spec, suffix); + } else if (spec.getIsMap()) { + // free key but only one type + handleMap(paramName, param, testOutput, spec, suffix); + } else { + handlePrimitive(param, testOutput); + } + return testOutput; + } + + private Map createDefaultOutput() { + Map testOutput = new HashMap<>(); + + // we need to set all types to false otherwise mustache will read the one from + // the parent context and run into a infinite loop + testOutput.put("isObject", false); + testOutput.put("isArray", false); + testOutput.put("isFreeFormObject", false); + testOutput.put("isString", false); + testOutput.put("isInteger", false); + testOutput.put("isDouble", false); + testOutput.put("isBoolean", false); + testOutput.put("isEnum", false); + + return testOutput; + } + + private void handleArray(String paramName, Object param, Map testOutput, + IJsonSchemaValidationProperties spec, int suffix) throws CTSException { + List items = (List) param; + + List values = new ArrayList<>(); + for (int i = 0; i < items.size(); i++) { + values.add(traverseParams(paramName + "_" + i, items.get(i), spec.getItems(), paramName, suffix + 1)); + } + + testOutput.put("isArray", true); + testOutput.put("value", values); + } + + private void handleEnum(Object param, Map testOutput) { + testOutput.put("isEnum", true); + testOutput.put("value", param); + } + + private void handleModel(String paramName, Object param, Map testOutput, + IJsonSchemaValidationProperties spec, String baseType, String parent, int suffix) throws CTSException { + assert (spec.getHasVars()); + assert (spec.getItems() == null); + + if (spec instanceof CodegenModel && ((CodegenModel) spec).oneOf.size() > 0) { + // find a discriminator to handle oneOf + CodegenModel model = (CodegenModel) spec; + IJsonSchemaValidationProperties match = findMatchingOneOf(param, model); + testOutput.clear(); + testOutput.putAll(traverseParams(paramName, param, match, parent, suffix)); + testOutput.put("oneOfModel", baseType); + return; + } + + Map vars = (Map) param; + List values = new ArrayList<>(); + for (Entry entry : vars.entrySet()) { + IJsonSchemaValidationProperties varSpec = null; + for (CodegenProperty vs : spec.getVars()) { + if (vs.baseName.equals(entry.getKey())) { + varSpec = vs; + break; + } + } + if (varSpec == null) { + throw new CTSException("Parameter " + entry.getKey() + " not found in " + paramName + + ". You might have a type conflict in the spec for " + baseType); + } + + values.add(traverseParams(entry.getKey(), entry.getValue(), varSpec, paramName, suffix + 1)); + } + testOutput.put("isObject", true); + testOutput.put("value", values); + } + + private void handleObject(String paramName, Object param, Map testOutput, + IJsonSchemaValidationProperties spec, int suffix) throws CTSException { + assert (!spec.getHasVars()); + assert (spec.getItems() == null); + + Map vars = (Map) param; + + List values = new ArrayList<>(); + for (Entry entry : vars.entrySet()) { + CodegenParameter objSpec = new CodegenParameter(); + objSpec.dataType = inferDataType(entry.getValue(), objSpec, null); + values.add(traverseParams(entry.getKey(), entry.getValue(), objSpec, paramName, suffix + 1)); + } + + testOutput.put("isFreeFormObject", true); + testOutput.put("value", values); + } + + private void handleMap(String paramName, Object param, Map testOutput, + IJsonSchemaValidationProperties spec, int suffix) throws CTSException { + assert (!spec.getHasVars()); + assert (spec.getItems() != null); + + Map vars = (Map) param; + + List values = new ArrayList<>(); + for (Entry entry : vars.entrySet()) { + values.add(traverseParams(entry.getKey(), entry.getValue(), spec.getItems(), paramName, suffix + 1)); + } + + testOutput.put("isFreeFormObject", true); + testOutput.put("value", values); + } + + private void handlePrimitive(Object param, Map testOutput) throws CTSException { + inferDataType(param, null, testOutput); + testOutput.put("value", param); + } + + private String getTypeName(IJsonSchemaValidationProperties param) { + if (param instanceof CodegenParameter) { + return ((CodegenParameter) param).dataType; + } + if (param instanceof CodegenProperty) { + return ((CodegenProperty) param).dataType; + } + if (param instanceof CodegenModel) { + return ((CodegenModel) param).classname; + } + if (param instanceof CodegenResponse) { + return ((CodegenResponse) param).dataType; + } + return null; + } + + private boolean isEnum(IJsonSchemaValidationProperties param) { + if (param instanceof CodegenParameter) { + return ((CodegenParameter) param).isEnum; + } + if (param instanceof CodegenProperty) { + return ((CodegenProperty) param).isEnum; + } + if (param instanceof CodegenModel) { + return ((CodegenModel) param).isEnum; + } + return false; + } + + private String inferDataType(Object param, CodegenParameter spec, Map output) throws CTSException { + switch (param.getClass().getSimpleName()) { + case "String": + if (spec != null) + spec.setIsString(true); + if (output != null) + output.put("isString", true); + return "String"; + case "Integer": + if (spec != null) + spec.setIsNumber(true); + if (output != null) + output.put("isInteger", true); + return "Integer"; + case "Double": + if (spec != null) + spec.setIsNumber(true); + if (output != null) + output.put("isDouble", true); + return "Double"; + case "Boolean": + if (spec != null) + spec.setIsBoolean(true); + if (output != null) + output.put("isBoolean", true); + return "Boolean"; + default: + throw new CTSException("Unknown type: " + param.getClass().getSimpleName()); + } + } + + private IJsonSchemaValidationProperties findMatchingOneOf(Object param, CodegenModel model) throws CTSException { + if (param instanceof Map) { + // for object, check which has the most of property in common + int maxCount = 0; + CodegenModel bestOneOf = model.interfaceModels.get(0); + for (CodegenModel oneOf : model.interfaceModels) { + if (oneOf.vars.size() == 0) { + continue; + } + + Map map = (Map) param; + int commonCount = 0; + for (String prop : map.keySet()) { + for (CodegenProperty propOneOf : oneOf.vars) { + if (prop.equals(propOneOf.name)) { + commonCount++; + } + } + } + if (commonCount > maxCount) { + maxCount = commonCount; + bestOneOf = oneOf; + } + } + return bestOneOf; + } + if (param instanceof List) { + // no idea for list + return null; + } + + CodegenParameter maybeMatch = new CodegenParameter(); + String paramType = inferDataType(param, maybeMatch, null); + maybeMatch.dataType = paramType; + + for (String oneOfName : model.oneOf) { + if (oneOfName.equals(paramType)) { + return maybeMatch; + } + } + for (CodegenModel oneOf : model.interfaceModels) { + if (oneOf.dataType.equals(paramType)) + return oneOf; + } + return null; + } +} diff --git a/generators/src/main/java/com/algolia/codegen/cts/Request.java b/generators/src/main/java/com/algolia/codegen/cts/Request.java new file mode 100644 index 0000000000..bd9433949b --- /dev/null +++ b/generators/src/main/java/com/algolia/codegen/cts/Request.java @@ -0,0 +1,67 @@ +package com.algolia.codegen.cts; + +import java.io.IOException; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonRawValue; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.TreeNode; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +public class Request { + public String testName; + public String method; + public Map parameters; + public RequestProp request; + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Request {\n"); + sb.append(" testName: ").append(testName).append("\n"); + sb.append(" method: ").append(method).append("\n"); + sb.append(" parameters: ").append(parameters).append("\n"); + sb.append(" request: ").append(request).append("\n"); + sb.append("}"); + return sb.toString(); + } +} + +class RequestProp { + public String path; + public String method; + + @JsonDeserialize(using = RawDeserializer.class) + public Object data; + + @JsonDeserialize(using = RawDeserializer.class) + public Object searchParams; + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RequestProp {\n"); + sb.append(" path: ").append(path).append("\n"); + sb.append(" method: ").append(method).append("\n"); + sb.append(" data: ").append(data).append("\n"); + sb.append(" searchParams: ").append(searchParams).append("\n"); + sb.append("}"); + return sb.toString(); + } +} + +// Output json to raw string with quotes +class RawDeserializer extends JsonDeserializer { + + @Override + public String deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + + TreeNode tree = jp.getCodec().readTree(jp); + return tree.toString(); + } +} diff --git a/generators/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig b/generators/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig new file mode 100644 index 0000000000..b7d2d08d16 --- /dev/null +++ b/generators/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig @@ -0,0 +1,2 @@ +com.algolia.codegen.AlgoliaJavaGenerator +com.algolia.codegen.cts.AlgoliaCtsGenerator diff --git a/gradle/gradle/wrapper/gradle-wrapper.properties b/gradle/gradle/wrapper/gradle-wrapper.properties index 2e6e5897b5..41dfb87909 100644 --- a/gradle/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/playground/java/src/main/java/com/algolia/playground/App.java b/playground/java/src/main/java/com/algolia/playground/App.java index 98baf5765f..071830147f 100644 --- a/playground/java/src/main/java/com/algolia/playground/App.java +++ b/playground/java/src/main/java/com/algolia/playground/App.java @@ -3,6 +3,7 @@ import com.algolia.model.search.*; import com.algolia.search.SearchApi; import com.algolia.ApiException; +import com.algolia.utils.echo.*; import io.github.cdimascio.dotenv.Dotenv; @@ -12,10 +13,11 @@ public static void main(String[] args) { SearchApi client = new SearchApi(dotenv.get("ALGOLIA_APPLICATION_ID"), dotenv.get("ALGOLIA_SEARCH_KEY")); String indexName = dotenv.get("SEARCH_INDEX"); - SearchParams params = new SearchParams(); + SearchParamsObject params = new SearchParamsObject(); + params.setAroundRadius(AroundRadius.of(5)); params.setQuery(dotenv.get("SEARCH_QUERY")); try { - SearchResponse result = client.search(indexName, params); + SearchResponse result = client.search(indexName, SearchParams.of(params)); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling SearchApi#search"); diff --git a/playground/javascript/browser/tsconfig.json b/playground/javascript/browser/tsconfig.json index 0ab41dfc98..54152b47cb 100644 --- a/playground/javascript/browser/tsconfig.json +++ b/playground/javascript/browser/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../../base.tsconfig.json", + "extends": "../../../config/base.tsconfig.json", "compilerOptions": { "outDir": "dist", "lib": ["dom"] diff --git a/playground/javascript/node/tsconfig.json b/playground/javascript/node/tsconfig.json index 6170db0681..ff404088c6 100644 --- a/playground/javascript/node/tsconfig.json +++ b/playground/javascript/node/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../../base.tsconfig.json", + "extends": "../../../config/base.tsconfig.json", "compilerOptions": { "outDir": "dist" }, diff --git a/scripts/common.ts b/scripts/common.ts index 41dcf7643d..04cc19c0b4 100644 --- a/scripts/common.ts +++ b/scripts/common.ts @@ -15,7 +15,14 @@ export const ROOT_DIR = path.resolve(process.cwd(), '..'); export const GENERATORS = Object.fromEntries( Object.entries(openapitools['generator-cli'].generators).map(([key, gen]) => { - return [key, { ...gen, ...splitGeneratorKey(key) }]; + return [ + key, + { + ...gen, + output: gen.output.replace('#{cwd}/', ''), + ...splitGeneratorKey(key), + }, + ]; }) ); diff --git a/scripts/cts/generate.ts b/scripts/cts/generate.ts index e2b416835c..f6200e7e15 100644 --- a/scripts/cts/generate.ts +++ b/scripts/cts/generate.ts @@ -1,4 +1,4 @@ -import { toAbsolutePath } from '../common'; +import { run, toAbsolutePath } from '../common'; import { getTestOutputFolder } from '../config'; import { formatter } from '../formatter'; import { createSpinner } from '../oraLog'; @@ -14,10 +14,19 @@ async function ctsGenerate( createSpinner(`generating CTS for ${generator.key}`, verbose).start().info(); switch (generator.language) { case 'javascript': - case 'java': await generateRequestsTests(generator, verbose); await generateClientTests(generator, verbose); break; + case 'java': + // eslint-disable-next-line no-warning-comments + // TODO: We can remove this once https://github.com/OpenAPITools/openapi-generator-cli/issues/439 is fixed, + // and just call it with `yarn openapi-generator-cli --custom-generator=generators/build/libs/algolia-java-openapi-generator-1.0.0.jar` + await run( + `./gradle/gradlew --no-daemon -p generators assemble && \ + java -cp /tmp/openapi-generator-cli.jar:generators/build/libs/algolia-java-openapi-generator-1.0.0.jar -ea org.openapitools.codegen.OpenAPIGenerator generate -c config/openapitools-java-cts.json`, + { verbose } + ); + break; default: } } diff --git a/scripts/generate.ts b/scripts/generate.ts index 5a6d5a594c..fb8aa9c890 100644 --- a/scripts/generate.ts +++ b/scripts/generate.ts @@ -10,8 +10,7 @@ async function preGen( { language, client, key, output }: Generator, verbose?: boolean ): Promise { - const folder = output.replace('#{cwd}/', ''); - await runIfExists(`./scripts/pre-gen/${language}.sh`, `${folder} ${key}`, { + await runIfExists(`./scripts/pre-gen/${language}.sh`, `${output} ${key}`, { verbose, }); @@ -19,9 +18,19 @@ async function preGen( } async function generateClient( - { key }: Generator, + { language, key }: Generator, verbose?: boolean ): Promise { + if (language === 'java') { + // eslint-disable-next-line no-warning-comments + // TODO: We can remove this once https://github.com/OpenAPITools/openapi-generator-cli/issues/439 is fixed + await run( + `./gradle/gradlew --no-daemon -p generators assemble && \ + java -cp /tmp/openapi-generator-cli.jar:generators/build/libs/algolia-java-openapi-generator-1.0.0.jar -ea org.openapitools.codegen.OpenAPIGenerator generate -c config/openapitools-java.json`, + { verbose } + ); + return; + } await run(`yarn openapi-generator-cli generate --generator-key ${key}`, { verbose, }); @@ -31,8 +40,7 @@ async function postGen( { language, key, output }: Generator, verbose?: boolean ): Promise { - const folder = output.replace('#{cwd}/', ''); - await runIfExists(`./scripts/post-gen/${language}.sh`, `${folder} ${key}`, { + await runIfExists(`./scripts/post-gen/${language}.sh`, `${output} ${key}`, { verbose, }); } @@ -56,7 +64,7 @@ export async function generate( spinner.text = `post-gen ${gen.key}`; await postGen(gen, verbose); - if (gen.language === 'javascript' && CI) { + if (CI && gen.language === 'javascript') { // because the CI is parallelized, run the formatter for each client await formatter(gen.language, gen.output, verbose); } @@ -66,9 +74,11 @@ export async function generate( const langs = [...new Set(generators.map((gen) => gen.language))]; for (const lang of langs) { - if (!CI || lang !== 'javascript') { + if (!(CI && lang === 'javascript')) { await formatter(lang, getLanguageFolder(lang), verbose); } + + // build common packages if (lang === 'javascript') { const spinner = createSpinner( 'cleaning JavaScript client utils', diff --git a/scripts/post-gen/java.sh b/scripts/post-gen/java.sh deleted file mode 100755 index 49a5bfbe21..0000000000 --- a/scripts/post-gen/java.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -# Break on non-zero code -set -e - -DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" -# Move to the root (easier to locate other scripts) -cd ${DIR}/../.. - -FOLDER=$1 - -# Restore the oneOf spec -mv ./specs/search/paths/search/search.yml.bak ./specs/search/paths/search/search.yml -mv ./specs/search/paths/objects/deleteBy.yml.bak ./specs/search/paths/objects/deleteBy.yml -mv ./specs/search/paths/objects/partialUpdate.yml.bak ./specs/search/paths/objects/partialUpdate.yml - -# Replace {} (OpenAPI default) with new Object -find "$FOLDER" -type f -name "*.java" | xargs sed -i -e 's~= {}~= new Object()~g' - -# Create a special class for the OneOf integer string (not complete yet, juste here for compilation) -echo "package com.algolia.model;public class OneOfintegerstring {}" > $FOLDER/algoliasearch-core/com/algolia/model/search/OneOfintegerstring.java -echo 'package com.algolia.model;import com.google.gson.annotations.SerializedName;public class OneOfstringbuiltInOperation { @SerializedName("_operation") private String _operation; @SerializedName("value") private String value;public void set_operation(String op){_operation = op;} public void setValue(String value) {this.value=value;} }' > $FOLDER/algoliasearch-core/com/algolia/model/search/OneOfstringbuiltInOperation.java - -# Generate types for the EchoRequester, to be able to keep the correct response type on the API method. - -# Extract the normal response to extend it -responses=($(grep -o 'public .*ApiCallback<.*>' $FOLDER/algoliasearch-core/com/algolia/**/*Api.java | sed 's/public.*ApiCallback$//; s/ //; s/^Map $FOLDER/algoliasearch-core/com/algolia/utils/echo/EchoResponse.java diff --git a/scripts/pre-gen/java.sh b/scripts/pre-gen/java.sh deleted file mode 100755 index 2c5fb11e59..0000000000 --- a/scripts/pre-gen/java.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -# Break on non-zero code -set -e - -DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" -# Move to the root (easier to locate other scripts) -cd ${DIR}/../.. - -# Remove the oneOf in the spec until it's supported (https://github.com/OpenAPITools/openapi-generator/issues/10880). - -# Remove the oneOf and only keep the last $ref -perl -0777 -i.bak -pe "s/oneOf[\s\S]*- \$ref(?!.*- \$ref)//g" ./specs/search/paths/search/search.yml -perl -0777 -i.bak -pe "s/oneOf[\s\S]*- \$ref(?!.*- \$ref)//g" ./specs/search/paths/objects/deleteBy.yml -perl -0777 -i.bak -pe "s/oneOf[\s\S]*- \$ref(?!.*- \$ref)//g" ./specs/search/paths/objects/partialUpdate.yml diff --git a/scripts/release/common.ts b/scripts/release/common.ts index 61d154dcf0..5f97b2839d 100644 --- a/scripts/release/common.ts +++ b/scripts/release/common.ts @@ -1,4 +1,4 @@ -import config from '../../release.config.json'; +import config from '../../config/release.config.json'; export const RELEASED_TAG = config.releasedTag; export const MAIN_BRANCH = config.mainBranch; diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json index ab90a217cc..eacb895f56 100644 --- a/scripts/tsconfig.json +++ b/scripts/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../base.tsconfig.json", + "extends": "../config/base.tsconfig.json", "compilerOptions": { "typeRoots": ["../node_modules/@types"], "types": ["node", "jest"], diff --git a/specs/bundled/analytics.yml b/specs/bundled/analytics.yml index a40ec0ed0f..1e7fbe5ae3 100644 --- a/specs/bundled/analytics.yml +++ b/specs/bundled/analytics.yml @@ -118,7 +118,7 @@ components: type: integer description: Number of hits that the search query matched. example: 20 - getTopSearchesResponseSimple: + topSearchesResponse: type: object additionalProperties: false required: @@ -161,7 +161,7 @@ components: conversionCount: type: integer description: The number of converted clicks. - getTopSearchesResponseWithAnalytics: + topSearchesResponseWithAnalytics: type: object additionalProperties: false required: @@ -204,8 +204,8 @@ components: $ref: '#/components/schemas/nbHits' getTopSearchesResponse: oneOf: - - $ref: '#/components/schemas/getTopSearchesResponseSimple' - - $ref: '#/components/schemas/getTopSearchesResponseWithAnalytics' + - $ref: '#/components/schemas/topSearchesResponse' + - $ref: '#/components/schemas/topSearchesResponseWithAnalytics' ErrorBase: description: Error. type: object @@ -220,7 +220,7 @@ components: hit: description: The hit. type: string - getTopHitsResponseSimple: + topHitsResponse: type: object additionalProperties: false required: @@ -240,7 +240,7 @@ components: $ref: '#/components/schemas/hit' count: $ref: '#/components/schemas/count' - getTopHitsResponseWithAnalytics: + topHitsResponseWithAnalytics: type: object additionalProperties: false required: @@ -277,8 +277,8 @@ components: $ref: '#/components/schemas/conversionCount' getTopHitsResponse: oneOf: - - $ref: '#/components/schemas/getTopHitsResponseSimple' - - $ref: '#/components/schemas/getTopHitsResponseWithAnalytics' + - $ref: '#/components/schemas/topHitsResponse' + - $ref: '#/components/schemas/topHitsResponseWithAnalytics' attribute: description: The attribute. type: string diff --git a/scripts/post-gen/javaEchoResponse.mustache b/templates/java/EchoResponse.mustache similarity index 50% rename from scripts/post-gen/javaEchoResponse.mustache rename to templates/java/EchoResponse.mustache index 1d9694e6c5..6fc98aaf00 100644 --- a/scripts/post-gen/javaEchoResponse.mustache +++ b/templates/java/EchoResponse.mustache @@ -1,7 +1,7 @@ package com.algolia.utils.echo; import com.algolia.Pair; -import com.algolia.model.*; +import com.algolia.model.search.*; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -35,29 +35,33 @@ public class EchoResponse { return params; } - {{#responses}} - public static class {{{className}}} extends {{{superClass}}} implements EchoResponseInterface { - private Request request; + {{#apiInfo}}{{#apis}} + public static class {{baseName}}Echo { + {{#operations}}{{#operation}} + public static class {{#lambda.titlecase}}{{{operationId}}}{{/lambda.titlecase}} extends {{{returnType}}} implements EchoResponseInterface { + private Request request; - public {{{className}}}(Request request) { - this.request = request; - } + public {{#lambda.titlecase}}{{{operationId}}}{{/lambda.titlecase}}(Request request) { + this.request = request; + } - public String getPath() { - return request.url().encodedPath(); - } + public String getPath() { + return request.url().encodedPath(); + } - public String getMethod() { - return request.method(); - } + public String getMethod() { + return request.method(); + } - public String getBody() { - return parseRequestBody(request); - } + public String getBody() { + return parseRequestBody(request); + } - public List getQueryParams() { - return buildQueryParams(request); + public List getQueryParams() { + return buildQueryParams(request); + } } + {{/operation}}{{/operations}} } - {{/responses}} + {{/apis}}{{/apiInfo}} } diff --git a/templates/java/JSON.mustache b/templates/java/JSON.mustache index 00b5bd0d14..c412ab1b51 100644 --- a/templates/java/JSON.mustache +++ b/templates/java/JSON.mustache @@ -51,20 +51,18 @@ import io.gsonfire.GsonFireBuilder; import okio.ByteString; public class JSON { - private Gson gson; - private boolean isLenientOnJson = false; - private DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); - private SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); - {{#joda}} - private DateTimeTypeAdapter dateTimeTypeAdapter = new DateTimeTypeAdapter(); - private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); - {{/joda}} - {{#jsr310}} - private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); - private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); - {{/jsr310}} - private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); - private RetainFieldMapFactory mapAdapter = new RetainFieldMapFactory(); + private static Gson gson; + private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); + private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); + private static RetainFieldMapFactory mapAdapter = new RetainFieldMapFactory(); + + static { + gson = createGson() + .registerTypeAdapter(Date.class, dateTypeAdapter) + .registerTypeAdapter(byte[].class, byteArrayAdapter) + .registerTypeAdapterFactory(mapAdapter) + .create(); + } public static GsonBuilder createGson() { GsonFireBuilder fireBuilder = new GsonFireBuilder() @@ -85,30 +83,8 @@ public class JSON { }) {{/discriminator}} {{/model}} - {{/models}} - ; - GsonBuilder builder = fireBuilder.createGsonBuilder(); - {{#disableHtmlEscaping}} - builder.disableHtmlEscaping(); - {{/disableHtmlEscaping}} - return builder; - } - - public JSON() { - gson = createGson() - .registerTypeAdapter(Date.class, dateTypeAdapter) - .registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter) - {{#joda}} - .registerTypeAdapter(DateTime.class, dateTimeTypeAdapter) - .registerTypeAdapter(LocalDate.class, localDateTypeAdapter) - {{/joda}} - {{#jsr310}} - .registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter) - .registerTypeAdapter(LocalDate.class, localDateTypeAdapter) - {{/jsr310}} - .registerTypeAdapter(byte[].class, byteArrayAdapter) - .registerTypeAdapterFactory(mapAdapter) - .create(); + {{/models}}; + return fireBuilder.createGsonBuilder(); } /** @@ -116,7 +92,7 @@ public class JSON { * * @return Gson */ - public Gson getGson() { + public static Gson getGson() { return gson; } @@ -126,14 +102,8 @@ public class JSON { * @param gson Gson * @return JSON */ - public JSON setGson(Gson gson) { - this.gson = gson; - return this; - } - - public JSON setLenientOnJson(boolean lenientOnJson) { - isLenientOnJson = lenientOnJson; - return this; + public static void setGson(Gson gon) { + gson = gon; } /** @@ -142,7 +112,7 @@ public class JSON { * @param obj Object * @return String representation of the JSON */ - public String serialize(Object obj) { + public static String serialize(Object obj) { return gson.toJson(obj); } @@ -154,20 +124,13 @@ public class JSON { * @param returnType The type to deserialize into * @return The deserialized Java object */ - public T deserialize(String body, Type returnType) { + public static T deserialize(String body, Type returnType) { try { - if (isLenientOnJson) { - JsonReader jsonReader = new JsonReader(new StringReader(body)); - // see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean) - jsonReader.setLenient(true); - return gson.fromJson(jsonReader, returnType); - } else { - return gson.fromJson(body, returnType); - } + return gson.fromJson(body, returnType); } catch (JsonParseException e) { // Fallback processing when failed to parse JSON form response body: // return the response body string directly for the String return type; - if (returnType.equals(String.class)) { + if (returnType != null && returnType.equals(String.class)) { return (T) body; } else { throw (e); @@ -175,347 +138,94 @@ public class JSON { } } - /** - * Gson TypeAdapter for Byte Array type - */ - public class ByteArrayAdapter extends TypeAdapter { - - @Override - public void write(JsonWriter out, byte[] value) throws IOException { - if (value == null) { - out.nullValue(); - } else { - out.value(ByteString.of(value).base64()); - } - } - - @Override - public byte[] read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String bytesAsBase64 = in.nextString(); - ByteString byteString = ByteString.decodeBase64(bytesAsBase64); - return byteString.toByteArray(); - } - } - } - - {{#joda}} - /** - * Gson TypeAdapter for Joda DateTime type - */ - public static class DateTimeTypeAdapter extends TypeAdapter { - - private DateTimeFormatter formatter; - - public DateTimeTypeAdapter() { - this(new DateTimeFormatterBuilder() - .append(ISODateTimeFormat.dateTime().getPrinter(), ISODateTimeFormat.dateOptionalTimeParser().getParser()) - .toFormatter()); - } - - public DateTimeTypeAdapter(DateTimeFormatter formatter) { - this.formatter = formatter; - } - - public void setFormat(DateTimeFormatter dateFormat) { - this.formatter = dateFormat; - } - - @Override - public void write(JsonWriter out, DateTime date) throws IOException { - if (date == null) { - out.nullValue(); - } else { - out.value(formatter.print(date)); - } - } - - @Override - public DateTime read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - return formatter.parseDateTime(date); - } - } - } - - /** - * Gson TypeAdapter for Joda LocalDate type - */ - public class LocalDateTypeAdapter extends TypeAdapter { - - private DateTimeFormatter formatter; - - public LocalDateTypeAdapter() { - this(ISODateTimeFormat.date()); - } - - public LocalDateTypeAdapter(DateTimeFormatter formatter) { - this.formatter = formatter; - } - - public void setFormat(DateTimeFormatter dateFormat) { - this.formatter = dateFormat; - } - - @Override - public void write(JsonWriter out, LocalDate date) throws IOException { - if (date == null) { - out.nullValue(); - } else { - out.value(formatter.print(date)); - } - } - - @Override - public LocalDate read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - return formatter.parseLocalDate(date); - } - } + public static void setDateFormat(DateFormat dateFormat) { + dateTypeAdapter.setFormat(dateFormat); } +} - public JSON setDateTimeFormat(DateTimeFormatter dateFormat) { - dateTimeTypeAdapter.setFormat(dateFormat); - return this; - } +/** +* Gson TypeAdapter for Byte Array type +*/ +class ByteArrayAdapter extends TypeAdapter { - public JSON setLocalDateFormat(DateTimeFormatter dateFormat) { - localDateTypeAdapter.setFormat(dateFormat); - return this; +@Override +public void write(JsonWriter out, byte[] value) throws IOException { + if (value == null) { + out.nullValue(); + } else { + out.value(ByteString.of(value).base64()); } +} - {{/joda}} - {{#jsr310}} - /** - * Gson TypeAdapter for JSR310 OffsetDateTime type - */ - public static class OffsetDateTimeTypeAdapter extends TypeAdapter { - - private DateTimeFormatter formatter; - - public OffsetDateTimeTypeAdapter() { - this(DateTimeFormatter.ISO_OFFSET_DATE_TIME); - } - - public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { - this.formatter = formatter; - } - - public void setFormat(DateTimeFormatter dateFormat) { - this.formatter = dateFormat; - } - - @Override - public void write(JsonWriter out, OffsetDateTime date) throws IOException { - if (date == null) { - out.nullValue(); - } else { - out.value(formatter.format(date)); - } - } - - @Override - public OffsetDateTime read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - if (date.endsWith("+0000")) { - date = date.substring(0, date.length()-5) + "Z"; - } - return OffsetDateTime.parse(date, formatter); - } - } +@Override +public byte[] read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String bytesAsBase64 = in.nextString(); + ByteString byteString = ByteString.decodeBase64(bytesAsBase64); + return byteString.toByteArray(); } +} +} - /** - * Gson TypeAdapter for JSR310 LocalDate type - */ - public class LocalDateTypeAdapter extends TypeAdapter { - - private DateTimeFormatter formatter; +/** +* Gson TypeAdapter for java.util.Date type +* If the dateFormat is null, ISO8601Utils will be used. +*/ +class DateTypeAdapter extends TypeAdapter { - public LocalDateTypeAdapter() { - this(DateTimeFormatter.ISO_LOCAL_DATE); - } +private DateFormat dateFormat; - public LocalDateTypeAdapter(DateTimeFormatter formatter) { - this.formatter = formatter; - } +public DateTypeAdapter() {} - public void setFormat(DateTimeFormatter dateFormat) { - this.formatter = dateFormat; - } +public DateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; +} - @Override - public void write(JsonWriter out, LocalDate date) throws IOException { - if (date == null) { - out.nullValue(); - } else { - out.value(formatter.format(date)); - } - } +public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; +} - @Override - public LocalDate read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - return LocalDate.parse(date, formatter); - } +@Override +public void write(JsonWriter out, Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = ISO8601Utils.format(date, true); } + out.value(value); } +} - public JSON setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { - offsetDateTimeTypeAdapter.setFormat(dateFormat); - return this; - } - - public JSON setLocalDateFormat(DateTimeFormatter dateFormat) { - localDateTypeAdapter.setFormat(dateFormat); - return this; - } - - {{/jsr310}} - /** - * Gson TypeAdapter for java.sql.Date type - * If the dateFormat is null, a simple "yyyy-MM-dd" format will be used - * (more efficient than SimpleDateFormat). - */ - public static class SqlDateTypeAdapter extends TypeAdapter { - - private DateFormat dateFormat; - - public SqlDateTypeAdapter() {} - - public SqlDateTypeAdapter(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } - - public void setFormat(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } - - @Override - public void write(JsonWriter out, java.sql.Date date) throws IOException { - if (date == null) { - out.nullValue(); - } else { - String value; - if (dateFormat != null) { - value = dateFormat.format(date); - } else { - value = date.toString(); - } - out.value(value); - } - } - - @Override - public java.sql.Date read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - try { - if (dateFormat != null) { - return new java.sql.Date(dateFormat.parse(date).getTime()); - } - return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); - } catch (ParseException e) { - throw new JsonParseException(e); +@Override +public Date read(JsonReader in) throws IOException { + try { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return dateFormat.parse(date); } - } - } - } - - /** - * Gson TypeAdapter for java.util.Date type - * If the dateFormat is null, ISO8601Utils will be used. - */ - public static class DateTypeAdapter extends TypeAdapter { - - private DateFormat dateFormat; - - public DateTypeAdapter() {} - - public DateTypeAdapter(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } - - public void setFormat(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } - - @Override - public void write(JsonWriter out, Date date) throws IOException { - if (date == null) { - out.nullValue(); - } else { - String value; - if (dateFormat != null) { - value = dateFormat.format(date); - } else { - value = ISO8601Utils.format(date, true); + return ISO8601Utils.parse(date, new ParsePosition(0)); + } catch (ParseException e) { + throw new JsonParseException(e); } - out.value(value); - } - } - - @Override - public Date read(JsonReader in) throws IOException { - try { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - try { - if (dateFormat != null) { - return dateFormat.parse(date); - } - return ISO8601Utils.parse(date, new ParsePosition(0)); - } catch (ParseException e) { - throw new JsonParseException(e); - } - } - } catch (IllegalArgumentException e) { - throw new JsonParseException(e); - } } + } catch (IllegalArgumentException e) { + throw new JsonParseException(e); } - - public JSON setDateFormat(DateFormat dateFormat) { - dateTypeAdapter.setFormat(dateFormat); - return this; - } - - public JSON setSqlDateFormat(DateFormat dateFormat) { - sqlDateTypeAdapter.setFormat(dateFormat); - return this; - } +} } // https://stackoverflow.com/questions/21458468/gson-wont-properly-serialise-a-class-that-extends-hashmap diff --git a/templates/java/libraries/okhttp-gson/ApiClient.mustache b/templates/java/libraries/okhttp-gson/ApiClient.mustache index 991a5644dd..261530c058 100644 --- a/templates/java/libraries/okhttp-gson/ApiClient.mustache +++ b/templates/java/libraries/okhttp-gson/ApiClient.mustache @@ -32,15 +32,12 @@ public class ApiClient { private DateFormat dateFormat; - private JSON json; - private Requester requester; /* * Constructor for ApiClient with custom Requester */ public ApiClient(String appId, String apiKey, Requester requester) { - json = new JSON(); setUserAgent("{{{httpUserAgent}}}{{^httpUserAgent}}OpenAPI-Generator/{{{artifactVersion}}}/java{{/httpUserAgent}}"); this.basePath = "https://" + appId + "-1.algolianet.com"; @@ -49,40 +46,10 @@ public class ApiClient { this.requester = requester; } - /** - * Get JSON - * - * @return JSON object - */ - public JSON getJSON() { - return json; - } - - /** - * Set JSON - * - * @param json JSON object - * @return Api client - */ - public ApiClient setJSON(JSON json) { - this.json = json; - return this; - } - public DateFormat getDateFormat() { return dateFormat; } - public ApiClient setDateFormat(DateFormat dateFormat) { - this.json.setDateFormat(dateFormat); - return this; - } - - public ApiClient setLenientOnJson(boolean lenientOnJson) { - this.json.setLenientOnJson(lenientOnJson); - return this; - } - /** * Set the User-Agent header's value (by adding to the default header map). * @@ -203,7 +170,7 @@ public class ApiClient { return ""; } else if (param instanceof Date {{#joda}}|| param instanceof DateTime || param instanceof LocalDate{{/joda}}{{#jsr310}}|| param instanceof OffsetDateTime || param instanceof LocalDate{{/jsr310}}) { //Serialize to json string and remove the " enclosing characters - String jsonStr = json.serialize(param); + String jsonStr = JSON.serialize(param); return jsonStr.substring(1, jsonStr.length() - 1); } else if (param instanceof Collection) { StringBuilder b = new StringBuilder(); @@ -399,7 +366,7 @@ public class ApiClient { contentType = "application/json"; } if (isJsonMime(contentType)) { - return json.deserialize(respBody, returnType); + return JSON.deserialize(respBody, returnType); } else if (returnType.equals(String.class)) { // Expecting string, return the raw response body. return (T) respBody; @@ -428,7 +395,7 @@ public class ApiClient { } else if (isJsonMime(contentType)) { String content; if (obj != null) { - content = json.serialize(obj); + content = JSON.serialize(obj); } else { content = null; } diff --git a/templates/java/libraries/okhttp-gson/api.mustache b/templates/java/libraries/okhttp-gson/api.mustache index c11a38d8fc..4239776734 100644 --- a/templates/java/libraries/okhttp-gson/api.mustache +++ b/templates/java/libraries/okhttp-gson/api.mustache @@ -111,7 +111,7 @@ public class {{classname}} extends ApiClient { public {{#returnType}}{{{.}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException { Call req = {{operationId}}ValidateBeforeCall({{#allParams}}{{paramName}}, {{/allParams}}null); if (req instanceof CallEcho) { - {{#returnType}}return new EchoResponse.{{#lambda.titlecase}}{{{operationId}}}{{/lambda.titlecase}}(((CallEcho)req).request());{{/returnType}} + {{#returnType}}return new EchoResponse.{{baseName}}Echo.{{#lambda.titlecase}}{{{operationId}}}{{/lambda.titlecase}}(((CallEcho)req).request());{{/returnType}} } Call call = (Call)req; {{#returnType}}Type returnType = new TypeToken<{{{.}}}>(){}.getType(); @@ -121,7 +121,7 @@ public class {{classname}} extends ApiClient { {{#optionalParams.0}} public {{#returnType}}{{{.}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#requiredParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}) throws ApiException { - {{#returnType}}return {{/returnType}}this.{{operationId}}({{#requiredParams}}{{paramName}}{{^-last}},{{/-last}}{{/requiredParams}}{{#requiredParams.0}},{{/requiredParams.0}}{{#optionalParams}}{{#defaultValue}}{{#isString}}"{{.}}"{{/isString}}{{^isString}}{{.}}{{/isString}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{^-last}},{{/-last}}{{/optionalParams}}); + {{#returnType}}return {{/returnType}}this.{{operationId}}({{#requiredParams}}{{paramName}}{{^-last}},{{/-last}}{{/requiredParams}}{{#requiredParams.0}},{{/requiredParams.0}}{{#optionalParams}}{{#schema}}{{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/schema}}{{^schema}}null{{/schema}}{{^-last}},{{/-last}}{{/optionalParams}}); } {{/optionalParams.0}} diff --git a/templates/java/model.mustache b/templates/java/model.mustache index bd1dc88ba7..13a53736c1 100644 --- a/templates/java/model.mustache +++ b/templates/java/model.mustache @@ -19,10 +19,6 @@ import javax.json.stream.JsonGenerator; import javax.json.stream.JsonParser; import javax.json.bind.annotation.JsonbProperty; {{/jsonb}} -{{#parcelableModel}} -import android.os.Parcelable; -import android.os.Parcel; -{{/parcelableModel}} {{#models}} {{#model}} diff --git a/templates/java/oneof_interface.mustache b/templates/java/oneof_interface.mustache index e2927410ff..1f9979e490 100644 --- a/templates/java/oneof_interface.mustache +++ b/templates/java/oneof_interface.mustache @@ -1,6 +1,54 @@ +import com.algolia.utils.CompoundType; +import com.algolia.JSON; + +import com.google.gson.TypeAdapter; +import com.google.gson.reflect.TypeToken; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +@JsonAdapter({{classname}}.Adapter.class) {{>additionalModelTypeAnnotations}} -public interface {{classname}} {{#vendorExtensions.x-implements}}{{#-first}}extends {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/vendorExtensions.x-implements}} { - {{#discriminator}} - public {{propertyType}} {{propertyGetter}}(); - {{/discriminator}} +public abstract class {{classname}} implements CompoundType { + {{#oneOf}} + public static {{classname}} of({{.}} inside) { + return new {{classname}}{{.}}(inside); + } + + {{/oneOf}} + public abstract Object getInsideValue(); + + public static class Adapter extends TypeAdapter<{{classname}}> { + @Override + public void write( + final JsonWriter out, + final {{classname}} oneOf) throws IOException { + TypeAdapter runtimeTypeAdapter = (TypeAdapter) JSON.getGson() + .getAdapter(TypeToken.get(oneOf.getInsideValue().getClass())); + runtimeTypeAdapter.write(out, oneOf.getInsideValue()); + } + + @Override + public {{classname}} read(final JsonReader jsonReader) + throws IOException { + return null; + } + } } + +{{#oneOf}} +@JsonAdapter({{classname}}.Adapter.class) +class {{classname}}{{.}} extends {{classname}} { + private final {{.}} insideValue; + + {{classname}}{{.}}({{.}} insideValue) { + this.insideValue = insideValue; + } + + @Override + public {{.}} getInsideValue() { + return insideValue; + } +} +{{/oneOf}} diff --git a/templates/java/openapi.mustache b/templates/java/openapi.mustache deleted file mode 100644 index 34fbb53f33..0000000000 --- a/templates/java/openapi.mustache +++ /dev/null @@ -1 +0,0 @@ -{{{openapi-yaml}}} diff --git a/templates/java/pojo.mustache b/templates/java/pojo.mustache index bf46406f4a..479efd798d 100644 --- a/templates/java/pojo.mustache +++ b/templates/java/pojo.mustache @@ -4,7 +4,7 @@ */{{#isDeprecated}} @Deprecated{{/isDeprecated}} {{>additionalModelTypeAnnotations}} -public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtensions.x-implements}}{{#-first}}implements {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{#-last}} {{/-last}}{{/vendorExtensions.x-implements}}{ +public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{ {{#serializableModel}} private static final long serialVersionUID = 1L; diff --git a/tests/CTS/methods/requests/search/addApiKey.json b/tests/CTS/methods/requests/search/addApiKey.json index 882e9c4f43..c503c2e0bb 100644 --- a/tests/CTS/methods/requests/search/addApiKey.json +++ b/tests/CTS/methods/requests/search/addApiKey.json @@ -2,7 +2,6 @@ { "method": "addApiKey", "parameters": { - "$objectName": "ApiKey", "acl": [ "search", "addObject" diff --git a/tests/CTS/methods/requests/search/addOrUpdateObject.json b/tests/CTS/methods/requests/search/addOrUpdateObject.json index 8ecab59078..c718ec67eb 100644 --- a/tests/CTS/methods/requests/search/addOrUpdateObject.json +++ b/tests/CTS/methods/requests/search/addOrUpdateObject.json @@ -5,7 +5,6 @@ "indexName": "indexName", "objectID": "uniqueID", "body": { - "$objectName": "Object", "key": "value" } }, diff --git a/tests/CTS/methods/requests/search/appendSource.json b/tests/CTS/methods/requests/search/appendSource.json index c936d0a41c..53b7a7940a 100644 --- a/tests/CTS/methods/requests/search/appendSource.json +++ b/tests/CTS/methods/requests/search/appendSource.json @@ -2,7 +2,6 @@ { "method": "appendSource", "parameters": { - "$objectName": "Source", "source": "theSource", "description": "theDescription" }, diff --git a/tests/CTS/methods/requests/search/assignUserId.json b/tests/CTS/methods/requests/search/assignUserId.json index 20275326f9..7abfe64b6c 100644 --- a/tests/CTS/methods/requests/search/assignUserId.json +++ b/tests/CTS/methods/requests/search/assignUserId.json @@ -4,7 +4,6 @@ "parameters": { "xAlgoliaUserID": "userID", "assignUserIdParams": { - "$objectName": "AssignUserIdParams", "cluster": "theCluster" } }, diff --git a/tests/CTS/methods/requests/search/batch.json b/tests/CTS/methods/requests/search/batch.json index 28a06dc5f1..fc28525200 100644 --- a/tests/CTS/methods/requests/search/batch.json +++ b/tests/CTS/methods/requests/search/batch.json @@ -4,19 +4,12 @@ "parameters": { "indexName": "theIndexName", "batchWriteParams": { - "$objectName": "BatchWriteParams", "requests": [ { - "$objectName": "Operation", - "action": { - "$enumType": "Action", - "value": "delete" - }, + "action": "delete", "body": { - "$objectName": "Object", "key": "value" - }, - "indexName": "otherIndexName" + } } ] } @@ -30,8 +23,7 @@ "action": "delete", "body": { "key": "value" - }, - "indexName": "otherIndexName" + } } ] } diff --git a/tests/CTS/methods/requests/search/batchAssignUserIds.json b/tests/CTS/methods/requests/search/batchAssignUserIds.json index 7d934f5543..0ed242e835 100644 --- a/tests/CTS/methods/requests/search/batchAssignUserIds.json +++ b/tests/CTS/methods/requests/search/batchAssignUserIds.json @@ -4,7 +4,6 @@ "parameters": { "xAlgoliaUserID": "userID", "batchAssignUserIdsParams": { - "$objectName": "BatchAssignUserIdsParams", "cluster": "theCluster", "users": [ "user1", diff --git a/tests/CTS/methods/requests/search/batchDictionaryEntries.json b/tests/CTS/methods/requests/search/batchDictionaryEntries.json index d8cca28eea..c4b8dfcb0a 100644 --- a/tests/CTS/methods/requests/search/batchDictionaryEntries.json +++ b/tests/CTS/methods/requests/search/batchDictionaryEntries.json @@ -5,28 +5,17 @@ "parameters": { "dictionaryName": "compounds", "batchDictionaryEntriesParams": { - "$objectName": "BatchDictionaryEntriesParams", "requests": [ { - "$objectName": "BatchDictionaryEntriesRequest", - "action": { - "$enumType": "DictionaryAction", - "value": "addEntry" - }, + "action": "addEntry", "body": { - "$objectName": "DictionaryEntry", "objectID": "1", "language": "en" } }, { - "$objectName": "BatchDictionaryEntriesRequest", - "action": { - "$enumType": "DictionaryAction", - "value": "deleteEntry" - }, + "action": "deleteEntry", "body": { - "$objectName": "DictionaryEntry", "objectID": "2", "language": "fr" } @@ -63,57 +52,40 @@ "parameters": { "dictionaryName": "compounds", "batchDictionaryEntriesParams": { - "$objectName": "BatchDictionaryEntriesParams", "clearExistingDictionaryEntries": false, "requests": [ { - "$objectName": "BatchDictionaryEntriesRequest", - "action": { - "$enumType": "DictionaryAction", - "value": "addEntry" - }, + "action": "addEntry", "body": { - "$objectName": "DictionaryEntry", "objectID": "1", "language": "en", - "word": "yo", + "word": "fancy", "words": [ - "yo", + "believe", "algolia" ], "decomposition": [ - "yo", + "trust", "algolia" ], - "state": { - "$enumType": "DictionaryEntryState", - "value": "enabled" - } + "state": "enabled" } }, { - "$objectName": "BatchDictionaryEntriesRequest", - "action": { - "$enumType": "DictionaryAction", - "value": "deleteEntry" - }, + "action": "deleteEntry", "body": { - "$objectName": "DictionaryEntry", "objectID": "2", "language": "fr", - "word": "salut", + "word": "humility", "words": [ - "salut", + "candor", "algolia" ], "decomposition": [ - "salut", + "grit", "algolia" ], - "state": { - "$enumType": "DictionaryEntryState", - "value": "enabled" - } + "state": "enabled" } } ] @@ -130,13 +102,13 @@ "body": { "objectID": "1", "language": "en", - "word": "yo", + "word": "fancy", "words": [ - "yo", + "believe", "algolia" ], "decomposition": [ - "yo", + "trust", "algolia" ], "state": "enabled" @@ -147,13 +119,13 @@ "body": { "objectID": "2", "language": "fr", - "word": "salut", + "word": "humility", "words": [ - "salut", + "candor", "algolia" ], "decomposition": [ - "salut", + "grit", "algolia" ], "state": "enabled" diff --git a/tests/CTS/methods/requests/search/batchRules.json b/tests/CTS/methods/requests/search/batchRules.json index acd26555c5..6d7653e0cd 100644 --- a/tests/CTS/methods/requests/search/batchRules.json +++ b/tests/CTS/methods/requests/search/batchRules.json @@ -5,43 +5,29 @@ "indexName": "indexName", "rule": [ { - "$objectName": "Rule", "objectID": "a-rule-id", "conditions": [ { - "$objectName": "Condition", "pattern": "smartphone", - "anchoring": { - "$enumType": "Anchoring", - "value": "contains" - } + "anchoring": "contains" } ], "consequence": { - "$objectName": "Consequence", "params": { - "$objectName": "ConsequenceParams", "filters": "category:smartphone" } } }, { - "$objectName": "Rule", "objectID": "a-second-rule-id", "conditions": [ { - "$objectName": "Condition", "pattern": "apple", - "anchoring": { - "$enumType": "Anchoring", - "value": "contains" - } + "anchoring": "contains" } ], "consequence": { - "$objectName": "Consequence", "params": { - "$objectName": "ConsequenceParams", "filters": "brand:apple" } } diff --git a/tests/CTS/methods/requests/search/browse.json b/tests/CTS/methods/requests/search/browse.json index 22f1f1c8b8..56fb3a8a25 100644 --- a/tests/CTS/methods/requests/search/browse.json +++ b/tests/CTS/methods/requests/search/browse.json @@ -16,7 +16,6 @@ "parameters": { "indexName": "indexName", "browseRequest": { - "$objectName": "BrowseRequest", "params": "query=foo&facetFilters=['bar']", "cursor": "cts" } diff --git a/tests/CTS/methods/requests/search/deleteBy.json b/tests/CTS/methods/requests/search/deleteBy.json index 6188cd02eb..4510f3cdee 100644 --- a/tests/CTS/methods/requests/search/deleteBy.json +++ b/tests/CTS/methods/requests/search/deleteBy.json @@ -4,7 +4,6 @@ "parameters": { "indexName": "theIndexName", "searchParams": { - "$objectName": "SearchParams", "query": "testQuery" } }, diff --git a/tests/CTS/methods/requests/search/getObjects.json b/tests/CTS/methods/requests/search/getObjects.json index a63a5caf61..ee802641f9 100644 --- a/tests/CTS/methods/requests/search/getObjects.json +++ b/tests/CTS/methods/requests/search/getObjects.json @@ -2,10 +2,8 @@ { "method": "getObjects", "parameters": { - "$objectName": "GetObjectsParams", "requests": [ { - "$objectName": "MultipleGetObjectsParams", "attributesToRetrieve": [ "attr1", "attr2" diff --git a/tests/CTS/methods/requests/search/multipleBatch.json b/tests/CTS/methods/requests/search/multipleBatch.json index fe3c3e8672..71326b5669 100644 --- a/tests/CTS/methods/requests/search/multipleBatch.json +++ b/tests/CTS/methods/requests/search/multipleBatch.json @@ -2,16 +2,10 @@ { "method": "multipleBatch", "parameters": { - "$objectName": "BatchParams", "requests": [ { - "$objectName": "Operation", - "action": { - "$enumType": "Action", - "value": "addObject" - }, + "action": "addObject", "body": { - "$objectName": "Object", "key": "value" }, "indexName": "theIndexName" diff --git a/tests/CTS/methods/requests/search/multipleQueries.json b/tests/CTS/methods/requests/search/multipleQueries.json index 5c18ccc6da..d994520843 100644 --- a/tests/CTS/methods/requests/search/multipleQueries.json +++ b/tests/CTS/methods/requests/search/multipleQueries.json @@ -2,24 +2,16 @@ { "method": "multipleQueries", "parameters": { - "$objectName": "MultipleQueriesParams", "requests": [ { - "$objectName": "MultipleQueries", "indexName": "theIndexName", "query": "test", - "type": { - "$enumType": "MultipleQueriesType", - "value": "facet" - }, + "type": "facet", "facet": "theFacet", "params": "testParam" } ], - "strategy": { - "$enumType": "MultipleQueriesStrategy", - "value": "stopIfEnoughMatches" - } + "strategy": "stopIfEnoughMatches" }, "request": { "path": "/1/indexes/*/queries", diff --git a/tests/CTS/methods/requests/search/operationIndex.json b/tests/CTS/methods/requests/search/operationIndex.json index c7fc12ae01..b8584dbdf6 100644 --- a/tests/CTS/methods/requests/search/operationIndex.json +++ b/tests/CTS/methods/requests/search/operationIndex.json @@ -4,11 +4,7 @@ "parameters": { "indexName": "theIndexName", "operationIndexParams": { - "$objectName": "OperationIndexParams", - "operation": { - "$enumType": "OperationType", - "value": "copy" - }, + "operation": "copy", "destination": "dest", "scope": [ "rules", diff --git a/tests/CTS/methods/requests/search/partialUpdateObject.json b/tests/CTS/methods/requests/search/partialUpdateObject.json index f71e13cb93..9cfcf77523 100644 --- a/tests/CTS/methods/requests/search/partialUpdateObject.json +++ b/tests/CTS/methods/requests/search/partialUpdateObject.json @@ -4,12 +4,10 @@ "parameters": { "indexName": "theIndexName", "objectID": "uniqueID", - "stringBuiltInOperation": [ + "attributeOrBuiltInOperation": [ { - "$objectName": "Object", "id1": "test", "id2": { - "$objectName": "OneOfstringbuiltInOperation", "_operation": "AddUnique", "value": "test2" } diff --git a/tests/CTS/methods/requests/search/replaceSources.json b/tests/CTS/methods/requests/search/replaceSources.json index 363ea44501..11d64ae1f2 100644 --- a/tests/CTS/methods/requests/search/replaceSources.json +++ b/tests/CTS/methods/requests/search/replaceSources.json @@ -4,7 +4,6 @@ "parameters": { "source": [ { - "$objectName": "Source", "source": "theSource", "description": "theDescription" } diff --git a/tests/CTS/methods/requests/search/saveObject.json b/tests/CTS/methods/requests/search/saveObject.json index b8c4f6a015..529ecbc6fa 100644 --- a/tests/CTS/methods/requests/search/saveObject.json +++ b/tests/CTS/methods/requests/search/saveObject.json @@ -4,7 +4,6 @@ "parameters": { "indexName": "theIndexName", "body": { - "$objectName": "Object", "objectID": "id", "test": "val" } diff --git a/tests/CTS/methods/requests/search/saveRule.json b/tests/CTS/methods/requests/search/saveRule.json index 62dbe32b85..5dbb735fb9 100644 --- a/tests/CTS/methods/requests/search/saveRule.json +++ b/tests/CTS/methods/requests/search/saveRule.json @@ -5,22 +5,15 @@ "indexName": "indexName", "objectID": "id1", "rule": { - "$objectName": "Rule", "objectID": "id1", "conditions": [ { - "$objectName": "Condition", "pattern": "apple", - "anchoring": { - "$enumType": "Anchoring", - "value": "contains" - } + "anchoring": "contains" } ], "consequence": { - "$objectName": "Consequence", "params": { - "$objectName": "ConsequenceParams", "filters": "brand:apple" } } diff --git a/tests/CTS/methods/requests/search/saveSynonym.json b/tests/CTS/methods/requests/search/saveSynonym.json index 1d75227329..a812b9d08e 100644 --- a/tests/CTS/methods/requests/search/saveSynonym.json +++ b/tests/CTS/methods/requests/search/saveSynonym.json @@ -5,12 +5,8 @@ "indexName": "indexName", "objectID": "id1", "synonymHit": { - "$objectName": "SynonymHit", "objectID": "id1", - "type": { - "$enumType": "SynonymType", - "value": "synonym" - }, + "type": "synonym", "synonyms": [ "car", "vehicule", diff --git a/tests/CTS/methods/requests/search/saveSynonyms.json b/tests/CTS/methods/requests/search/saveSynonyms.json index 33376641aa..37eb61cea6 100644 --- a/tests/CTS/methods/requests/search/saveSynonyms.json +++ b/tests/CTS/methods/requests/search/saveSynonyms.json @@ -5,12 +5,8 @@ "indexName": "indexName", "synonymHit": [ { - "$objectName": "SynonymHit", "objectID": "id1", - "type": { - "$enumType": "SynonymType", - "value": "synonym" - }, + "type": "synonym", "synonyms": [ "car", "vehicule", @@ -18,12 +14,8 @@ ] }, { - "$objectName": "SynonymHit", "objectID": "id2", - "type": { - "$enumType": "SynonymType", - "value": "onewaysynonym" - }, + "type": "onewaysynonym", "input": "iphone", "synonyms": [ "ephone", diff --git a/tests/CTS/methods/requests/search/search.json b/tests/CTS/methods/requests/search/search.json index ded605a9ac..59e762fc6e 100644 --- a/tests/CTS/methods/requests/search/search.json +++ b/tests/CTS/methods/requests/search/search.json @@ -4,7 +4,6 @@ "parameters": { "indexName": "indexName", "searchParams": { - "$objectName": "SearchParams", "query": "myQuery" } }, diff --git a/tests/CTS/methods/requests/search/searchDictionaryEntries.json b/tests/CTS/methods/requests/search/searchDictionaryEntries.json index b0716bfe3d..ed44e1b463 100644 --- a/tests/CTS/methods/requests/search/searchDictionaryEntries.json +++ b/tests/CTS/methods/requests/search/searchDictionaryEntries.json @@ -5,7 +5,6 @@ "parameters": { "dictionaryName": "compounds", "searchDictionaryEntriesParams": { - "$objectName": "SearchDictionaryEntriesParams", "query": "foo" } }, @@ -23,7 +22,6 @@ "parameters": { "dictionaryName": "compounds", "searchDictionaryEntriesParams": { - "$objectName": "SearchDictionaryEntriesParams", "query": "foo", "page": 4, "hitsPerPage": 2, diff --git a/tests/CTS/methods/requests/search/searchForFacetValues.json b/tests/CTS/methods/requests/search/searchForFacetValues.json index c2f8ddba90..56d7627fc5 100644 --- a/tests/CTS/methods/requests/search/searchForFacetValues.json +++ b/tests/CTS/methods/requests/search/searchForFacetValues.json @@ -18,7 +18,6 @@ "indexName": "indexName", "facetName": "facetName", "searchForFacetValuesRequest": { - "$objectName": "SearchForFacetValuesRequest", "params": "query=foo&facetFilters=['bar']", "facetQuery": "foo", "maxFacetHits": 42 diff --git a/tests/CTS/methods/requests/search/searchRules.json b/tests/CTS/methods/requests/search/searchRules.json index a45997400f..8c9a181bcd 100644 --- a/tests/CTS/methods/requests/search/searchRules.json +++ b/tests/CTS/methods/requests/search/searchRules.json @@ -4,7 +4,6 @@ "parameters": { "indexName": "indexName", "searchRulesParams": { - "$objectName": "SearchRulesParams", "query": "something" } }, diff --git a/tests/CTS/methods/requests/search/searchUserIds.json b/tests/CTS/methods/requests/search/searchUserIds.json index 471332c78d..48f9ead386 100644 --- a/tests/CTS/methods/requests/search/searchUserIds.json +++ b/tests/CTS/methods/requests/search/searchUserIds.json @@ -2,7 +2,6 @@ { "method": "searchUserIds", "parameters": { - "$objectName": "SearchUserIdsParams", "query": "test", "clusterName": "theClusterName", "page": 5, diff --git a/tests/CTS/methods/requests/search/setDictionarySettings.json b/tests/CTS/methods/requests/search/setDictionarySettings.json index fcc2cb41c1..af1148b5c0 100644 --- a/tests/CTS/methods/requests/search/setDictionarySettings.json +++ b/tests/CTS/methods/requests/search/setDictionarySettings.json @@ -3,11 +3,8 @@ "method": "setDictionarySettings", "testName": "get setDictionarySettings results with minimal parameters", "parameters": { - "$objectName": "DictionarySettingsParams", "disableStandardEntries": { - "$objectName": "StandardEntries", "plurals": { - "$objectName": "Object", "fr": false, "en": false, "ru": true @@ -32,21 +29,16 @@ "method": "setDictionarySettings", "testName": "get setDictionarySettings results with all parameters", "parameters": { - "$objectName": "DictionarySettingsParams", "disableStandardEntries": { - "$objectName": "StandardEntries", "plurals": { - "$objectName": "Object", "fr": false, "en": false, "ru": true }, "stopwords": { - "$objectName": "Object", "fr": false }, "compounds": { - "$objectName": "Object", "ru": true } } diff --git a/tests/CTS/methods/requests/search/setSettings.json b/tests/CTS/methods/requests/search/setSettings.json index 3a7a342509..ec4a635343 100644 --- a/tests/CTS/methods/requests/search/setSettings.json +++ b/tests/CTS/methods/requests/search/setSettings.json @@ -4,7 +4,6 @@ "parameters": { "indexName": "theIndexName", "indexSettings": { - "$objectName": "IndexSettings", "paginationLimitedTo": 10 }, "forwardToReplicas": true diff --git a/tests/CTS/methods/requests/search/updateApiKey.json b/tests/CTS/methods/requests/search/updateApiKey.json index cbf966a8ec..f4d1a65486 100644 --- a/tests/CTS/methods/requests/search/updateApiKey.json +++ b/tests/CTS/methods/requests/search/updateApiKey.json @@ -4,7 +4,6 @@ "parameters": { "key": "myApiKey", "apiKey": { - "$objectName": "ApiKey", "acl": [ "search", "addObject" diff --git a/tests/CTS/methods/requests/templates/java/generateParams.mustache b/tests/CTS/methods/requests/templates/java/generateParams.mustache index 0987f57fa8..539c774dbc 100644 --- a/tests/CTS/methods/requests/templates/java/generateParams.mustache +++ b/tests/CTS/methods/requests/templates/java/generateParams.mustache @@ -2,10 +2,10 @@ {{#isInteger}}int {{{key}}}{{suffix}} = {{{value}}};{{/isInteger}} {{#isDouble}}double {{{key}}}{{suffix}} = {{{value}}};{{/isDouble}} {{#isBoolean}}boolean {{{key}}}{{suffix}} = {{{value}}};{{/isBoolean}} -{{#isEnum}}{{#value}}{{{enumType}}} {{{key}}}{{suffix}} = {{{enumType}}}.fromValue("{{{value}}}");{{/value}}{{/isEnum}} +{{#isEnum}}{{{objectName}}} {{{key}}}{{suffix}} = {{{objectName}}}.fromValue("{{{value}}}");{{/isEnum}} {{#isArray}}List {{{key}}}{{suffix}} = new ArrayList(); { {{#value}}{{> generateParams}}{{parent}}{{parentSuffix}}.add({{{key}}}{{suffix}});{{/value}} }{{/isArray}} {{#isObject}}{{{objectName}}} {{{key}}}{{suffix}} = new {{{objectName}}}(); -{ {{#value}}{{> generateParams}}{{parent}}{{parentSuffix}}.set{{#capitalize}}{{{key}}}{{/capitalize}}({{{key}}}{{suffix}}); +{ {{#value}}{{> generateParams}}{{parent}}{{parentSuffix}}.set{{#lambda.titlecase}}{{{key}}}{{/lambda.titlecase}}({{{key}}}{{suffix}}); {{/value}} }{{/isObject}}{{#isFreeFormObject}}HashMap {{{key}}}{{suffix}} = new HashMap(); { {{#value}}{{> generateParams}}{{parent}}{{parentSuffix}}.put("{{{key}}}", {{{key}}}{{suffix}}); {{/value}} }{{/isFreeFormObject}} diff --git a/tests/CTS/methods/requests/templates/java/requests.mustache b/tests/CTS/methods/requests/templates/java/requests.mustache index 44b719285d..5b3940022f 100644 --- a/tests/CTS/methods/requests/templates/java/requests.mustache +++ b/tests/CTS/methods/requests/templates/java/requests.mustache @@ -22,12 +22,10 @@ import org.skyscreamer.jsonassert.JSONCompareMode; @TestInstance(TestInstance.Lifecycle.PER_CLASS) class {{client}}Tests { private {{client}} client; - private JSON json; @BeforeAll void init() { client = new {{client}}("appId", "apiKey", new EchoRequester()); - json = new JSON(); } {{#blocks}} @@ -38,7 +36,7 @@ class {{client}}Tests { {{#parametersWithDataType}}{{> generateParams}}{{/parametersWithDataType}} EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.{{method}}({{#parametersWithDataType}}{{{key}}}{{suffix}}{{^-last}},{{/-last}}{{/parametersWithDataType}}); + return client.{{method}}({{#parametersWithDataType}}{{#oneOfModel}}{{{.}}}.of({{{key}}}{{suffix}}){{/oneOfModel}}{{^oneOfModel}}{{{key}}}{{suffix}}{{/oneOfModel}}{{^-last}},{{/-last}}{{/parametersWithDataType}}); }); assertEquals(req.getPath(), "{{{request.path}}}"); @@ -46,12 +44,12 @@ class {{client}}Tests { {{#request.data}} assertDoesNotThrow(() -> { - JSONAssert.assertEquals("{{#escapeQuotes}}{{{request.data}}}{{/escapeQuotes}}", req.getBody(), JSONCompareMode.STRICT_ORDER); + JSONAssert.assertEquals("{{#lambda.escapequotes}}{{{request.data}}}{{/lambda.escapequotes}}", req.getBody(), JSONCompareMode.STRICT_ORDER); }); {{/request.data}} {{#request.searchParams}} - HashMap expectedQuery = json.deserialize("{{#escapeQuotes}}{{{request.searchParams}}}{{/escapeQuotes}}", new TypeToken>() {}.getType()); + HashMap expectedQuery = JSON.deserialize("{{#lambda.escapequotes}}{{{request.searchParams}}}{{/lambda.escapequotes}}", new TypeToken>() {}.getType()); List acutalQuery = req.getQueryParams(); for (Pair p : acutalQuery) { assertEquals(expectedQuery.get(p.getName()), p.getValue()); diff --git a/tests/output/java/.openapi-generator-ignore b/tests/output/java/.openapi-generator-ignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java b/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java index 84ad278057..32fc8da903 100644 --- a/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java +++ b/tests/output/java/src/test/java/com/algolia/methods/requests/search.test.java @@ -5,7 +5,7 @@ import com.algolia.JSON; import com.algolia.Pair; -import com.algolia.model.*; +import com.algolia.model.search.*; import com.algolia.search.SearchApi; import com.algolia.utils.echo.*; import com.google.gson.reflect.TypeToken; @@ -21,49 +21,48 @@ class SearchApiTests { private SearchApi client; - private JSON json; @BeforeAll void init() { client = new SearchApi("appId", "apiKey", new EchoRequester()); - json = new JSON(); } @Test @DisplayName("addApiKey") void addApiKeyTest0() { - ApiKey param0 = new ApiKey(); + ApiKey apiKey0 = new ApiKey(); { List acl1 = new ArrayList(); { - String aclParam02 = "search"; + Acl acl_02 = Acl.fromValue("search"); - acl1.add(aclParam02); - String aclParam12 = "addObject"; + acl1.add(acl_02); - acl1.add(aclParam12); + Acl acl_12 = Acl.fromValue("addObject"); + + acl1.add(acl_12); } - param0.setAcl(acl1); + apiKey0.setAcl(acl1); String description1 = "my new api key"; - param0.setDescription(description1); + apiKey0.setDescription(description1); int validity1 = 300; - param0.setValidity(validity1); + apiKey0.setValidity(validity1); int maxQueriesPerIPPerHour1 = 100; - param0.setMaxQueriesPerIPPerHour(maxQueriesPerIPPerHour1); + apiKey0.setMaxQueriesPerIPPerHour(maxQueriesPerIPPerHour1); int maxHitsPerQuery1 = 20; - param0.setMaxHitsPerQuery(maxHitsPerQuery1); + apiKey0.setMaxHitsPerQuery(maxHitsPerQuery1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.addApiKey(param0); + return client.addApiKey(apiKey0); } ); @@ -83,19 +82,19 @@ void addApiKeyTest0() { @Test @DisplayName("addOrUpdateObject") void addOrUpdateObjectTest0() { - String indexName1 = "indexName"; + String indexName0 = "indexName"; - String objectID1 = "uniqueID"; + String objectID0 = "uniqueID"; - HashMap body1 = new HashMap(); + HashMap body0 = new HashMap(); { - String key2 = "value"; + String key1 = "value"; - body1.put("key", key2); + body0.put("key", key1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.addOrUpdateObject(indexName1, objectID1, body1); + return client.addOrUpdateObject(indexName0, objectID0, body0); } ); @@ -114,18 +113,18 @@ void addOrUpdateObjectTest0() { @Test @DisplayName("appendSource") void appendSourceTest0() { - Source param0 = new Source(); + Source source0 = new Source(); { String source1 = "theSource"; - param0.setSource(source1); + source0.setSource(source1); String description1 = "theDescription"; - param0.setDescription(description1); + source0.setDescription(description1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.appendSource(param0); + return client.appendSource(source0); } ); @@ -144,17 +143,17 @@ void appendSourceTest0() { @Test @DisplayName("assignUserId") void assignUserIdTest0() { - String xAlgoliaUserID1 = "userID"; + String xAlgoliaUserID0 = "userID"; - AssignUserIdParams assignUserIdParams1 = new AssignUserIdParams(); + AssignUserIdParams assignUserIdParams0 = new AssignUserIdParams(); { - String cluster2 = "theCluster"; + String cluster1 = "theCluster"; - assignUserIdParams1.setCluster(cluster2); + assignUserIdParams0.setCluster(cluster1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.assignUserId(xAlgoliaUserID1, assignUserIdParams1); + return client.assignUserId(xAlgoliaUserID0, assignUserIdParams0); } ); @@ -169,7 +168,7 @@ void assignUserIdTest0() { ); }); - HashMap expectedQuery = json.deserialize( + HashMap expectedQuery = JSON.deserialize( "{\"X-Algolia-User-ID\":\"userID\"}", new TypeToken>() {}.getType() ); @@ -182,37 +181,34 @@ void assignUserIdTest0() { @Test @DisplayName("batch") void batchTest0() { - String indexName1 = "theIndexName"; + String indexName0 = "theIndexName"; - BatchWriteParams batchWriteParams1 = new BatchWriteParams(); + BatchWriteParams batchWriteParams0 = new BatchWriteParams(); { - List requests2 = new ArrayList(); + List requests1 = new ArrayList(); { - Operation requestsParam03 = new Operation(); + Operation requests_02 = new Operation(); { - Action action4 = Action.fromValue("delete"); + Action action3 = Action.fromValue("delete"); - requestsParam03.setAction(action4); + requests_02.setAction(action3); - HashMap body4 = new HashMap(); + HashMap body3 = new HashMap(); { - String key5 = "value"; + String key4 = "value"; - body4.put("key", key5); + body3.put("key", key4); } - requestsParam03.setBody(body4); - String indexName4 = "otherIndexName"; - - requestsParam03.setIndexName(indexName4); + requests_02.setBody(body3); } - requests2.add(requestsParam03); + requests1.add(requests_02); } - batchWriteParams1.setRequests(requests2); + batchWriteParams0.setRequests(requests1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.batch(indexName1, batchWriteParams1); + return client.batch(indexName0, batchWriteParams0); } ); @@ -221,7 +217,7 @@ void batchTest0() { assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"requests\":[{\"action\":\"delete\",\"body\":{\"key\":\"value\"},\"indexName\":\"otherIndexName\"}]}", + "{\"requests\":[{\"action\":\"delete\",\"body\":{\"key\":\"value\"}}]}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -231,31 +227,31 @@ void batchTest0() { @Test @DisplayName("batchAssignUserIds") void batchAssignUserIdsTest0() { - String xAlgoliaUserID1 = "userID"; + String xAlgoliaUserID0 = "userID"; - BatchAssignUserIdsParams batchAssignUserIdsParams1 = new BatchAssignUserIdsParams(); + BatchAssignUserIdsParams batchAssignUserIdsParams0 = new BatchAssignUserIdsParams(); { - String cluster2 = "theCluster"; + String cluster1 = "theCluster"; - batchAssignUserIdsParams1.setCluster(cluster2); + batchAssignUserIdsParams0.setCluster(cluster1); - List users2 = new ArrayList(); + List users1 = new ArrayList(); { - String usersParam03 = "user1"; + String users_02 = "user1"; - users2.add(usersParam03); - String usersParam13 = "user2"; + users1.add(users_02); + String users_12 = "user2"; - users2.add(usersParam13); + users1.add(users_12); } - batchAssignUserIdsParams1.setUsers(users2); + batchAssignUserIdsParams0.setUsers(users1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { return client.batchAssignUserIds( - xAlgoliaUserID1, - batchAssignUserIdsParams1 + xAlgoliaUserID0, + batchAssignUserIdsParams0 ); } ); @@ -271,7 +267,7 @@ void batchAssignUserIdsTest0() { ); }); - HashMap expectedQuery = json.deserialize( + HashMap expectedQuery = JSON.deserialize( "{\"X-Algolia-User-ID\":\"userID\"}", new TypeToken>() {}.getType() ); @@ -284,58 +280,58 @@ void batchAssignUserIdsTest0() { @Test @DisplayName("get batchDictionaryEntries results with minimal parameters") void batchDictionaryEntriesTest0() { - String dictionaryName1 = "compounds"; + DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); - BatchDictionaryEntriesParams batchDictionaryEntriesParams1 = new BatchDictionaryEntriesParams(); + BatchDictionaryEntriesParams batchDictionaryEntriesParams0 = new BatchDictionaryEntriesParams(); { - List requests2 = new ArrayList(); + List requests1 = new ArrayList(); { - BatchDictionaryEntriesRequest requestsParam03 = new BatchDictionaryEntriesRequest(); + BatchDictionaryEntriesRequest requests_02 = new BatchDictionaryEntriesRequest(); { - DictionaryAction action4 = DictionaryAction.fromValue("addEntry"); + DictionaryAction action3 = DictionaryAction.fromValue("addEntry"); - requestsParam03.setAction(action4); + requests_02.setAction(action3); - DictionaryEntry body4 = new DictionaryEntry(); + DictionaryEntry body3 = new DictionaryEntry(); { - String objectID5 = "1"; + String objectID4 = "1"; - body4.setObjectID(objectID5); - String language5 = "en"; + body3.setObjectID(objectID4); + String language4 = "en"; - body4.setLanguage(language5); + body3.setLanguage(language4); } - requestsParam03.setBody(body4); + requests_02.setBody(body3); } - requests2.add(requestsParam03); + requests1.add(requests_02); - BatchDictionaryEntriesRequest requestsParam13 = new BatchDictionaryEntriesRequest(); + BatchDictionaryEntriesRequest requests_12 = new BatchDictionaryEntriesRequest(); { - DictionaryAction action4 = DictionaryAction.fromValue("deleteEntry"); + DictionaryAction action3 = DictionaryAction.fromValue("deleteEntry"); - requestsParam13.setAction(action4); + requests_12.setAction(action3); - DictionaryEntry body4 = new DictionaryEntry(); + DictionaryEntry body3 = new DictionaryEntry(); { - String objectID5 = "2"; + String objectID4 = "2"; - body4.setObjectID(objectID5); - String language5 = "fr"; + body3.setObjectID(objectID4); + String language4 = "fr"; - body4.setLanguage(language5); + body3.setLanguage(language4); } - requestsParam13.setBody(body4); + requests_12.setBody(body3); } - requests2.add(requestsParam13); + requests1.add(requests_12); } - batchDictionaryEntriesParams1.setRequests(requests2); + batchDictionaryEntriesParams0.setRequests(requests1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { return client.batchDictionaryEntries( - dictionaryName1, - batchDictionaryEntriesParams1 + dictionaryName0, + batchDictionaryEntriesParams0 ); } ); @@ -355,130 +351,130 @@ void batchDictionaryEntriesTest0() { @Test @DisplayName("get batchDictionaryEntries results with all parameters") void batchDictionaryEntriesTest1() { - String dictionaryName1 = "compounds"; + DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); - BatchDictionaryEntriesParams batchDictionaryEntriesParams1 = new BatchDictionaryEntriesParams(); + BatchDictionaryEntriesParams batchDictionaryEntriesParams0 = new BatchDictionaryEntriesParams(); { - boolean clearExistingDictionaryEntries2 = false; + boolean clearExistingDictionaryEntries1 = false; - batchDictionaryEntriesParams1.setClearExistingDictionaryEntries( - clearExistingDictionaryEntries2 + batchDictionaryEntriesParams0.setClearExistingDictionaryEntries( + clearExistingDictionaryEntries1 ); - List requests2 = new ArrayList(); + List requests1 = new ArrayList(); { - BatchDictionaryEntriesRequest requestsParam03 = new BatchDictionaryEntriesRequest(); + BatchDictionaryEntriesRequest requests_02 = new BatchDictionaryEntriesRequest(); { - DictionaryAction action4 = DictionaryAction.fromValue("addEntry"); + DictionaryAction action3 = DictionaryAction.fromValue("addEntry"); - requestsParam03.setAction(action4); + requests_02.setAction(action3); - DictionaryEntry body4 = new DictionaryEntry(); + DictionaryEntry body3 = new DictionaryEntry(); { - String objectID5 = "1"; + String objectID4 = "1"; - body4.setObjectID(objectID5); - String language5 = "en"; + body3.setObjectID(objectID4); + String language4 = "en"; - body4.setLanguage(language5); - String word5 = "yo"; + body3.setLanguage(language4); + String word4 = "fancy"; - body4.setWord(word5); + body3.setWord(word4); - List words5 = new ArrayList(); + List words4 = new ArrayList(); { - String wordsParam06 = "yo"; + String words_05 = "believe"; - words5.add(wordsParam06); - String wordsParam16 = "algolia"; + words4.add(words_05); + String words_15 = "algolia"; - words5.add(wordsParam16); + words4.add(words_15); } - body4.setWords(words5); + body3.setWords(words4); - List decomposition5 = new ArrayList(); + List decomposition4 = new ArrayList(); { - String decompositionParam06 = "yo"; + String decomposition_05 = "trust"; - decomposition5.add(decompositionParam06); - String decompositionParam16 = "algolia"; + decomposition4.add(decomposition_05); + String decomposition_15 = "algolia"; - decomposition5.add(decompositionParam16); + decomposition4.add(decomposition_15); } - body4.setDecomposition(decomposition5); + body3.setDecomposition(decomposition4); - DictionaryEntryState state5 = DictionaryEntryState.fromValue( + DictionaryEntryState state4 = DictionaryEntryState.fromValue( "enabled" ); - body4.setState(state5); + body3.setState(state4); } - requestsParam03.setBody(body4); + requests_02.setBody(body3); } - requests2.add(requestsParam03); + requests1.add(requests_02); - BatchDictionaryEntriesRequest requestsParam13 = new BatchDictionaryEntriesRequest(); + BatchDictionaryEntriesRequest requests_12 = new BatchDictionaryEntriesRequest(); { - DictionaryAction action4 = DictionaryAction.fromValue("deleteEntry"); + DictionaryAction action3 = DictionaryAction.fromValue("deleteEntry"); - requestsParam13.setAction(action4); + requests_12.setAction(action3); - DictionaryEntry body4 = new DictionaryEntry(); + DictionaryEntry body3 = new DictionaryEntry(); { - String objectID5 = "2"; + String objectID4 = "2"; - body4.setObjectID(objectID5); - String language5 = "fr"; + body3.setObjectID(objectID4); + String language4 = "fr"; - body4.setLanguage(language5); - String word5 = "salut"; + body3.setLanguage(language4); + String word4 = "humility"; - body4.setWord(word5); + body3.setWord(word4); - List words5 = new ArrayList(); + List words4 = new ArrayList(); { - String wordsParam06 = "salut"; + String words_05 = "candor"; - words5.add(wordsParam06); - String wordsParam16 = "algolia"; + words4.add(words_05); + String words_15 = "algolia"; - words5.add(wordsParam16); + words4.add(words_15); } - body4.setWords(words5); + body3.setWords(words4); - List decomposition5 = new ArrayList(); + List decomposition4 = new ArrayList(); { - String decompositionParam06 = "salut"; + String decomposition_05 = "grit"; - decomposition5.add(decompositionParam06); - String decompositionParam16 = "algolia"; + decomposition4.add(decomposition_05); + String decomposition_15 = "algolia"; - decomposition5.add(decompositionParam16); + decomposition4.add(decomposition_15); } - body4.setDecomposition(decomposition5); + body3.setDecomposition(decomposition4); - DictionaryEntryState state5 = DictionaryEntryState.fromValue( + DictionaryEntryState state4 = DictionaryEntryState.fromValue( "enabled" ); - body4.setState(state5); + body3.setState(state4); } - requestsParam13.setBody(body4); + requests_12.setBody(body3); } - requests2.add(requestsParam13); + requests1.add(requests_12); } - batchDictionaryEntriesParams1.setRequests(requests2); + batchDictionaryEntriesParams0.setRequests(requests1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { return client.batchDictionaryEntries( - dictionaryName1, - batchDictionaryEntriesParams1 + dictionaryName0, + batchDictionaryEntriesParams0 ); } ); @@ -488,7 +484,7 @@ void batchDictionaryEntriesTest1() { assertDoesNotThrow(() -> { JSONAssert.assertEquals( - "{\"clearExistingDictionaryEntries\":false,\"requests\":[{\"action\":\"addEntry\",\"body\":{\"objectID\":\"1\",\"language\":\"en\",\"word\":\"yo\",\"words\":[\"yo\",\"algolia\"],\"decomposition\":[\"yo\",\"algolia\"],\"state\":\"enabled\"}},{\"action\":\"deleteEntry\",\"body\":{\"objectID\":\"2\",\"language\":\"fr\",\"word\":\"salut\",\"words\":[\"salut\",\"algolia\"],\"decomposition\":[\"salut\",\"algolia\"],\"state\":\"enabled\"}}]}", + "{\"clearExistingDictionaryEntries\":false,\"requests\":[{\"action\":\"addEntry\",\"body\":{\"objectID\":\"1\",\"language\":\"en\",\"word\":\"fancy\",\"words\":[\"believe\",\"algolia\"],\"decomposition\":[\"trust\",\"algolia\"],\"state\":\"enabled\"}},{\"action\":\"deleteEntry\",\"body\":{\"objectID\":\"2\",\"language\":\"fr\",\"word\":\"humility\",\"words\":[\"candor\",\"algolia\"],\"decomposition\":[\"grit\",\"algolia\"],\"state\":\"enabled\"}}]}", req.getBody(), JSONCompareMode.STRICT_ORDER ); @@ -498,95 +494,95 @@ void batchDictionaryEntriesTest1() { @Test @DisplayName("batchRules") void batchRulesTest0() { - String indexName1 = "indexName"; + String indexName0 = "indexName"; - List rule1 = new ArrayList(); + List rule0 = new ArrayList(); { - Rule ruleParam02 = new Rule(); + Rule rule_01 = new Rule(); { - String objectID3 = "a-rule-id"; + String objectID2 = "a-rule-id"; - ruleParam02.setObjectID(objectID3); + rule_01.setObjectID(objectID2); - List conditions3 = new ArrayList(); + List conditions2 = new ArrayList(); { - Condition conditionsParam04 = new Condition(); + Condition conditions_03 = new Condition(); { - String pattern5 = "smartphone"; + String pattern4 = "smartphone"; - conditionsParam04.setPattern(pattern5); + conditions_03.setPattern(pattern4); - Anchoring anchoring5 = Anchoring.fromValue("contains"); + Anchoring anchoring4 = Anchoring.fromValue("contains"); - conditionsParam04.setAnchoring(anchoring5); + conditions_03.setAnchoring(anchoring4); } - conditions3.add(conditionsParam04); + conditions2.add(conditions_03); } - ruleParam02.setConditions(conditions3); + rule_01.setConditions(conditions2); - Consequence consequence3 = new Consequence(); + Consequence consequence2 = new Consequence(); { - ConsequenceParams params4 = new ConsequenceParams(); + ConsequenceParams params3 = new ConsequenceParams(); { - String filters5 = "category:smartphone"; + String filters4 = "category:smartphone"; - params4.setFilters(filters5); + params3.setFilters(filters4); } - consequence3.setParams(params4); + consequence2.setParams(params3); } - ruleParam02.setConsequence(consequence3); + rule_01.setConsequence(consequence2); } - rule1.add(ruleParam02); + rule0.add(rule_01); - Rule ruleParam12 = new Rule(); + Rule rule_11 = new Rule(); { - String objectID3 = "a-second-rule-id"; + String objectID2 = "a-second-rule-id"; - ruleParam12.setObjectID(objectID3); + rule_11.setObjectID(objectID2); - List conditions3 = new ArrayList(); + List conditions2 = new ArrayList(); { - Condition conditionsParam04 = new Condition(); + Condition conditions_03 = new Condition(); { - String pattern5 = "apple"; + String pattern4 = "apple"; - conditionsParam04.setPattern(pattern5); + conditions_03.setPattern(pattern4); - Anchoring anchoring5 = Anchoring.fromValue("contains"); + Anchoring anchoring4 = Anchoring.fromValue("contains"); - conditionsParam04.setAnchoring(anchoring5); + conditions_03.setAnchoring(anchoring4); } - conditions3.add(conditionsParam04); + conditions2.add(conditions_03); } - ruleParam12.setConditions(conditions3); + rule_11.setConditions(conditions2); - Consequence consequence3 = new Consequence(); + Consequence consequence2 = new Consequence(); { - ConsequenceParams params4 = new ConsequenceParams(); + ConsequenceParams params3 = new ConsequenceParams(); { - String filters5 = "brand:apple"; + String filters4 = "brand:apple"; - params4.setFilters(filters5); + params3.setFilters(filters4); } - consequence3.setParams(params4); + consequence2.setParams(params3); } - ruleParam12.setConsequence(consequence3); + rule_11.setConsequence(consequence2); } - rule1.add(ruleParam12); + rule0.add(rule_11); } - boolean forwardToReplicas1 = true; + boolean forwardToReplicas0 = true; - boolean clearExistingRules1 = true; + boolean clearExistingRules0 = true; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { return client.batchRules( - indexName1, - rule1, - forwardToReplicas1, - clearExistingRules1 + indexName0, + rule0, + forwardToReplicas0, + clearExistingRules0 ); } ); @@ -602,7 +598,7 @@ void batchRulesTest0() { ); }); - HashMap expectedQuery = json.deserialize( + HashMap expectedQuery = JSON.deserialize( "{\"forwardToReplicas\":\"true\",\"clearExistingRules\":\"true\"}", new TypeToken>() {}.getType() ); @@ -615,10 +611,10 @@ void batchRulesTest0() { @Test @DisplayName("get browse results with minimal parameters") void browseTest0() { - String indexName1 = "indexName"; + String indexName0 = "indexName"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.browse(indexName1); + return client.browse(indexName0); } ); @@ -629,20 +625,20 @@ void browseTest0() { @Test @DisplayName("get browse results with all parameters") void browseTest1() { - String indexName1 = "indexName"; + String indexName0 = "indexName"; - BrowseRequest browseRequest1 = new BrowseRequest(); + BrowseRequest browseRequest0 = new BrowseRequest(); { - String params2 = "query=foo&facetFilters=['bar']"; + String params1 = "query=foo&facetFilters=['bar']"; - browseRequest1.setParams(params2); - String cursor2 = "cts"; + browseRequest0.setParams(params1); + String cursor1 = "cts"; - browseRequest1.setCursor(cursor2); + browseRequest0.setCursor(cursor1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.browse(indexName1, browseRequest1); + return client.browse(indexName0, browseRequest0); } ); @@ -661,10 +657,10 @@ void browseTest1() { @Test @DisplayName("clearAllSynonyms") void clearAllSynonymsTest0() { - String indexName1 = "indexName"; + String indexName0 = "indexName"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.clearAllSynonyms(indexName1); + return client.clearAllSynonyms(indexName0); } ); @@ -675,10 +671,10 @@ void clearAllSynonymsTest0() { @Test @DisplayName("clearObjects") void clearObjectsTest0() { - String indexName1 = "theIndexName"; + String indexName0 = "theIndexName"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.clearObjects(indexName1); + return client.clearObjects(indexName0); } ); @@ -689,10 +685,10 @@ void clearObjectsTest0() { @Test @DisplayName("clearRules") void clearRulesTest0() { - String indexName1 = "indexName"; + String indexName0 = "indexName"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.clearRules(indexName1); + return client.clearRules(indexName0); } ); @@ -703,10 +699,10 @@ void clearRulesTest0() { @Test @DisplayName("deleteApiKey") void deleteApiKeyTest0() { - String key1 = "myTestApiKey"; + String key0 = "myTestApiKey"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteApiKey(key1); + return client.deleteApiKey(key0); } ); @@ -717,17 +713,17 @@ void deleteApiKeyTest0() { @Test @DisplayName("deleteBy") void deleteByTest0() { - String indexName1 = "theIndexName"; + String indexName0 = "theIndexName"; - SearchParams searchParams1 = new SearchParams(); + SearchParamsObject searchParams0 = new SearchParamsObject(); { - String query2 = "testQuery"; + String query1 = "testQuery"; - searchParams1.setQuery(query2); + searchParams0.setQuery(query1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteBy(indexName1, searchParams1); + return client.deleteBy(indexName0, SearchParams.of(searchParams0)); } ); @@ -746,10 +742,10 @@ void deleteByTest0() { @Test @DisplayName("deleteIndex") void deleteIndexTest0() { - String indexName1 = "theIndexName"; + String indexName0 = "theIndexName"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteIndex(indexName1); + return client.deleteIndex(indexName0); } ); @@ -760,12 +756,12 @@ void deleteIndexTest0() { @Test @DisplayName("deleteObject") void deleteObjectTest0() { - String indexName1 = "theIndexName"; + String indexName0 = "theIndexName"; - String objectID1 = "uniqueID"; + String objectID0 = "uniqueID"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteObject(indexName1, objectID1); + return client.deleteObject(indexName0, objectID0); } ); @@ -776,12 +772,12 @@ void deleteObjectTest0() { @Test @DisplayName("deleteRule") void deleteRuleTest0() { - String indexName1 = "indexName"; + String indexName0 = "indexName"; - String objectID1 = "id1"; + String objectID0 = "id1"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteRule(indexName1, objectID1); + return client.deleteRule(indexName0, objectID0); } ); @@ -792,10 +788,10 @@ void deleteRuleTest0() { @Test @DisplayName("deleteSource") void deleteSourceTest0() { - String source1 = "theSource"; + String source0 = "theSource"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteSource(source1); + return client.deleteSource(source0); } ); @@ -806,12 +802,12 @@ void deleteSourceTest0() { @Test @DisplayName("deleteSynonym") void deleteSynonymTest0() { - String indexName1 = "indexName"; + String indexName0 = "indexName"; - String objectID1 = "id1"; + String objectID0 = "id1"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.deleteSynonym(indexName1, objectID1); + return client.deleteSynonym(indexName0, objectID0); } ); @@ -822,10 +818,10 @@ void deleteSynonymTest0() { @Test @DisplayName("getApiKey") void getApiKeyTest0() { - String key1 = "myTestApiKey"; + String key0 = "myTestApiKey"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getApiKey(key1); + return client.getApiKey(key0); } ); @@ -860,23 +856,23 @@ void getDictionarySettingsTest0() { @Test @DisplayName("getLogs") void getLogsTest0() { - int offset1 = 5; + int offset0 = 5; - int length1 = 10; + int length0 = 10; - String indexName1 = "theIndexName"; + String indexName0 = "theIndexName"; - String type1 = "all"; + LogType type0 = LogType.fromValue("all"); EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getLogs(offset1, length1, indexName1, type1); + return client.getLogs(offset0, length0, indexName0, type0); } ); assertEquals(req.getPath(), "/1/logs"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = json.deserialize( + HashMap expectedQuery = JSON.deserialize( "{\"offset\":\"5\",\"length\":\"10\",\"indexName\":\"theIndexName\",\"type\":\"all\"}", new TypeToken>() {}.getType() ); @@ -889,29 +885,29 @@ void getLogsTest0() { @Test @DisplayName("getObject") void getObjectTest0() { - String indexName1 = "theIndexName"; + String indexName0 = "theIndexName"; - String objectID1 = "uniqueID"; + String objectID0 = "uniqueID"; - List attributesToRetrieve1 = new ArrayList(); + List attributesToRetrieve0 = new ArrayList(); { - String attributesToRetrieveParam02 = "attr1"; + String attributesToRetrieve_01 = "attr1"; - attributesToRetrieve1.add(attributesToRetrieveParam02); - String attributesToRetrieveParam12 = "attr2"; + attributesToRetrieve0.add(attributesToRetrieve_01); + String attributesToRetrieve_11 = "attr2"; - attributesToRetrieve1.add(attributesToRetrieveParam12); + attributesToRetrieve0.add(attributesToRetrieve_11); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getObject(indexName1, objectID1, attributesToRetrieve1); + return client.getObject(indexName0, objectID0, attributesToRetrieve0); } ); assertEquals(req.getPath(), "/1/indexes/theIndexName/uniqueID"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = json.deserialize( + HashMap expectedQuery = JSON.deserialize( "{\"attributesToRetrieve\":\"attr1,attr2\"}", new TypeToken>() {}.getType() ); @@ -924,38 +920,38 @@ void getObjectTest0() { @Test @DisplayName("getObjects") void getObjectsTest0() { - GetObjectsParams param0 = new GetObjectsParams(); + GetObjectsParams getObjectsParams0 = new GetObjectsParams(); { List requests1 = new ArrayList(); { - MultipleGetObjectsParams requestsParam02 = new MultipleGetObjectsParams(); + MultipleGetObjectsParams requests_02 = new MultipleGetObjectsParams(); { List attributesToRetrieve3 = new ArrayList(); { - String attributesToRetrieveParam04 = "attr1"; + String attributesToRetrieve_04 = "attr1"; - attributesToRetrieve3.add(attributesToRetrieveParam04); - String attributesToRetrieveParam14 = "attr2"; + attributesToRetrieve3.add(attributesToRetrieve_04); + String attributesToRetrieve_14 = "attr2"; - attributesToRetrieve3.add(attributesToRetrieveParam14); + attributesToRetrieve3.add(attributesToRetrieve_14); } - requestsParam02.setAttributesToRetrieve(attributesToRetrieve3); + requests_02.setAttributesToRetrieve(attributesToRetrieve3); String objectID3 = "uniqueID"; - requestsParam02.setObjectID(objectID3); + requests_02.setObjectID(objectID3); String indexName3 = "theIndexName"; - requestsParam02.setIndexName(indexName3); + requests_02.setIndexName(indexName3); } - requests1.add(requestsParam02); + requests1.add(requests_02); } - param0.setRequests(requests1); + getObjectsParams0.setRequests(requests1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getObjects(param0); + return client.getObjects(getObjectsParams0); } ); @@ -974,12 +970,12 @@ void getObjectsTest0() { @Test @DisplayName("getRule") void getRuleTest0() { - String indexName1 = "indexName"; + String indexName0 = "indexName"; - String objectID1 = "id1"; + String objectID0 = "id1"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getRule(indexName1, objectID1); + return client.getRule(indexName0, objectID0); } ); @@ -990,10 +986,10 @@ void getRuleTest0() { @Test @DisplayName("getSettings") void getSettingsTest0() { - String indexName1 = "theIndexName"; + String indexName0 = "theIndexName"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSettings(indexName1); + return client.getSettings(indexName0); } ); @@ -1016,12 +1012,12 @@ void getSourcesTest0() { @Test @DisplayName("getSynonym") void getSynonymTest0() { - String indexName1 = "indexName"; + String indexName0 = "indexName"; - String objectID1 = "id1"; + String objectID0 = "id1"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getSynonym(indexName1, objectID1); + return client.getSynonym(indexName0, objectID0); } ); @@ -1032,12 +1028,12 @@ void getSynonymTest0() { @Test @DisplayName("getTask") void getTaskTest0() { - String indexName1 = "theIndexName"; + String indexName0 = "theIndexName"; - int taskID1 = 123; + int taskID0 = 123; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getTask(indexName1, taskID1); + return client.getTask(indexName0, taskID0); } ); @@ -1060,10 +1056,10 @@ void getTopUserIdsTest0() { @Test @DisplayName("getUserId") void getUserIdTest0() { - String userID1 = "uniqueID"; + String userID0 = "uniqueID"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.getUserId(userID1); + return client.getUserId(userID0); } ); @@ -1074,17 +1070,17 @@ void getUserIdTest0() { @Test @DisplayName("hasPendingMappings") void hasPendingMappingsTest0() { - boolean getClusters1 = true; + boolean getClusters0 = true; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.hasPendingMappings(getClusters1); + return client.hasPendingMappings(getClusters0); } ); assertEquals(req.getPath(), "/1/clusters/mapping/pending"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = json.deserialize( + HashMap expectedQuery = JSON.deserialize( "{\"getClusters\":\"true\"}", new TypeToken>() {}.getType() ); @@ -1121,17 +1117,17 @@ void listClustersTest0() { @Test @DisplayName("listIndices") void listIndicesTest0() { - int page1 = 8; + int page0 = 8; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.listIndices(page1); + return client.listIndices(page0); } ); assertEquals(req.getPath(), "/1/indexes"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = json.deserialize( + HashMap expectedQuery = JSON.deserialize( "{\"page\":\"8\"}", new TypeToken>() {}.getType() ); @@ -1144,19 +1140,19 @@ void listIndicesTest0() { @Test @DisplayName("listUserIds") void listUserIdsTest0() { - int page1 = 8; + int page0 = 8; - int hitsPerPage1 = 100; + int hitsPerPage0 = 100; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.listUserIds(page1, hitsPerPage1); + return client.listUserIds(page0, hitsPerPage0); } ); assertEquals(req.getPath(), "/1/clusters/mapping"); assertEquals(req.getMethod(), "GET"); - HashMap expectedQuery = json.deserialize( + HashMap expectedQuery = JSON.deserialize( "{\"page\":\"8\",\"hitsPerPage\":\"100\"}", new TypeToken>() {}.getType() ); @@ -1169,15 +1165,15 @@ void listUserIdsTest0() { @Test @DisplayName("multipleBatch") void multipleBatchTest0() { - BatchParams param0 = new BatchParams(); + BatchParams batchParams0 = new BatchParams(); { List requests1 = new ArrayList(); { - Operation requestsParam02 = new Operation(); + OperationIndexName requests_02 = new OperationIndexName(); { Action action3 = Action.fromValue("addObject"); - requestsParam02.setAction(action3); + requests_02.setAction(action3); HashMap body3 = new HashMap(); { @@ -1185,19 +1181,19 @@ void multipleBatchTest0() { body3.put("key", key4); } - requestsParam02.setBody(body3); + requests_02.setBody(body3); String indexName3 = "theIndexName"; - requestsParam02.setIndexName(indexName3); + requests_02.setIndexName(indexName3); } - requests1.add(requestsParam02); + requests1.add(requests_02); } - param0.setRequests(requests1); + batchParams0.setRequests(requests1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.multipleBatch(param0); + return client.multipleBatch(batchParams0); } ); @@ -1216,43 +1212,43 @@ void multipleBatchTest0() { @Test @DisplayName("multipleQueries") void multipleQueriesTest0() { - MultipleQueriesParams param0 = new MultipleQueriesParams(); + MultipleQueriesParams multipleQueriesParams0 = new MultipleQueriesParams(); { List requests1 = new ArrayList(); { - MultipleQueries requestsParam02 = new MultipleQueries(); + MultipleQueries requests_02 = new MultipleQueries(); { String indexName3 = "theIndexName"; - requestsParam02.setIndexName(indexName3); + requests_02.setIndexName(indexName3); String query3 = "test"; - requestsParam02.setQuery(query3); + requests_02.setQuery(query3); MultipleQueriesType type3 = MultipleQueriesType.fromValue("facet"); - requestsParam02.setType(type3); + requests_02.setType(type3); String facet3 = "theFacet"; - requestsParam02.setFacet(facet3); + requests_02.setFacet(facet3); String params3 = "testParam"; - requestsParam02.setParams(params3); + requests_02.setParams(params3); } - requests1.add(requestsParam02); + requests1.add(requests_02); } - param0.setRequests(requests1); + multipleQueriesParams0.setRequests(requests1); MultipleQueriesStrategy strategy1 = MultipleQueriesStrategy.fromValue( "stopIfEnoughMatches" ); - param0.setStrategy(strategy1); + multipleQueriesParams0.setStrategy(strategy1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.multipleQueries(param0); + return client.multipleQueries(multipleQueriesParams0); } ); @@ -1271,32 +1267,33 @@ void multipleQueriesTest0() { @Test @DisplayName("operationIndex") void operationIndexTest0() { - String indexName1 = "theIndexName"; + String indexName0 = "theIndexName"; - OperationIndexParams operationIndexParams1 = new OperationIndexParams(); + OperationIndexParams operationIndexParams0 = new OperationIndexParams(); { - OperationType operation2 = OperationType.fromValue("copy"); + OperationType operation1 = OperationType.fromValue("copy"); - operationIndexParams1.setOperation(operation2); - String destination2 = "dest"; + operationIndexParams0.setOperation(operation1); + String destination1 = "dest"; - operationIndexParams1.setDestination(destination2); + operationIndexParams0.setDestination(destination1); - List scope2 = new ArrayList(); + List scope1 = new ArrayList(); { - String scopeParam03 = "rules"; + ScopeType scope_02 = ScopeType.fromValue("rules"); - scope2.add(scopeParam03); - String scopeParam13 = "settings"; + scope1.add(scope_02); - scope2.add(scopeParam13); + ScopeType scope_12 = ScopeType.fromValue("settings"); + + scope1.add(scope_12); } - operationIndexParams1.setScope(scope2); + operationIndexParams0.setScope(scope1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.operationIndex(indexName1, operationIndexParams1); + return client.operationIndex(indexName0, operationIndexParams0); } ); @@ -1315,40 +1312,42 @@ void operationIndexTest0() { @Test @DisplayName("partialUpdateObject") void partialUpdateObjectTest0() { - String indexName1 = "theIndexName"; + String indexName0 = "theIndexName"; - String objectID1 = "uniqueID"; + String objectID0 = "uniqueID"; - List stringBuiltInOperation1 = new ArrayList(); + List attributeOrBuiltInOperation0 = new ArrayList(); { - HashMap stringBuiltInOperationParam02 = new HashMap(); + HashMap attributeOrBuiltInOperation_01 = new HashMap(); { - String id13 = "test"; + String id12 = "test"; - stringBuiltInOperationParam02.put("id1", id13); + attributeOrBuiltInOperation_01.put("id1", id12); - OneOfstringbuiltInOperation id23 = new OneOfstringbuiltInOperation(); + BuiltInOperation id22 = new BuiltInOperation(); { - String _operation4 = "AddUnique"; + BuiltInOperationType operation3 = BuiltInOperationType.fromValue( + "AddUnique" + ); - id23.set_operation(_operation4); - String value4 = "test2"; + id22.setOperation(operation3); + String value3 = "test2"; - id23.setValue(value4); + id22.setValue(value3); } - stringBuiltInOperationParam02.put("id2", id23); + attributeOrBuiltInOperation_01.put("id2", id22); } - stringBuiltInOperation1.add(stringBuiltInOperationParam02); + attributeOrBuiltInOperation0.add(attributeOrBuiltInOperation_01); } - boolean createIfNotExists1 = true; + boolean createIfNotExists0 = true; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { return client.partialUpdateObject( - indexName1, - objectID1, - stringBuiltInOperation1, - createIfNotExists1 + indexName0, + objectID0, + attributeOrBuiltInOperation0, + createIfNotExists0 ); } ); @@ -1364,7 +1363,7 @@ void partialUpdateObjectTest0() { ); }); - HashMap expectedQuery = json.deserialize( + HashMap expectedQuery = JSON.deserialize( "{\"createIfNotExists\":\"true\"}", new TypeToken>() {}.getType() ); @@ -1377,10 +1376,10 @@ void partialUpdateObjectTest0() { @Test @DisplayName("removeUserId") void removeUserIdTest0() { - String userID1 = "uniqueID"; + String userID0 = "uniqueID"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.removeUserId(userID1); + return client.removeUserId(userID0); } ); @@ -1391,22 +1390,22 @@ void removeUserIdTest0() { @Test @DisplayName("replaceSources") void replaceSourcesTest0() { - List source1 = new ArrayList(); + List source0 = new ArrayList(); { - Source sourceParam02 = new Source(); + Source source_01 = new Source(); { - String source3 = "theSource"; + String source2 = "theSource"; - sourceParam02.setSource(source3); - String description3 = "theDescription"; + source_01.setSource(source2); + String description2 = "theDescription"; - sourceParam02.setDescription(description3); + source_01.setDescription(description2); } - source1.add(sourceParam02); + source0.add(source_01); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.replaceSources(source1); + return client.replaceSources(source0); } ); @@ -1425,10 +1424,10 @@ void replaceSourcesTest0() { @Test @DisplayName("restoreApiKey") void restoreApiKeyTest0() { - String key1 = "myApiKey"; + String key0 = "myApiKey"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.restoreApiKey(key1); + return client.restoreApiKey(key0); } ); @@ -1439,20 +1438,20 @@ void restoreApiKeyTest0() { @Test @DisplayName("saveObject") void saveObjectTest0() { - String indexName1 = "theIndexName"; + String indexName0 = "theIndexName"; - HashMap body1 = new HashMap(); + HashMap body0 = new HashMap(); { - String objectID2 = "id"; + String objectID1 = "id"; - body1.put("objectID", objectID2); - String test2 = "val"; + body0.put("objectID", objectID1); + String test1 = "val"; - body1.put("test", test2); + body0.put("test", test1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.saveObject(indexName1, body1); + return client.saveObject(indexName0, body0); } ); @@ -1471,54 +1470,54 @@ void saveObjectTest0() { @Test @DisplayName("saveRule") void saveRuleTest0() { - String indexName1 = "indexName"; + String indexName0 = "indexName"; - String objectID1 = "id1"; + String objectID0 = "id1"; - Rule rule1 = new Rule(); + Rule rule0 = new Rule(); { - String objectID2 = "id1"; + String objectID1 = "id1"; - rule1.setObjectID(objectID2); + rule0.setObjectID(objectID1); - List conditions2 = new ArrayList(); + List conditions1 = new ArrayList(); { - Condition conditionsParam03 = new Condition(); + Condition conditions_02 = new Condition(); { - String pattern4 = "apple"; + String pattern3 = "apple"; - conditionsParam03.setPattern(pattern4); + conditions_02.setPattern(pattern3); - Anchoring anchoring4 = Anchoring.fromValue("contains"); + Anchoring anchoring3 = Anchoring.fromValue("contains"); - conditionsParam03.setAnchoring(anchoring4); + conditions_02.setAnchoring(anchoring3); } - conditions2.add(conditionsParam03); + conditions1.add(conditions_02); } - rule1.setConditions(conditions2); + rule0.setConditions(conditions1); - Consequence consequence2 = new Consequence(); + Consequence consequence1 = new Consequence(); { - ConsequenceParams params3 = new ConsequenceParams(); + ConsequenceParams params2 = new ConsequenceParams(); { - String filters4 = "brand:apple"; + String filters3 = "brand:apple"; - params3.setFilters(filters4); + params2.setFilters(filters3); } - consequence2.setParams(params3); + consequence1.setParams(params2); } - rule1.setConsequence(consequence2); + rule0.setConsequence(consequence1); } - boolean forwardToReplicas1 = true; + boolean forwardToReplicas0 = true; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { return client.saveRule( - indexName1, - objectID1, - rule1, - forwardToReplicas1 + indexName0, + objectID0, + rule0, + forwardToReplicas0 ); } ); @@ -1534,7 +1533,7 @@ void saveRuleTest0() { ); }); - HashMap expectedQuery = json.deserialize( + HashMap expectedQuery = JSON.deserialize( "{\"forwardToReplicas\":\"true\"}", new TypeToken>() {}.getType() ); @@ -1547,44 +1546,44 @@ void saveRuleTest0() { @Test @DisplayName("saveSynonym") void saveSynonymTest0() { - String indexName1 = "indexName"; + String indexName0 = "indexName"; - String objectID1 = "id1"; + String objectID0 = "id1"; - SynonymHit synonymHit1 = new SynonymHit(); + SynonymHit synonymHit0 = new SynonymHit(); { - String objectID2 = "id1"; + String objectID1 = "id1"; - synonymHit1.setObjectID(objectID2); + synonymHit0.setObjectID(objectID1); - SynonymType type2 = SynonymType.fromValue("synonym"); + SynonymType type1 = SynonymType.fromValue("synonym"); - synonymHit1.setType(type2); + synonymHit0.setType(type1); - List synonyms2 = new ArrayList(); + List synonyms1 = new ArrayList(); { - String synonymsParam03 = "car"; + String synonyms_02 = "car"; - synonyms2.add(synonymsParam03); - String synonymsParam13 = "vehicule"; + synonyms1.add(synonyms_02); + String synonyms_12 = "vehicule"; - synonyms2.add(synonymsParam13); - String synonymsParam23 = "auto"; + synonyms1.add(synonyms_12); + String synonyms_22 = "auto"; - synonyms2.add(synonymsParam23); + synonyms1.add(synonyms_22); } - synonymHit1.setSynonyms(synonyms2); + synonymHit0.setSynonyms(synonyms1); } - boolean forwardToReplicas1 = true; + boolean forwardToReplicas0 = true; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { return client.saveSynonym( - indexName1, - objectID1, - synonymHit1, - forwardToReplicas1 + indexName0, + objectID0, + synonymHit0, + forwardToReplicas0 ); } ); @@ -1600,7 +1599,7 @@ void saveSynonymTest0() { ); }); - HashMap expectedQuery = json.deserialize( + HashMap expectedQuery = JSON.deserialize( "{\"forwardToReplicas\":\"true\"}", new TypeToken>() {}.getType() ); @@ -1613,78 +1612,78 @@ void saveSynonymTest0() { @Test @DisplayName("saveSynonyms") void saveSynonymsTest0() { - String indexName1 = "indexName"; + String indexName0 = "indexName"; - List synonymHit1 = new ArrayList(); + List synonymHit0 = new ArrayList(); { - SynonymHit synonymHitParam02 = new SynonymHit(); + SynonymHit synonymHit_01 = new SynonymHit(); { - String objectID3 = "id1"; + String objectID2 = "id1"; - synonymHitParam02.setObjectID(objectID3); + synonymHit_01.setObjectID(objectID2); - SynonymType type3 = SynonymType.fromValue("synonym"); + SynonymType type2 = SynonymType.fromValue("synonym"); - synonymHitParam02.setType(type3); + synonymHit_01.setType(type2); - List synonyms3 = new ArrayList(); + List synonyms2 = new ArrayList(); { - String synonymsParam04 = "car"; + String synonyms_03 = "car"; - synonyms3.add(synonymsParam04); - String synonymsParam14 = "vehicule"; + synonyms2.add(synonyms_03); + String synonyms_13 = "vehicule"; - synonyms3.add(synonymsParam14); - String synonymsParam24 = "auto"; + synonyms2.add(synonyms_13); + String synonyms_23 = "auto"; - synonyms3.add(synonymsParam24); + synonyms2.add(synonyms_23); } - synonymHitParam02.setSynonyms(synonyms3); + synonymHit_01.setSynonyms(synonyms2); } - synonymHit1.add(synonymHitParam02); + synonymHit0.add(synonymHit_01); - SynonymHit synonymHitParam12 = new SynonymHit(); + SynonymHit synonymHit_11 = new SynonymHit(); { - String objectID3 = "id2"; + String objectID2 = "id2"; - synonymHitParam12.setObjectID(objectID3); + synonymHit_11.setObjectID(objectID2); - SynonymType type3 = SynonymType.fromValue("onewaysynonym"); + SynonymType type2 = SynonymType.fromValue("onewaysynonym"); - synonymHitParam12.setType(type3); - String input3 = "iphone"; + synonymHit_11.setType(type2); + String input2 = "iphone"; - synonymHitParam12.setInput(input3); + synonymHit_11.setInput(input2); - List synonyms3 = new ArrayList(); + List synonyms2 = new ArrayList(); { - String synonymsParam04 = "ephone"; + String synonyms_03 = "ephone"; - synonyms3.add(synonymsParam04); - String synonymsParam14 = "aphone"; + synonyms2.add(synonyms_03); + String synonyms_13 = "aphone"; - synonyms3.add(synonymsParam14); - String synonymsParam24 = "yphone"; + synonyms2.add(synonyms_13); + String synonyms_23 = "yphone"; - synonyms3.add(synonymsParam24); + synonyms2.add(synonyms_23); } - synonymHitParam12.setSynonyms(synonyms3); + synonymHit_11.setSynonyms(synonyms2); } - synonymHit1.add(synonymHitParam12); + synonymHit0.add(synonymHit_11); } - boolean forwardToReplicas1 = true; + boolean forwardToReplicas0 = true; - boolean replaceExistingSynonyms1 = false; + boolean replaceExistingSynonyms0 = false; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { return client.saveSynonyms( - indexName1, - synonymHit1, - forwardToReplicas1, - replaceExistingSynonyms1 + indexName0, + synonymHit0, + forwardToReplicas0, + replaceExistingSynonyms0 ); } ); @@ -1700,7 +1699,7 @@ void saveSynonymsTest0() { ); }); - HashMap expectedQuery = json.deserialize( + HashMap expectedQuery = JSON.deserialize( "{\"forwardToReplicas\":\"true\",\"replaceExistingSynonyms\":\"false\"}", new TypeToken>() {}.getType() ); @@ -1713,17 +1712,17 @@ void saveSynonymsTest0() { @Test @DisplayName("search") void searchTest0() { - String indexName1 = "indexName"; + String indexName0 = "indexName"; - SearchParams searchParams1 = new SearchParams(); + SearchParamsObject searchParams0 = new SearchParamsObject(); { - String query2 = "myQuery"; + String query1 = "myQuery"; - searchParams1.setQuery(query2); + searchParams0.setQuery(query1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.search(indexName1, searchParams1); + return client.search(indexName0, SearchParams.of(searchParams0)); } ); @@ -1742,19 +1741,19 @@ void searchTest0() { @Test @DisplayName("get searchDictionaryEntries results with minimal parameters") void searchDictionaryEntriesTest0() { - String dictionaryName1 = "compounds"; + DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); - SearchDictionaryEntriesParams searchDictionaryEntriesParams1 = new SearchDictionaryEntriesParams(); + SearchDictionaryEntriesParams searchDictionaryEntriesParams0 = new SearchDictionaryEntriesParams(); { - String query2 = "foo"; + String query1 = "foo"; - searchDictionaryEntriesParams1.setQuery(query2); + searchDictionaryEntriesParams0.setQuery(query1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { return client.searchDictionaryEntries( - dictionaryName1, - searchDictionaryEntriesParams1 + dictionaryName0, + searchDictionaryEntriesParams0 ); } ); @@ -1774,30 +1773,30 @@ void searchDictionaryEntriesTest0() { @Test @DisplayName("get searchDictionaryEntries results with all parameters") void searchDictionaryEntriesTest1() { - String dictionaryName1 = "compounds"; + DictionaryType dictionaryName0 = DictionaryType.fromValue("compounds"); - SearchDictionaryEntriesParams searchDictionaryEntriesParams1 = new SearchDictionaryEntriesParams(); + SearchDictionaryEntriesParams searchDictionaryEntriesParams0 = new SearchDictionaryEntriesParams(); { - String query2 = "foo"; + String query1 = "foo"; - searchDictionaryEntriesParams1.setQuery(query2); + searchDictionaryEntriesParams0.setQuery(query1); - int page2 = 4; + int page1 = 4; - searchDictionaryEntriesParams1.setPage(page2); + searchDictionaryEntriesParams0.setPage(page1); - int hitsPerPage2 = 2; + int hitsPerPage1 = 2; - searchDictionaryEntriesParams1.setHitsPerPage(hitsPerPage2); - String language2 = "fr"; + searchDictionaryEntriesParams0.setHitsPerPage(hitsPerPage1); + String language1 = "fr"; - searchDictionaryEntriesParams1.setLanguage(language2); + searchDictionaryEntriesParams0.setLanguage(language1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { return client.searchDictionaryEntries( - dictionaryName1, - searchDictionaryEntriesParams1 + dictionaryName0, + searchDictionaryEntriesParams0 ); } ); @@ -1817,12 +1816,12 @@ void searchDictionaryEntriesTest1() { @Test @DisplayName("get searchForFacetValues results with minimal parameters") void searchForFacetValuesTest0() { - String indexName1 = "indexName"; + String indexName0 = "indexName"; - String facetName1 = "facetName"; + String facetName0 = "facetName"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchForFacetValues(indexName1, facetName1); + return client.searchForFacetValues(indexName0, facetName0); } ); @@ -1833,29 +1832,29 @@ void searchForFacetValuesTest0() { @Test @DisplayName("get searchForFacetValues results with all parameters") void searchForFacetValuesTest1() { - String indexName1 = "indexName"; + String indexName0 = "indexName"; - String facetName1 = "facetName"; + String facetName0 = "facetName"; - SearchForFacetValuesRequest searchForFacetValuesRequest1 = new SearchForFacetValuesRequest(); + SearchForFacetValuesRequest searchForFacetValuesRequest0 = new SearchForFacetValuesRequest(); { - String params2 = "query=foo&facetFilters=['bar']"; + String params1 = "query=foo&facetFilters=['bar']"; - searchForFacetValuesRequest1.setParams(params2); - String facetQuery2 = "foo"; + searchForFacetValuesRequest0.setParams(params1); + String facetQuery1 = "foo"; - searchForFacetValuesRequest1.setFacetQuery(facetQuery2); + searchForFacetValuesRequest0.setFacetQuery(facetQuery1); - int maxFacetHits2 = 42; + int maxFacetHits1 = 42; - searchForFacetValuesRequest1.setMaxFacetHits(maxFacetHits2); + searchForFacetValuesRequest0.setMaxFacetHits(maxFacetHits1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { return client.searchForFacetValues( - indexName1, - facetName1, - searchForFacetValuesRequest1 + indexName0, + facetName0, + searchForFacetValuesRequest0 ); } ); @@ -1875,17 +1874,17 @@ void searchForFacetValuesTest1() { @Test @DisplayName("searchRules") void searchRulesTest0() { - String indexName1 = "indexName"; + String indexName0 = "indexName"; - SearchRulesParams searchRulesParams1 = new SearchRulesParams(); + SearchRulesParams searchRulesParams0 = new SearchRulesParams(); { - String query2 = "something"; + String query1 = "something"; - searchRulesParams1.setQuery(query2); + searchRulesParams0.setQuery(query1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchRules(indexName1, searchRulesParams1); + return client.searchRules(indexName0, searchRulesParams0); } ); @@ -1904,10 +1903,10 @@ void searchRulesTest0() { @Test @DisplayName("searchSynonyms") void searchSynonymsTest0() { - String indexName1 = "indexName"; + String indexName0 = "indexName"; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchSynonyms(indexName1); + return client.searchSynonyms(indexName0); } ); @@ -1918,26 +1917,26 @@ void searchSynonymsTest0() { @Test @DisplayName("searchUserIds") void searchUserIdsTest0() { - SearchUserIdsParams param0 = new SearchUserIdsParams(); + SearchUserIdsParams searchUserIdsParams0 = new SearchUserIdsParams(); { String query1 = "test"; - param0.setQuery(query1); + searchUserIdsParams0.setQuery(query1); String clusterName1 = "theClusterName"; - param0.setClusterName(clusterName1); + searchUserIdsParams0.setClusterName(clusterName1); int page1 = 5; - param0.setPage(page1); + searchUserIdsParams0.setPage(page1); int hitsPerPage1 = 10; - param0.setHitsPerPage(hitsPerPage1); + searchUserIdsParams0.setHitsPerPage(hitsPerPage1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.searchUserIds(param0); + return client.searchUserIds(searchUserIdsParams0); } ); @@ -1956,7 +1955,7 @@ void searchUserIdsTest0() { @Test @DisplayName("get setDictionarySettings results with minimal parameters") void setDictionarySettingsTest0() { - DictionarySettingsParams param0 = new DictionarySettingsParams(); + DictionarySettingsParams dictionarySettingsParams0 = new DictionarySettingsParams(); { StandardEntries disableStandardEntries1 = new StandardEntries(); { @@ -1976,11 +1975,13 @@ void setDictionarySettingsTest0() { } disableStandardEntries1.setPlurals(plurals2); } - param0.setDisableStandardEntries(disableStandardEntries1); + dictionarySettingsParams0.setDisableStandardEntries( + disableStandardEntries1 + ); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.setDictionarySettings(param0); + return client.setDictionarySettings(dictionarySettingsParams0); } ); @@ -1999,7 +2000,7 @@ void setDictionarySettingsTest0() { @Test @DisplayName("get setDictionarySettings results with all parameters") void setDictionarySettingsTest1() { - DictionarySettingsParams param0 = new DictionarySettingsParams(); + DictionarySettingsParams dictionarySettingsParams0 = new DictionarySettingsParams(); { StandardEntries disableStandardEntries1 = new StandardEntries(); { @@ -2035,11 +2036,13 @@ void setDictionarySettingsTest1() { } disableStandardEntries1.setCompounds(compounds2); } - param0.setDisableStandardEntries(disableStandardEntries1); + dictionarySettingsParams0.setDisableStandardEntries( + disableStandardEntries1 + ); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.setDictionarySettings(param0); + return client.setDictionarySettings(dictionarySettingsParams0); } ); @@ -2058,22 +2061,22 @@ void setDictionarySettingsTest1() { @Test @DisplayName("setSettings") void setSettingsTest0() { - String indexName1 = "theIndexName"; + String indexName0 = "theIndexName"; - IndexSettings indexSettings1 = new IndexSettings(); + IndexSettings indexSettings0 = new IndexSettings(); { - int paginationLimitedTo2 = 10; + int paginationLimitedTo1 = 10; - indexSettings1.setPaginationLimitedTo(paginationLimitedTo2); + indexSettings0.setPaginationLimitedTo(paginationLimitedTo1); } - boolean forwardToReplicas1 = true; + boolean forwardToReplicas0 = true; EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { return client.setSettings( - indexName1, - indexSettings1, - forwardToReplicas1 + indexName0, + indexSettings0, + forwardToReplicas0 ); } ); @@ -2089,7 +2092,7 @@ void setSettingsTest0() { ); }); - HashMap expectedQuery = json.deserialize( + HashMap expectedQuery = JSON.deserialize( "{\"forwardToReplicas\":\"true\"}", new TypeToken>() {}.getType() ); @@ -2102,37 +2105,38 @@ void setSettingsTest0() { @Test @DisplayName("updateApiKey") void updateApiKeyTest0() { - String key1 = "myApiKey"; + String key0 = "myApiKey"; - ApiKey apiKey1 = new ApiKey(); + ApiKey apiKey0 = new ApiKey(); { - List acl2 = new ArrayList(); + List acl1 = new ArrayList(); { - String aclParam03 = "search"; + Acl acl_02 = Acl.fromValue("search"); - acl2.add(aclParam03); - String aclParam13 = "addObject"; + acl1.add(acl_02); - acl2.add(aclParam13); + Acl acl_12 = Acl.fromValue("addObject"); + + acl1.add(acl_12); } - apiKey1.setAcl(acl2); + apiKey0.setAcl(acl1); - int validity2 = 300; + int validity1 = 300; - apiKey1.setValidity(validity2); + apiKey0.setValidity(validity1); - int maxQueriesPerIPPerHour2 = 100; + int maxQueriesPerIPPerHour1 = 100; - apiKey1.setMaxQueriesPerIPPerHour(maxQueriesPerIPPerHour2); + apiKey0.setMaxQueriesPerIPPerHour(maxQueriesPerIPPerHour1); - int maxHitsPerQuery2 = 20; + int maxHitsPerQuery1 = 20; - apiKey1.setMaxHitsPerQuery(maxHitsPerQuery2); + apiKey0.setMaxHitsPerQuery(maxHitsPerQuery1); } EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { - return client.updateApiKey(key1, apiKey1); + return client.updateApiKey(key0, apiKey0); } ); diff --git a/tests/output/javascript/src/methods/requests/search.test.ts b/tests/output/javascript/src/methods/requests/search.test.ts index d0f3780f81..125edae37e 100644 --- a/tests/output/javascript/src/methods/requests/search.test.ts +++ b/tests/output/javascript/src/methods/requests/search.test.ts @@ -81,26 +81,14 @@ describe('batch', () => { const req = (await client.batch({ indexName: 'theIndexName', batchWriteParams: { - requests: [ - { - action: 'delete', - body: { key: 'value' }, - indexName: 'otherIndexName', - }, - ], + requests: [{ action: 'delete', body: { key: 'value' } }], }, })) as unknown as EchoResponse; expect(req.path).toEqual('/1/indexes/theIndexName/batch'); expect(req.method).toEqual('POST'); expect(req.data).toEqual({ - requests: [ - { - action: 'delete', - body: { key: 'value' }, - indexName: 'otherIndexName', - }, - ], + requests: [{ action: 'delete', body: { key: 'value' } }], }); expect(req.searchParams).toEqual(undefined); }); @@ -160,9 +148,9 @@ describe('batchDictionaryEntries', () => { body: { objectID: '1', language: 'en', - word: 'yo', - words: ['yo', 'algolia'], - decomposition: ['yo', 'algolia'], + word: 'fancy', + words: ['believe', 'algolia'], + decomposition: ['trust', 'algolia'], state: 'enabled', }, }, @@ -171,9 +159,9 @@ describe('batchDictionaryEntries', () => { body: { objectID: '2', language: 'fr', - word: 'salut', - words: ['salut', 'algolia'], - decomposition: ['salut', 'algolia'], + word: 'humility', + words: ['candor', 'algolia'], + decomposition: ['grit', 'algolia'], state: 'enabled', }, }, @@ -191,9 +179,9 @@ describe('batchDictionaryEntries', () => { body: { objectID: '1', language: 'en', - word: 'yo', - words: ['yo', 'algolia'], - decomposition: ['yo', 'algolia'], + word: 'fancy', + words: ['believe', 'algolia'], + decomposition: ['trust', 'algolia'], state: 'enabled', }, }, @@ -202,9 +190,9 @@ describe('batchDictionaryEntries', () => { body: { objectID: '2', language: 'fr', - word: 'salut', - words: ['salut', 'algolia'], - decomposition: ['salut', 'algolia'], + word: 'humility', + words: ['candor', 'algolia'], + decomposition: ['grit', 'algolia'], state: 'enabled', }, }, @@ -759,7 +747,7 @@ describe('partialUpdateObject', () => { const req = (await client.partialUpdateObject({ indexName: 'theIndexName', objectID: 'uniqueID', - stringBuiltInOperation: [ + attributeOrBuiltInOperation: [ { id1: 'test', id2: { _operation: 'AddUnique', value: 'test2' } }, ], createIfNotExists: true, diff --git a/tests/output/javascript/tsconfig.json b/tests/output/javascript/tsconfig.json index c5cb759b73..4e3e73f4b3 100644 --- a/tests/output/javascript/tsconfig.json +++ b/tests/output/javascript/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../../base.tsconfig.json", + "extends": "../../../config/base.tsconfig.json", "compilerOptions": { "typeRoots": ["../../../node_modules/@types"], "types": ["node", "jest"],