Resource Pricing

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

NameMethodValueDescriptionRequired
actGETresource_pricingThe action will return the done as 1 on successful addition/editing of the resource pricingYes
space_h_rate_-1POSTIntSet the hourly rate for the disk usage for all the server group, for specific servergroup pass the sgid in place of -1No
space_m_rate_-1POSTIntSet the monthly rate for the disk usage for all the server group, for specific servergroup pass the sgid in place of -1No
space_y_rate_-1POSTIntSet the yearly rate for the disk usage for all the server group, for specific servergroup pass the sgid in place of -1No
cores_h_rate_-1POSTIntSet the hourly rate for the cpu usage for all the server group, for specific servergroup pass the sgid in place of -1No
cores_m_rate_-1POSTIntSet the monthly rate for the cpu usage for all the server group, for specific servergroup pass the sgid in place of -1No
cores_y_rate_-1POSTIntSet the yearly rate for the cpu usage for all the server group, for specific servergroup pass the sgid in place of -1No
ram_h_rate_-1POSTIntSet the hourly rate for the ram usage for all the server group, for specific servergroup pass the sgid in place of -1No
ram_m_rate_-1POSTIntSet the monthly rate for the ram usage for all the server group, for specific servergroup pass the sgid in place of -1No
ram_y_rate_-1POSTIntSet the yearly rate for the ram usage for all the server group, for specific servergroup pass the sgid in place of -1No
ips_h_rate_-1POSTIntSet the hourly rate for the ip usage for all the server group, for specific servergroup pass the sgid in place of -1No
ips_m_rate_-1POSTIntSet the monthly rate for the ip usage for all the server group, for specific servergroup pass the sgid in place of -1No
ips_y_rate_-1POSTIntSet the yearly rate for the ip usage for all the server group, for specific servergroup pass the sgid in place of -1No
bandwidth_h_rate_-1POSTIntSet the hourly rate for the bandwidth usage for all the server group, for specific servergroup pass the sgid in place of -1No

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"
}
Was this helpful to you?