Skip to content

Instantly share code, notes, and snippets.

@EvanBoyle
Last active September 25, 2020 15:52
Show Gist options
  • Save EvanBoyle/bbe031e49bb5842f0c443f479e34acdb to your computer and use it in GitHub Desktop.
Save EvanBoyle/bbe031e49bb5842f0c443f479e34acdb to your computer and use it in GitHub Desktop.
NodeJS Automation API Shape
export declare type ConfigValue = {
value: string;
secret?: boolean;
};
export declare type ConfigMap = {
[key: string]: ConfigValue;
};
import { ConfigMap, ConfigValue } from "./config";
import { ProjectSettings } from "./projectSettings";
import { Stack } from "./stack";
import { StackSettings } from "./stackSettings";
import { PulumiFn, StackSummary, Workspace } from "./workspace";
export declare class LocalWorkspace implements Workspace {
ready: Promise<any[]>;
private workDir;
private pulumiHome?;
private program?;
private envVars;
private secretsProvider?;
static NewStackLocalSource(stackName: string, workDir: string, opts?: LocalWorkspaceOpts): Promise<Stack>;
static UpsertStackLocalSource(stackName: string, workDir: string, opts?: LocalWorkspaceOpts): Promise<Stack>;
static SelectStackLocalSource(stackName: string, workDir: string, opts?: LocalWorkspaceOpts): Promise<Stack>;
private static localSourceStackHelper;
static NewStackInlineSource(stackName: string, projectName: string, program: PulumiFn, opts?: LocalWorkspaceOpts): Promise<Stack>;
static UpsertStackInlineSource(stackName: string, projectName: string, program: PulumiFn, opts?: LocalWorkspaceOpts): Promise<Stack>;
static SelectStackInlineSource(stackName: string, projectName: string, program: PulumiFn, opts?: LocalWorkspaceOpts): Promise<Stack>;
private static inlineSourceStackHelper;
constructor(opts?: LocalWorkspaceOpts);
projectSettings(): Promise<ProjectSettings>;
saveProjectSettings(settings: ProjectSettings): Promise<void>;
stackSettings(stackName: string): Promise<StackSettings>;
saveStackSettings(settings: StackSettings, stackName: string): Promise<void>;
createStack(stackName: string): Promise<void>;
selectStack(stackName: string): Promise<void>;
removeStack(stackName: string): Promise<void>;
getConfig(stackName: string, key: string): Promise<ConfigValue>;
getAllConfig(stackName: string): Promise<ConfigMap>;
setConfig(stackName: string, key: string, value: ConfigValue): Promise<void>;
setAllConfig(stackName: string, config: ConfigMap): Promise<void>;
removeConfig(stackName: string, key: string): Promise<void>;
removeAllConfig(stackName: string, keys: string[]): Promise<void>;
refreshConfig(stackName: string): Promise<ConfigMap>;
getEnvVars(): {
[key: string]: string;
};
setEnvVars(envs: {
[key: string]: string;
}): void;
setEnvVar(key: string, value: string): void;
unsetEnvVar(key: string): void;
getWorkDir(): string;
getPulumiHome(): string | undefined;
whoAmI(): Promise<string>;
stack(): Promise<StackSummary | undefined>;
listStacks(): Promise<StackSummary[]>;
getProgram(): PulumiFn | undefined;
setProgram(program: PulumiFn): void;
serializeArgsForOp(_: string): Promise<string[]>;
postCommandCallback(_: string): Promise<void>;
private runPulumiCmd;
}
export declare type LocalWorkspaceOpts = {
workDir?: string;
pulumiHome?: string;
program?: PulumiFn;
envVars?: {
[key: string]: string;
};
secretsProvider?: string;
projectSettings?: ProjectSettings;
stackSettings?: {
[key: string]: StackSettings;
};
};
export declare class ProjectSettings {
name: string;
runtime: ProjectRuntimeInfo;
main?: string;
description?: string;
author?: string;
website?: string;
license?: string;
config?: string;
template?: ProjectTemplate;
backend?: ProjectBackend;
static fromJSON(obj: any): ProjectSettings;
static fromYAML(text: string): ProjectSettings;
constructor();
toYAML(): string;
}
export declare class ProjectRuntimeInfo {
name: string;
options?: {
[key: string]: any;
};
static fromJSON(obj: any): ProjectRuntimeInfo;
constructor();
toJSON(): any;
}
export declare type ProjectTemplate = {
description?: string;
quickstart?: string;
config?: {
[key: string]: ProjectTemplateConfigValue;
};
important?: boolean;
};
export declare type ProjectTemplateConfigValue = {
description?: string;
default?: string;
secret?: boolean;
};
export declare type ProjectBackend = {
url?: string;
};
import { ConfigMap, ConfigValue } from "./config";
import { PulumiFn, Workspace } from "./workspace";
export declare type StackInitMode = "create" | "select" | "upsert";
export declare class Stack {
ready: Promise<any>;
private name;
private workspace;
static Create(name: string, workspace: Workspace): Promise<Stack>;
static Select(name: string, workspace: Workspace): Promise<Stack>;
static Upsert(name: string, workspace: Workspace): Promise<Stack>;
constructor(name: string, workspace: Workspace, mode: StackInitMode);
up(opts?: UpOptions): Promise<UpResult>;
preview(opts?: PreviewOptions): Promise<PreviewResult>;
refresh(opts?: RefreshOptions): Promise<RefreshResult>;
destroy(opts?: DestroyOptions): Promise<DestroyResult>;
getName(): string;
getWorkspace(): Workspace;
getConfig(key: string): Promise<ConfigValue>;
getAllConfig(): Promise<ConfigMap>;
setConfig(key: string, value: ConfigValue): Promise<void>;
setAllConfig(config: ConfigMap): Promise<void>;
removeConfig(key: string): Promise<void>;
removeAllConfig(keys: string[]): Promise<void>;
refreshConfig(): Promise<ConfigMap>;
outputs(): Promise<OutputMap>;
history(): Promise<UpdateSummary[]>;
info(): Promise<UpdateSummary | undefined>;
private runPulumiCmd;
}
export declare function FullyQualifiedStackName(org: string, project: string, stack: string): string;
export declare type OutputValue = {
value: any;
secret: boolean;
};
export declare type OutputMap = {
[key: string]: OutputValue;
};
export declare type UpdateSummary = {
kind: UpdateKind;
startTime: number;
message: string;
environment: {
[key: string]: string;
};
config: ConfigMap;
result: UpdateResult;
endTime: number;
version: number;
Deployment?: RawJSON;
resourceChanges?: OpMap;
};
export declare type UpdateKind = "update" | "preview" | "refresh" | "rename" | "destroy" | "import";
export declare type UpdateResult = "not-started" | "in-progress" | "succeeded" | "failed";
export declare type OpType = "same" | "create" | "update" | "delete" | "replace" | "create-replacement" | "delete-replaced";
export declare type OpMap = {
[key in OpType]: number;
};
export declare type RawJSON = string;
export declare type UpResult = {
stdout: string;
stderr: string;
outputs: OutputMap;
summary: UpdateSummary;
};
export declare type PreviewResult = {
stdout: string;
stderr: string;
summary: UpdateSummary;
};
export declare type RefreshResult = {
stdout: string;
stderr: string;
summary: UpdateSummary;
};
export declare type DestroyResult = {
stdout: string;
stderr: string;
summary: UpdateSummary;
};
export declare type UpOptions = {
parallel?: number;
message?: string;
expectNoChanges?: boolean;
replace?: string[];
target?: string[];
targetDependents?: boolean;
onOutput?: (out: string) => void;
program?: PulumiFn;
};
export declare type PreviewOptions = {
parallel?: number;
message?: string;
expectNoChanges?: boolean;
replace?: string[];
target?: string[];
targetDependents?: boolean;
program?: PulumiFn;
};
export declare type RefreshOptions = {
parallel?: number;
message?: string;
expectNoChanges?: boolean;
target?: string[];
onOutput?: (out: string) => void;
};
export declare type DestroyOptions = {
parallel?: number;
message?: string;
target?: string[];
targetDependents?: boolean;
onOutput?: (out: string) => void;
};
export declare class StackSettings {
secretsProvider?: string;
encryptedKey?: string;
encryptionSalt?: string;
config?: {
[key: string]: StackSettingsConfigValue;
};
static fromJSON(obj: any): StackSettings;
static fromYAML(text: string): StackSettings;
toYAML(): string;
}
export declare class StackSettingsConfigValue {
value?: string;
secure?: string;
static fromJSON(obj: any): StackSettingsConfigValue;
toJSON(): any;
}
import { ConfigMap, ConfigValue } from "./config";
import { ProjectSettings } from "./projectSettings";
import { StackSettings } from "./stackSettings";
export interface Workspace {
projectSettings(): Promise<ProjectSettings>;
saveProjectSettings(settings: ProjectSettings): Promise<void>;
stackSettings(stackName: string): Promise<StackSettings>;
saveStackSettings(settings: StackSettings, stackName: string): Promise<void>;
serializeArgsForOp(stackName: string): Promise<string[]>;
postCommandCallback(stackName: string): Promise<void>;
getConfig(stackName: string, key: string): Promise<ConfigValue>;
getAllConfig(stackName: string): Promise<ConfigMap>;
setConfig(stackName: string, key: string, value: ConfigValue): Promise<void>;
setAllConfig(stackName: string, config: ConfigMap): Promise<void>;
removeConfig(stackName: string, key: string): Promise<void>;
removeAllConfig(stackName: string, keys: string[]): Promise<void>;
refreshConfig(stackName: string): Promise<ConfigMap>;
getEnvVars(): {
[key: string]: string;
};
setEnvVars(envs: {
[key: string]: string;
}): void;
setEnvVar(key: string, value: string): void;
unsetEnvVar(key: string): void;
getWorkDir(): string;
getPulumiHome(): string | undefined;
whoAmI(): Promise<string>;
stack(): Promise<StackSummary | undefined>;
createStack(stackName: string): Promise<void>;
selectStack(stackName: string): Promise<void>;
removeStack(stackName: string): Promise<void>;
listStacks(): Promise<StackSummary[]>;
getProgram(): PulumiFn | undefined;
setProgram(program: PulumiFn): void;
}
export declare type StackSummary = {
name: string;
current: boolean;
lastUpdate?: string;
updateInProgress: boolean;
resourceCount?: number;
url?: string;
};
export declare type PulumiFn = () => Promise<any>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment