Environment =
object
A saved immutable Environment.
readonlyid:ID
The ID of the environment.
readonlyname:string
The name of the environment.
readonlyvariables:EnvironmentVariable[]
The variables of the environment.
readonlyversion:number
The version of the environment.
EnvironmentSDK =
object
The SDK for the Environment service.
createEnvironment(
input:CreateEnvironmentInput):Promise<Environment>
Create a new environment.
| Parameter | Type | Description |
|---|---|---|
input |
CreateEnvironmentInput |
The input for the creation. |
Promise<Environment>
The created environment.
deleteEnvironment(
id:ID):Promise<void>
Delete an environment by its ID.
| Parameter | Type | Description |
|---|---|---|
id |
ID |
The ID of the environment. |
Promise<void>
getEnvironment(
id:ID):Promise<Environment|undefined>
Get an environment by its ID.
| Parameter | Type | Description |
|---|---|---|
id |
ID |
The ID of the environment. |
Promise<Environment | undefined>
The environment or undefined if not found.
getEnvironments():
Promise<Environment[]>
Get all the environments.
Promise<Environment[]>
An array of Environment
getVar(
name:string):string|undefined
Get the value of an environment variable.
| Parameter | Type | Description |
|---|---|---|
name |
string |
The name of the environment variable. |
string | undefined
The value of the environment variable.
getVars():
EnvironmentVariable[]
Get all the environment variables. It includes the global environment and the selected environment. Those variables can change over time so avoid caching them.
An array of EnvironmentVariable
setVar(
input:SetVarInput):Promise<void>
Sets an environment variable to a given value. This will override any existing value. The environment variable can be set either on the currently selected environment or the global environment.
| Parameter | Type |
|---|---|
input |
SetVarInput |
Promise<void>
If trying to set when a project is not selected.
If trying to set when an environment is not selected (with global: false).
await sdk.env.setVar({
name: "USER_SECRET",
value: "my secret value",
secret: true,
global: false
});updateEnvironment(
id:ID,input:UpdateEnvironmentInput):Promise<Environment>
Update an environment.
| Parameter | Type | Description |
|---|---|---|
id |
ID |
The ID of the environment. |
input |
UpdateEnvironmentInput |
The input for the update. |
Promise<Environment>
The updated environment.
If the version passed in is not equal to the current version of the environment.
const environment = await sdk.env.getEnvironment(id);
await sdk.env.updateEnvironment(id, {
version: environment.version,
name: "new name",
variables: [{ name: "USER_SECRET", value: "new secret value", secret: true }],
});EnvironmentVariable =
object
A saved immutable Finding.
readonlyisSecret:boolean
If the environment variable is a secret
readonlyname:string
The name of the environment variable
readonlyvalue:string
The value of the environment variable
SetVarInput =
object
Input for the setVar of EnvironmentSDK.
optionalenv:string
The name of the Environment to set the variable on.
This will take precedence over the global flag if provided.
global:
boolean
If the environment variable should be set on the global environment or the currently selected environment. By default, it will be set globally.
truename:
string
Name of the environment variable
secret:
boolean
If the environment variable should be treated as secret.
falsevalue:
string
Value of the environment variable