UNPKG

@alauda-fe/common

Version:

Alauda frontend team common codes.

78 lines (77 loc) 3.77 kB
/** * @packageDocumentation * @module utils */ import { DialogService, MessageService } from '@alauda/ui'; import { Injector } from '@angular/core'; import { Observable } from 'rxjs'; import { K8sApiService, K8sResourceDefinition, ResourceDeleteParams } from '../../api/public-api'; import { TranslateService } from '../../translate/public-api'; import { KubernetesResource, Status } from '../types/public-api'; import * as i0 from "@angular/core"; export declare const METADATA = "metadata"; export declare const NAMESPACE = "namespace"; export declare const NAME = "name"; export declare const CREATION_TIMESTAMP = "creationTimestamp"; export declare const ANNOTATIONS = "annotations"; export declare const LABELS = "labels"; export declare const DISPLAY_NAME = "display-name"; export declare const DESCRIPTION = "description"; export declare const CREATOR = "creator"; export declare const UPDATED__AT = "updated-at"; export declare const PROJECT = "project"; export declare const CLUSTER = "cluster"; export interface BaseNormalizeTypeParams { type: string; baseDomain: string; prefix?: string; } export declare class K8sUtilService<R extends string = string> { protected injector: Injector; protected dialog: DialogService; protected message: MessageService; protected k8sApi: K8sApiService<R>; protected translate: TranslateService; protected baseDomain: string; constructor(injector: Injector); /** * @param type - 对应资源的翻译 key */ deleteResource<T extends KubernetesResource>(params: ResourceDeleteParams<R, T>, typeOrOptions: string | { type: string; content: string; }): Observable<Status>; updateResource<T extends KubernetesResource>({ type, definition, cluster, resource, silent, }: { type?: R; definition?: K8sResourceDefinition; cluster: string; resource: T; silent?: boolean; }): Observable<T>; updateGlobalResource<T extends KubernetesResource>({ type, definition, namespaced, resource, namespace, silent, }: { type?: R; definition?: K8sResourceDefinition; namespaced?: boolean; resource: T; namespace?: string; silent?: boolean; }): Observable<T>; normalizeType(type: string, prefix?: string): string; normalizeType(params: BaseNormalizeTypeParams): string; getAnnotation<T extends KubernetesResource>(resource: T, type: string, prefix?: string): string; getAnnotation<T extends KubernetesResource>(resource: T, params: BaseNormalizeTypeParams): string; getNamespace<T extends KubernetesResource>(resource: T): T["metadata"]["namespace"]; getName<T extends KubernetesResource>(resource: T): T["metadata"]["name"]; getCreationTimestamp<T extends KubernetesResource>(resource: T): T["metadata"]["creationTimestamp"]; getDisplayName<T extends KubernetesResource>(resource: T, prefix?: string): string; getUnionDisplayName<T extends KubernetesResource>(resource: T, namePrefix?: string | false, displayNamePrefix?: string): string; getDescription<T extends KubernetesResource>(resource: T, prefix?: string): string; getCreator<T extends KubernetesResource>(resource: T, prefix?: string): string; getUpdatedAt<T extends KubernetesResource>(resource: T, prefix?: string): string; getLabel<T extends KubernetesResource>(resource: T, type: string, prefix?: string): string; getLabel<T extends KubernetesResource>(resource: T, params: BaseNormalizeTypeParams): string; getProject<T extends KubernetesResource>(resource: T): string; private retryUpdate; static ɵfac: i0.ɵɵFactoryDeclaration<K8sUtilService<any>, never>; static ɵprov: i0.ɵɵInjectableDeclaration<K8sUtilService<any>>; }