Virtualizor Cloud Billing System allows setting the pricing for various resources which users can add on top of their existing plans. For example, if a user wants more disk space, he can buy tnat and will be billed for it.
The Resource Pricing API allows you to set pricing for your servers resources i.e. storage(disks), CPU cores, RAM memory, IP addresses and bandwidth.
Pricing can be set for all regions and / or for a particular region. However, all the regions pricing is compulsory and also the hourly rate is compulsory for resource pricing to enable the same. For bandwidth there is only an overage rate.
If you don't set the resource rates, then the users cannot modify these resources and will be allowed resources as per the VPS plan
For more information, you can refer this Resource Pricing Guide.
HTTP Request
https://hostname:4085/index.php?act=resource_pricing
Parameters
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | resource_pricing | The action will return the done as 1 on successful addition/editing of the resource pricing | Yes |
space_h_rate_-1 | POST | Int | Set the hourly rate for the disk usage for all the server group, for specific servergroup pass the sgid in place of -1 | No |
space_m_rate_-1 | POST | Int | Set the monthly rate for the disk usage for all the server group, for specific servergroup pass the sgid in place of -1 | No |
space_y_rate_-1 | POST | Int | Set the yearly rate for the disk usage for all the server group, for specific servergroup pass the sgid in place of -1 | No |
cores_h_rate_-1 | POST | Int | Set the hourly rate for the cpu usage for all the server group, for specific servergroup pass the sgid in place of -1 | No |
cores_m_rate_-1 | POST | Int | Set the monthly rate for the cpu usage for all the server group, for specific servergroup pass the sgid in place of -1 | No |
cores_y_rate_-1 | POST | Int | Set the yearly rate for the cpu usage for all the server group, for specific servergroup pass the sgid in place of -1 | No |
ram_h_rate_-1 | POST | Int | Set the hourly rate for the ram usage for all the server group, for specific servergroup pass the sgid in place of -1 | No |
ram_m_rate_-1 | POST | Int | Set the monthly rate for the ram usage for all the server group, for specific servergroup pass the sgid in place of -1 | No |
ram_y_rate_-1 | POST | Int | Set the yearly rate for the ram usage for all the server group, for specific servergroup pass the sgid in place of -1 | No |
ips_h_rate_-1 | POST | Int | Set the hourly rate for the ip usage for all the server group, for specific servergroup pass the sgid in place of -1 | No |
ips_m_rate_-1 | POST | Int | Set the monthly rate for the ip usage for all the server group, for specific servergroup pass the sgid in place of -1 | No |
ips_y_rate_-1 | POST | Int | Set the yearly rate for the ip usage for all the server group, for specific servergroup pass the sgid in place of -1 | No |
bandwidth_h_rate_-1 | POST | Int | Set the hourly rate for the bandwidth usage for all the server group, for specific servergroup pass the sgid in place of -1 | No |
Sample Code
<?php
require_once('/usr/local/virtualizor/sdk/admin.php');
$key = 'your_api_key';
$pass = 'your_api_pass';
$ip = 'your_server_ip';
$admin = new Virtualizor_Admin_API($ip, $key, $pass);
$post = array();
// For all regions
$post['space_h_rate_-1'] = 32;
$post['space_m_rate_-1'] = 12;
$post['space_y_rate_-1'] = 12;
$post['cores_h_rate_-1'] = 30 ;
$post['cores_m_rate_-1'] = 30 ;
$post['cores_y_rate_-1'] = 30 ;
$post['ram_h_rate_-1'] = 30 ;
$post['ram_m_rate_-1'] = 30 ;
$post['ram_y_rate_-1'] = 30 ;
$post['ips_h_rate_-1'] = 23 ;
$post['ips_m_rate_-1'] = 12 ;
$post['ips_y_rate_-1'] = 32;
$post['bandwidth_h_rate_-1'] = 23 ;
// For default servergroup use ID 0 instead of -1
$output = $admin->resourcepricing($post);
print_r(json_encode($output));
?>
Output
{
"title": "Resource Pricing",
"done": 1,
"pricing": {
"space": {
"h_rate": {
"-1": 32,
"0": 2
},
"m_rate": {
"-1": 12
},
"y_rate": {
"-1": 12
}
},
"cores": {
"h_rate": {
"-1": 30
},
"m_rate": {
"-1": 30
},
"y_rate": {
"-1": 30
}
},
"ram": {
"h_rate": {
"-1": 30
},
"m_rate": {
"-1": 30
},
"y_rate": {
"-1": 30
}
},
"ips": {
"h_rate": {
"-1": 23
},
"m_rate": {
"-1": 12
},
"y_rate": {
"-1": 32
}
},
"bandwidth": {
"h_rate": {
"-1": 23
}
}
},
"servergroups": {
"0": {
"sgid": 0,
"sg_name": "Default",
"sg_reseller_name": "Default",
"sg_desc": "Default Group",
"sg_select": 0
},
"2": {
"sgid": "2",
"sg_name": "test_sg",
"sg_reseller_name": "US",
"sg_desc": "This is just test",
"sg_select": "0"
}
},
"resource_types": [
"space",
"cores",
"ram",
"ips",
"bandwidth"
],
"timenow": 1537213329,
"time_taken": "0.233"
}