From 5e664e3ed73395570fa5310238562ad55ed21053 Mon Sep 17 00:00:00 2001 From: "Sebastian Alvarez salvarez@coveo.com" Date: Mon, 21 Oct 2019 17:02:22 -0400 Subject: [PATCH 1/5] feat: added Indexes API calls Defined Interfaces for the creation of indexes model, and added the basic calls for get, list, create and delete. Will be adding the rest in the next commits when I'm able to test --- src/resources/Indexes/Indexes.ts | 27 +++++++ src/resources/Indexes/IndexesInterface.ts | 85 +++++++++++++++++++++ src/resources/Indexes/index.ts | 2 + src/resources/Indexes/tests/Indexes.spec.ts | 50 ++++++++++++ src/resources/PlatformResources.ts | 3 + src/resources/index.ts | 1 + 6 files changed, 168 insertions(+) create mode 100644 src/resources/Indexes/Indexes.ts create mode 100644 src/resources/Indexes/IndexesInterface.ts create mode 100644 src/resources/Indexes/index.ts create mode 100644 src/resources/Indexes/tests/Indexes.spec.ts diff --git a/src/resources/Indexes/Indexes.ts b/src/resources/Indexes/Indexes.ts new file mode 100644 index 000000000..2d9b2a4e3 --- /dev/null +++ b/src/resources/Indexes/Indexes.ts @@ -0,0 +1,27 @@ +import API from '../../APICore'; +import Resource from '../Resource'; +import {CreateCoveoIndexModel, IndexAttributes} from './IndexesInterface'; + +export default class Indexes extends Resource { + static baseUrl = `/rest/organizations/${API.orgPlaceholder}/indexes`; + + list() { + return this.api.get(Indexes.baseUrl); + } + + create(indexModal: CreateCoveoIndexModel) { + return this.api.post(Indexes.baseUrl, indexModal); + } + + delete(indexId: string) { + return this.api.delete(`${Indexes.baseUrl}/${indexId}`); + } + + get(indexId: string) { + return this.api.get(`${Indexes.baseUrl}/${indexId}`); + } + + restore(backupId: string) { + return this.api.post(Indexes.baseUrl, {id: backupId}); + } +} diff --git a/src/resources/Indexes/IndexesInterface.ts b/src/resources/Indexes/IndexesInterface.ts new file mode 100644 index 000000000..30c44bca8 --- /dev/null +++ b/src/resources/Indexes/IndexesInterface.ts @@ -0,0 +1,85 @@ +export interface IndexStorageSpec { + numberOfIops: number; + sizeInGibibytes: number; + sizeInGigabytes: number; + storageType: string; +} + +export interface IndexMachineSpec { + architecture: string; + storageSpec: IndexStorageSpec; +} + +export interface IndexSourceStatistics { + collectionId: number; + documentCount: number; + documentTotalSize: number; + sourceId: number; +} + +export interface IndexStatusStats { + diskSpaceUsed: number; + documentCount: number; + documentsTotalSize: number; + lastAppliedTransactionTimestamp: number; + lastCommitTimestamp: number; + numberOfQueries: number; + numberOfSlices: number; + pendingTransactions: number; + realtimeDiskSpaceUsed: number; + realtimeDocumentCount: number; + realtimeDocumentsTotalSize: number; + realtimePendingTransactions: number; + remainingDiskSpace: number; + sourceStatistics: IndexSourceStatistics[]; + totalMemoryUsed: number; + totalPhysicalMemory: number; +} + +export interface IndexStatus { + internalStatus: string; + online: boolean; + readOnlyStatus: string; + stats: IndexStatusStats; +} + +export interface IndexAttributes { + adminUri: string; + agentId: string; + id: string; + logicalIndex: string; + machineSpec: IndexMachineSpec; + name: string; + organizationId: string; + region: string; + searchUri: string; + status: IndexStatus; + storages: IndexStorageSpec[]; + type: string; +} + +export interface CreateCoveoIndexModel { + copyFromId?: string; + logicalIndexId?: string; + machineSpec?: IndexMachineSpecModel; + online?: boolean; + region?: string; + versions?: IndexVersionsModel; +} + +export interface IndexMachineSpecModel { + architecture: string; + storageSpec: IndexStorageSpecModel; +} + +export interface IndexStorageSpecModel { + numberOfIops: number; + sizeInGibibytes: number; + sizeInGigabytes: number; + storageType: string; +} + +export interface IndexVersionsModel { + indexerVersion: string; + securityCacheVersion: string; +} diff --git a/src/resources/Indexes/index.ts b/src/resources/Indexes/index.ts new file mode 100644 index 000000000..8a55cf9cc --- /dev/null +++ b/src/resources/Indexes/index.ts @@ -0,0 +1,2 @@ +export * from './Indexes'; +export * from './IndexesInterface'; diff --git a/src/resources/Indexes/tests/Indexes.spec.ts b/src/resources/Indexes/tests/Indexes.spec.ts new file mode 100644 index 000000000..98ad67d78 --- /dev/null +++ b/src/resources/Indexes/tests/Indexes.spec.ts @@ -0,0 +1,50 @@ +import API from '../../../APICore'; +import Indexes from '../Indexes'; + +jest.mock('../../../APICore'); + +const APIMock: jest.Mock = API as any; + +describe('Cluster', () => { + let indexes: Indexes; + const api = new APIMock() as jest.Mocked; + + beforeEach(() => { + jest.clearAllMocks(); + indexes = new Indexes(api); + }); + + describe('list', () => { + it('should make a GET call to the Cluster base url', () => { + indexes.list(); + expect(api.get).toHaveBeenCalledTimes(1); + expect(api.get).toHaveBeenCalledWith(Indexes.baseUrl); + }); + }); + + describe('get', () => { + it('should make a GET call for specific index', () => { + const indexId = 'ABC123'; + indexes.get(indexId); + expect(api.get).toHaveBeenCalledTimes(1); + expect(api.get).toHaveBeenCalledWith(`${Indexes.baseUrl}/${indexId}`); + }); + }); + + describe('delete', () => { + it('should make a DELETE call for specific index', () => { + const indexId = 'ABC123'; + indexes.delete(indexId); + expect(api.delete).toHaveBeenCalledTimes(1); + expect(api.delete).toHaveBeenCalledWith(`${Indexes.baseUrl}/${indexId}`); + }); + }); + + describe('create', () => { + it('should make a CREATE call with no arguments', () => { + indexes.create({}); + expect(api.post).toHaveBeenCalledTimes(1); + expect(api.post).toHaveBeenCalledWith(Indexes.baseUrl, {}); + }); + }); +}); diff --git a/src/resources/PlatformResources.ts b/src/resources/PlatformResources.ts index e93529fa4..fcccc0a62 100644 --- a/src/resources/PlatformResources.ts +++ b/src/resources/PlatformResources.ts @@ -2,6 +2,7 @@ import API from '../APICore'; import ApiKey from './ApiKeys/ApiKeys'; import Catalog from './Catalogs/Catalog'; import Group from './Groups/Groups'; +import Indexes from './Indexes/Indexes'; import Organization from './Organizations/Organization'; import Resource from './Resource'; @@ -9,6 +10,7 @@ const resourcesMap: Array<{key: string; resource: typeof Resource}> = [ {key: 'catalog', resource: Catalog}, {key: 'group', resource: Group}, {key: 'organization', resource: Organization}, + {key: 'indexes', resource: Indexes}, {key: 'apiKey', resource: ApiKey}, ]; @@ -18,6 +20,7 @@ class PlatformResources { catalog: Catalog; group: Group; organization: Organization; + indexes: Indexes; apiKey: ApiKey; registerAll() { diff --git a/src/resources/index.ts b/src/resources/index.ts index ec9c48f09..eaeacadb8 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -3,5 +3,6 @@ export * from './PlatformResources'; export * from './Catalogs'; export * from './Groups'; export * from './Organizations'; +export * from './Indexes'; export * from './License'; export * from './ApiKeys'; From 7677c9bf382f4a3cd4148317bc843582e092a733 Mon Sep 17 00:00:00 2001 From: "Sebastian Alvarez salvarez@coveo.com" Date: Wed, 23 Oct 2019 10:37:57 -0400 Subject: [PATCH 2/5] feat(component): added Indexes API calls Created main API calls for Indexes table. There are 10 actions, but could probably extend if more actions are required. Also, added interfaces for parameters and return values for each call, as well as UTs. ADUI-4844 --- src/resources/Indexes/Indexes.ts | 42 +++++++-- src/resources/Indexes/IndexesInterface.ts | 23 +++-- src/resources/Indexes/tests/Indexes.spec.ts | 94 +++++++++++++++++++++ 3 files changed, 148 insertions(+), 11 deletions(-) diff --git a/src/resources/Indexes/Indexes.ts b/src/resources/Indexes/Indexes.ts index 2d9b2a4e3..630209bf5 100644 --- a/src/resources/Indexes/Indexes.ts +++ b/src/resources/Indexes/Indexes.ts @@ -1,16 +1,18 @@ import API from '../../APICore'; import Resource from '../Resource'; -import {CreateCoveoIndexModel, IndexAttributes} from './IndexesInterface'; +import {CreateCoveoIndexModel, IndexAttributes, IndexStatisticsModel, PageModel} from './IndexesInterface'; export default class Indexes extends Resource { static baseUrl = `/rest/organizations/${API.orgPlaceholder}/indexes`; + static indexBackupUrl = `/rest/organizations/${API.orgPlaceholder}/indexbackups/page`; list() { return this.api.get(Indexes.baseUrl); } - create(indexModal: CreateCoveoIndexModel) { - return this.api.post(Indexes.baseUrl, indexModal); + // Same for Copy Index but making sure to pass copyFromId and machineSpec + create(indexModal?: CreateCoveoIndexModel) { + return this.api.post<{id: string}>(Indexes.baseUrl, indexModal); } delete(indexId: string) { @@ -18,10 +20,38 @@ export default class Indexes extends Resource { } get(indexId: string) { - return this.api.get(`${Indexes.baseUrl}/${indexId}`); + return this.api.get(`${Indexes.baseUrl}/${indexId}`); } - restore(backupId: string) { - return this.api.post(Indexes.baseUrl, {id: backupId}); + backup(indexId: string) { + return this.api.post<{id: string}>(`${Indexes.baseUrl}/${indexId}/backup`, {}); + } + + getBackups() { + return this.api.get(`${Indexes.indexBackupUrl}`); + } + + forceCommit(indexId: string) { + return this.api.post(`${Indexes.baseUrl}/${indexId}/commit`, {}); + } + + readOnly(indexId: string, isReadOnly: boolean) { + return this.api.put(`${Indexes.baseUrl}/${indexId}/readonly`, {isReadOnly}); + } + + resize(indexId: string, sizeInGibibytes: number) { + return this.api.post(`${Indexes.baseUrl}/${indexId}/resize`, {sizeInGibibytes}); + } + + stats(indexId: string) { + return this.api.get(`${Indexes.baseUrl}/${indexId}/stats`); + } + + isOnline(indexId: string, isOnline: boolean) { + return this.api.put(`${Indexes.baseUrl}/${indexId}/online`, {isOnline}); + } + + restore(indexId: string, backupId: string) { + return this.api.post(`${Indexes.baseUrl}/${indexId}/restore`, {backupId}); } } diff --git a/src/resources/Indexes/IndexesInterface.ts b/src/resources/Indexes/IndexesInterface.ts index 30c44bca8..f82b00d4c 100644 --- a/src/resources/Indexes/IndexesInterface.ts +++ b/src/resources/Indexes/IndexesInterface.ts @@ -17,7 +17,7 @@ export interface IndexSourceStatistics { sourceId: number; } -export interface IndexStatusStats { +export interface IndexStatisticsModel { diskSpaceUsed: number; documentCount: number; documentsTotalSize: number; @@ -40,7 +40,7 @@ export interface IndexStatus { internalStatus: string; online: boolean; readOnlyStatus: string; - stats: IndexStatusStats; + stats: IndexStatisticsModel; } export interface IndexAttributes { @@ -61,13 +61,13 @@ export interface IndexAttributes { export interface CreateCoveoIndexModel { copyFromId?: string; logicalIndexId?: string; - machineSpec?: IndexMachineSpecModel; + machineSpec?: MachineSpecModel; online?: boolean; region?: string; versions?: IndexVersionsModel; } -export interface IndexMachineSpecModel { +export interface MachineSpecModel { architecture: string; storageSpec: IndexStorageSpecModel; } @@ -75,7 +75,6 @@ export interface IndexMachineSpecModel { export interface IndexStorageSpecModel { numberOfIops: number; sizeInGibibytes: number; - sizeInGigabytes: number; storageType: string; } @@ -83,3 +82,17 @@ export interface IndexVersionsModel { indexerVersion: string; securityCacheVersion: string; } + +export interface PageModel { + items: IndexBackupsItems[]; + totalEntries: number; + totalPages: number; +} + +export interface IndexBackupsItems { + backupId: string; + creationDate: number; + indexId: string; + logicalIndex: string; + organizationId: string; +} diff --git a/src/resources/Indexes/tests/Indexes.spec.ts b/src/resources/Indexes/tests/Indexes.spec.ts index 98ad67d78..f3582cf1f 100644 --- a/src/resources/Indexes/tests/Indexes.spec.ts +++ b/src/resources/Indexes/tests/Indexes.spec.ts @@ -1,5 +1,6 @@ import API from '../../../APICore'; import Indexes from '../Indexes'; +import {CreateCoveoIndexModel} from '../IndexesInterface'; jest.mock('../../../APICore'); @@ -46,5 +47,98 @@ describe('Cluster', () => { expect(api.post).toHaveBeenCalledTimes(1); expect(api.post).toHaveBeenCalledWith(Indexes.baseUrl, {}); }); + + it('should make a CREATE call to mimick COPY_INDEX', () => { + const indexToBeCopied: CreateCoveoIndexModel = { + copyFromId: 'originalIndexID', + machineSpec: { + architecture: 'T3_MEDIUM_UNLIMITED', + storageSpec: { + numberOfIops: 0, + sizeInGibibytes: 45, + storageType: 'STANDARD', + }, + }, + }; + + indexes.create(indexToBeCopied); + expect(api.post).toHaveBeenCalledTimes(1); + expect(api.post).toHaveBeenCalledWith(Indexes.baseUrl, indexToBeCopied); + }); + }); + + describe('backup', () => { + it('should make a BACKUP call for specified index', () => { + const indexId = 'ABC123'; + indexes.backup(indexId); + expect(api.post).toHaveBeenCalledTimes(1); + expect(api.post).toHaveBeenCalledWith(`${Indexes.baseUrl}/${indexId}/backup`, {}); + }); + }); + + describe('get all backups', () => { + it('should make a GETBACKUPS call', () => { + indexes.getBackups(); + expect(api.get).toHaveBeenCalledTimes(1); + expect(api.get).toHaveBeenCalledWith(`${Indexes.indexBackupUrl}`); + }); + }); + + describe('forceCommit', () => { + it('should make a FORCECOMMIT call for specified index', () => { + const indexId = 'ABC123'; + indexes.forceCommit(indexId); + expect(api.post).toHaveBeenCalledTimes(1); + expect(api.post).toHaveBeenCalledWith(`${Indexes.baseUrl}/${indexId}/commit`, {}); + }); + }); + + describe('readOnly', () => { + it('should make a READONLY call for specified index', () => { + const isReadOnly = true; + const indexId = 'ABC123'; + indexes.readOnly(indexId, isReadOnly); + expect(api.put).toHaveBeenCalledTimes(1); + expect(api.put).toHaveBeenCalledWith(`${Indexes.baseUrl}/${indexId}/readonly`, {isReadOnly}); + }); + }); + + describe('resize', () => { + it('should make a RESIZE call for specified index', () => { + const sizeInGibibytes = 100; + const indexId = 'ABC123'; + indexes.resize(indexId, sizeInGibibytes); + expect(api.post).toHaveBeenCalledTimes(1); + expect(api.post).toHaveBeenCalledWith(`${Indexes.baseUrl}/${indexId}/resize`, {sizeInGibibytes}); + }); + }); + + describe('stats', () => { + it('should make a RESIZE call for specified index', () => { + const indexId = 'ABC123'; + indexes.stats(indexId); + expect(api.get).toHaveBeenCalledTimes(1); + expect(api.get).toHaveBeenCalledWith(`${Indexes.baseUrl}/${indexId}/stats`); + }); + }); + + describe('isOnline', () => { + it('should make a ISONLINE call for specified index', () => { + const isOnline = true; + const indexId = 'ABC123'; + indexes.isOnline(indexId, isOnline); + expect(api.put).toHaveBeenCalledTimes(1); + expect(api.put).toHaveBeenCalledWith(`${Indexes.baseUrl}/${indexId}/online`, {isOnline}); + }); + }); + + describe('restore', () => { + it('should make a RESTORE call for specified index', () => { + const backupId = 'backUpID'; + const indexId = 'ABC123'; + indexes.restore(indexId, backupId); + expect(api.post).toHaveBeenCalledTimes(1); + expect(api.post).toHaveBeenCalledWith(`${Indexes.baseUrl}/${indexId}/restore`, {backupId}); + }); }); }); From 109ac29bea8949cdfdbbbd0d8726dcfb944832f2 Mon Sep 17 00:00:00 2001 From: "Sebastian Alvarez salvarez@coveo.com" Date: Thu, 24 Oct 2019 14:11:21 -0400 Subject: [PATCH 3/5] feat(component): add indexes API calls Provide a way to globalize Index API calls for the main actions. 4844 --- src/resources/Indexes/Indexes.ts | 18 ++++++++++++------ src/resources/Indexes/IndexesInterface.ts | 10 ++++++++++ src/resources/PlatformResources.ts | 6 +++--- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/resources/Indexes/Indexes.ts b/src/resources/Indexes/Indexes.ts index 526c7e74a..0e58afa55 100644 --- a/src/resources/Indexes/Indexes.ts +++ b/src/resources/Indexes/Indexes.ts @@ -1,7 +1,13 @@ import API from '../../APICore'; import {PageModel} from '../BaseInterfaces'; import Resource from '../Resource'; -import {CreateCoveoIndexModel, IndexAttributes, IndexBackupsItems, IndexStatisticsModel} from './IndexesInterface'; +import { + CreateCoveoIndexModel, + IndexAttributes, + IndexBackups, + IndexBackupsItems, + IndexStatisticsModel, +} from './IndexesInterface'; export default class Indexes extends Resource { static baseUrl = `/rest/organizations/${API.orgPlaceholder}/indexes`; @@ -28,8 +34,8 @@ export default class Indexes extends Resource { return this.api.post<{id: string}>(`${Indexes.baseUrl}/${indexId}/backup`, {}); } - getBackups() { - return this.api.get>(`${Indexes.indexBackupUrl}`); + getBackups(options: IndexBackups) { + return this.api.get>(this.buildPath(`${Indexes.indexBackupUrl}`, options)); } forceCommit(indexId: string) { @@ -37,7 +43,7 @@ export default class Indexes extends Resource { } readOnly(indexId: string, isReadOnly: boolean) { - return this.api.put(`${Indexes.baseUrl}/${indexId}/readonly`, {isReadOnly}); + return this.api.put(this.buildPath(`${Indexes.baseUrl}/${indexId}/readonly`, {isReadOnly}), {}); } resize(indexId: string, sizeInGibibytes: number) { @@ -49,10 +55,10 @@ export default class Indexes extends Resource { } isOnline(indexId: string, isOnline: boolean) { - return this.api.put(`${Indexes.baseUrl}/${indexId}/online`, {isOnline}); + return this.api.put(this.buildPath(`${Indexes.baseUrl}/${indexId}/online`, {isOnline}), {}); } restore(indexId: string, backupId: string) { - return this.api.post(`${Indexes.baseUrl}/${indexId}/restore`, {backupId}); + return this.api.post(this.buildPath(`${Indexes.baseUrl}/${indexId}/restore`, {backupId}), {}); } } diff --git a/src/resources/Indexes/IndexesInterface.ts b/src/resources/Indexes/IndexesInterface.ts index efadddbb8..81ce47bb0 100644 --- a/src/resources/Indexes/IndexesInterface.ts +++ b/src/resources/Indexes/IndexesInterface.ts @@ -90,3 +90,13 @@ export interface IndexBackupsItems { logicalIndex: string; organizationId: string; } + +export interface IndexBackups { + backupId: string; + from: number; + indexId: string; + order: string; + page: number; + perPage: number; + sortBy: string; +} diff --git a/src/resources/PlatformResources.ts b/src/resources/PlatformResources.ts index e54f24ddb..fce124df0 100644 --- a/src/resources/PlatformResources.ts +++ b/src/resources/PlatformResources.ts @@ -4,7 +4,7 @@ import AWS from './AWS/AWS'; import Catalog from './Catalogs/Catalog'; import Cluster from './Clusters/Cluster'; import Group from './Groups/Groups'; -import Indexes from './Indexes/Indexes'; +import Index from './Indexes/Indexes'; import Organization from './Organizations/Organization'; import Resource from './Resource'; import SecurityCache from './SecurityCache/SecurityCache'; @@ -15,7 +15,7 @@ const resourcesMap: Array<{key: string; resource: typeof Resource}> = [ {key: 'cluster', resource: Cluster}, {key: 'group', resource: Group}, {key: 'organization', resource: Organization}, - {key: 'indexes', resource: Indexes}, + {key: 'indexes', resource: Index}, {key: 'securityCache', resource: SecurityCache}, {key: 'apiKey', resource: ApiKey}, ]; @@ -28,7 +28,7 @@ class PlatformResources { cluster: Cluster; group: Group; organization: Organization; - indexes: Indexes; + index: Index; apiKey: ApiKey; securityCache: SecurityCache; From af9b028100c3768fcbc0495ff5203052ea1600c3 Mon Sep 17 00:00:00 2001 From: "Sebastian Alvarez salvarez@coveo.com" Date: Thu, 24 Oct 2019 16:07:59 -0400 Subject: [PATCH 4/5] feat(unit tests change): calibrated unit tests to match latest changes Since using the buildPath util changes the outcome of the path, made sure to include those expected outcomes on UTs 4844 --- src/resources/Indexes/Indexes.ts | 2 +- src/resources/Indexes/IndexesInterface.ts | 15 +++++++------- src/resources/Indexes/tests/Indexes.spec.ts | 23 ++++++++++++++++----- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/resources/Indexes/Indexes.ts b/src/resources/Indexes/Indexes.ts index 0e58afa55..070d1892d 100644 --- a/src/resources/Indexes/Indexes.ts +++ b/src/resources/Indexes/Indexes.ts @@ -34,7 +34,7 @@ export default class Indexes extends Resource { return this.api.post<{id: string}>(`${Indexes.baseUrl}/${indexId}/backup`, {}); } - getBackups(options: IndexBackups) { + getBackups(options?: IndexBackups) { return this.api.get>(this.buildPath(`${Indexes.indexBackupUrl}`, options)); } diff --git a/src/resources/Indexes/IndexesInterface.ts b/src/resources/Indexes/IndexesInterface.ts index 81ce47bb0..223ece7f7 100644 --- a/src/resources/Indexes/IndexesInterface.ts +++ b/src/resources/Indexes/IndexesInterface.ts @@ -92,11 +92,12 @@ export interface IndexBackupsItems { } export interface IndexBackups { - backupId: string; - from: number; - indexId: string; - order: string; - page: number; - perPage: number; - sortBy: string; + backupId?: string; + from?: number; + indexId?: string; + order?: string; + page?: number; + perPage?: number; + sortBy?: string; + to?: number; } diff --git a/src/resources/Indexes/tests/Indexes.spec.ts b/src/resources/Indexes/tests/Indexes.spec.ts index f3582cf1f..646fa7002 100644 --- a/src/resources/Indexes/tests/Indexes.spec.ts +++ b/src/resources/Indexes/tests/Indexes.spec.ts @@ -78,9 +78,22 @@ describe('Cluster', () => { describe('get all backups', () => { it('should make a GETBACKUPS call', () => { - indexes.getBackups(); + const options = { + backupId: 'backupId', + from: 0, + indexId: 'indexId', + order: 'asc', + page: 100, + perPage: 10, + sortBy: 'name', + to: 20, + }; + + indexes.getBackups(options); expect(api.get).toHaveBeenCalledTimes(1); - expect(api.get).toHaveBeenCalledWith(`${Indexes.indexBackupUrl}`); + expect(api.get).toHaveBeenCalledWith( + `${Indexes.indexBackupUrl}?backupId=backupId&from=0&indexId=indexId&order=asc&page=100&perPage=10&sortBy=name&to=20` + ); }); }); @@ -99,7 +112,7 @@ describe('Cluster', () => { const indexId = 'ABC123'; indexes.readOnly(indexId, isReadOnly); expect(api.put).toHaveBeenCalledTimes(1); - expect(api.put).toHaveBeenCalledWith(`${Indexes.baseUrl}/${indexId}/readonly`, {isReadOnly}); + expect(api.put).toHaveBeenCalledWith(`${Indexes.baseUrl}/${indexId}/readonly?isReadOnly=true`, {}); }); }); @@ -128,7 +141,7 @@ describe('Cluster', () => { const indexId = 'ABC123'; indexes.isOnline(indexId, isOnline); expect(api.put).toHaveBeenCalledTimes(1); - expect(api.put).toHaveBeenCalledWith(`${Indexes.baseUrl}/${indexId}/online`, {isOnline}); + expect(api.put).toHaveBeenCalledWith(`${Indexes.baseUrl}/${indexId}/online?isOnline=true`, {}); }); }); @@ -138,7 +151,7 @@ describe('Cluster', () => { const indexId = 'ABC123'; indexes.restore(indexId, backupId); expect(api.post).toHaveBeenCalledTimes(1); - expect(api.post).toHaveBeenCalledWith(`${Indexes.baseUrl}/${indexId}/restore`, {backupId}); + expect(api.post).toHaveBeenCalledWith(`${Indexes.baseUrl}/${indexId}/restore?backupId=backUpID`, {}); }); }); }); From e4074c1715e56cc04b564abfe5dcbba47fb76a5a Mon Sep 17 00:00:00 2001 From: "Sebastian Alvarez salvarez@coveo.com" Date: Fri, 25 Oct 2019 09:46:24 -0400 Subject: [PATCH 5/5] fix(component): changed name of interface IndexBackupsOptionsO The interface is actually called IndexBackupsOptions in swagger, it was mistakenly called IndexBackup --- src/resources/Indexes/Indexes.ts | 4 ++-- src/resources/Indexes/IndexesInterface.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/resources/Indexes/Indexes.ts b/src/resources/Indexes/Indexes.ts index 070d1892d..9540929e9 100644 --- a/src/resources/Indexes/Indexes.ts +++ b/src/resources/Indexes/Indexes.ts @@ -4,8 +4,8 @@ import Resource from '../Resource'; import { CreateCoveoIndexModel, IndexAttributes, - IndexBackups, IndexBackupsItems, + IndexBackupsOptions, IndexStatisticsModel, } from './IndexesInterface'; @@ -34,7 +34,7 @@ export default class Indexes extends Resource { return this.api.post<{id: string}>(`${Indexes.baseUrl}/${indexId}/backup`, {}); } - getBackups(options?: IndexBackups) { + getBackups(options?: IndexBackupsOptions) { return this.api.get>(this.buildPath(`${Indexes.indexBackupUrl}`, options)); } diff --git a/src/resources/Indexes/IndexesInterface.ts b/src/resources/Indexes/IndexesInterface.ts index 223ece7f7..cb0f9f740 100644 --- a/src/resources/Indexes/IndexesInterface.ts +++ b/src/resources/Indexes/IndexesInterface.ts @@ -91,7 +91,7 @@ export interface IndexBackupsItems { organizationId: string; } -export interface IndexBackups { +export interface IndexBackupsOptions { backupId?: string; from?: number; indexId?: string;