Use the Edit Recipe API to update a recipe present on the Virtualizor panel. Recipes are predefined bash scripts that are created by admin for endusers. Only the activated recipes are visible to the enduser. These recipes can be executed on the VPS during their creation. Recipes can also be applied while the VPS is running, however you need to stop then start the VPS for the execution of the recipe to take place. The API response will contain "done" as "1" if the recipe has been successfully updated.
HTTP Request
https://hostname:4085/index.php?act=editrecipe&rid=RID
Parameters
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | editrecipe | The action will return done as 1 after the recipes has been edited | Yes |
rid | GET | Int | The recipe ID | Yes |
name | POST | text | The name of the recipe | Yes |
code | POST | text | The code that will be executed by the recipe at the time of call | Yes |
desc | POST | text | The description for the recipe | No |
logo | POST | text | The logo url for the recipe | No |
shell | POST | text | Provide the shell type using which the recipe should be executed (Since 3.1.3 version) | No |
Valid shell types (Since v3.1.3)
Value | Description |
---|---|
Default(sh shell) | #!/bin/sh |
Bash | #!/bin/bash |
Ksh | #!/bin/ksh |
Zsh | #!/bin/zsh |
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['rid'] = 23;
$post['name'] = 'test_recipe1';
$post['code'] = 'This is your test recipe';
$post['desc'] = 'This is the description for test recipe';
$post['shell'] = 'Bash';
$output = $admin->editrecipe($post);
print_r(json_encode($output));
?>
Output
{
"title": "Edit Recipe",
"done": 1,
"done_msg": "Recipe has been updated",
"timenow": 1536159013,
"time_taken": "0.204"
}