-----
====== Profiles ======
* Each **Permanent User**, **Voucher** or **BYOD Device** has to belong to a **Profile** and **Realm** in order to be useful to RADIUS.
* Before we can bulk import Permanent Users using a CSV file, we need to ensure that all the profiles used by the users in the CSV file already exist.
* In this page we will show you how to read profile names from a text file and then add each one to RADIUSdesk using an API call.
* We will use PHP but the principles can be applied using any programming language.
-----------------
====== Add Profiles From List ======
* Below is the list of profiles we want to add.
MzanziFibre-12/1
MzanziFibre-25/5
MzanziFibre-25/10
MzanziFibre-50/20
MzanziFibre-100/40
MzanziFibre-100/20
MzanziFibre-250/20
MzanziFibre-250/25
MzanziFibre-250/100
MzanziFibre-400/40
MzanziFibre-500/200
MzanziFibre-1000/50
MzanziFibre-1000/400
* We store this file in the same directory as the script we will run to add them.
"on",
"id" => "",
"name" => "",
"data_limit_enabled" => "false",
"time_limit_enabled" => "false",
"speed_limit_enabled" => "false",
"logintime_1_span" => "disabled",
"logintime_2_span" => "disabled",
"logintime_3_span" => "disabled",
"session_limit_enabled" => "false",
"adv_data_limit_enabled"=> "false",
"adv_time_limit_enabled"=> "false",
"token" => $token,
"sel_language" => "4_4",
"cloud_id" => $cloud_id
];
// Loop through names and call API
foreach ($names as $name) {
$payload['name'] = $name;
$json_payload = json_encode($payload);
$ch = curl_init($api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$response = curl_exec($ch);
curl_close($ch);
echo "Added $name: $response\n";
}
?>
* There are a few items which will be unique to your specific deployment.
* It is
* The Token.
* The Cloud ID.
* The server's FQDN / IP Address.
* The Token can be found when you edit an Admin.
{{:technical:api:admin_api_key.png }}
* The Cloud ID is listed under the Cloud Applet.
{{:technical:api:mzanzifibre.png }}
* Below is the result of our script:
{{:technical:api:mzanzifibreprofiles.png }}