Environments Setup
Ductape allows you to provision apps and services in multiple environments. For example, a single application can have production, staging, and development environments.
Environments enable seamless development features when building products. Ductape also provides default workspace environments that are created each time an application is provisioned. These default environments can be updated in the Ductape web platform under the application or product tabs.
Creating an App Environment
- TypeScript
- Java
- Go
- .NET
import { DataFormats } from "@ductape/sdk/types";
const data = {
env_name: "develop",
slug: "dev",
description: "Development environment",
active: true,
base_url: "https://dev.example.app",
request_type: DataFormats.JSON
};
const environments = await ductape.app.environment.create(data);
Map<String, Object> data = Map.of(
"env_name", "develop",
"slug", "dev",
"description", "Development environment",
"active", true,
"base_url", "https://dev.example.app",
request_type: DataFormats.JSON
);
Map<String, Object> environments = ductape.app.environment.create(data);
data := map[string]any{
"env_name": "develop",
"slug": "dev",
"description": "Development environment",
"active": true,
"base_url": "https://dev.example.app",
request_type: DataFormats.JSON
};
environments := client.app.environment.create(data);
var data = new Dictionary<string, object?>
{
["env_name"] = "develop",
["slug"] = "dev",
["description"] = "Development environment",
["active"] = true,
["base_url"] = "https://dev.example.app",
request_type: DataFormats.JSON
};
var environments = await ductape.app.environment.create(data);
Required Fields
- env_name: The name of the environment (required).
- slug: A 3-letter identifier in lowercase that serves as a unique identifier for the environment (required).
- description: A description of the environment.
- active: A boolean indicating if the environment is active (defaults to
false). - base_url: The base URL of the environment.
- request_type: The type of requests accepted by the environment, using a value from the
DataFormatsenum.
Request Type Data Formats
| Key | Value |
|---|---|
| JSON | application/json |
| URLENCODED | application/x-www-form-urlencoded |
| FORMDATA | multipart/form-data |
| SOAP | SOAP |
| HTML | html |
Updating an App Environment
- TypeScript
- Java
- Go
- .NET
import { DataFormats } from "@ductape/sdk/types";
const slug = "prd";
const data = {
env_name: "production",
description: "Production environment",
active: true,
base_url: "https://prd.example.app",
request_type: DataFormats.JSON
};
const environments = await ductape.app.environment.update(slug, data);
Map<String, Object> slug = "prd";
Map<String, Object> data = Map.of(
"env_name", "production",
"description", "Production environment",
"active", true,
"base_url", "https://prd.example.app",
request_type: DataFormats.JSON
);
Map<String, Object> environments = ductape.app.environment.update(slug, data);
slug := "prd";
data := map[string]any{
"env_name": "production",
"description": "Production environment",
"active": true,
"base_url": "https://prd.example.app",
request_type: DataFormats.JSON
};
environments := client.app.environment.update(slug, data);
var slug = "prd";
var data = new Dictionary<string, object?>
{
["env_name"] = "production",
["description"] = "Production environment",
["active"] = true,
["base_url"] = "https://prd.example.app",
request_type: DataFormats.JSON
};
var environments = await ductape.app.environment.update(slug, data);
Fetching Environments
- TypeScript
- Java
- Go
- .NET
const environments = await ductape.app.environment.fetchAll();
Map<String, Object> environments = ductape.app.environment.fetchAll();
environments := client.app.environment.fetchAll();
var environments = await ductape.app.environment.fetchAll();
Fetching a Single Environment
- TypeScript
- Java
- Go
- .NET
const slug = "prd";
const environment = await ductape.app.environment.fetch(slug);
Map<String, Object> slug = "prd";
Map<String, Object> environment = ductape.app.environment.fetch(slug);
slug := "prd";
environment := client.app.environment.fetch(slug);
var slug = "prd";
var environment = await ductape.app.environment.fetch(slug);