diff --git a/clients/algoliasearch-client-javascript/client-search/model/deleteIndexResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/deleteIndexResponse.ts new file mode 100644 index 0000000000..4bc23f433f --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/deleteIndexResponse.ts @@ -0,0 +1,10 @@ +export type DeleteIndexResponse = { + /** + * TaskID of the indexing task to wait for. + */ + taskID?: number; + /** + * Date of deletion (ISO-8601 format). + */ + deleteAt?: Date; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/index.ts b/clients/algoliasearch-client-javascript/client-search/model/index.ts new file mode 100644 index 0000000000..af99e11692 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/index.ts @@ -0,0 +1,46 @@ +export type Index = { + /** + * Index name. + */ + name: string; + /** + * Index creation date. An empty string means that the index has no records. + */ + createdAt: Date; + /** + * Date of last update (ISO-8601 format). + */ + updatedAt: Date; + /** + * Number of records contained in the index. + */ + entries: number; + /** + * Number of bytes of the index in minified format. + */ + dataSize: number; + /** + * Number of bytes of the index binary file. + */ + fileSize: number; + /** + * Last build time. + */ + lastBuildTimeS: number; + /** + * Number of pending indexing operations. This value is deprecated and should not be used. + */ + numberOfPendingTask?: number; + /** + * A boolean which says whether the index has pending tasks. This value is deprecated and should not be used. + */ + pendingTask: boolean; + /** + * Only present if the index is a replica. Contains the name of the related primary index. + */ + primary?: string; + /** + * Only present if the index is a primary index with replicas. Contains the names of all linked replicas. + */ + replicas?: string[]; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/listIndicesObject.ts b/clients/algoliasearch-client-javascript/client-search/model/listIndicesObject.ts new file mode 100644 index 0000000000..2f81bb4ecf --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/listIndicesObject.ts @@ -0,0 +1,6 @@ +export type ListIndicesObject = { + /** + * Requested page (zero-based). When specified, will retrieve a specific page; the page size is implicitly set to 100. When null, will retrieve all indices (no pagination). + */ + page?: number | null; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/listIndicesResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/listIndicesResponse.ts new file mode 100644 index 0000000000..20328d99d5 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/listIndicesResponse.ts @@ -0,0 +1,12 @@ +import type { Index } from './index'; + +export type ListIndicesResponse = { + /** + * List of the fetched indices. + */ + items?: Index[]; + /** + * Number of pages. + */ + nbPages?: number; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/models.ts b/clients/algoliasearch-client-javascript/client-search/model/models.ts index 2ffeadb287..2fb37bde75 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/models.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/models.ts @@ -7,14 +7,19 @@ export * from './baseSearchResponse'; export * from './baseSearchResponseFacetsStats'; export * from './batchObject'; export * from './batchResponse'; +export * from './deleteIndexResponse'; export * from './errorBase'; export * from './highlightResult'; +export * from './index'; export * from './indexSettings'; export * from './indexSettingsAsSearchParams'; +export * from './listIndicesResponse'; export * from './multipleQueries'; export * from './multipleQueriesObject'; export * from './multipleQueriesResponse'; export * from './operation'; +export * from './operationIndexObject'; +export * from './operationIndexResponse'; export * from './rankingInfo'; export * from './rankingInfoMatchedGeoLocation'; export * from './record'; diff --git a/clients/algoliasearch-client-javascript/client-search/model/operationIndexObject.ts b/clients/algoliasearch-client-javascript/client-search/model/operationIndexObject.ts new file mode 100644 index 0000000000..b9e51d1194 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/operationIndexObject.ts @@ -0,0 +1,26 @@ +export type OperationIndexObject = { + /** + * Type of operation to perform (move or copy). + */ + operation: OperationIndexObject.OperationEnum; + /** + * The Algolia index name. + */ + destination: string; + /** + * Scope of the data to copy. When absent, a full copy is performed. When present, only the selected scopes are copied. + */ + scope?: OperationIndexObject.ScopeEnum[]; +}; + +export namespace OperationIndexObject { + export enum OperationEnum { + Move = 'move', + Copy = 'copy', + } + export enum ScopeEnum { + Settings = 'settings', + Synonyms = 'synonyms', + Rules = 'rules', + } +} diff --git a/clients/algoliasearch-client-javascript/client-search/model/operationIndexResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/operationIndexResponse.ts new file mode 100644 index 0000000000..974190a4a1 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/operationIndexResponse.ts @@ -0,0 +1,10 @@ +export type OperationIndexResponse = { + /** + * TaskID of the indexing task to wait for. + */ + taskID?: number; + /** + * 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 aa12cd5e03..f1957f0019 100644 --- a/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts +++ b/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts @@ -1,9 +1,13 @@ import type { BatchObject } from '../model/batchObject'; import type { BatchResponse } from '../model/batchResponse'; +import type { DeleteIndexResponse } from '../model/deleteIndexResponse'; import type { IndexSettings } from '../model/indexSettings'; +import type { ListIndicesResponse } from '../model/listIndicesResponse'; import { ApiKeyAuth } from '../model/models'; import type { MultipleQueriesObject } from '../model/multipleQueriesObject'; import type { MultipleQueriesResponse } from '../model/multipleQueriesResponse'; +import type { OperationIndexObject } from '../model/operationIndexObject'; +import type { OperationIndexResponse } from '../model/operationIndexResponse'; import type { SaveObjectResponse } from '../model/saveObjectResponse'; import type { SearchParams } from '../model/searchParams'; import type { SearchParamsAsString } from '../model/searchParamsAsString'; @@ -142,6 +146,38 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * Delete an existing index. + * + * @summary Delete index. + * @param indexName - The index in which to perform the request. + */ + deleteIndex(indexName: string): Promise { + const path = '/1/indexes/{indexName}'.replace( + '{indexName}', + encodeURIComponent(String(indexName)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (indexName === null || indexName === undefined) { + throw new Error( + 'Required parameter indexName was null or undefined when calling deleteIndex.' + ); + } + + const request: Request = { + method: 'DELETE', + path, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * Retrieve settings of a given indexName. * @@ -173,6 +209,33 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * List existing indexes from an application. + * + * @summary List existing indexes. + * @param page - Requested page (zero-based). When specified, will retrieve a specific page; the page size is implicitly set to 100. When null, will retrieve all indices (no pagination). + */ + listIndices(page?: number): Promise { + const path = '/1/indexes'; + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (page !== undefined) { + queryParameters.Page = page.toString(); + } + + const request: Request = { + method: 'GET', + path, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * Get search results for the given requests. * @@ -204,6 +267,49 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * Peforms a copy or a move operation on a index. + * + * @summary Copy/move index. + * @param indexName - The index in which to perform the request. + * @param operationIndexObject - The operationIndexObject. + */ + operationIndex( + indexName: string, + operationIndexObject: OperationIndexObject + ): Promise { + const path = '/1/indexes/{indexName}/operation'.replace( + '{indexName}', + encodeURIComponent(String(indexName)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (indexName === null || indexName === undefined) { + throw new Error( + 'Required parameter indexName was null or undefined when calling operationIndex.' + ); + } + + if (operationIndexObject === null || operationIndexObject === undefined) { + throw new Error( + 'Required parameter operationIndexObject was null or undefined when calling operationIndex.' + ); + } + + const request: Request = { + method: 'POST', + path, + data: operationIndexObject, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * Add an object to the index, automatically assigning it an object ID. * diff --git a/specs/common/parameters.yml b/specs/common/parameters.yml index 8c86ddbf46..ac0faf7da6 100644 --- a/specs/common/parameters.yml +++ b/specs/common/parameters.yml @@ -16,6 +16,16 @@ ForwardToReplicas: schema: type: boolean +# query +Page: + in: query + name: Page + description: Requested page (zero-based). When specified, will retrieve a specific page; the page size is implicitly set to 100. When null, will retrieve all indices (no pagination). + schema: + type: integer + nullable: true + default: null + # misc taskID: type: integer @@ -49,6 +59,11 @@ updatedAt: format: date-time description: Date of last update (ISO-8601 format). +deleteAt: + type: string + format: date-time + description: Date of deletion (ISO-8601 format). + indexName: type: string example: products diff --git a/specs/search/common/schemas/listIndicesResponse.yml b/specs/search/common/schemas/listIndicesResponse.yml new file mode 100644 index 0000000000..8064e93cba --- /dev/null +++ b/specs/search/common/schemas/listIndicesResponse.yml @@ -0,0 +1,62 @@ +listIndicesResponse: + type: object + additionalProperties: false + properties: + items: + type: array + description: List of the fetched indices. + items: + $ref: '#/index' + nbPages: + type: integer + description: Number of pages. + example: 100 + +index: + type: object + additionalProperties: false + properties: + name: + type: string + description: Index name. + createdAt: + type: string + format: date-time + description: Index creation date. An empty string means that the index has no records. + updatedAt: + $ref: '../../../common/parameters.yml#/updatedAt' + entries: + type: integer + description: Number of records contained in the index. + dataSize: + type: integer + description: Number of bytes of the index in minified format. + fileSize: + type: integer + description: Number of bytes of the index binary file. + lastBuildTimeS: + type: integer + description: Last build time + numberOfPendingTask: + type: integer + description: Number of pending indexing operations. This value is deprecated and should not be used. + pendingTask: + type: boolean + description: A boolean which says whether the index has pending tasks. This value is deprecated and should not be used. + primary: + type: string + description: Only present if the index is a replica. Contains the name of the related primary index. + replicas: + type: array + items: + type: string + description: Only present if the index is a primary index with replicas. Contains the names of all linked replicas. + required: + - name + - createdAt + - updatedAt + - entries + - dataSize + - fileSize + - lastBuildTimeS + - pendingTask diff --git a/specs/search/paths/manage_indices/copyIndex.yml b/specs/search/paths/manage_indices/copyIndex.yml deleted file mode 100644 index 6adb517bf4..0000000000 --- a/specs/search/paths/manage_indices/copyIndex.yml +++ /dev/null @@ -1 +0,0 @@ -post: diff --git a/specs/search/paths/manage_indices/listIndices.yml b/specs/search/paths/manage_indices/listIndices.yml index 3ddb9d7f54..82bf651070 100644 --- a/specs/search/paths/manage_indices/listIndices.yml +++ b/specs/search/paths/manage_indices/listIndices.yml @@ -1 +1,23 @@ get: + tags: + - search + operationId: listIndices + summary: List existing indexes. + description: List existing indexes from an application. + parameters: + - $ref: '../../../common/parameters.yml#/Page' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '../../common/schemas/listIndicesResponse.yml#/listIndicesResponse' + '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/manage_indices/operationIndex.yml b/specs/search/paths/manage_indices/operationIndex.yml new file mode 100644 index 0000000000..e293bd1557 --- /dev/null +++ b/specs/search/paths/manage_indices/operationIndex.yml @@ -0,0 +1,54 @@ +post: + tags: + - search + operationId: operationIndex + summary: Copy/move index. + description: Peforms a copy or a move operation on a index. + parameters: + - $ref: '../../../common/parameters.yml#/IndexName' + requestBody: + required: true + content: + application/json: + schema: + title: operationIndexObject + type: object + additionalProperties: false + properties: + operation: + type: string + enum: ['move', 'copy'] + description: Type of operation to perform (move or copy). + destination: + $ref: '../../../common/parameters.yml#/indexName' + scope: + type: array + items: + type: string + enum: ['settings', 'synonyms', 'rules'] + description: Scope of the data to copy. When absent, a full copy is performed. When present, only the selected scopes are copied. + required: + - operation + - destination + responses: + '200': + description: OK + content: + application/json: + schema: + title: operationIndexResponse + type: object + additionalProperties: false + properties: + taskID: + $ref: '../../../common/parameters.yml#/taskID' + updatedAt: + $ref: '../../../common/parameters.yml#/updatedAt' + '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/objects/objects.yml b/specs/search/paths/objects/objects.yml index e9b965e55b..4058193b6c 100644 --- a/specs/search/paths/objects/objects.yml +++ b/specs/search/paths/objects/objects.yml @@ -38,4 +38,33 @@ post: '404': $ref: '../../../common/responses/IndexNotFound.yml' # delete index -# delete: +delete: + tags: + - search + operationId: deleteIndex + summary: Delete index. + description: Delete an existing index. + parameters: + - $ref: '../../../common/parameters.yml#/IndexName' + responses: + '200': + description: OK + content: + application/json: + schema: + title: deleteIndexResponse + type: object + additionalProperties: false + properties: + taskID: + $ref: '../../../common/parameters.yml#/taskID' + deleteAt: + $ref: '../../../common/parameters.yml#/deleteAt' + '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/search/search.yml b/specs/search/paths/search/search.yml index f7fbc5b340..ac73618d83 100644 --- a/specs/search/paths/search/search.yml +++ b/specs/search/paths/search/search.yml @@ -19,7 +19,6 @@ post: content: application/json: schema: - title: searchResponse $ref: '../../common/schemas/SearchResponse.yml#/searchResponse' '400': $ref: '../../../common/responses/BadRequest.yml' diff --git a/specs/search/paths/settings/settings.yml b/specs/search/paths/settings/settings.yml index 47a10d5b8c..6d252c1785 100644 --- a/specs/search/paths/settings/settings.yml +++ b/specs/search/paths/settings/settings.yml @@ -11,7 +11,6 @@ get: content: application/json: schema: - title: indexSettings $ref: '../../common/schemas/IndexSettings.yml#/indexSettings' '400': $ref: '../../../common/responses/BadRequest.yml' @@ -35,7 +34,6 @@ put: content: application/json: schema: - title: indexSettings $ref: '../../common/schemas/IndexSettings.yml#/indexSettings' responses: '200': diff --git a/specs/search/spec.yml b/specs/search/spec.yml index 5fa9edbf6a..9ca319447a 100644 --- a/specs/search/spec.yml +++ b/specs/search/spec.yml @@ -56,10 +56,10 @@ paths: # ################################ # ### Manage Indices Endpoints ### # ################################ - # /1/indexes/{indexName}/operation: - # $ref: './paths/manage_indices/copyIndex.yml' - # /1/indexes: - # $ref: './paths/manage_indices/listIndices.yml' + /1/indexes/{indexName}/operation: + $ref: './paths/manage_indices/operationIndex.yml' + /1/indexes: + $ref: './paths/manage_indices/listIndices.yml' # # ########################## # ### Synonyms Endpoints ###