From 459132ebca58838ea354d56cc8b88fe6e3e0c2a7 Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Wed, 15 Dec 2021 14:33:44 +0100 Subject: [PATCH 01/11] feat: add keys endpoints to search client --- .../client-search/model/addApiKeyResponse.ts | 10 + .../client-search/model/apiKey.ts | 54 +++++ .../model/deleteApiKeyResponse.ts | 6 + .../client-search/model/keyObject.ts | 4 + .../client-search/model/keyObjectAllOf.ts | 6 + .../model/listApiKeysResponse.ts | 8 + .../client-search/model/models.ts | 7 + .../model/updateApiKeyResponse.ts | 10 + .../client-search/src/searchApi.ts | 194 ++++++++++++++++++ openapitools.json | 1 + specs/common/parameters.yml | 5 + specs/search/paths/keys/common/parameters.yml | 6 + specs/search/paths/keys/common/schemas.yml | 119 +++++++++++ specs/search/paths/keys/key.yml | 74 +++++++ specs/search/paths/keys/keys.yml | 47 +++++ specs/search/paths/keys/restoreApiKey.yml | 22 ++ specs/search/spec.yml | 12 +- 17 files changed, 579 insertions(+), 6 deletions(-) create mode 100644 clients/algoliasearch-client-javascript/client-search/model/addApiKeyResponse.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/apiKey.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/deleteApiKeyResponse.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/keyObject.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/keyObjectAllOf.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/listApiKeysResponse.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/updateApiKeyResponse.ts create mode 100644 specs/search/paths/keys/common/parameters.yml create mode 100644 specs/search/paths/keys/common/schemas.yml diff --git a/clients/algoliasearch-client-javascript/client-search/model/addApiKeyResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/addApiKeyResponse.ts new file mode 100644 index 0000000000..297c85db6e --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/addApiKeyResponse.ts @@ -0,0 +1,10 @@ +export type AddApiKeyResponse = { + /** + * Key string. + */ + key: string; + /** + * Date of creation (ISO-8601 format). + */ + createdAt: Date; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/apiKey.ts b/clients/algoliasearch-client-javascript/client-search/model/apiKey.ts new file mode 100644 index 0000000000..642228f8d0 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/apiKey.ts @@ -0,0 +1,54 @@ +/** + * Api Key object. + */ +export type ApiKey = { + /** + * Set of permissions associated with the key. + */ + acl: ApiKey.AclEnum[]; + /** + * A comment used to identify a key more easily in the dashboard. It is not interpreted by the API. + */ + description?: string; + /** + * Restrict this new API key to a list of indices or index patterns. If the list is empty, all indices are allowed. + */ + indexes?: string[]; + /** + * Maximum number of hits this API key can retrieve in one query. If zero, no limit is enforced. + */ + maxHitsPerQuery?: number; + /** + * Maximum number of API calls per hour allowed from a given IP address or a user token. + */ + maxQueriesPerIPPerHour?: number; + /** + * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + */ + queryParameters?: string; + /** + * Restrict this new API key to specific referers. If empty or blank, defaults to all referers. + */ + referers?: string[]; + /** + * Validity limit for this key in seconds. The key will automatically be removed after this period of time. + */ + validity?: number; +}; + +export namespace ApiKey { + export enum AclEnum { + Search = 'search', + Browse = 'browse', + AddObject = 'addObject', + DeleteObject = 'deleteObject', + DeleteIndex = 'deleteIndex', + Settings = 'settings', + EditSettings = 'editSettings', + Analytics = 'analytics', + Recommendation = 'recommendation', + ListIndexes = 'listIndexes', + Logs = 'logs', + SeeUnretrievableAttributes = 'seeUnretrievableAttributes', + } +} diff --git a/clients/algoliasearch-client-javascript/client-search/model/deleteApiKeyResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/deleteApiKeyResponse.ts new file mode 100644 index 0000000000..8e09705133 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/deleteApiKeyResponse.ts @@ -0,0 +1,6 @@ +export type DeleteApiKeyResponse = { + /** + * Date of deletion (ISO-8601 format). + */ + deletedAt: Date; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/keyObject.ts b/clients/algoliasearch-client-javascript/client-search/model/keyObject.ts new file mode 100644 index 0000000000..6496b1e3d2 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/keyObject.ts @@ -0,0 +1,4 @@ +import type { ApiKey } from './apiKey'; +import type { KeyObjectAllOf } from './keyObjectAllOf'; + +export type KeyObject = ApiKey & KeyObjectAllOf; diff --git a/clients/algoliasearch-client-javascript/client-search/model/keyObjectAllOf.ts b/clients/algoliasearch-client-javascript/client-search/model/keyObjectAllOf.ts new file mode 100644 index 0000000000..563e655b71 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/keyObjectAllOf.ts @@ -0,0 +1,6 @@ +export type KeyObjectAllOf = { + /** + * Date of creation (ISO-8601 format). + */ + createdAt: Date; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/listApiKeysResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/listApiKeysResponse.ts new file mode 100644 index 0000000000..1efa12e293 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/listApiKeysResponse.ts @@ -0,0 +1,8 @@ +import type { KeyObject } from './keyObject'; + +export type ListApiKeysResponse = { + /** + * List of api keys. + */ + keys: KeyObject[]; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/models.ts b/clients/algoliasearch-client-javascript/client-search/model/models.ts index a832ec3714..e1803096ad 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/models.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/models.ts @@ -1,6 +1,8 @@ /* eslint-disable no-param-reassign */ import type { RequestOptions } from '../utils/types'; +export * from './addApiKeyResponse'; +export * from './apiKey'; export * from './baseIndexSettings'; export * from './baseSearchParams'; export * from './baseSearchResponse'; @@ -8,6 +10,7 @@ export * from './baseSearchResponseFacetsStats'; export * from './batchObject'; export * from './batchResponse'; export * from './clearAllSynonymsResponse'; +export * from './deleteApiKeyResponse'; export * from './deleteIndexResponse'; export * from './deleteSynonymResponse'; export * from './errorBase'; @@ -15,6 +18,9 @@ export * from './highlightResult'; export * from './index'; export * from './indexSettings'; export * from './indexSettingsAsSearchParams'; +export * from './keyObject'; +export * from './keyObjectAllOf'; +export * from './listApiKeysResponse'; export * from './listIndicesResponse'; export * from './multipleQueries'; export * from './multipleQueriesObject'; @@ -37,6 +43,7 @@ export * from './setSettingsResponse'; export * from './snippetResult'; export * from './synonymHit'; export * from './synonymHitHighlightResult'; +export * from './updateApiKeyResponse'; export interface Authentication { /** diff --git a/clients/algoliasearch-client-javascript/client-search/model/updateApiKeyResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/updateApiKeyResponse.ts new file mode 100644 index 0000000000..1a30628a5f --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/updateApiKeyResponse.ts @@ -0,0 +1,10 @@ +export type UpdateApiKeyResponse = { + /** + * Key string. + */ + key: string; + /** + * Date of last update (ISO-8601 format). + */ + updatedAt: Date; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts b/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts index 0fd22b66f8..b965f9a1a2 100644 --- a/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts +++ b/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts @@ -1,9 +1,14 @@ +import type { AddApiKeyResponse } from '../model/addApiKeyResponse'; +import type { ApiKey } from '../model/apiKey'; import type { BatchObject } from '../model/batchObject'; import type { BatchResponse } from '../model/batchResponse'; import type { ClearAllSynonymsResponse } from '../model/clearAllSynonymsResponse'; +import type { DeleteApiKeyResponse } from '../model/deleteApiKeyResponse'; import type { DeleteIndexResponse } from '../model/deleteIndexResponse'; import type { DeleteSynonymResponse } from '../model/deleteSynonymResponse'; import type { IndexSettings } from '../model/indexSettings'; +import type { KeyObject } from '../model/keyObject'; +import type { ListApiKeysResponse } from '../model/listApiKeysResponse'; import type { ListIndicesResponse } from '../model/listIndicesResponse'; import { ApiKeyAuth } from '../model/models'; import type { MultipleQueriesObject } from '../model/multipleQueriesObject'; @@ -19,6 +24,7 @@ import type { SearchResponse } from '../model/searchResponse'; import type { SearchSynonymsResponse } from '../model/searchSynonymsResponse'; import type { SetSettingsResponse } from '../model/setSettingsResponse'; import type { SynonymHit } from '../model/synonymHit'; +import type { UpdateApiKeyResponse } from '../model/updateApiKeyResponse'; import { Transporter } from '../utils/Transporter'; import { shuffle } from '../utils/helpers'; import type { Requester } from '../utils/requester/Requester'; @@ -114,6 +120,36 @@ export class SearchApi { this.authentications[SearchApiKeys[key]].apiKey = value; } + /** + * Add a new API Key with specific permissions/restrictions. + * + * @summary Create a new API key. + * @param apiKey - The apiKey. + */ + addApiKey(apiKey: ApiKey): Promise { + const path = '/1/keys'; + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (apiKey === null || apiKey === undefined) { + throw new Error( + 'Required parameter apiKey was null or undefined when calling addApiKey.' + ); + } + + const request: Request = { + method: 'POST', + path, + data: apiKey, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * Performs multiple write operations in a single API call. * @@ -193,6 +229,38 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * Delete an existing API Key. + * + * @summary Delete an API key. + * @param key - API Key string. + */ + deleteApiKey(key: string): Promise { + const path = '/1/keys/{key}'.replace( + '{key}', + encodeURIComponent(String(key)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (key === null || key === undefined) { + throw new Error( + 'Required parameter key was null or undefined when calling deleteApiKey.' + ); + } + + const request: Request = { + method: 'DELETE', + path, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * Delete an existing index. * @@ -272,6 +340,38 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * Get the permissions of an API key. + * + * @summary Get an API key. + * @param key - API Key string. + */ + getApiKey(key: string): Promise { + const path = '/1/keys/{key}'.replace( + '{key}', + encodeURIComponent(String(key)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (key === null || key === undefined) { + throw new Error( + 'Required parameter key was null or undefined when calling getApiKey.' + ); + } + + const request: Request = { + method: 'GET', + path, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * Retrieve settings of a given indexName. * @@ -341,6 +441,28 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * List API keys, along with their associated rights. + * + * @summary Get the full list of API Keys. + */ + listApiKeys(): Promise { + const path = '/1/keys'; + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + const request: Request = { + method: 'GET', + path, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * List existing indexes from an application. * @@ -442,6 +564,38 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * Restore a deleted API key, along with its associated rights. + * + * @summary Restore an API key. + * @param key - API Key string. + */ + restoreApiKey(key: string): Promise { + const path = '/1/keys/{key}/restore'.replace( + '{key}', + encodeURIComponent(String(key)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (key === null || key === undefined) { + throw new Error( + 'Required parameter key was null or undefined when calling restoreApiKey.' + ); + } + + const request: Request = { + method: 'POST', + path, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * Add an object to the index, automatically assigning it an object ID. * @@ -750,6 +904,46 @@ export class SearchApi { queryParameters, }; + return this.sendRequest(request, requestOptions); + } + /** + * Replace every permission of an existing API key. + * + * @summary Update an API key. + * @param key - API Key string. + * @param apiKey - The apiKey. + */ + updateApiKey(key: string, apiKey: ApiKey): Promise { + const path = '/1/keys/{key}'.replace( + '{key}', + encodeURIComponent(String(key)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (key === null || key === undefined) { + throw new Error( + 'Required parameter key was null or undefined when calling updateApiKey.' + ); + } + + if (apiKey === null || apiKey === undefined) { + throw new Error( + 'Required parameter apiKey was null or undefined when calling updateApiKey.' + ); + } + + const request: Request = { + method: 'PUT', + path, + data: apiKey, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + return this.sendRequest(request, requestOptions); } } diff --git a/openapitools.json b/openapitools.json index 860cd53e01..682bd678a1 100644 --- a/openapitools.json +++ b/openapitools.json @@ -13,6 +13,7 @@ "gitHost": "algolia", "gitUserId": "algolia", "gitRepoId": "algoliasearch-client-javascript", + "reservedWordsMappings": "queryParameters=queryParameters", "additionalProperties": { "modelPropertyNaming": "original", "supportsES6": true, diff --git a/specs/common/parameters.yml b/specs/common/parameters.yml index 7034d231c1..053e57d876 100644 --- a/specs/common/parameters.yml +++ b/specs/common/parameters.yml @@ -83,6 +83,11 @@ abTestVariantID: type: integer description: If a search encounters an index that is being A/B tested, abTestVariantID reports the variant ID of the index used. +createdAt: + type: string + format: date-time + description: Date of creation (ISO-8601 format). + updatedAt: type: string format: date-time diff --git a/specs/search/paths/keys/common/parameters.yml b/specs/search/paths/keys/common/parameters.yml new file mode 100644 index 0000000000..550fd5e62f --- /dev/null +++ b/specs/search/paths/keys/common/parameters.yml @@ -0,0 +1,6 @@ +KeyString: + in: path + name: key + schema: + type: string + description: API Key string. diff --git a/specs/search/paths/keys/common/schemas.yml b/specs/search/paths/keys/common/schemas.yml new file mode 100644 index 0000000000..5a37e4515f --- /dev/null +++ b/specs/search/paths/keys/common/schemas.yml @@ -0,0 +1,119 @@ +apiKey: + type: object + description: Api Key object. + additionalProperties: false + properties: + acl: + type: array + description: Set of permissions associated with the key. + default: [] + items: + type: string + enum: + [ + 'search', + 'browse', + 'addObject', + 'deleteObject', + 'deleteIndex', + 'settings', + 'editSettings', + 'analytics', + 'recommendation', + 'listIndexes', + 'logs', + 'seeUnretrievableAttributes', + ] + description: + type: string + description: A comment used to identify a key more easily in the dashboard. It is not interpreted by the API. + default: '' + indexes: + type: array + description: Restrict this new API key to a list of indices or index patterns. If the list is empty, all indices are allowed. + default: [] + items: + type: string + maxHitsPerQuery: + type: integer + description: Maximum number of hits this API key can retrieve in one query. If zero, no limit is enforced. + default: 0 + maxQueriesPerIPPerHour: + type: integer + description: Maximum number of API calls per hour allowed from a given IP address or a user token. + default: 0 + queryParameters: + type: string + description: URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + default: '' + referers: + type: array + description: Restrict this new API key to specific referers. If empty or blank, defaults to all referers. + default: [] + items: + type: string + validity: + type: integer + description: Validity limit for this key in seconds. The key will automatically be removed after this period of time. + default: 0 + required: + - acl + +keyString: + type: string + description: Key string. + +keyObject: + allOf: + - $ref: '#/apiKey' + - type: object + required: + - createdAt + properties: + createdAt: + $ref: '../../../../common/parameters.yml#/createdAt' + +addApiKeyResponse: + type: object + additionalProperties: false + properties: + key: + $ref: '#/keyString' + createdAt: + $ref: '../../../../common/parameters.yml#/createdAt' + required: + - key + - createdAt + +updateApiKeyResponse: + type: object + additionalProperties: false + properties: + key: + $ref: '#/keyString' + updatedAt: + $ref: '../../../../common/parameters.yml#/updatedAt' + required: + - key + - updatedAt + +deleteApiKeyResponse: + type: object + additionalProperties: false + properties: + deletedAt: + $ref: '../../../../common/parameters.yml#/deleteAt' + required: + - deletedAt + +listApiKeysResponse: + type: object + additionalProperties: false + properties: + keys: + type: array + description: List of api keys. + items: + $ref: '#/keyObject' + required: + - keys diff --git a/specs/search/paths/keys/key.yml b/specs/search/paths/keys/key.yml index 9157e5af9a..734d2444ed 100644 --- a/specs/search/paths/keys/key.yml +++ b/specs/search/paths/keys/key.yml @@ -1,3 +1,77 @@ put: + tags: + - search + operationId: updateApiKey + summary: Update an API key. + description: Replace every permission of an existing API key. + parameters: + - $ref: 'common/parameters.yml#/KeyString' + requestBody: + required: true + content: + application/json: + schema: + $ref: 'common/schemas.yml#/apiKey' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: './common/schemas.yml#/updateApiKeyResponse' + '400': + $ref: '../../../common/responses/BadRequest.yml' + '402': + $ref: '../../../common/responses/FeatureNotEnabled.yml' + '403': + $ref: '../../../common/responses/MethodNotAllowed.yml' + '404': + $ref: '../../../common/responses/IndexNotFound.yml' + get: + tags: + - search + operationId: getApiKey + summary: Get an API key. + description: Get the permissions of an API key. + parameters: + - $ref: 'common/parameters.yml#/KeyString' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: './common/schemas.yml#/keyObject' + '400': + $ref: '../../../common/responses/BadRequest.yml' + '402': + $ref: '../../../common/responses/FeatureNotEnabled.yml' + '403': + $ref: '../../../common/responses/MethodNotAllowed.yml' + '404': + $ref: '../../../common/responses/IndexNotFound.yml' + delete: + tags: + - search + operationId: deleteApiKey + summary: Delete an API key. + description: Delete an existing API Key. + parameters: + - $ref: 'common/parameters.yml#/KeyString' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: './common/schemas.yml#/deleteApiKeyResponse' + '400': + $ref: '../../../common/responses/BadRequest.yml' + '402': + $ref: '../../../common/responses/FeatureNotEnabled.yml' + '403': + $ref: '../../../common/responses/MethodNotAllowed.yml' + '404': + $ref: '../../../common/responses/IndexNotFound.yml' diff --git a/specs/search/paths/keys/keys.yml b/specs/search/paths/keys/keys.yml index 9791372547..e6e08ee595 100644 --- a/specs/search/paths/keys/keys.yml +++ b/specs/search/paths/keys/keys.yml @@ -1,2 +1,49 @@ post: + tags: + - search + operationId: addApiKey + summary: Create a new API key. + description: Add a new API Key with specific permissions/restrictions. + requestBody: + required: true + content: + application/json: + schema: + $ref: 'common/schemas.yml#/apiKey' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: 'common/schemas.yml#/addApiKeyResponse' + '400': + $ref: '../../../common/responses/BadRequest.yml' + '402': + $ref: '../../../common/responses/FeatureNotEnabled.yml' + '403': + $ref: '../../../common/responses/MethodNotAllowed.yml' + '404': + $ref: '../../../common/responses/IndexNotFound.yml' + get: + tags: + - search + operationId: listApiKeys + summary: Get the full list of API Keys. + description: List API keys, along with their associated rights. + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: './common/schemas.yml#/listApiKeysResponse' + '400': + $ref: '../../../common/responses/BadRequest.yml' + '402': + $ref: '../../../common/responses/FeatureNotEnabled.yml' + '403': + $ref: '../../../common/responses/MethodNotAllowed.yml' + '404': + $ref: '../../../common/responses/IndexNotFound.yml' diff --git a/specs/search/paths/keys/restoreApiKey.yml b/specs/search/paths/keys/restoreApiKey.yml index 6adb517bf4..4725874430 100644 --- a/specs/search/paths/keys/restoreApiKey.yml +++ b/specs/search/paths/keys/restoreApiKey.yml @@ -1 +1,23 @@ post: + tags: + - search + operationId: restoreApiKey + summary: Restore an API key. + description: Restore a deleted API key, along with its associated rights. + parameters: + - $ref: 'common/parameters.yml#/KeyString' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: './common/schemas.yml#/addApiKeyResponse' + '400': + $ref: '../../../common/responses/BadRequest.yml' + '402': + $ref: '../../../common/responses/FeatureNotEnabled.yml' + '403': + $ref: '../../../common/responses/MethodNotAllowed.yml' + '404': + $ref: '../../../common/responses/IndexNotFound.yml' diff --git a/specs/search/spec.yml b/specs/search/spec.yml index 778518685f..318c04ad22 100644 --- a/specs/search/spec.yml +++ b/specs/search/spec.yml @@ -68,12 +68,12 @@ paths: # ###################### # ### Keys Endpoints ### # ###################### - # /1/keys: - # $ref: './paths/keys/keys.yml' - # /1/keys/{key}: - # $ref: './paths/keys/key.yml' - # /1/keys/{key}/restore: - # $ref: './paths/keys/restoreApiKey.yml' + /1/keys: + $ref: './paths/keys/keys.yml' + /1/keys/{key}: + $ref: './paths/keys/key.yml' + /1/keys/{key}/restore: + $ref: './paths/keys/restoreApiKey.yml' # ####################### # ### Rules Endpoints ### From 050991ff6af4fc140459f35838136284e11873de Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Wed, 15 Dec 2021 15:16:19 +0100 Subject: [PATCH 02/11] fix: some changes --- specs/search/paths/keys/common/parameters.yml | 2 + tests/CTS/clients/search/addApiKey.json | 26 ++++ tests/CTS/clients/search/deleteApiKey.json | 12 ++ tests/CTS/clients/search/getApiKey.json | 12 ++ tests/CTS/clients/search/listApiKeys.json | 11 ++ tests/CTS/clients/search/restoreApiKey.json | 13 ++ tests/CTS/clients/search/updateApiKey.json | 25 ++++ tests/output/javascript/search.test.ts | 111 ++++++++++++++---- 8 files changed, 189 insertions(+), 23 deletions(-) create mode 100644 tests/CTS/clients/search/addApiKey.json create mode 100644 tests/CTS/clients/search/deleteApiKey.json create mode 100644 tests/CTS/clients/search/getApiKey.json create mode 100644 tests/CTS/clients/search/listApiKeys.json create mode 100644 tests/CTS/clients/search/restoreApiKey.json create mode 100644 tests/CTS/clients/search/updateApiKey.json diff --git a/specs/search/paths/keys/common/parameters.yml b/specs/search/paths/keys/common/parameters.yml index 550fd5e62f..c74e1f51ca 100644 --- a/specs/search/paths/keys/common/parameters.yml +++ b/specs/search/paths/keys/common/parameters.yml @@ -1,6 +1,8 @@ KeyString: in: path name: key + required: true schema: type: string + example: 'myAPIKey' description: API Key string. diff --git a/tests/CTS/clients/search/addApiKey.json b/tests/CTS/clients/search/addApiKey.json new file mode 100644 index 0000000000..68b04f26ae --- /dev/null +++ b/tests/CTS/clients/search/addApiKey.json @@ -0,0 +1,26 @@ +[ + { + "method": "addApiKey", + "parameters": [ + { + "acl" : ["search", "addObject"], + "description": "my new api key", + "validity": 300, + "maxQueriesPerIPPerHour": 100, + "maxHitsPerQuery": 20 + } + ], + "request": { + "path": "/1/keys", + "method": "POST", + "data": { + "acl" : ["search", "addObject"], + "description": "my new api key", + "validity": 300, + "maxQueriesPerIPPerHour": 100, + "maxHitsPerQuery": 20 + } + } + } +] + \ No newline at end of file diff --git a/tests/CTS/clients/search/deleteApiKey.json b/tests/CTS/clients/search/deleteApiKey.json new file mode 100644 index 0000000000..ae15db1bdf --- /dev/null +++ b/tests/CTS/clients/search/deleteApiKey.json @@ -0,0 +1,12 @@ +[ + { + "method": "deleteApiKey", + "parameters": [ + "myApiKey" + ], + "request": { + "path": "/1/keys/myApiKey", + "method": "DELETE" + } + } +] diff --git a/tests/CTS/clients/search/getApiKey.json b/tests/CTS/clients/search/getApiKey.json new file mode 100644 index 0000000000..fafe514727 --- /dev/null +++ b/tests/CTS/clients/search/getApiKey.json @@ -0,0 +1,12 @@ +[ + { + "method": "getApiKey", + "parameters": [ + "myApiKey" + ], + "request": { + "path": "/1/keys/myApiKey", + "method": "GET" + } + } +] diff --git a/tests/CTS/clients/search/listApiKeys.json b/tests/CTS/clients/search/listApiKeys.json new file mode 100644 index 0000000000..2877329add --- /dev/null +++ b/tests/CTS/clients/search/listApiKeys.json @@ -0,0 +1,11 @@ +[ + { + "method": "listApiKeys", + "parameters": [], + "request": { + "path": "/1/keys", + "method": "GET" + } + } +] + \ No newline at end of file diff --git a/tests/CTS/clients/search/restoreApiKey.json b/tests/CTS/clients/search/restoreApiKey.json new file mode 100644 index 0000000000..6bac2dae90 --- /dev/null +++ b/tests/CTS/clients/search/restoreApiKey.json @@ -0,0 +1,13 @@ +[ + { + "method": "restoreApiKey", + "parameters": [ + "myApiKey" + ], + "request": { + "path": "/1/keys/myApiKey/restore", + "method": "POST" + } + } +] + \ No newline at end of file diff --git a/tests/CTS/clients/search/updateApiKey.json b/tests/CTS/clients/search/updateApiKey.json new file mode 100644 index 0000000000..5edfbaa0f0 --- /dev/null +++ b/tests/CTS/clients/search/updateApiKey.json @@ -0,0 +1,25 @@ +[ + { + "method": "updateApiKey", + "parameters": [ + "myApiKey", + { + "acl" : ["search", "addObject"], + "validity": 300, + "maxQueriesPerIPPerHour": 100, + "maxHitsPerQuery": 20 + } + ], + "request": { + "path": "/1/keys/myApiKey", + "method": "PUT", + "data": { + "acl" : ["search", "addObject"], + "validity": 300, + "maxQueriesPerIPPerHour": 100, + "maxHitsPerQuery": 20 + } + } + } +] + \ No newline at end of file diff --git a/tests/output/javascript/search.test.ts b/tests/output/javascript/search.test.ts index fee71e30f6..e85f743cdc 100644 --- a/tests/output/javascript/search.test.ts +++ b/tests/output/javascript/search.test.ts @@ -42,23 +42,19 @@ describe('Common Test Suite', () => { expect(req).toMatchObject({ path: '/1/indexes/indexName/synonyms/batch', method: 'POST', - data: { - synonymHit: [ - { - objectID: 'id1', - type: 'synonym', - synonyms: ['car', 'vehicule', 'auto'], - }, - { - objectID: 'id2', - type: 'onewaysynonym', - input: 'iphone', - synonyms: ['ephone', 'aphone', 'yphone'], - }, - ], - ForwardToReplicas: true, - ReplaceExistingSynonyms: false, - }, + data: [ + { + objectID: 'id1', + type: 'synonym', + synonyms: ['car', 'vehicule', 'auto'], + }, + { + objectID: 'id2', + type: 'onewaysynonym', + input: 'iphone', + synonyms: ['ephone', 'aphone', 'yphone'], + }, + ], }); }); @@ -79,6 +75,33 @@ describe('Common Test Suite', () => { }); }); + test('', async () => { + const req = await client.updateApiKey('myApiKey', { + acl: ['search', 'addObject'], + validity: 300, + maxQueriesPerIPPerHour: 100, + maxHitsPerQuery: 20, + }); + expect(req).toMatchObject({ + path: '/1/keys/myApiKey', + method: 'PUT', + data: { + acl: ['search', 'addObject'], + validity: 300, + maxQueriesPerIPPerHour: 100, + maxHitsPerQuery: 20, + }, + }); + }); + + test('', async () => { + const req = await client.deleteApiKey('myApiKey'); + expect(req).toMatchObject({ + path: '/1/keys/myApiKey', + method: 'DELETE', + }); + }); + test('clearAllSynonyms', async () => { const req = await client.clearAllSynonyms('indexName'); expect(req).toMatchObject({ @@ -87,6 +110,43 @@ describe('Common Test Suite', () => { }); }); + test('', async () => { + const req = await client.addApiKey({ + acl: ['search', 'addObject'], + description: 'my new api key', + validity: 300, + maxQueriesPerIPPerHour: 100, + maxHitsPerQuery: 20, + }); + expect(req).toMatchObject({ + path: '/1/keys', + method: 'POST', + data: { + acl: ['search', 'addObject'], + description: 'my new api key', + validity: 300, + maxQueriesPerIPPerHour: 100, + maxHitsPerQuery: 20, + }, + }); + }); + + test('', async () => { + const req = await client.restoreApiKey('myApiKey'); + expect(req).toMatchObject({ + path: '/1/keys/myApiKey/restore', + method: 'POST', + }); + }); + + test('', async () => { + const req = await client.getApiKey('myApiKey'); + expect(req).toMatchObject({ + path: '/1/keys/myApiKey', + method: 'GET', + }); + }); + test('deleteSynonym', async () => { const req = await client.deleteSynonym('indexName', 'id1'); expect(req).toMatchObject({ @@ -95,6 +155,14 @@ describe('Common Test Suite', () => { }); }); + test('', async () => { + const req = await client.listApiKeys(); + expect(req).toMatchObject({ + path: '/1/keys', + method: 'GET', + }); + }); + test('saveSynonym', async () => { const req = await client.saveSynonym( 'indexName', @@ -110,12 +178,9 @@ describe('Common Test Suite', () => { path: '/1/indexes/indexName/synonyms/id1', method: 'PUT', data: { - synonymHit: { - objectID: 'id1', - type: 'synonym', - synonyms: ['car', 'vehicule', 'auto'], - }, - ForwardToReplicas: true, + objectID: 'id1', + type: 'synonym', + synonyms: ['car', 'vehicule', 'auto'], }, }); }); From 76b843dd4c74ceba3ed7d9d0167e175bea808ebf Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Wed, 15 Dec 2021 15:35:49 +0100 Subject: [PATCH 03/11] fix: add test names --- tests/output/javascript/search.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/output/javascript/search.test.ts b/tests/output/javascript/search.test.ts index e85f743cdc..92f1dbbec7 100644 --- a/tests/output/javascript/search.test.ts +++ b/tests/output/javascript/search.test.ts @@ -75,7 +75,7 @@ describe('Common Test Suite', () => { }); }); - test('', async () => { + test('updateApiKey', async () => { const req = await client.updateApiKey('myApiKey', { acl: ['search', 'addObject'], validity: 300, @@ -94,7 +94,7 @@ describe('Common Test Suite', () => { }); }); - test('', async () => { + test('deleteApiKey', async () => { const req = await client.deleteApiKey('myApiKey'); expect(req).toMatchObject({ path: '/1/keys/myApiKey', @@ -110,7 +110,7 @@ describe('Common Test Suite', () => { }); }); - test('', async () => { + test('addApiKey', async () => { const req = await client.addApiKey({ acl: ['search', 'addObject'], description: 'my new api key', @@ -131,7 +131,7 @@ describe('Common Test Suite', () => { }); }); - test('', async () => { + test('restoreApiKey', async () => { const req = await client.restoreApiKey('myApiKey'); expect(req).toMatchObject({ path: '/1/keys/myApiKey/restore', @@ -139,7 +139,7 @@ describe('Common Test Suite', () => { }); }); - test('', async () => { + test('getApiKey', async () => { const req = await client.getApiKey('myApiKey'); expect(req).toMatchObject({ path: '/1/keys/myApiKey', @@ -155,7 +155,7 @@ describe('Common Test Suite', () => { }); }); - test('', async () => { + test('listApiKeys', async () => { const req = await client.listApiKeys(); expect(req).toMatchObject({ path: '/1/keys', From 6491d5aa07fa8d6e4aacce1c749a16a6dd57545b Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Thu, 16 Dec 2021 11:31:54 +0100 Subject: [PATCH 04/11] fix: removed non-duplicated responses --- specs/search/paths/keys/common/schemas.yml | 33 ---------------------- specs/search/paths/keys/key.yml | 21 ++++++++++++-- specs/search/paths/keys/keys.yml | 12 +++++++- 3 files changed, 30 insertions(+), 36 deletions(-) diff --git a/specs/search/paths/keys/common/schemas.yml b/specs/search/paths/keys/common/schemas.yml index 5a37e4515f..8cc51a822b 100644 --- a/specs/search/paths/keys/common/schemas.yml +++ b/specs/search/paths/keys/common/schemas.yml @@ -84,36 +84,3 @@ addApiKeyResponse: required: - key - createdAt - -updateApiKeyResponse: - type: object - additionalProperties: false - properties: - key: - $ref: '#/keyString' - updatedAt: - $ref: '../../../../common/parameters.yml#/updatedAt' - required: - - key - - updatedAt - -deleteApiKeyResponse: - type: object - additionalProperties: false - properties: - deletedAt: - $ref: '../../../../common/parameters.yml#/deleteAt' - required: - - deletedAt - -listApiKeysResponse: - type: object - additionalProperties: false - properties: - keys: - type: array - description: List of api keys. - items: - $ref: '#/keyObject' - required: - - keys diff --git a/specs/search/paths/keys/key.yml b/specs/search/paths/keys/key.yml index 734d2444ed..fe08d06dcd 100644 --- a/specs/search/paths/keys/key.yml +++ b/specs/search/paths/keys/key.yml @@ -18,7 +18,17 @@ put: content: application/json: schema: - $ref: './common/schemas.yml#/updateApiKeyResponse' + title: updateApiKeyResponse + type: object + additionalProperties: false + required: + - key + - updatedAt + properties: + key: + $ref: 'common/schemas.yml#/keyString' + updatedAt: + $ref: '../../../common/parameters.yml#/updatedAt' '400': $ref: '../../../common/responses/BadRequest.yml' '402': @@ -66,7 +76,14 @@ delete: content: application/json: schema: - $ref: './common/schemas.yml#/deleteApiKeyResponse' + title: deleteApiKeyResponse + type: object + additionalProperties: false + required: + - deletedAt + properties: + deletedAt: + $ref: '../../../common/parameters.yml#/deleteAt' '400': $ref: '../../../common/responses/BadRequest.yml' '402': diff --git a/specs/search/paths/keys/keys.yml b/specs/search/paths/keys/keys.yml index e6e08ee595..256e89a655 100644 --- a/specs/search/paths/keys/keys.yml +++ b/specs/search/paths/keys/keys.yml @@ -38,7 +38,17 @@ get: content: application/json: schema: - $ref: './common/schemas.yml#/listApiKeysResponse' + title: listApiKeysResponse + type: object + additionalProperties: false + required: + - keys + properties: + keys: + type: array + description: List of api keys. + items: + $ref: 'common/schemas.yml#/keyObject' '400': $ref: '../../../common/responses/BadRequest.yml' '402': From 3522cf60e2f8d7059443e4d8c7039869d7df53cd Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Thu, 16 Dec 2021 11:46:09 +0100 Subject: [PATCH 05/11] fix: keyObject definition --- .../client-search/model/createdAtObject.ts | 6 ++++++ .../client-search/model/keyObject.ts | 4 ++-- .../client-search/model/models.ts | 2 +- specs/search/paths/keys/common/schemas.yml | 15 +++++++++------ 4 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 clients/algoliasearch-client-javascript/client-search/model/createdAtObject.ts diff --git a/clients/algoliasearch-client-javascript/client-search/model/createdAtObject.ts b/clients/algoliasearch-client-javascript/client-search/model/createdAtObject.ts new file mode 100644 index 0000000000..c0881596f3 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/createdAtObject.ts @@ -0,0 +1,6 @@ +export type CreatedAtObject = { + /** + * Date of creation (ISO-8601 format). + */ + createdAt: Date; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/keyObject.ts b/clients/algoliasearch-client-javascript/client-search/model/keyObject.ts index 6496b1e3d2..6eaf9302c1 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/keyObject.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/keyObject.ts @@ -1,4 +1,4 @@ import type { ApiKey } from './apiKey'; -import type { KeyObjectAllOf } from './keyObjectAllOf'; +import type { CreatedAtObject } from './createdAtObject'; -export type KeyObject = ApiKey & KeyObjectAllOf; +export type KeyObject = ApiKey & CreatedAtObject; diff --git a/clients/algoliasearch-client-javascript/client-search/model/models.ts b/clients/algoliasearch-client-javascript/client-search/model/models.ts index e1803096ad..455c2aae96 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/models.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/models.ts @@ -10,6 +10,7 @@ export * from './baseSearchResponseFacetsStats'; export * from './batchObject'; export * from './batchResponse'; export * from './clearAllSynonymsResponse'; +export * from './createdAtObject'; export * from './deleteApiKeyResponse'; export * from './deleteIndexResponse'; export * from './deleteSynonymResponse'; @@ -19,7 +20,6 @@ export * from './index'; export * from './indexSettings'; export * from './indexSettingsAsSearchParams'; export * from './keyObject'; -export * from './keyObjectAllOf'; export * from './listApiKeysResponse'; export * from './listIndicesResponse'; export * from './multipleQueries'; diff --git a/specs/search/paths/keys/common/schemas.yml b/specs/search/paths/keys/common/schemas.yml index 8cc51a822b..aea9a3f425 100644 --- a/specs/search/paths/keys/common/schemas.yml +++ b/specs/search/paths/keys/common/schemas.yml @@ -63,15 +63,18 @@ keyString: type: string description: Key string. +createdAtObject: + type: object + required: + - createdAt + properties: + createdAt: + $ref: '../../../../common/parameters.yml#/createdAt' + keyObject: allOf: - $ref: '#/apiKey' - - type: object - required: - - createdAt - properties: - createdAt: - $ref: '../../../../common/parameters.yml#/createdAt' + - $ref: '#/createdAtObject' addApiKeyResponse: type: object From 83dfade54d2f8895dc26a2c462b22676832908a7 Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Thu, 16 Dec 2021 11:49:34 +0100 Subject: [PATCH 06/11] fix: update tests --- tests/CTS/clients/search/deleteApiKey.json | 4 ++-- tests/CTS/clients/search/getApiKey.json | 4 ++-- tests/output/javascript/search.test.ts | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/CTS/clients/search/deleteApiKey.json b/tests/CTS/clients/search/deleteApiKey.json index ae15db1bdf..d192ef9b37 100644 --- a/tests/CTS/clients/search/deleteApiKey.json +++ b/tests/CTS/clients/search/deleteApiKey.json @@ -2,10 +2,10 @@ { "method": "deleteApiKey", "parameters": [ - "myApiKey" + "myTestApiKey" ], "request": { - "path": "/1/keys/myApiKey", + "path": "/1/keys/myTestApiKey", "method": "DELETE" } } diff --git a/tests/CTS/clients/search/getApiKey.json b/tests/CTS/clients/search/getApiKey.json index fafe514727..b2d22b47cc 100644 --- a/tests/CTS/clients/search/getApiKey.json +++ b/tests/CTS/clients/search/getApiKey.json @@ -2,10 +2,10 @@ { "method": "getApiKey", "parameters": [ - "myApiKey" + "myTestApiKey" ], "request": { - "path": "/1/keys/myApiKey", + "path": "/1/keys/myTestApiKey", "method": "GET" } } diff --git a/tests/output/javascript/search.test.ts b/tests/output/javascript/search.test.ts index 92f1dbbec7..2fd84d64a3 100644 --- a/tests/output/javascript/search.test.ts +++ b/tests/output/javascript/search.test.ts @@ -95,9 +95,9 @@ describe('Common Test Suite', () => { }); test('deleteApiKey', async () => { - const req = await client.deleteApiKey('myApiKey'); + const req = await client.deleteApiKey('myTestApiKey'); expect(req).toMatchObject({ - path: '/1/keys/myApiKey', + path: '/1/keys/myTestApiKey', method: 'DELETE', }); }); @@ -140,9 +140,9 @@ describe('Common Test Suite', () => { }); test('getApiKey', async () => { - const req = await client.getApiKey('myApiKey'); + const req = await client.getApiKey('myTestApiKey'); expect(req).toMatchObject({ - path: '/1/keys/myApiKey', + path: '/1/keys/myTestApiKey', method: 'GET', }); }); From 5230c26bc23b35c62d2b36fe3be59009785575b6 Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Thu, 16 Dec 2021 11:52:21 +0100 Subject: [PATCH 07/11] fix: line breaks --- tests/CTS/clients/search/deleteApiKey.json | 2 ++ tests/CTS/clients/search/getApiKey.json | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/CTS/clients/search/deleteApiKey.json b/tests/CTS/clients/search/deleteApiKey.json index d192ef9b37..ae882c0dee 100644 --- a/tests/CTS/clients/search/deleteApiKey.json +++ b/tests/CTS/clients/search/deleteApiKey.json @@ -10,3 +10,5 @@ } } ] + + diff --git a/tests/CTS/clients/search/getApiKey.json b/tests/CTS/clients/search/getApiKey.json index b2d22b47cc..69b6c8c766 100644 --- a/tests/CTS/clients/search/getApiKey.json +++ b/tests/CTS/clients/search/getApiKey.json @@ -10,3 +10,5 @@ } } ] + + From 587916f4c7e377656094d0f0e7b34e4e51885eb4 Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Thu, 16 Dec 2021 11:55:06 +0100 Subject: [PATCH 08/11] fix: line breaks --- tests/CTS/clients/search/deleteApiKey.json | 1 - tests/CTS/clients/search/getApiKey.json | 1 - 2 files changed, 2 deletions(-) diff --git a/tests/CTS/clients/search/deleteApiKey.json b/tests/CTS/clients/search/deleteApiKey.json index ae882c0dee..7f6b1ddadc 100644 --- a/tests/CTS/clients/search/deleteApiKey.json +++ b/tests/CTS/clients/search/deleteApiKey.json @@ -11,4 +11,3 @@ } ] - diff --git a/tests/CTS/clients/search/getApiKey.json b/tests/CTS/clients/search/getApiKey.json index 69b6c8c766..6cfe88ee19 100644 --- a/tests/CTS/clients/search/getApiKey.json +++ b/tests/CTS/clients/search/getApiKey.json @@ -11,4 +11,3 @@ } ] - From 7d4ab3d1c5ee6a1d6daabf21f50b13809ca923a9 Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Thu, 16 Dec 2021 12:01:00 +0100 Subject: [PATCH 09/11] fix: finish merge --- .../client-search/src/searchApi.ts | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts b/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts index e008bd97f8..87d4ff7eba 100644 --- a/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts +++ b/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts @@ -342,7 +342,6 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } - /** * Get the permissions of an API key. * @@ -374,8 +373,7 @@ export class SearchApi { }; return this.sendRequest(request, requestOptions); - } - + } /** * Return the lastest log entries. * @@ -528,6 +526,28 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * List API keys, along with their associated rights. + * + * @summary Get the full list of API Keys. + */ + listApiKeys(): Promise { + const path = '/1/keys'; + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + const request: Request = { + method: 'GET', + path, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * List existing indexes from an application. * From ea0ea0c42ea800520ff8b988cff5bbc65b4f1026 Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Thu, 16 Dec 2021 14:17:40 +0100 Subject: [PATCH 10/11] fix: last review --- .../client-search/model/apiKey.ts | 12 +++++++----- specs/search/paths/keys/common/schemas.yml | 12 +++++++----- tests/CTS/clients/search/deleteApiKey.json | 1 - tests/CTS/clients/search/getApiKey.json | 1 - 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/clients/algoliasearch-client-javascript/client-search/model/apiKey.ts b/clients/algoliasearch-client-javascript/client-search/model/apiKey.ts index 642228f8d0..b514ca853a 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/apiKey.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/apiKey.ts @@ -38,17 +38,19 @@ export type ApiKey = { export namespace ApiKey { export enum AclEnum { - Search = 'search', - Browse = 'browse', AddObject = 'addObject', + Analytics = 'analytics', + Browse = 'browse', DeleteObject = 'deleteObject', DeleteIndex = 'deleteIndex', - Settings = 'settings', EditSettings = 'editSettings', - Analytics = 'analytics', - Recommendation = 'recommendation', ListIndexes = 'listIndexes', Logs = 'logs', + Personalization = 'personalization', + Recommendation = 'recommendation', + Search = 'search', SeeUnretrievableAttributes = 'seeUnretrievableAttributes', + Settings = 'settings', + Usage = 'usage', } } diff --git a/specs/search/paths/keys/common/schemas.yml b/specs/search/paths/keys/common/schemas.yml index aea9a3f425..6c06e41a4b 100644 --- a/specs/search/paths/keys/common/schemas.yml +++ b/specs/search/paths/keys/common/schemas.yml @@ -11,18 +11,20 @@ apiKey: type: string enum: [ - 'search', - 'browse', 'addObject', + 'analytics', + 'browse', 'deleteObject', 'deleteIndex', - 'settings', 'editSettings', - 'analytics', - 'recommendation', 'listIndexes', 'logs', + 'personalization', + 'recommendation', + 'search', 'seeUnretrievableAttributes', + 'settings', + 'usage', ] description: type: string diff --git a/tests/CTS/clients/search/deleteApiKey.json b/tests/CTS/clients/search/deleteApiKey.json index 7f6b1ddadc..d192ef9b37 100644 --- a/tests/CTS/clients/search/deleteApiKey.json +++ b/tests/CTS/clients/search/deleteApiKey.json @@ -10,4 +10,3 @@ } } ] - diff --git a/tests/CTS/clients/search/getApiKey.json b/tests/CTS/clients/search/getApiKey.json index 6cfe88ee19..b2d22b47cc 100644 --- a/tests/CTS/clients/search/getApiKey.json +++ b/tests/CTS/clients/search/getApiKey.json @@ -10,4 +10,3 @@ } } ] - From e78d10ee24e1eb0074779559ead9285ec214bd44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Vannicatte?= Date: Thu, 16 Dec 2021 14:20:53 +0100 Subject: [PATCH 11/11] fix: json files --- tests/CTS/clients/search/addApiKey.json | 5 ++-- .../CTS/clients/search/clearAllSynonyms.json | 4 +--- tests/CTS/clients/search/deleteApiKey.json | 4 +--- tests/CTS/clients/search/deleteSynonym.json | 5 +--- tests/CTS/clients/search/getApiKey.json | 4 +--- tests/CTS/clients/search/getSynonym.json | 5 +--- tests/CTS/clients/search/listApiKeys.json | 1 - tests/CTS/clients/search/restoreApiKey.json | 5 +--- tests/CTS/clients/search/saveSynonym.json | 12 ++-------- tests/CTS/clients/search/saveSynonyms.json | 24 ++++--------------- tests/CTS/clients/search/searchSynonyms.json | 6 +---- tests/CTS/clients/search/updateApiKey.json | 5 ++-- 12 files changed, 17 insertions(+), 63 deletions(-) diff --git a/tests/CTS/clients/search/addApiKey.json b/tests/CTS/clients/search/addApiKey.json index 68b04f26ae..6f06c6f1d8 100644 --- a/tests/CTS/clients/search/addApiKey.json +++ b/tests/CTS/clients/search/addApiKey.json @@ -3,7 +3,7 @@ "method": "addApiKey", "parameters": [ { - "acl" : ["search", "addObject"], + "acl": ["search", "addObject"], "description": "my new api key", "validity": 300, "maxQueriesPerIPPerHour": 100, @@ -14,7 +14,7 @@ "path": "/1/keys", "method": "POST", "data": { - "acl" : ["search", "addObject"], + "acl": ["search", "addObject"], "description": "my new api key", "validity": 300, "maxQueriesPerIPPerHour": 100, @@ -23,4 +23,3 @@ } } ] - \ No newline at end of file diff --git a/tests/CTS/clients/search/clearAllSynonyms.json b/tests/CTS/clients/search/clearAllSynonyms.json index aef6c4f841..0fc48d2f72 100644 --- a/tests/CTS/clients/search/clearAllSynonyms.json +++ b/tests/CTS/clients/search/clearAllSynonyms.json @@ -1,9 +1,7 @@ [ { "method": "clearAllSynonyms", - "parameters": [ - "indexName" - ], + "parameters": ["indexName"], "request": { "path": "/1/indexes/indexName/synonyms/clear", "method": "POST" diff --git a/tests/CTS/clients/search/deleteApiKey.json b/tests/CTS/clients/search/deleteApiKey.json index d192ef9b37..40500b64f5 100644 --- a/tests/CTS/clients/search/deleteApiKey.json +++ b/tests/CTS/clients/search/deleteApiKey.json @@ -1,9 +1,7 @@ [ { "method": "deleteApiKey", - "parameters": [ - "myTestApiKey" - ], + "parameters": ["myTestApiKey"], "request": { "path": "/1/keys/myTestApiKey", "method": "DELETE" diff --git a/tests/CTS/clients/search/deleteSynonym.json b/tests/CTS/clients/search/deleteSynonym.json index dd4ded6712..f29f8d6279 100644 --- a/tests/CTS/clients/search/deleteSynonym.json +++ b/tests/CTS/clients/search/deleteSynonym.json @@ -1,10 +1,7 @@ [ { "method": "deleteSynonym", - "parameters": [ - "indexName", - "id1" - ], + "parameters": ["indexName", "id1"], "request": { "path": "/1/indexes/indexName/synonyms/id1", "method": "DELETE" diff --git a/tests/CTS/clients/search/getApiKey.json b/tests/CTS/clients/search/getApiKey.json index b2d22b47cc..e6c5bb40e9 100644 --- a/tests/CTS/clients/search/getApiKey.json +++ b/tests/CTS/clients/search/getApiKey.json @@ -1,9 +1,7 @@ [ { "method": "getApiKey", - "parameters": [ - "myTestApiKey" - ], + "parameters": ["myTestApiKey"], "request": { "path": "/1/keys/myTestApiKey", "method": "GET" diff --git a/tests/CTS/clients/search/getSynonym.json b/tests/CTS/clients/search/getSynonym.json index d9744d14e6..8b19584a92 100644 --- a/tests/CTS/clients/search/getSynonym.json +++ b/tests/CTS/clients/search/getSynonym.json @@ -1,10 +1,7 @@ [ { "method": "getSynonym", - "parameters": [ - "indexName", - "id1" - ], + "parameters": ["indexName", "id1"], "request": { "path": "/1/indexes/indexName/synonyms/id1", "method": "GET" diff --git a/tests/CTS/clients/search/listApiKeys.json b/tests/CTS/clients/search/listApiKeys.json index 2877329add..cb50fe1097 100644 --- a/tests/CTS/clients/search/listApiKeys.json +++ b/tests/CTS/clients/search/listApiKeys.json @@ -8,4 +8,3 @@ } } ] - \ No newline at end of file diff --git a/tests/CTS/clients/search/restoreApiKey.json b/tests/CTS/clients/search/restoreApiKey.json index 6bac2dae90..6db1e0419e 100644 --- a/tests/CTS/clients/search/restoreApiKey.json +++ b/tests/CTS/clients/search/restoreApiKey.json @@ -1,13 +1,10 @@ [ { "method": "restoreApiKey", - "parameters": [ - "myApiKey" - ], + "parameters": ["myApiKey"], "request": { "path": "/1/keys/myApiKey/restore", "method": "POST" } } ] - \ No newline at end of file diff --git a/tests/CTS/clients/search/saveSynonym.json b/tests/CTS/clients/search/saveSynonym.json index b09dac23cd..4a07116797 100644 --- a/tests/CTS/clients/search/saveSynonym.json +++ b/tests/CTS/clients/search/saveSynonym.json @@ -7,11 +7,7 @@ { "objectID": "id1", "type": "synonym", - "synonyms": [ - "car", - "vehicule", - "auto" - ] + "synonyms": ["car", "vehicule", "auto"] }, true ], @@ -21,11 +17,7 @@ "data": { "objectID": "id1", "type": "synonym", - "synonyms": [ - "car", - "vehicule", - "auto" - ] + "synonyms": ["car", "vehicule", "auto"] } } } diff --git a/tests/CTS/clients/search/saveSynonyms.json b/tests/CTS/clients/search/saveSynonyms.json index 3823d93b44..03e08326ef 100644 --- a/tests/CTS/clients/search/saveSynonyms.json +++ b/tests/CTS/clients/search/saveSynonyms.json @@ -7,21 +7,13 @@ { "objectID": "id1", "type": "synonym", - "synonyms": [ - "car", - "vehicule", - "auto" - ] + "synonyms": ["car", "vehicule", "auto"] }, { "objectID": "id2", "type": "onewaysynonym", "input": "iphone", - "synonyms": [ - "ephone", - "aphone", - "yphone" - ] + "synonyms": ["ephone", "aphone", "yphone"] } ], true, @@ -34,21 +26,13 @@ { "objectID": "id1", "type": "synonym", - "synonyms": [ - "car", - "vehicule", - "auto" - ] + "synonyms": ["car", "vehicule", "auto"] }, { "objectID": "id2", "type": "onewaysynonym", "input": "iphone", - "synonyms": [ - "ephone", - "aphone", - "yphone" - ] + "synonyms": ["ephone", "aphone", "yphone"] } ] } diff --git a/tests/CTS/clients/search/searchSynonyms.json b/tests/CTS/clients/search/searchSynonyms.json index 758967861f..d3db2bdc51 100644 --- a/tests/CTS/clients/search/searchSynonyms.json +++ b/tests/CTS/clients/search/searchSynonyms.json @@ -1,11 +1,7 @@ [ { "method": "searchSynonyms", - "parameters": [ - "indexName", - "queryString", - "onewaysynonym" - ], + "parameters": ["indexName", "queryString", "onewaysynonym"], "request": { "path": "/1/indexes/indexName/synonyms/search", "method": "POST" diff --git a/tests/CTS/clients/search/updateApiKey.json b/tests/CTS/clients/search/updateApiKey.json index 5edfbaa0f0..8c3c3ebc41 100644 --- a/tests/CTS/clients/search/updateApiKey.json +++ b/tests/CTS/clients/search/updateApiKey.json @@ -4,7 +4,7 @@ "parameters": [ "myApiKey", { - "acl" : ["search", "addObject"], + "acl": ["search", "addObject"], "validity": 300, "maxQueriesPerIPPerHour": 100, "maxHitsPerQuery": 20 @@ -14,7 +14,7 @@ "path": "/1/keys/myApiKey", "method": "PUT", "data": { - "acl" : ["search", "addObject"], + "acl": ["search", "addObject"], "validity": 300, "maxQueriesPerIPPerHour": 100, "maxHitsPerQuery": 20 @@ -22,4 +22,3 @@ } } ] - \ No newline at end of file