Skip to content

Commit

Permalink
Merge pull request #22 from svde/master
Browse files Browse the repository at this point in the history
add get_global_footer_policies & get_firewall_footer_policies
  • Loading branch information
akshaymane920 authored Jan 6, 2023
2 parents ecff4fc + 97104f6 commit f4b264c
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 13 deletions.
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,15 @@ fortimngr.get_global_header_policies

fortimngr.get_firewall_header_policies

### 26) Create your own policy in your Policy Package.
### 26) Get global footer policy

fortimngr.get_global_footer_policies

### 27) Get footer policy

fortimngr.get_firewall_footer_policies

### 28) Create your own policy in your Policy Package.

```python
>>> fortimngr.add_firewall_policy(policy_package_name="YourPolicyPackageName",
Expand Down Expand Up @@ -398,7 +406,7 @@ fortimngr.get_firewall_header_policies
logtraffic=2 Means Log All Sessions


### 27) Update the policy in your Policy Package.
### 29) Update the policy in your Policy Package.

```python
>>> fortimngr.update_firewall_policy(policy_package_name="YourPolicyPackageName",
Expand All @@ -415,7 +423,7 @@ fortimngr.get_firewall_header_policies
* data: You can get the **kwargs parameters with "show_params_for_policy_update()" method


### 28) Delete the policy in your Policy Package.
### 30) Delete the policy in your Policy Package.

```python
>>> fortimngr.delete_firewall_policy(policy_package_name="YourPolicyPackageName",
Expand All @@ -430,7 +438,7 @@ fortimngr.get_firewall_header_policies



### 29) Move Firewall Policy.
### 31) Move Firewall Policy.

```python
>>> fortimngr.move_firewall_policy(policy_package_name="LocalLab",
Expand All @@ -448,14 +456,14 @@ fortimngr.get_firewall_header_policies

# User Operations : Installing the Policy Package.

### 30) Installing the Policy Package.
### 32) Installing the Policy Package.

```python
>>> fortimngr.install_policy_package(package_name="Your Policy Package name")

```

### 31) Adding Installation Targets to a Policy Package.
### 33) Adding Installation Targets to a Policy Package.

```python
>>> fortimngr.add_install_target(device_name="FortiGateVM64",
Expand All @@ -472,7 +480,7 @@ fortimngr.get_firewall_header_policies

# Show Params for updation of Policies and Objects.

### 32) Parameters for updating Address Object.
### 34) Parameters for updating Address Object.

```python
>>> fortimngr.show_params_for_object_update()
Expand All @@ -487,7 +495,7 @@ fortimngr.get_firewall_header_policies
subnet[list] : IP/Netmask
object_type(int) : Type

### 33) Parameters for updating Policy.
### 35) Parameters for updating Policy.

```python
>>> fortimngr.show_params_for_policy_update()
Expand All @@ -508,7 +516,7 @@ fortimngr.get_firewall_header_policies

# User Operations : Adding scripts in Fortimanager.

### 34) Add a script in FortiManager's Database.
### 36) Add a script in FortiManager's Database.

```python
>>> fortimngr.create_script(name="Test Script Template",
Expand All @@ -528,13 +536,13 @@ fortimngr.get_firewall_header_policies
```


### 35) Get all scripts from FortiManager's Database.
### 37) Get all scripts from FortiManager's Database.

```python
>>> fortimngr.get_all_scripts()
```

### 36) Delete a script from FortiManager's Database.
### 38) Delete a script from FortiManager's Database.

```python
>>> fortimngr.delete_script(name="Test Script Template")
Expand All @@ -543,7 +551,7 @@ fortimngr.get_firewall_header_policies

* :param name: Specify a name for the script tha need to be deleted.

### 37) Run a script on FortiManager's Database/ FortiGate's Remote CLI.
### 39) Run a script on FortiManager's Database/ FortiGate's Remote CLI.

```python
>>> fortimngr.run_script_on_single_device(script_name="test_script",
Expand Down Expand Up @@ -574,7 +582,7 @@ fortimngr.get_firewall_header_policies
```
* :param script_name: Specify the script name that should be executed on the specified devices

### 38) Backup FortiGate's configuration from FortiManager and store it in TFTP server.
### 40) Backup FortiGate's configuration from FortiManager and store it in TFTP server.

```python
>>> fortimngr.backup_config_of_fortiGate_to_tftp(tftp_ip="1.1.1.1",
Expand Down
41 changes: 41 additions & 0 deletions src/pyFortiManagerAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,47 @@ def get_firewall_header_policies(self, policy_package_name="default", policyid=F
get_firewall_header_policies = session.post(url=self.base_url, json=payload, verify=self.verify)
return get_firewall_header_policies.json()["result"]

# Footer
def get_global_footer_policies(self, policy_package_name="default", policyid=False):
"""
Get global footer policies
"""
url = f"pm/config/global/pkg/{policy_package_name}/global/footer/policy"
if policyid:
url = url + str(policyid)
session = self.login()
payload = {
"method": "get",
"params": [
{
"url": url
}
],
"session": self.sessionid
}
get_global_footer_policies = session.post(url=self.base_url, json=payload, verify=self.verify)
return get_global_footer_policies.json()["result"]

def get_firewall_footer_policies(self, policy_package_name="default", policyid=False):
"""
Get adom footer policies
"""
url = f"pm/config/adom/{self.adom}/obj/global/footer/policy"
if policyid:
url = url + str(policyid)
session = self.login()
payload = {
"method": "get",
"params": [
{
"url": url
}
],
"session": self.sessionid
}
get_firewall_footer_policies = session.post(url=self.base_url, json=payload, verify=self.verify)
return get_firewall_footer_policies.json()["result"]

# Firewall Interfaces
def get_device_interfaces(self, device):
"""
Expand Down

0 comments on commit f4b264c

Please sign in to comment.