/cloud/stack/overwrite
POST https://api.sitehost.nz/1.2/cloud/stack/overwrite.json
Overwrite 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 origin stack.Example: ch-servername |
name | string | Yes | The name of the origin stack.Example: cc567a321b123c |
destination_server | string | Yes | The server where you want to overwrite the stack onto. This can be the same as source_server .Example: ch-servername |
destination_stack | string | Yes | The name of the destination stack you want to overwrite onto.Example: cc987a456b321a |
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 destination stack after overwriting. 0 for false and 1 for true, default is 0 .Example: 1 |
|
params[only][0] | integer | The directories on the destination stack to overwrite. Can be one of these values - application , config , crontabs .Example: application |
|
params[databases][0][clone_db_from] | string | The origin database. 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 | The MySQL host for the origin database. 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 | The destination database you want to overwrite onto. This parameter accepts one or more values in the format of params[databases][0][db_name]=existingdb1, params[databases][1][db_name]=existingdb1 .Example: existingdb |
|
params[databases][0][origin_container] | string | The container name that the overwritten 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 |
Code Samples
JavaScript PHP Rails Pythonvar xmlHttp = new XMLHttpRequest();
xmlHttp.open("POST", "https://api.sitehost.nz/1.2/cloud/stack/overwrite.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("destination_stack", "cc987a456b321a");
data.append("params[copy_env_file]", "1");
data.append("params[shutdown]", "1");
data.append("params[only][0]", "application");
data.append("params[databases][0][clone_db_from]", "mydatabase");
data.append("params[databases][0][mysql_host]", "mysql57");
data.append("params[databases][0][db_name]", "existingdb");
data.append("params[databases][0][origin_container]", "cc567a321b123c");
xmlHttp.send(data);
var response = xmlHttp.responseText;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sitehost.nz/1.2/cloud/stack/overwrite.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',
'destination_stack' => 'cc987a456b321a',
'params[copy_env_file]' => 1,
'params[shutdown]' => 1,
'params[only][0]' => application,
'params[databases][0][clone_db_from]' => 'mydatabase',
'params[databases][0][mysql_host]' => 'mysql57',
'params[databases][0][db_name]' => 'existingdb',
'params[databases][0][origin_container]' => 'cc567a321b123c',
);
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.2/cloud/stack/overwrite.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",
"destination_stack" => "cc987a456b321a",
"params[copy_env_file]" => 1,
"params[shutdown]" => 1,
"params[only][0]" => application,
"params[databases][0][clone_db_from]" => "mydatabase",
"params[databases][0][mysql_host]" => "mysql57",
"params[databases][0][db_name]" => "existingdb",
"params[databases][0][origin_container]" => "cc567a321b123c",
}
request.set_form_data(body)
response = http.request(request)
import requests
from collections import OrderedDict
uri = 'https://api.sitehost.nz/1.2/cloud/stack/overwrite.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['destination_stack'] = 'cc987a456b321a'
body['params[copy_env_file]'] = 1
body['params[shutdown]'] = 1
body['params[only][0]'] = application
body['params[databases][0][clone_db_from]'] = 'mydatabase'
body['params[databases][0][mysql_host]'] = 'mysql57'
body['params[databases][0][db_name]'] = 'existingdb'
body['params[databases][0][origin_container]'] = 'cc567a321b123c'
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
}