跳到主要内容

Create new sandbox

Learn how to add and configure the "Create new sandbox" action in your Buddy pipeline

Create new sandbox

POST参数

名称类型描述
action
必填
StringThe ID of the action.
type
必填
StringThe type of the action. Must be set to SANDBOX_CREATE_NEW.
sandbox_name 必填StringDefines the name of the created sandbox.
sandbox_distribution 必填StringDefines the OS distro of the sandbox. Can be one of ubuntu/focal or debian/buster.
sandbox_playbooksSandboxPlaybook[]Defines the list of playbooks to install during the sandbox creation.
tagsString[]The list of tags applied to the sandbox.
ram_limit 必填IntDefines the amount of RAM available to the sandbox. Can be one of 2 or 4.
cpu_limit 必填IntDefines the number of vCPUs of the sandbox. Can be one of 1 or 2.
disk_size_limit 必填IntDefines the sandbox disk size. Expressed in GB. Can be one of 5 or 10.
mappings 必填Mapping[]Defines the port-subdomain mappings that allow to access exposed resources on the sandbox.
application_portIntDefines the port used in the mapping.
subdomainStringDefines the subdomain used in the mapping.
usernameStringDefines the basic auth username required to access the exposed resources.
passwordStringDefines the basic auth password required to access the exposed resources.

Sample Request (with playbooks)

POST https://api.buddy.works/workspaces/buddy/projects/company-website/pipelines/2/actions

JSON

{
"name": "Create new sandbox",
"type": "SANDBOX_CREATE_NEW",
"trigger_time": "ON_EVERY_EXECUTION",
"last_execution_status": "SUCCESSFUL",
"disabled": false,
"sandbox_name": "new sandbox with playbooks",
"ignore_errors": false,
"run_next_parallel": false,
"sandbox_distribution": "ubuntu/focal",
"sandbox_playbooks": [
{
"type": "APACHE",
"install_php": true,
"php_version": "8.0",
"php_modules": [
"gd",
"mysql",
"opcache",
"curl",
"xml",
"mbstring",
"imagick",
"zip"
],
"modules": [
"expires",
"headers",
"rewrite"
]
},
{
"type": "DOCKER"
},
{
"type": "MONGO",
"version": "5.0"
},
{
"type": "NODE",
"version": "12"
},
{
"type": "POSTGRES",
"db": "test",
"user": "test",
"password": "test"
},
{
"type": "REDIS"
},
{
"type": "RUBY",
"version": "2.7"
},
{
"type": "MYSQL",
"version": "8.0",
"db": "wp",
"user": "wp",
"password": "wp"
},
{
"type": "WORDPRESS",
"db": "wp",
"user": "wp",
"password": "wp",
"phrase": "wp"
}
],
"ram_limit": 2,
"cpu_limit": 1,
"disk_size_limit": 5,
"mappings": [
{
"application_port": 80,
"subdomain": "buddy-subdomain",
"username": "root",
"password": "secure!SNCLQcJdggA0xk2lxAxhiw==.ud7C2Ucd/M6SB9rtTHYvVQ=="
}
]
}

示例响应

HTTP

Status: 201 Created
X-Rate-Limit-Limit: 1
X-Rate-Limit-Remaining: 999

JSON

{
"url": "https://api.buddy.works/workspaces/buddy/projects/company-website/pipelines/2/actions/2",
"html_url": "https://app.buddy.works/buddy/company-website/pipelines/action/2/edit",
"id": 2,
"name": "Create new sandbox",
"type": "SANDBOX_CREATE_NEW",
"trigger_time": "ON_EVERY_EXECUTION",
"last_execution_status": "SUCCESSFUL",
"disabled": false,
"sandbox_name": "new sandbox with playbooks",
"tags": [],
"ignore_errors": false,
"run_next_parallel": false,
"sandbox_distribution": "ubuntu/focal",
"sandbox_playbooks": [
{
"type": "APACHE",
"install_php": true,
"php_version": "8.0",
"php_modules": [
"gd",
"mysql",
"opcache",
"curl",
"xml",
"mbstring",
"imagick",
"zip"
],
"modules": [
"expires",
"headers",
"rewrite"
]
},
{
"type": "DOCKER"
},
{
"type": "MONGO",
"version": "5.0"
},
{
"type": "NODE",
"version": "12"
},
{
"type": "POSTGRES",
"db": "test",
"user": "test",
"password": "test"
},
{
"type": "REDIS"
},
{
"type": "RUBY",
"version": "2.7"
},
{
"type": "MYSQL",
"version": "8.0",
"db": "wp",
"user": "wp",
"password": "wp"
},
{
"type": "WORDPRESS",
"db": "wp",
"user": "wp",
"password": "wp",
"phrase": "wp"
}
],
"ram_limit": 2,
"cpu_limit": 1,
"disk_size_limit": 5,
"return_existing": false,
"mappings": [
{
"application_port": 80,
"subdomain": "subdomain",
"username": "",
"password": ""
}
],
"pipeline": {
"url": "https://api.buddy.works/workspaces/buddy/projects/company-website/pipelines/2",
"html_url": "https://app.buddy.works/buddy/company-website/pipelines/pipeline/2",
"id": 2,
"name": "Live mirror",
"refs": [
"refs/heads/master"
],
"last_execution_status": "SUCCESSFUL",
"last_execution_revision": "506a3963507943d6908154f4bc9646e829128a08"
}
}

Duplicate existing sandbox

POST参数

名称类型描述
action
必填
StringThe ID of the action.
type
必填
StringThe type of the action. Must be set to SANDBOX_CREATE_FROM_SANDBOX.
sandbox_name 必填StringDefines the name of the created sandbox.
sandbox_id 必填StringDefines the ID of the existing sandbox used to create new sandbox.
tagsString[]The list of tags applied to sandbox.
ram_limit 必填IntDefines the amount of RAM available to the sandbox. Can be one of 2 or 4.
cpu_limit 必填IntDefines the number of vCPUs of the sandbox. Can be one of 1 or 2.
disk_size_limit 必填IntDefines the sandbox disk size. Expressed in GB. Can be one of 5 or 10.
mappings 必填Mapping[]Defines the port-subdomain mappings that allow to access exposed resources on the sandbox.
application_portIntDefines the port used in the mapping.
subdomainStringDefines the subdomain used in the mapping.
usernameStringDefines the basic auth username required to access the exposed resources.
passwordStringDefines the basic auth password required to access the exposed resources.

Sample Request

POST https://api.buddy.works/workspaces/buddy/projects/company-website/pipelines/2/actions

JSON

{
"name": "Create new sandbox from existing",
"type": "SANDBOX_CREATE_FROM_SANDBOX",
"trigger_time": "ON_EVERY_EXECUTION",
"tags": [
"tag_1",
"tag_2"
],
"sandbox_name": "sandbox-buddy",
"sandbox_id": "BJ7YnoUVtfGdo",
"ram_limit": 2,
"cpu_limit": 1,
"disk_size_limit": 5,
"mappings": [
{
"application_port": 80,
"subdomain": "buddy-subdomain",
"username": "root",
"password": "password!@#$"
}
]
}

示例响应

HTTP

Status: 201 Created
X-Rate-Limit-Limit: 1
X-Rate-Limit-Remaining: 999

JSON

{
"url": "https://api.buddy.works/workspaces/buddy/projects/company-website/pipelines/2/actions/2",
"html_url": "https://app.buddy.works/buddy/company-website/pipelines/action/2/edit",
"id": 2,
"name": "Create new sandbox from existing",
"type": "SANDBOX_CREATE_FROM_SANDBOX",
"trigger_time": "ON_EVERY_EXECUTION",
"last_execution_status": "INITIAL",
"tags": [
"tag_1",
"tag_2"
],
"sandbox_name": "sandbox-buddy",
"sandbox_id": "BJ7YnoUVtfGdo",
"ram_limit": 2,
"cpu_limit": 1,
"disk_size_limit": 5,
"mappings": [
{
"application_port": 80,
"subdomain": "buddy-subdomain",
"username": "root",
"password": "secure!SNCLQcJdggA0xk2lxAxhiw==.ud7C2Ucd/M6SB9rtTHYvVQ=="
}
],
"pipeline": {
"url": "https://api.buddy.works/workspaces/buddy/projects/company-website/pipelines/2",
"html_url": "https://app.buddy.works/buddy/company-website/pipelines/pipeline/2",
"id": 2,
"name": "Live mirror",
"refs": [
"refs/heads/master"
],
"last_execution_status": "SUCCESSFUL",
"last_execution_revision": "506a3963507943d6908154f4bc9646e829128a08"
}
}

Create from snapshot

POST参数

名称类型描述
action
必填
StringThe ID of the action.
type
必填
StringThe type of the action. Must be set to SANDBOX_CREATE_FROM_SNAPSHOT.
sandbox_name 必填StringDefines the name of the created sandbox.
snapshot_id 必填StringDefines the ID of the snapshot used to create a sandbox.
tagsString[]The list list of tags applied to sandbox.
ram_limit 必填IntDefines the amount of RAM available to the sandbox. Can be one of 2 or 4.
cpu_limit 必填IntDefines the number of vCPUs of the sandbox. Can be one of 1 or 2.
disk_size_limit 必填IntDefines the sandbox disk size. Expressed in GB. Can be one of 5 or 10.
mappings 必填Mapping[]Defines the port-subdomain mappings that allow to access exposed resources on the sandbox.
application_portIntDefines the port used in the mapping.
subdomainStringDefines the subdomain used in the mapping.
usernameStringDefines the basic auth username required to access the exposed resources.
passwordStringDefines the basic auth password required to access the exposed resources.

Sample Request

POST https://api.buddy.works/workspaces/buddy/projects/company-website/pipelines/2/actions

JSON

{
"name": "Create new sandbox from snapshot",
"type": "SANDBOX_CREATE_FROM_SNAPSHOT",
"trigger_time": "ON_EVERY_EXECUTION",
"tags": [
"tag_1",
"tag_2"
],
"sandbox_name": "sandbox-buddy",
"snapshot_id": "sn-SsWzv1Y1xBrYX",
"ram_limit": 2,
"cpu_limit": 1,
"disk_size_limit": 5,
"mappings": [
{
"application_port": 80,
"subdomain": "buddy-subdomain",
"username": "root",
"password": "password!@#$"
}
]
}

示例响应

HTTP

Status: 201 Created
X-Rate-Limit-Limit: 1
X-Rate-Limit-Remaining: 999

JSON

{
"url": "https://api.buddy.works/workspaces/buddy/projects/company-website/pipelines/2/actions/2",
"html_url": "https://app.buddy.works/buddy/company-website/pipelines/action/2/edit",
"id": 2,
"name": "Create new sandbox from snapshot",
"type": "SANDBOX_CREATE_FROM_SNAPSHOT",
"trigger_time": "ON_EVERY_EXECUTION",
"last_execution_status": "INITIAL",
"tags": [
"tag_1",
"tag_2"
],
"sandbox_name": "sandbox-buddy",
"snapshot_id": "sn-SsWzv1Y1xBrYX",
"ram_limit": 2,
"cpu_limit": 1,
"disk_size_limit": 5,
"mappings": [
{
"application_port": 80,
"subdomain": "buddy-subdomain",
"username": "root",
"password": "secure!SNCLQcJdggA0xk2lxAxhiw==.ud7C2Ucd/M6SB9rtTHYvVQ=="
}
],
"pipeline": {
"url": "https://api.buddy.works/workspaces/buddy/projects/company-website/pipelines/2",
"html_url": "https://app.buddy.works/buddy/company-website/pipelines/pipeline/2",
"id": 2,
"name": "Live mirror",
"refs": [
"refs/heads/master"
],
"last_execution_status": "SUCCESSFUL",
"last_execution_revision": "506a3963507943d6908154f4bc9646e829128a08"
}
}