UNPKG

@openshift-console/dynamic-plugin-sdk-internal

Version:
209 lines (208 loc) 5.11 kB
import { Extension } from '../types'; export type { ResolvedExtension } from '../types'; export type ExtensionHook<T, R = any> = (options: R) => ExtensionHookResult<T>; export type ExtensionHookResult<T> = [T, boolean, any]; export type ExtensionK8sModel = { group: string; version: string; kind: string; }; export type ExtensionK8sGroupModel = { group: string; version?: string; kind?: string; }; export type ExtensionK8sGroupKindModel = { group: string; version?: string; kind: string; }; export type ExtensionK8sKindVersionModel = { group?: string; version: string; kind: string; }; export type K8sModel = { abbr: string; kind: string; label: string; labelKey?: string; labelPlural: string; labelPluralKey?: string; plural: string; propagationPolicy?: 'Foreground' | 'Background'; id?: string; crd?: boolean; apiVersion: string; apiGroup?: string; namespaced?: boolean; selector?: Selector; labels?: { [key: string]: string; }; annotations?: { [key: string]: string; }; verbs?: K8sVerb[]; shortNames?: string[]; badge?: BadgeType; color?: string; legacyPluralURL?: boolean; }; /** * @deprecated migrated to new type K8sModel, use K8sModel over K8sKind */ export type K8sKind = K8sModel; export declare enum Operator { Exists = "Exists", DoesNotExist = "DoesNotExist", In = "In", NotIn = "NotIn", Equals = "Equals", NotEqual = "NotEqual", GreaterThan = "GreaterThan", LessThan = "LessThan", NotEquals = "NotEquals" } export type MatchExpression = { key: string; operator: Operator | string; values?: string[]; }; export type MatchLabels = { [key: string]: string; }; export type Selector = { matchLabels?: MatchLabels; matchExpressions?: MatchExpression[]; }; export type K8sVerb = 'create' | 'get' | 'list' | 'update' | 'patch' | 'delete' | 'deletecollection' | 'watch' | 'impersonate'; declare enum BadgeType { DEV = "Dev Preview", TECH = "Tech Preview" } export declare const enum AlertStates { Firing = "firing", NotFiring = "not-firing", Pending = "pending", Silenced = "silenced" } export declare const enum SilenceStates { Active = "active", Expired = "expired", Pending = "pending" } export declare const enum AlertSeverity { Critical = "critical", Info = "info", None = "none", Warning = "warning" } export declare const enum RuleStates { Firing = "firing", Inactive = "inactive", Pending = "pending", Silenced = "silenced" } export type Silence = { comment: string; createdBy: string; endsAt: string; firingAlerts: Alert[]; id?: string; matchers: { isEqual?: boolean; isRegex: boolean; name: string; value: string; }[]; name?: string; startsAt: string; status?: { state: SilenceStates; }; updatedAt?: string; }; export type PrometheusAlert = { activeAt?: string; annotations: PrometheusLabels; labels: PrometheusLabels & { alertname: string; severity?: AlertSeverity | string; }; state: AlertStates; value?: number | string; }; export type Alert = PrometheusAlert & { rule: Rule; silencedBy?: Silence[]; }; export type Alerts = { data: Alert[]; loaded: boolean; loadError?: string | Error; }; export type PrometheusRule = { alerts: PrometheusAlert[]; annotations: PrometheusLabels; duration: number; labels: PrometheusLabels & { severity?: string; }; name: string; query: string; state: RuleStates; type: string; }; export type Rule = PrometheusRule & { id: string; sourceId?: string; silencedBy?: Silence[]; }; export type PrometheusLabels = { [key: string]: string; }; export type PrometheusValue = [number, string]; type Group = { rules: PrometheusRule[]; file: string; name: string; }; export type PrometheusRulesResponse = { data: { groups: Group[]; }; status: string; }; export type DiscoveryResources = { adminResources: string[]; allResources: string[]; configResources: K8sKind[]; clusterOperatorConfigResources: K8sKind[]; models: K8sKind[]; namespacedSet: Set<string>; safeResources: string[]; groupVersionMap: { [key: string]: { versions: string[]; preferredVersion: string; }; }; }; export type AlwaysOnExtension<P extends {} = any> = Omit<Extension<P>, 'flags'>; declare namespace ExtensionProperties { interface ModelDefinition { /** Additional Kubernetes model definitions to register with Console. */ models: K8sModel[]; } } export interface ModelDefinition extends AlwaysOnExtension<ExtensionProperties.ModelDefinition> { type: 'ModelDefinition'; } export declare enum PrometheusEndpoint { LABEL = "api/v1/label", QUERY = "api/v1/query", QUERY_RANGE = "api/v1/query_range", RULES = "api/v1/rules", TARGETS = "api/v1/targets" }