NOC API

Overview

If you are a Virtualizor NOC and want to automate Virtualizor License management you can do that easily with the Virtualizor NOC API.

Download

The Virtualizor NOC API is available only to the NOCs and you can download it from the NOC Panel : 
http://www.softaculous.com/clients?ca=download_api 
There are many examples at the bottom of the API file to test.

Example:

Here are a few examples to manage Virtualizor Licenses. 

NOTE : You should include the NOC API file that you just downloaded. And initiate the Class using your NOCusername and NOCpassword.

include_once 'noc_api.inc';
$noc = new SOFT_NOC('username', 'password');

If you want Virtualizor to use JSON for handling the data please add the following variable :

$noc->json = 1;

Purchase/Renew Virtualizor Licenses

$noc->virt_buy('188.188.188.188', '1M', '1');
  • 1st Parameter : Your server’s IP
  • 2nd Parameter : The period for which you wish to renew. 1M will extend by one months, 8M will extend by eight months, 1Y will extend by One year
  • 3rd Parameter : Auto Renew 1 to enable auto renew and 0 to disable auto renew.

List Virtualizor License Details

$noc->virt_licenses();
  • All Parameters are optional. When nothing is specified a list of all your license will be returned.
  • 1st Parameter : License Key. This will get details related to License key.
  • 2nd Parameter : Primary IP of a License to get the details of that particular License.
  • 3rd Parameter : Expiry date. Possible values 1, 2, 3.
    • 1 – All Expired Licenses under your account
    • 2 – Expiring in 7 Days
    • 3 – Expiring in 15 Days
  • 4th Parameter : Start value. This is the start limit of the number of licenses you wish to list. Eg you wish to list the licenses from 100th license pass the value as 99.
  • 5th Parameter : Length of return from start value. This is the number of licenses you wish to list from the start value. Eg you wish to list the 100th licenses pass the start value as 99 and length value as 1.
  • 6th Parameter : Authorized Email. This will list the licenses with the provided email.

Edit IP of a Virtualizor License

$noc->virt_editips(1000, '198.198.198.198');
  • 1st Parameter : License ID. You can get the license id from the licenses() function.
  • 2nd Parameter : New IP. This is the new IP for the provided license.

License Logs

Search Logs by License Key :

$noc->virt_licenselogs('88888-88888-88888-88888-88888');
  • 1st Parameter : License Key for which you need license logs.

or

$noc->virt_licenselogs('','5','192.168.1.1');
  • 1st Parameter : Empty.
  • 2nd Parameter : Limit. The number of action logs to be retrieved. Default = 0.
  • 3rd Parameter : IP address. The License IP.

Auto Renewals

$noc->virt_renewals();
  • All Parameters are optional. If no parameters are passed it will list all the licenses with Auto Renewals under your account.
  • 1st Parameter : License Key. This will search by License key.
  • 2nd Parameter : Server IP. This will search by Server IP.
  • 3th Parameter : Start value. This is the start limit of the number of licenses you wish to list. Eg you wish to list the licenses from 100th license pass the value as 99.
  • 4th Parameter : Length of return from start value. This is the number of licenses you wish to list from the start value. Eg you wish to list the 100th licenses pass the start value as 99 and length value as 1.

Add Auto Renewal

$noc->virt_addautorenewal('88888-88888-88888-88888-88888');
  • 1st Parameter : License Key for which you want to enable Auto Renewal.

Cancel Auto Renewal

$noc->virt_removeautorenewal('88888-88888-88888-88888-88888');
  • 1st Parameter : License Key for which you want to disable Auto Renewal.

Refund a Transaction

$noc->virt_refund(100);
  • 1st Parameter : Action ID for which you wish to claim a Refund. You can get the action id from the licenselogs() function.

Cancel Virtualizor License

$noc->virt_remove('88888-88888-88888-88888-88888', '0');
  • Only one parameter is compulsory. You can pass any one parameter.
  • 1st Parameter : License Key for which you want to cancel license.
  • 2nd Parameter : Force Remove. Set this as 1 if you want to forcefully remove the license without claiming a refund.

Refund and Cancel Virtualizor License

$noc->virt_refund_and_cancel('88888-88888-88888-88888-88888', '198.198.198.198','0');
  • Only one parameter is compulsory. You can pass any one parameter.
  • 1st Parameter : License Key for which you want to refund and then cancel license.
  • 2nd Parameter : Server IP for which you want to refund and then cancel license.
  • 3rd Parameter (Optional) : Pass this as 1 if you want to force cancel license without claiming a refund (if the refund is not eligible).

Debugging

If there are any Errors while executing the above tasks the Errors will be returned in the $noc->error variable. You can print the errors :

$noc->r($noc->error);

If the above variable is empty then the tasks were completed without any errors.

Output in XML

You can also convert the output to XML.

$data = $noc->licenses();
echo ArrayToXML::toXML($data); 

This will display the data in XML format.

Output in JSON

You can also convert the output to JSON.

$data = $noc->licenses();
echo array2json($data); 

This will display the data in JSON format.

Was this helpful to you?