/
githubmirror
/
ydb-embedded-ui
Обзор
Документация
Войти
/
githubmirror
/
ydb-embedded-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/services/api/meta.ts
119 строк
4 KB
Hellen
feat(TopicData): support new meta handler for data (#4026)
19 июн 2026, 14:42
Не верифицирован
19 июн 2026, 14:42
7e2effd
Код
Авторство
О чём код?
import type {MetaCapabilitiesResponse} from '../../types/api/capabilities'; import type {MetaEnvironmentsResponse} from '../../types/api/environments'; import type {HealthCheckAPIResponse} from '../../types/api/healthcheck'; import type { MetaBaseClusterInfo, MetaBaseClusters, MetaClusters, MetaTenants, } from '../../types/api/meta'; import type {TopicDataRequest, TopicDataResponse} from '../../types/api/topic'; import type {TUserToken} from '../../types/api/whoami'; import {parseMetaTenants} from '../parsers/parseMetaTenants'; import type {AxiosOptions} from './base'; import {BaseMetaAPI} from './baseMeta'; export class MetaAPI extends BaseMetaAPI { metaAuthenticate(params: {user: string; password: string}) { return this.post(this.getPath('/meta/login'), params, {}); } metaLogout() { return this.post(this.getPath('/meta/logout'), {}, {}); } metaWhoami() { return this.post<TUserToken>(this.getPath('/meta/whoami'), {}, {}); } getMetaCapabilities() { return this.get<MetaCapabilitiesResponse>( this.getPath('/capabilities'), {}, {timeout: 1000}, ); } getMetaEnvironments() { return this.get<MetaEnvironmentsResponse>(this.getPath('/meta/environments'), {}); } getClustersList(_?: never, {signal}: {signal?: AbortSignal} = {}) { return this.get<MetaClusters>(this.getPath('/meta/clusters'), null, { requestConfig: {signal}, }); } getTenants( {clusterName, database}: {clusterName?: string; database?: string}, {signal}: AxiosOptions = {}, ) { return this.get<MetaTenants>( // cp_databases never should be proxying to cluster this.getPath('/meta/cp_databases'), { cluster_name: clusterName, database_name: database, }, {requestConfig: {signal}}, ).then(parseMetaTenants); } getTenantsV2( { database, clusterName, environmentName, }: {clusterName?: string; database?: string; environmentName?: string}, {signal}: AxiosOptions = {}, ) { return this.get<MetaTenants>( this.getPath('/meta/databases', clusterName), { cluster_name: clusterName, environment_name: environmentName, database, }, {requestConfig: {signal}}, ).then(parseMetaTenants); } getClusterBaseInfo( clusterName: string, {concurrentId, signal}: AxiosOptions = {}, ): Promise<MetaBaseClusterInfo> { return this.get<MetaBaseClusters>( this.getPath('/meta/db_clusters', clusterName), { name: clusterName, }, {concurrentId, requestConfig: {signal}}, ).then((data) => data.clusters[0]); } getClusterHealth( {clusterName}: {clusterName: string}, {concurrentId, signal}: AxiosOptions = {}, ) { return this.get<HealthCheckAPIResponse>( this.getPath('/meta/cluster_health'), {cluster_name: clusterName}, {concurrentId, requestConfig: {signal}}, ); } getSchemaTopicData( {clusterName, ...params}: TopicDataRequest & {clusterName?: string}, {concurrentId, signal}: AxiosOptions = {}, ) { return this.get<TopicDataResponse>( this.getPath('/meta/schema_topic_data', clusterName), {cluster_name: clusterName, ...params}, { concurrentId, requestConfig: {signal}, }, ); } }