/cloud/stack/copy
POST https://api.sitehost.nz/1.3/cloud/stack/copy.json
Clone a stack
Form Parameters
Parameter | Type | Required | Description |
client_id | integer | Yes | The ID for the client that the stack belongs to.Example: 1 |
source_server | string | Yes | The server that contains the stack you want to clone.Example: ch-servername |
name | string | Yes | The name of the stack you want to clone.Example: cc567a321b123c |
destination_server | string | Yes | The server where you want to clone the stack onto. This can be the same as source_server .Example: ch-servername |
label | string | Yes | The label for the new stack.Example: cloned.co.nz |
params[aliases][0] | string | A list of aliases you want to add to the new stack.Example: aliases.co.nz | |
params[copy_env_file] | integer | Copy the environment variables. 0 for false and 1 for true, default is 0 .Example: 1 |
|
params[shutdown] | integer | Shutdown the new stack after cloning. 0 for false and 1 for true, default is 0 .Example: 1 |
|
params[databases][0][clone_db_from] | string | Name of the database you are cloning from source_server .This parameter accepts one or more values in the format of params[databases][0][clone_db_from]=db1, params[databases][1][clone_db_from]=db2 .Example: mydatabase |
|
params[databases][0][mysql_host] | string | MySQL host for the database you are cloning. This parameter accepts one or more values in the format of params[databases][0][mysql_host]=mysql57, params[databases][1][mysql_host]=mysql56 .Example: mysql57 |
|
params[databases][0][db_name] | string | Name for the clone database. This parameter accepts one or more values in the format of params[databases][0][db_name]=newdb1, params[databases][1][db_name]=newdb2 .Example: newdb |
|
params[databases][0][origin_container] | string | Container name that the clone database associates to. This parameter accepts one or more values in the format of params[databases][0][origin_container]=cc567a321b123c, params[databases][1][origin_container]=cc123a321b123d .Example: cc567a321b123c |
|
params[database_users][0][clone_grants_from] | string | Existing database user you wish to clone the set of permissions from. This parameter accepts one or more values in the format of params[database_users][0][clone_grants_from]=user1, params[database_users][1][clone_grants_from]=user2 .Example: dbuser |
|
params[database_users][0][mysql_host] | string | MySQL host for the database user's permission you are cloning. This parameter accepts one or more values in the format of params[database_users][0][mysql_host]=mysql57, params[database_users][1][mysql_host]=mysql56 .Example: mysql57 |
|
params[database_users][0][username] | string | Name for the new database user you are creating that will have the same set of permissions as the existing user specified in clone_grants_from .This parameter accepts one or more values in the format of params[database_users][0][username]=newuser1, params[database_users][1][username]=newuser2 .Example: newuser |
|
params[database_users][0][password] | string | Passwords for the new database user you are creating. This parameter accepts one or more values in the format of params[database_users][0][password]=asecurepassword, params[database_users][1][password]=anothersecurepassword .Example: somesecurepassword |
|
params[database_users][0][database] | string | The clone database that the new database user has access to. This should be one of the values from params[databases][0][db_name] .This parameter accepts one or more values in the format of params[database_users][0][database]=newdb1, params[database_users][1][database]=newdb2 .Example: newdb |
Code Samples
JavaScript PHP Rails Pythonvar xmlHttp = new XMLHttpRequest();
xmlHttp.open("POST", "https://api.sitehost.nz/1.3/cloud/stack/copy.json", false);
var data = new FormData();
data.append("apikey", "your_key_here");
data.append("client_id", "1");
data.append("source_server", "ch-servername");
data.append("name", "cc567a321b123c");
data.append("destination_server", "ch-servername");
data.append("label", "cloned.co.nz");
data.append("params[aliases][0]", "aliases.co.nz");
data.append("params[copy_env_file]", "1");
data.append("params[shutdown]", "1");
data.append("params[databases][0][clone_db_from]", "mydatabase");
data.append("params[databases][0][mysql_host]", "mysql57");
data.append("params[databases][0][db_name]", "newdb");
data.append("params[databases][0][origin_container]", "cc567a321b123c");
data.append("params[database_users][0][clone_grants_from]", "dbuser");
data.append("params[database_users][0][mysql_host]", "mysql57");
data.append("params[database_users][0][username]", "newuser");
data.append("params[database_users][0][password]", "somesecurepassword");
data.append("params[database_users][0][database]", "newdb");
xmlHttp.send(data);
var response = xmlHttp.responseText;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sitehost.nz/1.3/cloud/stack/copy.json");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$body = array(
'apikey' => 'your_key_here',
'client_id' => 1,
'source_server' => 'ch-servername',
'name' => 'cc567a321b123c',
'destination_server' => 'ch-servername',
'label' => 'cloned.co.nz',
'params[aliases][0]' => 'aliases.co.nz',
'params[copy_env_file]' => 1,
'params[shutdown]' => 1,
'params[databases][0][clone_db_from]' => 'mydatabase',
'params[databases][0][mysql_host]' => 'mysql57',
'params[databases][0][db_name]' => 'newdb',
'params[databases][0][origin_container]' => 'cc567a321b123c',
'params[database_users][0][clone_grants_from]' => 'dbuser',
'params[database_users][0][mysql_host]' => 'mysql57',
'params[database_users][0][username]' => 'newuser',
'params[database_users][0][password]' => 'somesecurepassword',
'params[database_users][0][database]' => 'newdb',
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
require 'net/http'
require 'uri'
uri = URI.parse("https://api.sitehost.nz/1.3/cloud/stack/copy.json")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri)
body = {"apikey" => "your_key_here",
"client_id" => 1,
"source_server" => "ch-servername",
"name" => "cc567a321b123c",
"destination_server" => "ch-servername",
"label" => "cloned.co.nz",
"params[aliases][0]" => "aliases.co.nz",
"params[copy_env_file]" => 1,
"params[shutdown]" => 1,
"params[databases][0][clone_db_from]" => "mydatabase",
"params[databases][0][mysql_host]" => "mysql57",
"params[databases][0][db_name]" => "newdb",
"params[databases][0][origin_container]" => "cc567a321b123c",
"params[database_users][0][clone_grants_from]" => "dbuser",
"params[database_users][0][mysql_host]" => "mysql57",
"params[database_users][0][username]" => "newuser",
"params[database_users][0][password]" => "somesecurepassword",
"params[database_users][0][database]" => "newdb",
}
request.set_form_data(body)
response = http.request(request)
import requests
from collections import OrderedDict
uri = 'https://api.sitehost.nz/1.3/cloud/stack/copy.json'
# We need ordered dictionary because parameters have to be in the right order.
# Refer to Developer Notes for more information.
body = OrderedDict()
body['apikey'] = 'your_key_here'
body['client_id'] = 1
body['source_server'] = 'ch-servername'
body['name'] = 'cc567a321b123c'
body['destination_server'] = 'ch-servername'
body['label'] = 'cloned.co.nz'
body['params[aliases][0]'] = 'aliases.co.nz'
body['params[copy_env_file]'] = 1
body['params[shutdown]'] = 1
body['params[databases][0][clone_db_from]'] = 'mydatabase'
body['params[databases][0][mysql_host]'] = 'mysql57'
body['params[databases][0][db_name]'] = 'newdb'
body['params[databases][0][origin_container]'] = 'cc567a321b123c'
body['params[database_users][0][clone_grants_from]'] = 'dbuser'
body['params[database_users][0][mysql_host]'] = 'mysql57'
body['params[database_users][0][username]'] = 'newuser'
body['params[database_users][0][password]'] = 'somesecurepassword'
body['params[database_users][0][database]'] = 'newdb'
response = requests.post(uri, data=body)
Response
200:application/json
{
"return": {
"job_id": "3433562",
"destination_stack": "cc987a123b456a"
},
"msg": "Successful",
"status": true
}
"return": {
"job_id": "3433562",
"destination_stack": "cc987a123b456a"
},
"msg": "Successful",
"status": true
}