-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from coveo/feature-clusters-resource
feat(clusters): add cluster resource
- Loading branch information
Showing
6 changed files
with
200 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import API from '../../APICore'; | ||
import Resource from '../Resource'; | ||
import {ClusterAgentModel, ClusterModel, ClusterStatusModel} from './ClusterInterfaces'; | ||
|
||
export default class Cluster extends Resource { | ||
static baseUrl = `/rest/organizations/${API.orgPlaceholder}/clusters`; | ||
|
||
list() { | ||
return this.api.get<ClusterModel[]>(Cluster.baseUrl); | ||
} | ||
|
||
listAgents(id: string) { | ||
return this.api.get<ClusterAgentModel[]>(`${Cluster.baseUrl}/${id}/agents`); | ||
} | ||
|
||
live() { | ||
return this.api.get<ClusterModel>(`${Cluster.baseUrl}/live`); | ||
} | ||
|
||
status(id: string) { | ||
return this.api.get<ClusterStatusModel>(`${Cluster.baseUrl}/${id}/status`); | ||
} | ||
|
||
synchronize(id: string) { | ||
return this.api.post<{}>(`${Cluster.baseUrl}/${id}/synchronize`, {}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
export interface ClusterResource { | ||
id: string; | ||
name: string; | ||
createdDate?: number; | ||
status: 'QUEUED_TO_CREATE' | 'CREATING' | 'REMOVING' | 'UPGRADING' | 'PAUSED' | 'COMPLETED' | 'ERROR'; | ||
type: string; | ||
numberOfRetries: number; | ||
} | ||
|
||
export interface ClusterStatusModel { | ||
orgReadOnlyStatus: boolean; | ||
currentProvisioningProgress: number; | ||
initialProvisioningDone: boolean; | ||
lastProvisioningCompletedDate?: number; | ||
ongoing: boolean; | ||
resources: ClusterResource[]; | ||
retryScheduled: boolean; | ||
status: 'ERROR' | 'HEALTHY'; | ||
} | ||
|
||
export interface ClusterTopologyModel { | ||
agents: ClusterTopologyAgentModel[]; | ||
crawlerDbConnectionString: string; | ||
dpmDocUri: string; | ||
indexDocUri: string; | ||
indexers: ClusterIndexerModel[]; | ||
rabbitServerId: string; | ||
secCacheJobUri: string; | ||
secClusterSyncUri: string; | ||
securityCaches: ClusterSecurityCacheModel[]; | ||
securityProviderDbConnectionString: string; | ||
securityProviders: ClusterSecurityProviderModel[]; | ||
topologyId: string; | ||
} | ||
|
||
export interface ClusterTopologyAgentModel { | ||
id: string; | ||
machineSpec: ClusterMachineSpecModel; | ||
storages: ClusterStorageSpecModel[]; | ||
} | ||
|
||
export interface ClusterStorageSpecModel { | ||
numberOfIops: number; | ||
sizeInGibibytes: number; | ||
sizeInGigabytes: number; | ||
storageType: 'STANDARD' | 'SSD' | 'PROVISIONED_SSD'; | ||
} | ||
|
||
export interface ClusterMachineSpecModel { | ||
architecture: string; | ||
storageSpec: ClusterStorageSpecModel; | ||
} | ||
|
||
export interface ClusterComponentModel { | ||
adminPort: number; | ||
adminUri: string; | ||
agentId: string; | ||
componentName: string; | ||
componentPlatform: string; | ||
componentVersion: string; | ||
id: string; | ||
name: string; | ||
} | ||
|
||
export interface ClusterIndexerModel extends ClusterComponentModel { | ||
indexerDocUri: string; | ||
searchPort: number; | ||
searchServerUri: string; | ||
} | ||
|
||
export interface ClusterSecurityCacheModel extends ClusterComponentModel { | ||
secCacheSyncUri: string; | ||
} | ||
|
||
export interface ClusterSecurityProviderModel extends ClusterComponentModel { | ||
type: string; | ||
useDefaultConfiguration: boolean; | ||
} | ||
|
||
export interface ClusterModel { | ||
id: string; | ||
identityTargetMode: string; | ||
liveCluster: boolean; | ||
organizationId: string; | ||
componentVersions: { | ||
connectorsVersion: string; | ||
indexerVersion: string; | ||
securityCacheVersion: string; | ||
securityProviderVersion: string; | ||
}; | ||
clusterTopology: ClusterTopologyModel; | ||
} | ||
|
||
export interface ClusterAgentModel { | ||
id: string; | ||
name: string; | ||
description: string; | ||
platform: string; | ||
version: string; | ||
status: ClusterNodeStatusModel; | ||
} | ||
|
||
export interface ClusterNodeStatusModel { | ||
message: string; | ||
severity: string; | ||
status: string; | ||
timestamp: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './Cluster'; | ||
export * from './ClusterInterfaces'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import API from '../../../APICore'; | ||
import Cluster from '../Cluster'; | ||
|
||
jest.mock('../../../APICore'); | ||
|
||
const APIMock: jest.Mock<API> = API as any; | ||
|
||
describe('Cluster', () => { | ||
let cluster: Cluster; | ||
const api = new APIMock() as jest.Mocked<API>; | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
cluster = new Cluster(api); | ||
}); | ||
|
||
describe('list', () => { | ||
it('should make a GET call to the Cluster base url', () => { | ||
cluster.list(); | ||
expect(api.get).toHaveBeenCalledTimes(1); | ||
expect(api.get).toHaveBeenCalledWith(Cluster.baseUrl); | ||
}); | ||
}); | ||
|
||
describe('listAgents', () => { | ||
it('should make a GET call to the cluster agents url', () => { | ||
const clusterToGet = 'cluster-to-get'; | ||
cluster.listAgents(clusterToGet); | ||
expect(api.get).toHaveBeenCalledTimes(1); | ||
expect(api.get).toHaveBeenCalledWith(`${Cluster.baseUrl}/${clusterToGet}/agents`); | ||
}); | ||
}); | ||
|
||
describe('live', () => { | ||
it('should make a GET call to the live cluster url', () => { | ||
cluster.live(); | ||
expect(api.get).toHaveBeenCalledTimes(1); | ||
expect(api.get).toHaveBeenCalledWith(`${Cluster.baseUrl}/live`); | ||
}); | ||
}); | ||
|
||
describe('status', () => { | ||
it('should make a GET call to the status cluster url', () => { | ||
const clusterToGet = 'cluster-to-get'; | ||
cluster.status(clusterToGet); | ||
expect(api.get).toHaveBeenCalledTimes(1); | ||
expect(api.get).toHaveBeenCalledWith(`${Cluster.baseUrl}/${clusterToGet}/status`); | ||
}); | ||
}); | ||
|
||
describe('synchronize', () => { | ||
it('should make a POST call to the live cluster url', () => { | ||
const clusterToSync = 'cluster-to-sync'; | ||
cluster.synchronize(clusterToSync); | ||
expect(api.post).toHaveBeenCalledTimes(1); | ||
expect(api.post).toHaveBeenCalledWith(`${Cluster.baseUrl}/${clusterToSync}/synchronize`, {}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters