Application Programming Interface

Set Server Snapshot Schedule


Description:

This function enables you to set schedule for creating server snapshot.

URLs:
  • Sandbox URL: https://node.co.id/api-sandbox/v1/set_server_snapshot_schedule
  • Real API URL: https://node.co.id/api/v1/set_server_snapshot_schedule
Request Parameters:
Parameter Required Type Max Length Description
server_id Yes String 50 characters The ID of server.
daily_snapshot No String 5 characters Available options:
  • yes
  • no (default)
daily_snapshot_max_age Conditional Integer (days) 2 digits The days you want to retain the daily snapshot files. This parameter is required if "daily_snapshot" value is "yes".
Minimum value: 1
weekly_snapshot No String 5 characters Available options:
  • yes
  • no (default)
weekly_snapshot_max_age Conditional Integer (weeks) 2 digits The days you want to retain the weekly snapshot files. This parameter is required if "weekly_snapshot" value is "yes".
Minimum value: 1
monthly_snapshot No String 5 characters Available options:
  • yes
  • no (default)
monthly_snapshot_max_age Conditional Integer (months) 2 digits The days you want to retain the monthly snapshot files. This parameter is required if "monthly_snapshot" value is "yes".
Minimum value: 1
JSON Response:
    
        
{
    "code"    : "OK",
    "message" : "The server snapshot schedule has been set.",
    "data"    : {
        "server_id"                : "12345",
        "daily_snapshot"           : "yes",
        "daily_snapshot_max_age"   : 7,
        "weekly_snapshot"          : "no",
        "weekly_snapshot_max_age"  : 0,
        "monthly_snapshot"         : "no",
        "monthly_snapshot_max_age" : 0
    }
}
    
XML Response:
    
        
<?xml version="1.0" encoding="utf-8"?>
<code>OK</code>
<message>The server snapshot schedule has been set.</message>
<data>
    <server_id>12345</server_id>
    <daily_snapshot>yes</daily_snapshot>
    <daily_snapshot_max_age>7</daily_snapshot_max_age>
    <weekly_snapshot>no</weekly_snapshot>
    <weekly_snapshot_max_age>0</weekly_snapshot_max_age>
    <monthly_snapshot>no</monthly_snapshot>
    <monthly_snapshot_max_age>0</monthly_snapshot_max_age>
</data>
    
PHP Example:
    
        
<?php
$url      = "https://node.co.id/api-sandbox/v1/set_server_snapshot_schedule";
//$url    = "https://node.co.id/api/v1/set_server_snapshot_schedule";
$user_id  = "12312";
$API_key  = "hasdh6ghvhgFDa454565jasdbNBS";
$random   = rand(10000,99999).uniqid().rand(100000,999999);
$checksum = sha1(sha1(sha1($user_id.$API_key.$random)));
$data = array(
    "user_id"                  => $user_id,
    "random"                   => $random,
    "format"                   => "json",
    "checksum"                 => $checksum,
    "server_id"                => "12345",
    "daily_snapshot"           => "yes",
    "daily_snapshot_max_age"   => 7,
    "weekly_snapshot"          => "no",
    "weekly_snapshot_max_age"  => 0,
    "monthly_snapshot"         => "no",
    "monthly_snapshot_max_age" => 0
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
$output = curl_exec($ch);
$curl_error = curl_errno($ch);
curl_close($ch);
if ($curl_error){
    echo "Unable to connect to API Server.";
} else {
    $outputArray = json_decode($output,true);
    if (!$outputArray){
        echo "Invalid JSON Format";
    } else {
        if ($outputArray["code"] == "OK"){
            print_r($outputArray);
            // Do what you want to do here if OK
        } else {
            echo "Error Message: ".$outputArray["message"];
            // Do what you want to do here if not OK
        }
    }
}