Application Programming Interface

Delete Snapshot


Description:

This function enables you to delete snapshot of a server instance.

URLs:
  • Sandbox URL: https://node.co.id/api-sandbox/v1/delete_snapshot
  • Real API URL: https://node.co.id/api/v1/delete_snapshot
Request Parameters:
Parameter Required Type Max Length Description
snapshot_id Yes String 50 characters The ID of snapshot you want to delete.
JSON Response:
    
        
{
    "code"    : "OK",
    "message" : "Snapshot has been deleted.",
    "data"    : {
        "snapshot_id"     : "hjgasd7hagdj",
        "snapshot_status" : "deleted"
    }
}
    
XML Response:
    
        
<?xml version="1.0" encoding="utf-8"?>
<code>OK</code>
<message>Snapshot has been deleted.</message>
<data>
    <snapshot_id>hjgasd7hagdj</snapshot_id>
    <snapshot_status>deleted</snapshot_status>
</data>
    
PHP Example:
    
        
<?php
$url      = "https://node.co.id/api-sandbox/v1/delete_snapshot";
//$url    = "https://node.co.id/api/v1/delete_snapshot";
$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,
    "snapshot_id" => "hjgasd7hagdj"
);
$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
        }
    }
}