Skip to content

feat: (APIC-190) Add manage indices endpoints #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
export type Index = {
/**
* Name of the index
*/
name?: string;
/**
* Date of the index creation. (ISO-8601 format)
*/
createdAt?: Date;
/**
* Date of the index last update. (ISO-8601 format)
*/
updatedAt?: Date;
/**
* Entries in the index
*/
entries?: number;
/**
* data size of the index
*/
dataSize?: number;
/**
* file size of the index
*/
fileSize?: number;
/**
* Last build time
*/
lastBuildTimeS?: number;
/**
* Number of pending tasks
*/
numberOfPendingTask?: number;
/**
* Pending task ?
*/
pendingTask?: boolean;
};
Original file line number Diff line number Diff line change
@@ -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;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Index } from './index';

export type ListIndicesResponse = {
items?: Array<Index>;
/**
* Number of pages
*/
nbPages?: number;
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@ 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 './listIndicesObject';
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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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?: Array<OperationIndexObject.ScopeEnum>;
};

export namespace OperationIndexObject {
export enum OperationEnum {
Move = 'move',
Copy = 'copy',
}
export enum ScopeEnum {
Settings = 'settings',
Synonyms = 'synonyms',
Rules = 'rules',
}
}
Original file line number Diff line number Diff line change
@@ -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;
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
<<<<<<< HEAD
import { shuffle } from '../utils/helpers';
import { Transporter } from '../utils/Transporter';
import { Headers, Host, Request, RequestOptions } from '../utils/types';
import { Requester } from '../utils/requester/Requester';

import { BatchObject } from '../model/batchObject';
import { BatchResponse } from '../model/batchResponse';
import { DeleteIndexResponse } from '../model/deleteIndexResponse';
import { ErrorBase } from '../model/errorBase';
import { IndexSettings } from '../model/indexSettings';
import { ListIndicesObject } from '../model/listIndicesObject';
import { ListIndicesResponse } from '../model/listIndicesResponse';
import { MultipleQueriesObject } from '../model/multipleQueriesObject';
import { MultipleQueriesResponse } from '../model/multipleQueriesResponse';
import { OperationIndexObject } from '../model/operationIndexObject';
import { OperationIndexResponse } from '../model/operationIndexResponse';
import { SaveObjectResponse } from '../model/saveObjectResponse';
import { SearchParams } from '../model/searchParams';
import { SearchParamsAsString } from '../model/searchParamsAsString';
import { SearchResponse } from '../model/searchResponse';
import { SetSettingsResponse } from '../model/setSettingsResponse';
=======
import type { BatchObject } from '../model/batchObject';
import type { BatchResponse } from '../model/batchResponse';
import type { IndexSettings } from '../model/indexSettings';
>>>>>>> main
import { ApiKeyAuth } from '../model/models';
import type { MultipleQueriesObject } from '../model/multipleQueriesObject';
import type { MultipleQueriesResponse } from '../model/multipleQueriesResponse';
Expand Down Expand Up @@ -143,7 +167,41 @@ export class SearchApi {
return this.sendRequest(request, requestOptions);
}
/**
<<<<<<< HEAD
* Delete an existing index.
* @summary delete index
* @param indexName The index in which to perform the request
*/
public async deleteIndex(indexName: string): Promise<DeleteIndexResponse> {
const path = '/1/indexes/{indexName}'.replace(
'{' + 'indexName' + '}',
encodeURIComponent(String(indexName))
);
let headers: Headers = { Accept: 'application/json' };
let queryParameters: Record<string, string> = {};

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.
>>>>>>> main
*
* @param indexName - The index in which to perform the request.
*/
Expand Down Expand Up @@ -176,7 +234,41 @@ export class SearchApi {
/**
* Get search results for the given requests.
*
<<<<<<< HEAD
* @summary List existing indexes
* @param listIndicesObject
*/
public async listIndices(listIndicesObject: ListIndicesObject): Promise<ListIndicesResponse> {
const path = '/1/indexes';
let headers: Headers = { Accept: 'application/json' };
let queryParameters: Record<string, string> = {};

if (listIndicesObject === null || listIndicesObject === undefined) {
throw new Error(
'Required parameter listIndicesObject was null or undefined when calling listIndices.'
);
}

const request: Request = {
method: 'GET',
path,
data: listIndicesObject,
};

const requestOptions: RequestOptions = {
headers,
queryParameters,
};

return this.sendRequest(request, requestOptions);
}
/**
*
* @summary Get search results for the given requests.
* @param multipleQueriesObject
=======
* @param multipleQueriesObject - The multipleQueriesObject.
>>>>>>> main
*/
multipleQueries(
multipleQueriesObject: MultipleQueriesObject
Expand Down Expand Up @@ -205,10 +297,59 @@ export class SearchApi {
return this.sendRequest(request, requestOptions);
}
/**
<<<<<<< HEAD
* 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
*/
public async operationIndex(
indexName: string,
operationIndexObject: OperationIndexObject
): Promise<OperationIndexResponse> {
const path = '/1/indexes/{indexName}/operation'.replace(
'{' + 'indexName' + '}',
encodeURIComponent(String(indexName))
);
let headers: Headers = { Accept: 'application/json' };
let queryParameters: Record<string, string> = {};

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
* @summary Save object
* @param indexName The index in which to perform the request
* @param requestBody
=======
* Add an object to the index, automatically assigning it an object ID.
*
* @param indexName - The index in which to perform the request.
* @param requestBody - The Algolia object.
>>>>>>> main
*/
saveObject(
indexName: string,
Expand Down
5 changes: 5 additions & 0 deletions specs/common/parameters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,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
Expand Down
46 changes: 46 additions & 0 deletions specs/search/common/schemas/listIndicesResponse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
listIndicesResponse:
type: object
additionalProperties: false
properties:
items:
type: array
items:
$ref: '#/index'
nbPages:
type: integer
description: 'Number of pages'
example: 100

index:
type: object
additionalProperties: false
properties:
name:
type: string
description: Name of the index
createdAt:
type: string
format: date-time
description: Date of the index creation. (ISO-8601 format)
updatedAt:
type: string
format: date-time
description: Date of the index last update. (ISO-8601 format)
entries:
type: integer
description: Entries in the index
dataSize:
type: integer
description: data size of the index
fileSize:
type: integer
description: file size of the index
lastBuildTimeS:
type: integer
description: Last build time
numberOfPendingTask:
type: integer
description: Number of pending tasks
pendingTask:
type: boolean
description: Pending task ?
1 change: 0 additions & 1 deletion specs/search/paths/manage_indices/copyIndex.yml

This file was deleted.

33 changes: 33 additions & 0 deletions specs/search/paths/manage_indices/listIndices.yml
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
get:
tags:
- search
operationId: listIndices
summary: List existing indexes
requestBody:
required: true
content:
application/json:
schema:
title: listIndicesObject
type: object
additionalProperties: false
properties:
page:
type: integer
default: null
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).
responses:
'200':
description: OK
content:
application/json:
schema:
title: listIndicesResponse
$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'
Loading