XGAPI
Sophos XG API
Tags
Table of Contents
- $config : Config
- $config : Config
- __construct() : mixed
- Constructor takes care of checking and registering firewall's configuration information.
- get() : array<string|int, mixed>
- Method to retrieve data from the firewall.
- remove() : bool
- Method to remove data on the firewall.
- set() : bool
- Method to set data on the firewall.
- curlRequest() : array<string|int, mixed>
- Method to request the firewall's API using curl library.
Properties
$config
public
Config
$config
Config object with all needed information.
$config
private
Config
$config
Methods
__construct()
Constructor takes care of checking and registering firewall's configuration information.
public
__construct(Config $config) : mixed
Parameters
- $config : Config
-
Object containing all necessary configuration.
Return values
mixed —get()
Method to retrieve data from the firewall.
public
get(array<string|int, mixed> $entities) : array<string|int, mixed>
Parameters
- $entities : array<string|int, mixed>
-
One or several Sophos XG firewall entities. See API documentation. Those entities can be the key of an array of filter, if it is only a string then there is no filter on this entity. Each filter is an array where the first element must be the name of the element on which we filter, second element is the type of comparison ('=', '!=' or 'like'), third element is the value of the filter. E.g. ['entity1' => [['Name', '=', 'First entity'], ['IPv4', '!=', '172.20.1.1']], 'entity2' => [['Name', 'like', 'Second entity']]]
Return values
array<string|int, mixed> —PHP array of entities containing array of results.
remove()
Method to remove data on the firewall.
public
remove(array<string|int, mixed> $entities) : bool
Parameters
- $entities : array<string|int, mixed>
-
One or several Sophos XG firewall entities. See API documentation. Each entities is an array of the entity's name to remove e.g. ['IPHost'=>['OBJ_TEST', 'OBJ_TEST2'], 'QoSPolicy'=>['SHP_TST']]
Return values
bool —Request status.
set()
Method to set data on the firewall.
public
set(array<string|int, mixed> $entities) : bool
Parameters
- $entities : array<string|int, mixed>
-
One or several Sophos XG firewall entities. See API documentation. Each entities is an array of the entity's properties to declare e.g. ['IPHost'=> [['Name'=>'IP_TEST', 'IPFamily'=>'IPv4', 'HostType'=>'IP', 'HostGroupList'=>['HostGroup'=>'GBL_IP-GRP_SIE'], 'IPAddress'=>'172.20.1.230', 'Subnet'=>'255.255.255.0'], ['Name'=>'IP_TEST2', 'IPFamily'=>'IPv4', 'HostType'=>'IP', 'HostGroupList'=>['HostGroup'=>'GBL_IP-GRP_SIE'], 'IPAddress'=>'172.20.1.231', 'Subnet'=>'255.255.255.0'] ], 'QoSPolicy'=>[['Name'=>'QOS_TEST', 'PolicyBasedOn'=>'FirewallRule', 'BandwidthUsageType'=>'Shared', 'ImplementationOn'=>'Total', 'PolicyType'=>'Strict', 'Priority'=>'Normal4', 'TotalBandwidth'=>'6875'] ] ]
Return values
bool —Request status.
curlRequest()
Method to request the firewall's API using curl library.
private
curlRequest(DOMDocument $xml) : array<string|int, mixed>
Parameters
- $xml : DOMDocument
-
DOMDocument object containing the request core without login information. The document first element must be "Get", "Set" or "Remove".
Return values
array<string|int, mixed> —Firewall's raw XML response as a PHP array.