Environments
Manage environments
This API allows you to manage environments.
Method parameters
Each environment is a part of project which is identified by projectIdentifier (name or ID) which is passed directly to the environments method.
// pass the project identifier (name or ID) to the environments method
await stashbase.environments({ project: 'my-project' }).list()Get
Get single environment by name or id.
Parameters
This method takes single paramter.
Prop
Type
Example
const { data, error } = await stashbase
.environments({ project: 'some-super-project' })
.get('api-dev')
if (error) {
// handle error
} else {
// do something with the data
}List
List environments in a selected project.
Parameters
This mehtod takes no parameters.
Example
const { data, error } = await stashbase.environments({ project: 'project' }).list()
if (error) {
// handle error
} else {
// do something with the data
}Load
When using this method, the SDK client will get the secrets from the environment and inject them as environment variables in the application process.
Parameters
This method takes second parameter which is optional object parameter with the following optional properties:
Prop
Type
Example
const { error } = await stashbase
.environments({ project: 'project-identifier' }) // pass the project
.load('api-dev', {
printSecrets: 'masked',
})
// check for errors
if (error) {
// handle error
}Load or throw
This method is similar to load but it will throw an error if something goes wrong instead of returning the error as property.
Parameters
This method takes second parameter which is optional object parameter with the following optional properties:
Prop
Type
Example
const { error } = await stashbase
.environments({ project: 'project-identifier' })
.loadOrThrow('api-dev', {
printSecrets: 'name',
})Create
Create new environment in a project.
This method returns id and name properties.
Parameters
This method takes object parameter with the following properties:
Prop
Type
Example
const { data, error } = await stashbase
.environments({ project: 'project-identifier' }) // pass the project
.create({
name: 'public_api-dev',
isProduction: false,
description: 'Development environment for the public API.',
})
if (error) {
// handle error
}Update
Update existing environment in a project.
Parameters
This method takes two parameters.
Prop
Type
Data
This UpdateEnvironmentData object requires at least one property to be provided.
Prop
Type
Example
const { error } = await stashbase
.environments({ project: 'project-identifier' })
.update('api-dev', {
name: 'public_api-dev',
isProduction: false,
description: 'Development environment for the public API.',
})Delete
Remove existing environment in a selected project.
Parameters
This method takes single parameter.
Prop
Type
Example
const { error } = await stashbase.environments({ project: 'project' }).delete('api-dev')
if (error) {
// handle error
}