Description
Use the List Storage API to list storages on your server. Also list storages by searching either by user name or storage name.
Parameters
Sample Code
curl -ku "username:password" "https://hostip:2005/index.php?api=json&act=storage"
<?php
$user = 'your_user';
$pass = 'your_password';
$ip = 'your_ip';
$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@'.$ip.':2005/index.php?api=json&act=storage';
// Set the curl parameters
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if(!empty($post)){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}
// Get response from the server.
$resp = curl_exec($ch);
// The response will hold a string as per the API response method. In this case its PHP JSON
$res = json_decode($resp, true);
// Done ?
if(!empty($res['storage'])){
print_r($res['storage']);
}
<?php
include_once('/usr/local/webuzo/sdk/webuzo_sdk_v2.php');
$user = 'your_user';
$pass = 'your_password';
$host = 'your_ip';
$webuzo = new Webuzo_Admin_SDK($user, $pass, $host);
$res = $webuzo->list_storage();
// Done/Error
if(!empty($res['storage'])){
print_r($res['storage']);
}
?>
Output
Array ( [/home] => Array ( [uuid] => 87e2a0f6 [name] => Default Storage [type] => ext4 [alert] => 90 [size] => 14.73 [used] => 9.1 [free] => 5.63 [users] => Array ( [bk] => /home/bk [jack] => /home/jack[rersrsr] => /home/rersrsr [reselmain] => /home/reselmain [resuser] => /home/resuser [same] => /home/same [testuser1] => /home/testuser1 [user1] => /home/user1 [demouser] => /home/demouser) ) [/home2] => Array ( [name] => curlstorage [uuid] => 2migfrcb [type] => ext4 [alert] => 85 [size] => 14.73 [used] => 9.1 [free] => 5.63 ) )