Code Documentation¶
-
class
pyfortiapi.
FortiGate
(ipaddr, username, password, timeout=10, vdom='root', port='443', verify=False)¶ -
create_address_group
(group_name, data)¶ Create address group
Parameters: - group_name – Address group to be created
- data – JSON Data with which to create the address group
Returns: HTTP Status Code.
-
create_firewall_address
(address, data)¶ Create firewall address record
Parameters: - address – Address record to be created
- data – JSON Data with which to create the address record
Returns: HTTP Status Code
-
create_firewall_policy
(policy_id, data)¶ Create firewall Policy
Parameters: - policy_id – ID of policy to be created
- data – Data with which to create policy
Returns: HTTP Status Code
-
create_firewall_service
(service_name, data)¶ Create service
Parameters: - service_name – Service to be created
- data – JSON Data with which to create the service
Returns: HTTP Status Code
-
create_service_category
(category, data)¶ Create service category
Parameters: - category – Service category to be created
- data – JSON Data with which to create the service category
Returns: HTTP Status Code
-
create_service_group
(group_name, data)¶ Create service group
Parameters: - group_name – Service group to be created
- data – JSON Data with which to create the service group
Returns: HTTP Status Code
-
create_snmp_community
(community_id, data)¶ Create SNMP community
Parameters: - community_id – ID of the SNMP Community to be created
- data – JSON Data with which to create the SNMP community
Returns: HTTP Status Code
-
delete
(url)¶ Perform DELETE operation on provided URL
Parameters: url – Target of DELETE operation Returns: HTTP status code returned from DELETE operation
-
delete_address_group
(group_name)¶ Delete firewall address group
Parameters: group_name – Address group to be deleted Returns: HTTP Status Code
-
delete_firewall_address
(address)¶ Delete firewall address record
Parameters: address – Address record to be deleted Returns: HTTP Status Code
-
delete_firewall_policy
(policy_id)¶ Delete firewall policy
Parameters: policy_id – ID of policy to be deleted Returns: HTTP Status Code
-
delete_firewall_service
(service_name)¶ Delete firewall service
Parameters: service_name – Service categrory to be deleted Returns: HTTP Status Code
-
delete_service_category
(category)¶ Delete firewall service category
Parameters: category – Service categrory to be deleted Returns: HTTP Status Code
-
delete_service_group
(group_name)¶ Delete firewall service group
Parameters: group_name – Service categrory to be deleted Returns: HTTP Status Code
-
delete_snmp_community
(community_id)¶ Delete SNMP community
Parameters: community_id – ID of the SNMP Community to be deleted Returns: HTTP Status Code
-
does_exist
(object_url)¶ GET URL to assert whether it exists within the firewall
Parameters: object_url – Object to locate Returns: Bool - True if exists, False if not
-
get
(url)¶ Perform GET operation on provided URL
Parameters: url – Target of GET operation Returns: Request result if successful (type list), HTTP status code otherwise (type int)
-
get_address_group
(specific=False, filters=False)¶ Get address group object information from firewall
Parameters: - specific – If provided, a specific object will be returned. If not, all objects will be returned.
- filters – If provided, the raw filter is appended to the API call.
Returns: JSON data for all objects in scope of request, nested in a list.
-
get_firewall_address
(specific=False, filters=False)¶ Get address object information from firewall
Parameters: - specific – If provided, a specific object will be returned. If not, all objects will be returned.
- filters – If provided, the raw filter is appended to the API call.
Returns: JSON data for all objects in scope of request, nested in a list.
-
get_firewall_policy
(specific=False, filters=False)¶ Get firewall policy information from firewall
Parameters: - specific – If provided, a specific object will be returned. If not, all objects will be returned. Specific can either be the policy name, or the policy ID.
- filters – If provided, the raw filter is appended to the API call.
Returns: JSON data for all objects in scope of request, nested in a list.
-
get_firewall_service
(specific=False, filters=False)¶ Get service object information from firewall
Parameters: - specific – If provided, a specific object will be returned. If not, all objects will be returned.
- filters – If provided, the raw filter is appended to the API call.
Returns: JSON data for all objects in scope of request, nested in a list.
-
get_internet_services
(specific=False, filters=False)¶ Get ISDB (internet services database)
Parameters: - specific – If provided, a specific object will be returned.
- filters – If provided, the raw filter is appended to the API call.
Returns: JSON data for all objects in scope of request, nested in a list.
-
get_service_category
(specific=False, filters=False)¶ Get service category information from firewall
Parameters: - specific – If provided, a specific object will be returned. If not, all objects will be returned.
- filters – If provided, the raw filter is appended to the API call.
Returns: JSON data for all objects in scope of request, nested in a list.
-
get_service_group
(specific=False, filters=False)¶ Get service group information from firewall
Parameters: - specific – If provided, a specific object will be returned. If not, all objects will be returned.
- filters – If provided, the raw filter is appended to the API call.
Returns: JSON data for all objects in scope of request, nested in a list.
-
get_snmp_community
(specific=False, filters=False)¶ Get SNMP community information from firewall
Parameters: - specific – If provided, a specific object will be returned. If not, all objects will be returned. Specific can either be the Community string, or its internal ID.
- filters – If provided, the raw filter is appended to the API call.
Returns: JSON data for all objects in scope of request, nested in a list.
-
login
()¶ Log in to FortiGate with info provided in during class instantiation
Returns: Open Session
-
logout
(session)¶ Log out of device
Parameters: session – Session created by login method Returns: None
-
move_firewall_policy
(policy_id, position, neighbour)¶ Move firewall policy to new location
Parameters: - policy_id – ID of firewall policy being moved
- position – “before” or “after”
- neighbour – ID of policy being used as positional reference
Returns: HTTP Status Code
-
post
(url, data)¶ Perform POST operation on provided URL
Parameters: - url – Target of POST operation
- data – JSON data. MUST be a correctly formatted string. e.g. “{‘key’: ‘value’}”
Returns: HTTP status code returned from POST operation
-
put
(url, data)¶ Perform PUT operation on provided URL
Parameters: - url – Target of PUT operation
- data – JSON data. MUST be a correctly formatted string. e.g. “{‘key’: ‘value’}”
Returns: HTTP status code returned from PUT operation
-
update_address_group
(group_name, data)¶ Update address group with provided data
Parameters: - group_name – Address group being updated
- data – JSON Data with which to upate the address group
Returns: HTTP Status Code
-
update_firewall_address
(address, data)¶ Update firewall address record with provided data
Parameters: - address – Address record being updated
- data – JSON Data with which to upate the address record
Returns: HTTP Status Code
-
update_firewall_policy
(policy_id, data)¶ Update firewall policy with provided data
Parameters: - policy_id – ID of firewall policy to be updated
- data – Data with which to update the firewall policy
Returns: HTTP Status Code
-
update_firewall_service
(service_name, data)¶ Update service with provided data
Parameters: - service_name – Service being updated
- data – JSON Data with which to upate the service
Returns: HTTP Status Code
-
update_service_category
(category, data)¶ Update service category with provided data.
Parameters: - category – Service category being updated
- data – JSON Data with which to upate the service category
Returns: HTTP Status Code
-
update_service_group
(group_name, data)¶ Update service group with provided data
Parameters: - group_name – Service group being updated
- data – JSON Data with which to upate the service group
Returns: HTTP Status Code
-
update_snmp_community
(community_id, data)¶ Update SNMP community with provided data
Parameters: - community_id – ID of community being updated
- data – JSON Data with which to update the community
Returns: HTTP Status Code
-