Use the Add User Plan API to create user plan on the Virtualizor panel. These plans help facilitate creation of user. Using this API you can create custom plans for Admin, Cloud and Normal user.
An admin user plan allows you to create user with admin privileges, these privileges can be managed using the Administrator ACL module.
A cloud user plan allows you create cloud user which can launch his own Virtual Private Server instances and manage new users as well. With cloud user plan you can adjust parameters like number of Virtual Private Servers that the user can create, amount of server resources that he can use and much more. The API response will contain "done" as the ID of the created user plan on success.
HTTP Request
https://hostname:4085/index.php?act=adduser_plans
Parameters
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | adduser_plans | The action specified to perform the operation and will return "done" as the user plan ID on success | Yes |
plan_name | POST | text | The unique name of the plan | Yes |
priority | POST | Int | The type of user plan 0 for normal user, 1 admin user, 2 for cloud | Yes |
dnsplan_id | POST | Int | The ID of the dns plan | No |
acl_id | POST | Int | The acl ID for admin user | No |
num_vs | POST | Int | The maximum number of Virtual Private Servers this user can create. Zero (0) for unlimited | No |
inhouse_billing | POST | 1/0 | If enabled, Virtualizor will calculate resource usage and create invoices for the VPSes | No |
num_users | POST | Int | The maximum number of sub-users this user can create. Zero (0) for unlimited. | No |
space | POST | Int | Max Disk Space in GB | No |
ram | POST | Int | The Maximum amount ram in MB | No |
burst | POST | Int | The Maximum amount burst in MB | No |
bandwidth | POST | Int | Zero (0) means unlimited bandwidth | No |
cpu | POST | Int | Default CPU weight | No |
cores | POST | Int | Max Cores per VPS. The user cannot create a VPS above this limit | No |
cpu_percent | POST | Int | All VPS created by the user would have this CPU %. This is per core base. E.g. If user creates VPS with 2 cores and percentage is 40 total 80% will be assigned. | No |
num_cores | POST | Int | The total number of cores allowed. Zero (0) means unlimited cores | No |
num_ipv4 | POST | Int | The max number of ipv4 ips that the user can create | No |
num_ipv6_subnet | POST | Int | The max number of ipv6 subnet that the user can create | No |
num_ipv6 | POST | Int | The max number of ipv6 ips that the user can create | No |
network_speed | POST | Int | The network speed in KB/s. Pass 0 or leave empty for no restriction. | No |
upload_speed | POST | Int | The upload speed in KB/s. Pass 0 or leave empty for no restriction. | No |
band_suspend | POST | 1/0 | If checked then all the cloud user's VPS(s) will be suspended if the specified bandwidth limit is exceeded | No |
service_period | POST | Int | The billing cycle start date for bandwidth calculation, valid values (0-31) | No |
allowed_virts | POST | array | The Virtualization type to allow this user refer below table for valid values | No |
sgs | POST | array | The array of server group IDs | No |
mgs | POST | array | The array of media group values | No |
space_per_vm | POST | Int | The maximum space per vps | No |
total_iops_sec | POST | Int | The total Iops per second (Only supported for kvm and proxk) | No |
read_bytes_sec | POST | Int | The read Iops per second (Only supported for kvm and proxk) | No |
write_bytes_sec | POST | Int | The write Iops per second (Only supported for kvm and proxk) | No |
Allowed Virtualization
( openvz | xen | xenhvm | kvm | xcp | xcphvm | lxc | proxo | proxk | proxl | vzk | vzo ) |
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();
$post['plan_name'] = 'api_plan';
$post['priority'] = 0;
$output = $admin->add_user_plans($post);
print_r(json_encode($output));
?>
Output
{
"title": "Add User Plan",
"done": "5",
"mgs": {
"3": {
"mgid": "3",
"mg_name": "testing for apia",
"mg_desc": "Testing for the api",
"mg_type": "kvm"
}
},
"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"
}
},
"timenow": 1537471672,
"time_taken": "0.131"
}