-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmeta.ts
46 lines (41 loc) · 1.33 KB
/
meta.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import {metaBackend as META_BACKEND} from '../../store';
import type {
MetaBaseClusterInfo,
MetaBaseClusters,
MetaClusters,
MetaTenants,
} from '../../types/api/meta';
import {parseMetaTenants} from '../parsers/parseMetaTenants';
import type {AxiosOptions} from './base';
import {BaseYdbAPI} from './base';
export class MetaAPI extends BaseYdbAPI {
getPath(path: string) {
return `${META_BACKEND ?? ''}${path}`;
}
getClustersList(_?: never, {signal}: {signal?: AbortSignal} = {}) {
return this.get<MetaClusters>(this.getPath('/meta/clusters'), null, {
requestConfig: {signal},
});
}
getTenants(clusterName?: string, {signal}: AxiosOptions = {}) {
return this.get<MetaTenants>(
this.getPath('/meta/cp_databases'),
{
cluster_name: clusterName,
},
{requestConfig: {signal}},
).then(parseMetaTenants);
}
getClusterBaseInfo(
clusterName: string,
{concurrentId, signal}: AxiosOptions = {},
): Promise<MetaBaseClusterInfo> {
return this.get<MetaBaseClusters>(
this.getPath('/meta/db_clusters'),
{
name: clusterName,
},
{concurrentId, requestConfig: {signal}},
).then((data) => data.clusters[0]);
}
}