/// <reference types="node" />
import * as stream from "stream";
import * as request from "request";
import * as k8s from "@kubernetes/client-node";
import { ClusterWithIngress, SpecialConfigTypesEnum } from '@codiac.io/codiac-domain';
import { IBetterLogger } from "@codiac.io/codiac-common";
import { CommandBaseEnterprise } from '../../command-base-enterprise';
import { RootMap } from '../../apis/codiac-api/contracts';
import { AssetReplicaContext, K8sContainerContext } from '../../relay/contracts';
import { LogOptions } from '../../apis/codiac-relay/contracts';
import { InteractionModes } from "../../uilogic/config-ui-utils";
import { ConfigUiUtils } from "../../uilogic/config-ui-utils";
import { K8sUtils } from "../../ops/k8s/k8s-utils";
/** The value provided as input that indicates
 * a user's desire to be prompted with a list from which choose the value(s),
 * instead of entering them manually or taking a default. */
export declare const PROMPT_ME_DESIGNATOR = "?";
export type TextValueParent = {
    text: string;
    value: string;
    children?: TextValueParent[];
};
export type ScopePedigree = {
    scope: string;
    target: string;
    parent?: ScopePedigree;
};
export type ScopedValuePedigree = {
    scope: string;
    target: string;
    value?: string;
    parent?: ScopedValuePedigree;
};
export declare enum AssetContentType {
    "logs" = "logs",
    "term" = "term",
    "exec" = "exec",
    "env" = "env",
    "config" = "config",
    "status" = "status"
}
export type AssetReplicaContentRequest = {
    content: AssetContentType;
} & AssetReplicaContext;
export type ContentArguments = (LogOptions | ExecArgs | TermArgs | ConfigFileArgs);
export type AssetContentRequest = {
    enterprise: string;
    context: AssetReplicaContext;
    contentType: AssetContentType;
    k8sEntities: K8sContainerContext;
    contentOptions: ContentArguments;
    replicas?: k8s.V1Pod[] | undefined;
};
/** This belongs to k8s - not us, but @kubernetes/client-node has no enum or constants for these magic strings...
 *
 * @see https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase
*/
export declare enum K8S_POD_PHASES {
    "Pending" = "Pending",
    "Running" = "Running",
    "Succeeded" = "Succeeded",
    "Failed" = "Failed",
    "Unknown" = "Unknown"
}
export type BuildCandidateOptions = {
    partialReq: Partial<AssetReplicaContentRequest>;
    contentOptions: ContentArguments;
    interactionMode: InteractionModes;
};
export default class AssetView extends CommandBaseEnterprise {
    static description: string;
    static aliases: string[];
    static flags: {
        help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
        enterprise: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
        asset: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
        environment: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
        cabinet: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
        replica: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
        type: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
        terminal: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
        logsFollow: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
        logsTail: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
        configFile: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
        configType: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
        silent: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
        echo: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
        "to-script": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
        "take-defaults": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
    };
    static strict: boolean;
    static args: {
        cmd: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
    };
    private get uiCloudPvd();
    private _uiCloudPvd_backer;
    private takeDefaults;
    protected get configUtils(): ConfigUiUtils;
    private _configUtils_backer;
    protected get k8sUtils(): K8sUtils;
    private _k8sUtils_backer;
    protected bootstrap(): void;
    protected runAsync(): Promise<void>;
    captureArgs(): Promise<[Partial<AssetContentRequest>, (InteractionModes | undefined), boolean]>;
    private buildCandidate_silently;
    private buildCandidate_interactively;
    private promptForContentOptions;
    private promptForLogOptions;
    private promptForExecOptions;
    private promptForTerminalOptions;
    private promptForContentType;
    private promptForAsset;
    protected deriveClusterFrom(enterprise: string, environment: string, cabinet: string, rootMap: RootMap): ClusterWithIngress;
    private buildSelectChoicesFrom;
    /**
     *
     * @param enterprise
     * @param environment
     * @param cabinet
     * @param asset
     * @param ctrInPod (Optional, defaults to the first one in the spec) The name of the running container (not the image) inside the pod (relevant only when there's more than one).
     * @param defaultValue
     * @returns
     */
    protected promptForReplica(replicas: k8s.V1Pod[], ctrInPod: string | undefined, defaultValue?: string | undefined): Promise<K8sContainerContext>;
    renderSelectedContent(context: AssetReplicaContext, contentType: AssetContentType, k8sEntities: K8sContainerContext, contentOptions?: ContentArguments | undefined, replicas?: k8s.V1Pod[] | undefined): Promise<void>;
    /** Gets the cluster cnxn specs from the relay, then makes the k8s call from the cli.
     *
     * Throws any errors. */
    protected fetchReplicas(context: AssetReplicaContext, namespace: string, k8sClient?: k8s.CoreV1Api): Promise<k8s.V1Pod[]>;
    protected watchStatus_NEW(context: AssetReplicaContext, namespace: string, retry?: number): Promise<void>;
    /** Wrapper for k8s client to handler exceptions (esp 401 and 403).
     *
     * Without this wrapper, the k8s client crashes the whole process with unhandled errors.
     */
    private tryListNamespacedPods;
    protected watchReplicaSet(context: AssetReplicaContext, namespace: string, replicaSets?: k8s.V1ReplicaSet[] | undefined): Promise<void>;
    protected watchStatus(context: AssetReplicaContext, namespace: string, replicas?: k8s.V1Pod[] | undefined): Promise<void>;
    /** Mutates canvas */
    private renderReplicaStatusRow;
    private renderCondition;
    private renderPodState;
    private unblockAndSleep;
    /** Fetches pods if not already provided. */
    protected showStatus(context: AssetReplicaContext, namespace: string, replicas?: k8s.V1Pod[] | undefined, k8sApi?: k8s.CoreV1Api): Promise<void>;
    protected showLogs(context: Required<AssetReplicaContext>, logOptions?: LogOptions | undefined): Promise<void>;
    /**
     * @param context Fully qualified path, in terms of Codiac entities, to identify a single replica of an asset in a cabinet.
     * @param execArgs Parameters identifying the ultimate command to run and the console behavior.
     * @param K8sEntities The identifying names of the relevant kubernetes objects, corresponding to the asset replica context, that fully qualify the desired container. */
    protected runExec(context: AssetReplicaContext, execArgs: ExecArgs, k8sEntities: Required<K8sContainerContext>): Promise<void>;
    /** Parses the stream number from the incoming message,
     * and writes the data to the designated target stream.
     *
     * (The k8s client prefixes the buffer with the stream number at position 0)
     */
    routeK8sWebSocketMessage(msg: any): void;
}
export declare class ExecArgs {
    command: string | string[];
    tty: boolean;
    constructor(command: string | string[], tty?: boolean);
}
export declare class ConfigFileArgs {
    rootPathName?: string | undefined;
    configType?: SpecialConfigTypesEnum | undefined;
    constructor(rootPathName?: string | undefined, configType?: SpecialConfigTypesEnum | undefined);
}
export declare class TermArgs {
    terminalStartup: "bash" | "sh" | string;
    /**
     *
     * @param terminalStartup The type of terminal to open.  This command may change depending on what terminal or command shell types are available in the image.
     */
    constructor(terminalStartup: "bash" | "sh" | string);
}
/** Idnetifies a container, in a pod, in a namespace, in a cluster. */
export declare class K8sContainerRef {
    namespace: string;
    podName: string;
    /** This should be optional. When there's only one container in a pod,
     * we should be able to derive this from the pod spec. */
    containerName: string;
    constructor(namespace: string, podName: string, 
    /** This should be optional. When there's only one container in a pod,
     * we should be able to derive this from the pod spec. */
    containerName: string);
}
export declare class LogStreamer {
    private logger;
    constructor(logger: IBetterLogger);
    go(requestOptions: request.Options, stream: stream.Writable): Promise<request.Request>;
}
