diff --git a/packages/clients/src/api/cockpit/index.ts b/packages/clients/src/api/cockpit/index.ts new file mode 100644 index 000000000..1984b471f --- /dev/null +++ b/packages/clients/src/api/cockpit/index.ts @@ -0,0 +1 @@ +export * as v1beta1 from './v1beta1/index.gen' diff --git a/packages/clients/src/api/cockpit/v1beta1/api.gen.ts b/packages/clients/src/api/cockpit/v1beta1/api.gen.ts new file mode 100644 index 000000000..eba357f54 --- /dev/null +++ b/packages/clients/src/api/cockpit/v1beta1/api.gen.ts @@ -0,0 +1,440 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import { + API as ParentAPI, + enrichForPagination, + urlParams, + validatePathParam, + waitForResource, +} from '../../../bridge' +import type { WaitForOptions } from '../../../bridge' +import { COCKPIT_TRANSIENT_STATUSES } from './content.gen' +import { + marshalActivateCockpitRequest, + marshalCreateContactPointRequest, + marshalCreateGrafanaUserRequest, + marshalCreateTokenRequest, + marshalDeactivateCockpitRequest, + marshalDeleteContactPointRequest, + marshalDeleteGrafanaUserRequest, + marshalDisableManagedAlertsRequest, + marshalEnableManagedAlertsRequest, + marshalResetCockpitGrafanaRequest, + marshalResetGrafanaUserPasswordRequest, + marshalTriggerTestAlertRequest, + unmarshalCockpit, + unmarshalContactPoint, + unmarshalGrafanaUser, + unmarshalListContactPointsResponse, + unmarshalListGrafanaUsersResponse, + unmarshalListTokensResponse, + unmarshalToken, +} from './marshalling.gen' +import type { + ActivateCockpitRequest, + Cockpit, + ContactPoint, + CreateContactPointRequest, + CreateGrafanaUserRequest, + CreateTokenRequest, + DeactivateCockpitRequest, + DeleteContactPointRequest, + DeleteGrafanaUserRequest, + DeleteTokenRequest, + DisableManagedAlertsRequest, + EnableManagedAlertsRequest, + GetCockpitRequest, + GetTokenRequest, + GrafanaUser, + ListContactPointsRequest, + ListContactPointsResponse, + ListGrafanaUsersRequest, + ListGrafanaUsersResponse, + ListTokensRequest, + ListTokensResponse, + ResetCockpitGrafanaRequest, + ResetGrafanaUserPasswordRequest, + Token, + TriggerTestAlertRequest, +} from './types.gen' + +const jsonContentHeaders = { + 'Content-Type': 'application/json; charset=utf-8', +} + +/** + * Cockpit API. + * + * This API allows to manage Cockpits. + */ +export class API extends ParentAPI { + activateCockpit = (request: Readonly = {}) => + this.client.fetch( + { + body: JSON.stringify( + marshalActivateCockpitRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1beta1/activate`, + }, + unmarshalCockpit, + ) + + /** + * Get the cockpit associated with the given project ID. + * + * @param request - The request {@link GetCockpitRequest} + * @returns A Promise of Cockpit + */ + getCockpit = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/cockpit/v1beta1/cockpit`, + urlParams: urlParams([ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ]), + }, + unmarshalCockpit, + ) + + /** + * Waits for {@link Cockpit} to be in a final state. + * + * @param request - The request {@link GetCockpitRequest} + * @param options - The waiting options + * @returns A Promise of Cockpit + */ + waitForCockpit = ( + request: Readonly = {}, + options?: Readonly>, + ) => + waitForResource( + options?.stop ?? + (res => + Promise.resolve(!COCKPIT_TRANSIENT_STATUSES.includes(res.status))), + this.getCockpit, + request, + options, + ) + + deactivateCockpit = (request: Readonly = {}) => + this.client.fetch( + { + body: JSON.stringify( + marshalDeactivateCockpitRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1beta1/deactivate`, + }, + unmarshalCockpit, + ) + + /** + * Reset the Grafana your cockpit associated with the given project ID. + * + * @param request - The request {@link ResetCockpitGrafanaRequest} + * @returns A Promise of Cockpit + */ + resetCockpitGrafana = (request: Readonly = {}) => + this.client.fetch( + { + body: JSON.stringify( + marshalResetCockpitGrafanaRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1beta1/reset-grafana`, + }, + unmarshalCockpit, + ) + + /** + * Create token associated with the given project ID. + * + * @param request - The request {@link CreateTokenRequest} + * @returns A Promise of Token + */ + createToken = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateTokenRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1beta1/tokens`, + }, + unmarshalToken, + ) + + protected pageOfListTokens = (request: Readonly = {}) => + this.client.fetch( + { + method: 'GET', + path: `/cockpit/v1beta1/tokens`, + urlParams: urlParams( + ['order_by', request.orderBy ?? 'created_at_asc'], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + [ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ], + ), + }, + unmarshalListTokensResponse, + ) + + /** + * List tokens associated with the given project ID. + * + * @param request - The request {@link ListTokensRequest} + * @returns A Promise of ListTokensResponse + */ + listTokens = (request: Readonly = {}) => + enrichForPagination('tokens', this.pageOfListTokens, request) + + /** + * Get the token associated with the given ID. + * + * @param request - The request {@link GetTokenRequest} + * @returns A Promise of Token + */ + getToken = (request: Readonly) => + this.client.fetch( + { + method: 'GET', + path: `/cockpit/v1beta1/tokens/${validatePathParam( + 'tokenId', + request.tokenId, + )}`, + }, + unmarshalToken, + ) + + /** + * Delete the token associated with the given ID. + * + * @param request - The request {@link DeleteTokenRequest} + */ + deleteToken = (request: Readonly) => + this.client.fetch({ + method: 'DELETE', + path: `/cockpit/v1beta1/tokens/${validatePathParam( + 'tokenId', + request.tokenId, + )}`, + }) + + /** + * Create an alert contact point for the default receiver. + * + * @param request - The request {@link CreateContactPointRequest} + * @returns A Promise of ContactPoint + */ + createContactPoint = (request: Readonly = {}) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateContactPointRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1beta1/contact-points`, + }, + unmarshalContactPoint, + ) + + protected pageOfListContactPoints = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/cockpit/v1beta1/contact-points`, + urlParams: urlParams( + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + [ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ], + ), + }, + unmarshalListContactPointsResponse, + ) + + /** + * List alert contact points associated with the given cockpit ID. + * + * @param request - The request {@link ListContactPointsRequest} + * @returns A Promise of ListContactPointsResponse + */ + listContactPoints = (request: Readonly = {}) => + enrichForPagination('contactPoints', this.pageOfListContactPoints, request) + + /** + * Delete an alert contact point for the default receiver. + * + * @param request - The request {@link DeleteContactPointRequest} + */ + deleteContactPoint = (request: Readonly = {}) => + this.client.fetch({ + body: JSON.stringify( + marshalDeleteContactPointRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1beta1/delete-contact-point`, + }) + + /** + * Enable managed alerts. + * + * @param request - The request {@link EnableManagedAlertsRequest} + */ + enableManagedAlerts = (request: Readonly = {}) => + this.client.fetch({ + body: JSON.stringify( + marshalEnableManagedAlertsRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1beta1/enable-managed-alerts`, + }) + + /** + * Disable managed alerts. + * + * @param request - The request {@link DisableManagedAlertsRequest} + */ + disableManagedAlerts = ( + request: Readonly = {}, + ) => + this.client.fetch({ + body: JSON.stringify( + marshalDisableManagedAlertsRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1beta1/disable-managed-alerts`, + }) + + /** + * Trigger a test alert to all receivers. + * + * @param request - The request {@link TriggerTestAlertRequest} + */ + triggerTestAlert = (request: Readonly = {}) => + this.client.fetch({ + body: JSON.stringify( + marshalTriggerTestAlertRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1beta1/trigger-test-alert`, + }) + + /** + * Create a grafana user for your grafana instance. + * + * @param request - The request {@link CreateGrafanaUserRequest} + * @returns A Promise of GrafanaUser + */ + createGrafanaUser = (request: Readonly) => + this.client.fetch( + { + body: JSON.stringify( + marshalCreateGrafanaUserRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1beta1/grafana-users`, + }, + unmarshalGrafanaUser, + ) + + protected pageOfListGrafanaUsers = ( + request: Readonly = {}, + ) => + this.client.fetch( + { + method: 'GET', + path: `/cockpit/v1beta1/grafana-users`, + urlParams: urlParams( + ['order_by', request.orderBy ?? 'login_asc'], + ['page', request.page], + [ + 'page_size', + request.pageSize ?? this.client.settings.defaultPageSize, + ], + [ + 'project_id', + request.projectId ?? this.client.settings.defaultProjectId, + ], + ), + }, + unmarshalListGrafanaUsersResponse, + ) + + /** + * List grafana users who are able to connect to your grafana instance. + * + * @param request - The request {@link ListGrafanaUsersRequest} + * @returns A Promise of ListGrafanaUsersResponse + */ + listGrafanaUsers = (request: Readonly = {}) => + enrichForPagination('grafanaUsers', this.pageOfListGrafanaUsers, request) + + /** + * Delete a grafana user from your grafana instance. + * + * @param request - The request {@link DeleteGrafanaUserRequest} + */ + deleteGrafanaUser = (request: Readonly) => + this.client.fetch({ + body: JSON.stringify( + marshalDeleteGrafanaUserRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1beta1/grafana-users/${validatePathParam( + 'grafanaUserId', + request.grafanaUserId, + )}/delete`, + }) + + /** + * Reset the Grafana user password from your grafana instance. + * + * @param request - The request {@link ResetGrafanaUserPasswordRequest} + * @returns A Promise of GrafanaUser + */ + resetGrafanaUserPassword = ( + request: Readonly, + ) => + this.client.fetch( + { + body: JSON.stringify( + marshalResetGrafanaUserPasswordRequest(request, this.client.settings), + ), + headers: jsonContentHeaders, + method: 'POST', + path: `/cockpit/v1beta1/grafana-users/${validatePathParam( + 'grafanaUserId', + request.grafanaUserId, + )}/reset-password`, + }, + unmarshalGrafanaUser, + ) +} diff --git a/packages/clients/src/api/cockpit/v1beta1/content.gen.ts b/packages/clients/src/api/cockpit/v1beta1/content.gen.ts new file mode 100644 index 000000000..ae34914cd --- /dev/null +++ b/packages/clients/src/api/cockpit/v1beta1/content.gen.ts @@ -0,0 +1,10 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import type { CockpitStatus } from './types.gen' + +/** Lists transient statutes of the enum {@link CockpitStatus}. */ +export const COCKPIT_TRANSIENT_STATUSES: CockpitStatus[] = [ + 'creating', + 'deleting', + 'updating', +] diff --git a/packages/clients/src/api/cockpit/v1beta1/index.gen.ts b/packages/clients/src/api/cockpit/v1beta1/index.gen.ts new file mode 100644 index 000000000..7a947c45b --- /dev/null +++ b/packages/clients/src/api/cockpit/v1beta1/index.gen.ts @@ -0,0 +1,38 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +export { API } from './api.gen' +export * from './content.gen' +export type { + ActivateCockpitRequest, + Cockpit, + CockpitEndpoints, + CockpitStatus, + ContactPoint, + ContactPointEmail, + CreateContactPointRequest, + CreateGrafanaUserRequest, + CreateTokenRequest, + DeactivateCockpitRequest, + DeleteContactPointRequest, + DeleteGrafanaUserRequest, + DeleteTokenRequest, + DisableManagedAlertsRequest, + EnableManagedAlertsRequest, + GetCockpitRequest, + GetTokenRequest, + GrafanaUser, + GrafanaUserRole, + ListContactPointsRequest, + ListContactPointsResponse, + ListGrafanaUsersRequest, + ListGrafanaUsersRequestOrderBy, + ListGrafanaUsersResponse, + ListTokensRequest, + ListTokensRequestOrderBy, + ListTokensResponse, + ResetCockpitGrafanaRequest, + ResetGrafanaUserPasswordRequest, + Token, + TokenScopes, + TriggerTestAlertRequest, +} from './types.gen' diff --git a/packages/clients/src/api/cockpit/v1beta1/marshalling.gen.ts b/packages/clients/src/api/cockpit/v1beta1/marshalling.gen.ts new file mode 100644 index 000000000..67c3064fc --- /dev/null +++ b/packages/clients/src/api/cockpit/v1beta1/marshalling.gen.ts @@ -0,0 +1,317 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. +import { + isJSONObject, + resolveOneOf, + unmarshalArrayOfObject, + unmarshalDate, +} from '../../../bridge' +import type { DefaultValues } from '../../../bridge' +import type { + ActivateCockpitRequest, + Cockpit, + CockpitEndpoints, + ContactPoint, + ContactPointEmail, + CreateContactPointRequest, + CreateGrafanaUserRequest, + CreateTokenRequest, + DeactivateCockpitRequest, + DeleteContactPointRequest, + DeleteGrafanaUserRequest, + DisableManagedAlertsRequest, + EnableManagedAlertsRequest, + GrafanaUser, + ListContactPointsResponse, + ListGrafanaUsersResponse, + ListTokensResponse, + ResetCockpitGrafanaRequest, + ResetGrafanaUserPasswordRequest, + Token, + TokenScopes, + TriggerTestAlertRequest, +} from './types.gen' + +const unmarshalContactPointEmail = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ContactPointEmail' failed as data isn't a dictionary.`, + ) + } + + return { to: data.to } as ContactPointEmail +} + +const unmarshalTokenScopes = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'TokenScopes' failed as data isn't a dictionary.`, + ) + } + + return { + queryLogs: data.query_logs, + queryMetrics: data.query_metrics, + setupAlerts: data.setup_alerts, + setupLogsRules: data.setup_logs_rules, + setupMetricsRules: data.setup_metrics_rules, + writeLogs: data.write_logs, + writeMetrics: data.write_metrics, + } as TokenScopes +} + +const unmarshalCockpitEndpoints = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'CockpitEndpoints' failed as data isn't a dictionary.`, + ) + } + + return { + alertmanagerUrl: data.alertmanager_url, + grafanaUrl: data.grafana_url, + logsUrl: data.logs_url, + metricsUrl: data.metrics_url, + } as CockpitEndpoints +} + +export const unmarshalContactPoint = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ContactPoint' failed as data isn't a dictionary.`, + ) + } + + return { + email: data.email ? unmarshalContactPointEmail(data.email) : undefined, + } as ContactPoint +} + +export const unmarshalGrafanaUser = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'GrafanaUser' failed as data isn't a dictionary.`, + ) + } + + return { + id: data.id, + login: data.login, + password: data.password, + role: data.role, + } as GrafanaUser +} + +export const unmarshalToken = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Token' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + id: data.id, + name: data.name, + projectId: data.project_id, + scopes: data.scopes ? unmarshalTokenScopes(data.scopes) : undefined, + secretKey: data.secret_key, + updatedAt: unmarshalDate(data.updated_at), + } as Token +} + +export const unmarshalCockpit = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'Cockpit' failed as data isn't a dictionary.`, + ) + } + + return { + createdAt: unmarshalDate(data.created_at), + endpoints: data.endpoints + ? unmarshalCockpitEndpoints(data.endpoints) + : undefined, + managedAlertsEnabled: data.managed_alerts_enabled, + projectId: data.project_id, + status: data.status, + updatedAt: unmarshalDate(data.updated_at), + } as Cockpit +} + +export const unmarshalListContactPointsResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListContactPointsResponse' failed as data isn't a dictionary.`, + ) + } + + return { + contactPoints: unmarshalArrayOfObject( + data.contact_points, + unmarshalContactPoint, + ), + hasAdditionalContactPoints: data.has_additional_contact_points, + hasAdditionalReceivers: data.has_additional_receivers, + totalCount: data.total_count, + } as ListContactPointsResponse +} + +export const unmarshalListGrafanaUsersResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListGrafanaUsersResponse' failed as data isn't a dictionary.`, + ) + } + + return { + grafanaUsers: unmarshalArrayOfObject( + data.grafana_users, + unmarshalGrafanaUser, + ), + totalCount: data.total_count, + } as ListGrafanaUsersResponse +} + +export const unmarshalListTokensResponse = (data: unknown) => { + if (!isJSONObject(data)) { + throw new TypeError( + `Unmarshalling the type 'ListTokensResponse' failed as data isn't a dictionary.`, + ) + } + + return { + tokens: unmarshalArrayOfObject(data.tokens, unmarshalToken), + totalCount: data.total_count, + } as ListTokensResponse +} + +const marshalContactPointEmail = ( + request: ContactPointEmail, + defaults: DefaultValues, +): Record => ({ + to: request.to, +}) + +const marshalContactPoint = ( + request: ContactPoint, + defaults: DefaultValues, +): Record => ({ + ...resolveOneOf([ + { + param: 'email', + value: request.email + ? marshalContactPointEmail(request.email, defaults) + : undefined, + }, + ]), +}) + +const marshalTokenScopes = ( + request: TokenScopes, + defaults: DefaultValues, +): Record => ({ + query_logs: request.queryLogs, + query_metrics: request.queryMetrics, + setup_alerts: request.setupAlerts, + setup_logs_rules: request.setupLogsRules, + setup_metrics_rules: request.setupMetricsRules, + write_logs: request.writeLogs, + write_metrics: request.writeMetrics, +}) + +export const marshalActivateCockpitRequest = ( + request: ActivateCockpitRequest, + defaults: DefaultValues, +): Record => ({ + project_id: request.projectId ?? defaults.defaultProjectId, +}) + +export const marshalCreateContactPointRequest = ( + request: CreateContactPointRequest, + defaults: DefaultValues, +): Record => ({ + contact_point: request.contactPoint + ? marshalContactPoint(request.contactPoint, defaults) + : undefined, + project_id: request.projectId ?? defaults.defaultProjectId, +}) + +export const marshalCreateGrafanaUserRequest = ( + request: CreateGrafanaUserRequest, + defaults: DefaultValues, +): Record => ({ + login: request.login, + project_id: request.projectId ?? defaults.defaultProjectId, + role: request.role ?? 'unknown_role', +}) + +export const marshalCreateTokenRequest = ( + request: CreateTokenRequest, + defaults: DefaultValues, +): Record => ({ + name: request.name, + project_id: request.projectId ?? defaults.defaultProjectId, + scopes: request.scopes + ? marshalTokenScopes(request.scopes, defaults) + : undefined, +}) + +export const marshalDeactivateCockpitRequest = ( + request: DeactivateCockpitRequest, + defaults: DefaultValues, +): Record => ({ + project_id: request.projectId ?? defaults.defaultProjectId, +}) + +export const marshalDeleteContactPointRequest = ( + request: DeleteContactPointRequest, + defaults: DefaultValues, +): Record => ({ + contact_point: request.contactPoint + ? marshalContactPoint(request.contactPoint, defaults) + : undefined, + project_id: request.projectId ?? defaults.defaultProjectId, +}) + +export const marshalDeleteGrafanaUserRequest = ( + request: DeleteGrafanaUserRequest, + defaults: DefaultValues, +): Record => ({ + project_id: request.projectId ?? defaults.defaultProjectId, +}) + +export const marshalDisableManagedAlertsRequest = ( + request: DisableManagedAlertsRequest, + defaults: DefaultValues, +): Record => ({ + project_id: request.projectId ?? defaults.defaultProjectId, +}) + +export const marshalEnableManagedAlertsRequest = ( + request: EnableManagedAlertsRequest, + defaults: DefaultValues, +): Record => ({ + project_id: request.projectId ?? defaults.defaultProjectId, +}) + +export const marshalResetCockpitGrafanaRequest = ( + request: ResetCockpitGrafanaRequest, + defaults: DefaultValues, +): Record => ({ + project_id: request.projectId ?? defaults.defaultProjectId, +}) + +export const marshalResetGrafanaUserPasswordRequest = ( + request: ResetGrafanaUserPasswordRequest, + defaults: DefaultValues, +): Record => ({ + project_id: request.projectId ?? defaults.defaultProjectId, +}) + +export const marshalTriggerTestAlertRequest = ( + request: TriggerTestAlertRequest, + defaults: DefaultValues, +): Record => ({ + project_id: request.projectId ?? defaults.defaultProjectId, +}) diff --git a/packages/clients/src/api/cockpit/v1beta1/types.gen.ts b/packages/clients/src/api/cockpit/v1beta1/types.gen.ts new file mode 100644 index 000000000..8a2f8cd46 --- /dev/null +++ b/packages/clients/src/api/cockpit/v1beta1/types.gen.ts @@ -0,0 +1,206 @@ +// This file was automatically generated. DO NOT EDIT. +// If you have any remark or suggestion do not hesitate to open an issue. + +export type CockpitStatus = + | 'unknown_status' + | 'creating' + | 'ready' + | 'deleting' + | 'updating' + | 'error' + +export type GrafanaUserRole = 'unknown_role' | 'editor' | 'viewer' + +export type ListGrafanaUsersRequestOrderBy = 'login_asc' | 'login_desc' + +export type ListTokensRequestOrderBy = + | 'created_at_asc' + | 'created_at_desc' + | 'name_asc' + | 'name_desc' + +/** Cockpit */ +export interface Cockpit { + /** Project ID */ + projectId: string + /** Created at */ + createdAt?: Date + /** Updated at */ + updatedAt?: Date + /** Endpoints */ + endpoints?: CockpitEndpoints + /** Status */ + status: CockpitStatus + /** Managed alerts enabled */ + managedAlertsEnabled: boolean +} + +/** Cockpit. endpoints */ +export interface CockpitEndpoints { + metricsUrl: string + logsUrl: string + alertmanagerUrl: string + grafanaUrl: string +} + +/** Alert contact point */ +export interface ContactPoint { + /** + * Alert contact point configuration. + * + * One-of ('configuration'): at most one of 'email' could be set. + */ + email?: ContactPointEmail +} + +export interface ContactPointEmail { + to: string +} + +/** Grafana user */ +export interface GrafanaUser { + id: number + login: string + role: GrafanaUserRole + password?: string +} + +/** List contact points response */ +export interface ListContactPointsResponse { + /** Total count of contact points */ + totalCount: number + /** Contact points array */ + contactPoints: ContactPoint[] + /** Has receivers other than default */ + hasAdditionalReceivers: boolean + /** Has unmanaged contact points */ + hasAdditionalContactPoints: boolean +} + +/** List grafana users response */ +export interface ListGrafanaUsersResponse { + totalCount: number + grafanaUsers: GrafanaUser[] +} + +/** List tokens response */ +export interface ListTokensResponse { + totalCount: number + tokens: Token[] +} + +/** Token */ +export interface Token { + id: string + projectId: string + name: string + createdAt?: Date + updatedAt?: Date + scopes?: TokenScopes + secretKey?: string +} + +/** Token scopes */ +export interface TokenScopes { + queryMetrics: boolean + writeMetrics: boolean + setupMetricsRules: boolean + queryLogs: boolean + writeLogs: boolean + setupLogsRules: boolean + setupAlerts: boolean +} + +export type ActivateCockpitRequest = { + projectId?: string +} + +export type GetCockpitRequest = { + projectId?: string +} + +export type DeactivateCockpitRequest = { + projectId?: string +} + +export type ResetCockpitGrafanaRequest = { + projectId?: string +} + +export type CreateTokenRequest = { + projectId?: string + name: string + scopes?: TokenScopes +} + +export type ListTokensRequest = { + page?: number + pageSize?: number + orderBy?: ListTokensRequestOrderBy + projectId?: string +} + +export type GetTokenRequest = { + tokenId: string +} + +export type DeleteTokenRequest = { + tokenId: string +} + +export type CreateContactPointRequest = { + /** Project ID */ + projectId?: string + /** Contact point to create */ + contactPoint?: ContactPoint +} + +export type ListContactPointsRequest = { + /** Page number */ + page?: number + /** Page size */ + pageSize?: number + /** Project ID */ + projectId?: string +} + +export type DeleteContactPointRequest = { + projectId?: string + /** Contact point to delete */ + contactPoint?: ContactPoint +} + +export type EnableManagedAlertsRequest = { + projectId?: string +} + +export type DisableManagedAlertsRequest = { + projectId?: string +} + +export type TriggerTestAlertRequest = { + projectId?: string +} + +export type CreateGrafanaUserRequest = { + projectId?: string + login: string + role?: GrafanaUserRole +} + +export type ListGrafanaUsersRequest = { + page?: number + pageSize?: number + orderBy?: ListGrafanaUsersRequestOrderBy + projectId?: string +} + +export type DeleteGrafanaUserRequest = { + grafanaUserId: number + projectId?: string +} + +export type ResetGrafanaUserPasswordRequest = { + grafanaUserId: number + projectId?: string +} diff --git a/packages/clients/src/api/index.ts b/packages/clients/src/api/index.ts index bc43b05fb..d95d69542 100644 --- a/packages/clients/src/api/index.ts +++ b/packages/clients/src/api/index.ts @@ -1,6 +1,7 @@ export * as Account from './account' export * as AppleSilicon from './applesilicon' export * as BareMetal from './baremetal' +export * as Cockpit from './cockpit' export * as Container from './container' export * as Domain from './domain' export * as FlexibleIP from './flexibleip'