FortiOSAPI
FortiOS API
Tags
Table of Contents
- $config : Config
- $session_key : string
- $transaction : int|null
- $config : Config
- $session_key : string
- $transaction : mixed
- __construct() : mixed
- Constructor takes care of checking and registering firewall's data and login to the API
- __destruct() : mixed
- Destructor takes care of logout.
- abortTransaction() : bool
- Abort a transaction (rollback operations).
- commitTransaction() : bool
- Commit a transaction (apply operations).
- listTransactions() : bool
- List all transactions.
- startTransaction() : bool
- Start a transaction (Warning : Fortinet says all tables are not supported but do not indicate which one exactly).
- curlRequest() : stdClass
- Method to request the firewall's API.
- httpBuildCustomQuery() : string
- Function used to build a query with params but following fortigate satndards.
- login() : bool
- Login in the firewall.
- logout() : Return
- Logout from the firewall.
Properties
$config
public
Config
$config
Config object with all needed information.
$session_key
public
string
$session_key
Authentication token kept in cache.
$transaction
public
int|null
$transaction
Ongoning transaction ID. WARNING : When going through the method prepareRequestData(), all upper case letter in function parameter name will be replaced by '-' and ;brought down to lower case. If you modify or add new endpoints replace all '-' in parameter name by the next letter in uppercase.
$config
private
Config
$config
$session_key
private
string
$session_key
= ''
$transaction
private
mixed
$transaction
Methods
__construct()
Constructor takes care of checking and registering firewall's data and login to the API
public
__construct(Config $config) : mixed
Parameters
- $config : Config
-
Object containing all necessary configuration.
Return values
mixed —__destruct()
Destructor takes care of logout.
public
__destruct() : mixed
Return values
mixed —abortTransaction()
Abort a transaction (rollback operations).
public
abortTransaction([string|null $vdom = null ]) : bool
Parameters
- $vdom : string|null = null
-
Specify the Virtual Domain from which results are returned or changes are applied to. If this parameter is not provided, the management VDOM will be used. If the admin does not have access to the VDOM, a permission error will be returned.
Return values
bool —Return TRUE on success and FALSE on failure.
commitTransaction()
Commit a transaction (apply operations).
public
commitTransaction([string|null $vdom = null ]) : bool
Parameters
- $vdom : string|null = null
-
Specify the Virtual Domain from which results are returned or changes are applied to. If this parameter is not provided, the management VDOM will be used. If the admin does not have access to the VDOM, a permission error will be returned.
Return values
bool —Return TRUE on success and FALSE on failure.
listTransactions()
List all transactions.
public
listTransactions([string $vdom = null ]) : bool
Parameters
- $vdom : string = null
Return values
bool —Return the firewall's response as an object. As of version 6.4.5, this method sometimes returns unparsable JSON.
startTransaction()
Start a transaction (Warning : Fortinet says all tables are not supported but do not indicate which one exactly).
public
startTransaction([int $timeout = null ][, string|null $vdom = null ]) : bool
Parameters
- $timeout : int = null
-
Transaction's timeout.
- $vdom : string|null = null
-
Specify the Virtual Domain from which results are returned or changes are applied to. If this parameter is not provided, the management VDOM will be used. If the admin does not have access to the VDOM, a permission error will be returned.
Return values
bool —Return TRUE on success and FALSE on failure.
curlRequest()
Method to request the firewall's API.
protected
curlRequest(string $method, string $endpoint[, int|string $pathData = null ][, stdClass|array<string|int, mixed> $queryData = null ][, stdClass|array<string|int, mixed> $bodyData = null ][, int $timeout = null ]) : stdClass
Parameters
- $method : string
-
HTTP method (e.g. 'GET', 'POST', 'PUT', 'DELETE' ...).
- $endpoint : string
-
API endpoint without the 2 first element ('rest' and API version '/api/vX'), e.g. /cmdb/router/static.
- $pathData : int|string = null
-
Data to be passed in the request path (only one).
- $queryData : stdClass|array<string|int, mixed> = null
-
Data to be passed in the request query as GET arguments.
- $bodyData : stdClass|array<string|int, mixed> = null
-
Data to be passed in the request body as a JSON object.
- $timeout : int = null
Return values
stdClass —Return firewall's response as a stdClass.
httpBuildCustomQuery()
Function used to build a query with params but following fortigate satndards.
private
httpBuildCustomQuery(array<string|int, mixed> $data) : string
Parameters
- $data : array<string|int, mixed>
-
Array of data.
Return values
string —Return the data encoded in a string to be passed as an URL.
login()
Login in the firewall.
private
login() : bool
Return values
bool —Return TRUE if successful or throw Exception if fails.
logout()
Logout from the firewall.
private
logout() : Return
Return values
Return —TRUE if successful, FALSE if it failed.