pyFortiManagerAPI


NamepyFortiManagerAPI JSON
Version 0.2.3 PyPI version JSON
download
home_pagehttps://github.com/akshaymane920/pyFortiManagerAPI
SummaryA Python wrapper for the FortiManager REST API
upload_time2023-10-15 13:33:35
maintainer
docs_urlNone
authorAkshay Mane
requires_python
license
keywords fortimanager restapi api fortigate fortinet python fortimanager api fortimanager api python python examples
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # pyFortiManagerAPI

A Python wrapper for the FortiManager JSON RPC API.

[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/dwyl/esta/issues) [![Upload Python Package](https://github.com/akshaymane920/pyFortimanagerAPI/actions/workflows/python-publish.yml/badge.svg)](https://github.com/akshaymane920/pyFortimanagerAPI/actions/workflows/python-publish.yml)  
### *** Video Tutorial to use the package is available on [YouTube](https://www.youtube.com/watch?v=4o7-AYPwuSM) ***

## Installation

Use the package manager [pip](https://pip.pypa.io/en/stable/) to install pyFortiManagerAPI.

```shell script
pip install pyFortiManagerAPI
```

## Getting Started

1. Creating Instance of the Module

```python
import pyFortiManagerAPI
fortimngr = pyFortiManagerAPI.FortiManager(host="", 
                                           username="",
                                           password="")
```

Required settings:
- host: Management Ip address of your FortiManager
- username/password: Specify your credentials to log into the device.

Optional settings:
- adom: Default is adom=root.
- protocol: Default is protocol=https. If set to protocol=http, then verify=False is set automatically.
- verify: Default is verify=True. If your Fortimanager has a self-signed certificate, set verify=False.
- proxies: Default is an empty dictionary (which means: use the environement variables). If you dont' want to use proxies, even if they are defined in your environment variables, then set 'proxies' to false. If you want to use other proxies than defined in your environment then you go like this:
    ```python
        proxies = {
            'http': 'http://10.10.1.10:3128',
            'https': 'http://10.10.1.10:1080'
        }
    ```
# User Operations : Adoms
### 1) Get all adoms from the FortiManager.
```python
>>> fortimngr.get_adoms()
```
```python
>>> fortimngr.get_adoms(name="root")
```
- ## Parameters
* name: Can get specific adom using name as a filter.

### 2) Set to different Adom
```python
>>> fortimngr.set_adom("adom_name")
```
- ## Parameters
* name of the admon you want to switch to.

### 3) Lock Adom (in workspace mode)
```python
>>> fortimngr.lock_adom()
```
```python
>>> fortimngr.lock_adom(name="root")
```
- ## Parameters
* name: Can lock specific adom using name as a filter.

### 4) Unlock Adom (in workspace mode)
```python
>>> fortimngr.unlock_adom()
```
```python
>>> fortimngr.unlock_adom(name="root")
```
- ## Parameters
* name: Can lock specific adom using name as a filter.

# User Operations : Policy Package
### 5) Get all the policy packages configured on FortiManager.
```python
>>> fortimngr.get_policy_packages()
```
```python
>>> fortimngr.get_policy_packages(name="default")
```
- ## Parameters
* name: Can get specific package using name as a filter.


### 6) Add your own policy package in FortiManager.
```python
>>> fortimngr.add_policy_package(name="TestPackage")
```
- ## Parameters
* name: Specify the Package Name.


# User Operations : Address Objects

### 7) Get all address objects from FortiManager.

```python
>>> fortimngr.get_firewall_address_objects()
```

### 7bis) Get all v6 address objects from FortiManager.

```python
>>> fortimngr.get_firewall_address_v6_objects()
```

### 8) Get specific address object from FortiManager.

```python
>>> fortimngr.get_firewall_address_objects(name="YourObjectName")
>>> fortimngr.get_firewall_address_v6_objects(name="YourObjectName")
```

- ## Parameters

* name: Specify object name that you want to see.

### 9) Create an address object.

```python
>>> fortimngr.add_firewall_address_object(name="TestObject",
                                          associated_interface="any",
                                          subnet=["1.1.1.1", "255.255.255.255"]
                                          )
```

- ## Parameters

* name: Specify object name that is to be created
* associated_interface: Provide interface to which this object belongs if any. {Default is kept any}
* subnet: Specify the subnet in a list format eg.["1.1.1.1", "255.255.255.255"]

### 9bis) Create an v6 address object.

```python
>>> fortimngr.add_firewall_address_v6_object(name="TestObject",
                                          subnet6="2001:0001:0001::2/128"]
                                          )
```

- ## Parameters

* name: Specify object name that is to be created
* associated_interface: Provide interface to which this object belongs if any. {Default is kept any}
* subnet: Specify the subnet in a list format eg.["1.1.1.1", "255.255.255.255"]
* subnet6 : Specify the subnet IPv6 in a string format eg. "2001:0001::1/128"
### 10) Update address object.

```python
>>> fortimngr.update_firewall_address_object(name="TestObject",
                                             associate_interface="port1",
                                             comment="Updated using API",
                                             subnet=["2.2.2.2","255.255.255.255"]
                                             )

>>> fortimngr.update_firewall_address_v6_object(name="TestObject",
                                             comment="Updated using API",
                                             subnet6="2001:0001::1/128"
                                             )
```
- ## Parameters

* name: Enter the name of the object that needs to be updated
* data: You can get the **kwargs parameters with "show_params_for_object_update()" method or "

### 11) Delete address object.

```python
>>> fortimngr.delete_firewall_address_object(object_name="TestObject")
```

- ## Parameters

* object_name: Specify the Object name you want to delete.

---

# User Operations : Address Groups

### 12) Get all address groups.

```python
>>> fortimngr.get_address_groups()
>>> fortimngr.get_address_v6_groups()
```

### 13) Get specific address group.

```python
>>> fortimngr.get_address_groups(name="TestGroup")
>>> fortimngr.get_address_v6_groups(name="TestGroup")
```

- ## Parameters

* name: Specify the name the address group.

### 14) Create your own address group.

```python
>>> fortimngr.add_address_group(name="Test_Group",                                
                                members=["TestObject1"])
>>> fortimngr.add_address_v6_group(name="Test_Group",
                                members=["TestObject1"])
```

- ## Parameters

* name: Enter the name of the address group. eg."Test_Group"
* members: pass your object names as members in a list eg. ["TestObject1", "TestObject2"]
  > Note: An address group should consist atleast 1 member.

### 15) Update the address group.

```python
>>> fortimngr.update_address_group(name="Test_Group",
                                   object_name="TestObject3",
                                   do="add")
>>> fortimngr.update_address_v6_group(name="Test_Group",
                                   object_name="TestObject3",
                                   do="add")
```

- ## Parameters

* name: Specify the name of the Address group you want to update
* object_name: Specify name of the object you wish to update(add/remove) in Members List
* do: Specify if you want to add or remove the object from the members list
  do="add" will add the object in the address group
  do="remove" will remove the object from address group

### 16) Delete the address group.

```python
>>> fortimngr.delete_address_group(name="Test_group")
>>> fortimngr.delete_address_v6_group(name="Test_group")
```

- ## Parameters

* name: Specify the name of the address group you wish to delete

---
# User Operations : VirtualIP Objects

### 17) Get all VIP objects from FortiManager.

```python
>>> fortimngr.get_firewall_vip_objects()
```

---

# User Operations : Add Devices

### 18) Add devices to FortiManager.

Add an existing device:

```python
>>> fortimngr.add_device(ip_address="192.168.0.100", 
                         username="admin", 
                         password="", 
                         name="FortiGateVM64", 
                         description=False)
```

or model a device that is to be deployed:

```python
>>> fortimngr.add_model_device(serial_no="FGTxxxxxxxx", 
                         name="FortiGateVM64")
                         username="admin", 
                         password="", 
```
Required arguments:
* serial_no
* name

Optional arguments:
* username (default=admin)
* password (default="")
* os_type (default="fos")
* os_ver (default=6)
* mr (default=4)
* platform_str (default "", "FortiGate-VM64" for virtual Fortigate)

### 19) Get devices From FortiManager.

```python
>>> fortimngr.get_devices()
```


# User Operations : Meta Data

### 20) Get Meta Data From FortiManager.
```python
>>> fortimngr.get_meta_data()
```

### 21) Add Meta Data to FortiManager.
```python
>>> fortimngr.add_meta_data(name="Meta_Data_1", 
                            status=1)
```

## Parameters
* :param name: name of the meta tag
* :param status: status of meta tag whether it should be active(1) or disabled(0)

### 22) Assign Meta Data to a FortiGate.
```python
>>> fortimngr.assign_meta_to_device(device="FortiGateVM64", 
                                    meta_name="Meta_Data_1", 
                                    meta_value="192.168.0.1/24")
```
## Parameters

* :param device: name of the device
* :param meta_name: name of the meta tag
* :param meta_value: value of the meta tag
# User Operations : Policies

### 23) Assign Meta Data to a FortiGate VDOM.
```python
>>> fortimngr.assign_meta_to_device_vdom(device="FortiGateVM64",
                                         vdom="vdom",
                                         meta_name="Meta_Data_1", 
                                         meta_value="192.168.0.1/24")
```
## Parameters

* :param device: name of the device
* :param vdom: Specify the Vdom
* :param meta_name: name of the meta tag
* :param meta_value: value of the meta tag
# User Operations : Policies

### 24) Get all the policies in your Policy Package.

```python
>>> fortimngr.get_firewall_policies(policy_package_name="YourPolicyPackageName")
```

- ## Parameters

* policy_package_name: Enter the policy package name.

### 25) Get specific policiy in your Policy Package using PolicyID filter.

```python
>>> fortimngr.get_firewall_policies(policy_package_name="YourPolicyPackageName", policyid=3)
```

- ## Parameters

* policy_package_name: Enter the policy package name.
* policyid: Can filter and get the policy you want using policyID

### 26) Get global header policy

fortimngr.get_global_header_policies

### 27) Get header policy

fortimngr.get_firewall_header_policies

### 28) Get global footer policy

fortimngr.get_global_footer_policies

### 29) Get footer policy

fortimngr.get_firewall_footer_policies

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

```python
>>> fortimngr.add_firewall_policy(policy_package_name="YourPolicyPackageName",
                                  name="YourPolicyName",
                                  source_interface="port1",
                                  source_address="all",
                                  destination_interface="port2",
                                  destination_address="all",
                                  service="ALL_TCP",
                                  logtraffic=2
                                  )
>>> fortimngr.add_firewall_policy_with_v6(policy_package_name="YourPolicyPackageName",
                                  name="YourPolicyName",
                                  source_interface="port1",
                                  source_address="all",
                                  source_address6="all",
                                  destination_interface="port2",
                                  destination_address="all",
                                  destination_address6="all",
                                  service="ALL_TCP",
                                  logtraffic=2
                                  )

```

- ## Parameters

* policy_package_name: Enter the name of the policy package eg. "default"
* name: Enter the policy name in a string format eg. "Test Policy"
* source_interface: Enter the source interface in a string format eg. "port1"
* source_address: Enter the src. address object name in string format or list
* source_address6: Enter the src. address v6 object name in string format or list
* destination_interface: Enter the source interface in a string format eg. "port2"
* destination_address: Enter the dst. address object name eg. "WAN_100.25.1.63_32"
* destination_address6: Enter the dst. address v6 object name in string format or list
* service: Enter the service you want to permit or deny in string eg. "ALL_UDP"
* schedule: Schedule time is kept 'always' as default.
* action: Permit(1) or Deny(0) the traffic. Default is set to Permit.
* logtraffic: Specify if you need to log all traffic or specific in int format.
*                  logtraffic=0  Means No Log
                   logtraffic=1  Means Log Security Events
                   logtraffic=2  Means Log All Sessions


### 31) Update the policy in your Policy Package.

```python
>>> fortimngr.update_firewall_policy(policy_package_name="YourPolicyPackageName",
                                     policyid=10,
                                     source_interface="port2",
                                     action=1,
                                     )
```

- ## Parameters

* policy_package_name: Enter the policy package name in which you policy belongs.
* policyid: Enter the Policy ID you want to edit
* data: You can get the **kwargs parameters with "show_params_for_policy_update()" method


### 32) Delete the policy in your Policy Package.

```python
>>> fortimngr.delete_firewall_policy(policy_package_name="YourPolicyPackageName",
                                     policyid=10)
```

- ## Parameters

* policy_package_name: Enter the policy package name in which you policy belongs
* policyid: Enter the policy ID of the policy you want to delete




### 33) Move Firewall Policy.

```python
>>> fortimngr.move_firewall_policy(policy_package_name="LocalLab",
                                   move_policyid=10, 
                                   option="after", 
                                   policyid=2)
```
- ## Parameters
*  policy_package_name: Enter the policy package name in which you policy belongs.
*  move_policyid: Enter the policy ID of the policy you want to move.
*  option: Specify if you want to move the policy above("before") the target policy or below("after") {default: before}.
*  policyid: Specify the target policy.
---


# User Operations : Installing the Policy Package.

### 34) Installing the Policy Package.

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

```

### 35) Adding Installation Targets to a Policy Package.

```python
>>> fortimngr.add_install_target(device_name="FortiGateVM64", 
                                 pkg_name="Test_Policy_Pakage", 
                                 vdom="root")
```
- ## Parameters

* :param device_name: name of the device
* :param pkg_name: name of the policy package
* :param vdom: name of the vdom (default=root)

---

# Show Params for updation of Policies and Objects.

### 36) Parameters for updating Address Object.

```python
>>> fortimngr.show_params_for_object_update()
```
        Parameters to create/update address object:

        PARAMETERS                   FIREWALL OBJECT SETTINGS
        allow_routing(int)          : Static Route Configuration
        associated_interface(str)   : Interface
        comment(str)                : Comments
        object_name(str)            : Address Name
        subnet[list]                : IP/Netmask
        object_type(int)            : Type

### 37) Parameters for updating Policy.

```python
>>> fortimngr.show_params_for_policy_update()
```
        Parameters to create/update Policy:

        PARAMETERS                       FIREWALL POLICY SETTINGS
        name(str)                       : Name
        source_interface(str)           : Incoming Interface
        source_address(str)             : Source Address
        destination_interface(str)      : Destination Interface
        destination_address(str)        : Destination Address
        service(str)                    : Service
        schedule(str)                   : Schedule
        action(int)                     : Action
        logtraffic(int)                 : Log Traffic
        comment(str)                    : Comments

# User Operations : Adding scripts in Fortimanager.

### 38) Add a script in FortiManager's Database.

```python
>>> fortimngr.create_script(name="Test Script Template", 
                            script_content="config system interface \n edit port 1 \n set ip 1.1.1.1/24", 
                            target=0)
```
- ## Parameters

* :param name: Specify a name for the script
* :param script_content: write the cli commands
* :param target: Set the target
```
      If Target = 0 than script runs on Device database
      If Target = 1 than script runs on Remote FortiGate CLI
      If Target = 2 than script runs on Policy package or Adom Database
      Default value is set to 0
```


### 39) Get all scripts from FortiManager's Database.

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

### 40) Delete a script from FortiManager's Database.

```python
>>> fortimngr.delete_script(name="Test Script Template")
```
- ## Parameters

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

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

```python
>>> fortimngr.run_script_on_single_device(script_name="test_script", 
                                          device_name="FortiGate-VM64", 
                                          vdom="root")
```
- ## Parameters

* :param device_name: Specify device name.
* :param vdom: Specify the Vdom
* :param script_name: Specify the script name that should be executed on the specified devices


```python
>>> fortimngr.run_script_on_multiple_devices(script_name="test_script", 
                                             devices=[{"name":"FortiGate-VM64", "vdom": "root"},
                                                      {"name":"Test-FortiGate-VM64", "vdom": "global"},
                                                      {"name":"Test-2-FortiGate-VM64", "vdom": "Test"}])
```
- ## Parameters

* :param devices: Specify devices in a list of dictionaries.
```
              eg. devices=[{"name": "FortiGateVM64-1", "vdom": "root"},
                           {"name": "FortiGateVM64-2", "vdom": "test"}
                           {"name": "FortiGateVM64-3", "vdom": "root"}]

```  
* :param script_name: Specify the script name that should be executed on the specified devices

### 42) 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", 
                                                 path="/FortiGate_backups", 
                                                 filename="FortiGate.conf", 
                                                 device_name="FortiGate-VM64", vdom="root")

```
####A small function to back up configuration on FortiGates from FortiManager and store it in TFTP Server.
This function leverages **_create_script()_** and **_run_script_on_single_device()_** methods from this package to backup the config.
- ## Parameters

* :param tftp_ip: Specify TFTP Server IP
* :param path: Specify the path to store the config
* :param filename: Specify the name of the backup file
* :param device_name: Specify the name of the device
* :param vdom: Specify the Vdom

## Contributing
- Being new to Python and this being my first publish, to get this module fully working for all of us, the Pull requests are welcome.

## License
[MIT](https://github.com/akshaymane920/pyFortiManagerAPI/blob/master/LICENSE.txt)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/akshaymane920/pyFortiManagerAPI",
    "name": "pyFortiManagerAPI",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "FortiManager,RestAPI,API,FortiGate,Fortinet,python,FortiManager API,FortiManager API Python,Python examples",
    "author": "Akshay Mane",
    "author_email": "akshaymane920@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/80/e2/c7e531a8fefbbe5ac1e3162fdca02b190e8050738bf56b25bce9506ba3f5/pyFortiManagerAPI-0.2.3.tar.gz",
    "platform": null,
    "description": "# pyFortiManagerAPI\n\nA Python wrapper for the FortiManager JSON RPC API.\n\n[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/dwyl/esta/issues) [![Upload Python Package](https://github.com/akshaymane920/pyFortimanagerAPI/actions/workflows/python-publish.yml/badge.svg)](https://github.com/akshaymane920/pyFortimanagerAPI/actions/workflows/python-publish.yml)  \n### *** Video Tutorial to use the package is available on [YouTube](https://www.youtube.com/watch?v=4o7-AYPwuSM) ***\n\n## Installation\n\nUse the package manager [pip](https://pip.pypa.io/en/stable/) to install pyFortiManagerAPI.\n\n```shell script\npip install pyFortiManagerAPI\n```\n\n## Getting Started\n\n1. Creating Instance of the Module\n\n```python\nimport pyFortiManagerAPI\nfortimngr = pyFortiManagerAPI.FortiManager(host=\"\", \n                                           username=\"\",\n                                           password=\"\")\n```\n\nRequired settings:\n- host: Management Ip address of your FortiManager\n- username/password: Specify your credentials to log into the device.\n\nOptional settings:\n- adom: Default is adom=root.\n- protocol: Default is protocol=https. If set to protocol=http, then verify=False is set automatically.\n- verify: Default is verify=True. If your Fortimanager has a self-signed certificate, set verify=False.\n- proxies: Default is an empty dictionary (which means: use the environement variables). If you dont' want to use proxies, even if they are defined in your environment variables, then set 'proxies' to false. If you want to use other proxies than defined in your environment then you go like this:\n    ```python\n        proxies = {\n            'http': 'http://10.10.1.10:3128',\n            'https': 'http://10.10.1.10:1080'\n        }\n    ```\n# User Operations : Adoms\n### 1) Get all adoms from the FortiManager.\n```python\n>>> fortimngr.get_adoms()\n```\n```python\n>>> fortimngr.get_adoms(name=\"root\")\n```\n- ## Parameters\n* name: Can get specific adom using name as a filter.\n\n### 2) Set to different Adom\n```python\n>>> fortimngr.set_adom(\"adom_name\")\n```\n- ## Parameters\n* name of the admon you want to switch to.\n\n### 3) Lock Adom (in workspace mode)\n```python\n>>> fortimngr.lock_adom()\n```\n```python\n>>> fortimngr.lock_adom(name=\"root\")\n```\n- ## Parameters\n* name: Can lock specific adom using name as a filter.\n\n### 4) Unlock Adom (in workspace mode)\n```python\n>>> fortimngr.unlock_adom()\n```\n```python\n>>> fortimngr.unlock_adom(name=\"root\")\n```\n- ## Parameters\n* name: Can lock specific adom using name as a filter.\n\n# User Operations : Policy Package\n### 5) Get all the policy packages configured on FortiManager.\n```python\n>>> fortimngr.get_policy_packages()\n```\n```python\n>>> fortimngr.get_policy_packages(name=\"default\")\n```\n- ## Parameters\n* name: Can get specific package using name as a filter.\n\n\n### 6) Add your own policy package in FortiManager.\n```python\n>>> fortimngr.add_policy_package(name=\"TestPackage\")\n```\n- ## Parameters\n* name: Specify the Package Name.\n\n\n# User Operations : Address Objects\n\n### 7) Get all address objects from FortiManager.\n\n```python\n>>> fortimngr.get_firewall_address_objects()\n```\n\n### 7bis) Get all v6 address objects from FortiManager.\n\n```python\n>>> fortimngr.get_firewall_address_v6_objects()\n```\n\n### 8) Get specific address object from FortiManager.\n\n```python\n>>> fortimngr.get_firewall_address_objects(name=\"YourObjectName\")\n>>> fortimngr.get_firewall_address_v6_objects(name=\"YourObjectName\")\n```\n\n- ## Parameters\n\n* name: Specify object name that you want to see.\n\n### 9) Create an address object.\n\n```python\n>>> fortimngr.add_firewall_address_object(name=\"TestObject\",\n                                          associated_interface=\"any\",\n                                          subnet=[\"1.1.1.1\", \"255.255.255.255\"]\n                                          )\n```\n\n- ## Parameters\n\n* name: Specify object name that is to be created\n* associated_interface: Provide interface to which this object belongs if any. {Default is kept any}\n* subnet: Specify the subnet in a list format eg.[\"1.1.1.1\", \"255.255.255.255\"]\n\n### 9bis) Create an v6 address object.\n\n```python\n>>> fortimngr.add_firewall_address_v6_object(name=\"TestObject\",\n                                          subnet6=\"2001:0001:0001::2/128\"]\n                                          )\n```\n\n- ## Parameters\n\n* name: Specify object name that is to be created\n* associated_interface: Provide interface to which this object belongs if any. {Default is kept any}\n* subnet: Specify the subnet in a list format eg.[\"1.1.1.1\", \"255.255.255.255\"]\n* subnet6 : Specify the subnet IPv6 in a string format eg. \"2001:0001::1/128\"\n### 10) Update address object.\n\n```python\n>>> fortimngr.update_firewall_address_object(name=\"TestObject\",\n                                             associate_interface=\"port1\",\n                                             comment=\"Updated using API\",\n                                             subnet=[\"2.2.2.2\",\"255.255.255.255\"]\n                                             )\n\n>>> fortimngr.update_firewall_address_v6_object(name=\"TestObject\",\n                                             comment=\"Updated using API\",\n                                             subnet6=\"2001:0001::1/128\"\n                                             )\n```\n- ## Parameters\n\n* name: Enter the name of the object that needs to be updated\n* data: You can get the **kwargs parameters with \"show_params_for_object_update()\" method or \"\n\n### 11) Delete address object.\n\n```python\n>>> fortimngr.delete_firewall_address_object(object_name=\"TestObject\")\n```\n\n- ## Parameters\n\n* object_name: Specify the Object name you want to delete.\n\n---\n\n# User Operations : Address Groups\n\n### 12) Get all address groups.\n\n```python\n>>> fortimngr.get_address_groups()\n>>> fortimngr.get_address_v6_groups()\n```\n\n### 13) Get specific address group.\n\n```python\n>>> fortimngr.get_address_groups(name=\"TestGroup\")\n>>> fortimngr.get_address_v6_groups(name=\"TestGroup\")\n```\n\n- ## Parameters\n\n* name: Specify the name the address group.\n\n### 14) Create your own address group.\n\n```python\n>>> fortimngr.add_address_group(name=\"Test_Group\",                                \n                                members=[\"TestObject1\"])\n>>> fortimngr.add_address_v6_group(name=\"Test_Group\",\n                                members=[\"TestObject1\"])\n```\n\n- ## Parameters\n\n* name: Enter the name of the address group. eg.\"Test_Group\"\n* members: pass your object names as members in a list eg. [\"TestObject1\", \"TestObject2\"]\n  > Note: An address group should consist atleast 1 member.\n\n### 15) Update the address group.\n\n```python\n>>> fortimngr.update_address_group(name=\"Test_Group\",\n                                   object_name=\"TestObject3\",\n                                   do=\"add\")\n>>> fortimngr.update_address_v6_group(name=\"Test_Group\",\n                                   object_name=\"TestObject3\",\n                                   do=\"add\")\n```\n\n- ## Parameters\n\n* name: Specify the name of the Address group you want to update\n* object_name: Specify name of the object you wish to update(add/remove) in Members List\n* do: Specify if you want to add or remove the object from the members list\n  do=\"add\" will add the object in the address group\n  do=\"remove\" will remove the object from address group\n\n### 16) Delete the address group.\n\n```python\n>>> fortimngr.delete_address_group(name=\"Test_group\")\n>>> fortimngr.delete_address_v6_group(name=\"Test_group\")\n```\n\n- ## Parameters\n\n* name: Specify the name of the address group you wish to delete\n\n---\n# User Operations : VirtualIP Objects\n\n### 17) Get all VIP objects from FortiManager.\n\n```python\n>>> fortimngr.get_firewall_vip_objects()\n```\n\n---\n\n# User Operations : Add Devices\n\n### 18) Add devices to FortiManager.\n\nAdd an existing device:\n\n```python\n>>> fortimngr.add_device(ip_address=\"192.168.0.100\", \n                         username=\"admin\", \n                         password=\"\", \n                         name=\"FortiGateVM64\", \n                         description=False)\n```\n\nor model a device that is to be deployed:\n\n```python\n>>> fortimngr.add_model_device(serial_no=\"FGTxxxxxxxx\", \n                         name=\"FortiGateVM64\")\n                         username=\"admin\", \n                         password=\"\", \n```\nRequired arguments:\n* serial_no\n* name\n\nOptional arguments:\n* username (default=admin)\n* password (default=\"\")\n* os_type (default=\"fos\")\n* os_ver (default=6)\n* mr (default=4)\n* platform_str (default \"\", \"FortiGate-VM64\" for virtual Fortigate)\n\n### 19) Get devices From FortiManager.\n\n```python\n>>> fortimngr.get_devices()\n```\n\n\n# User Operations : Meta Data\n\n### 20) Get Meta Data From FortiManager.\n```python\n>>> fortimngr.get_meta_data()\n```\n\n### 21) Add Meta Data to FortiManager.\n```python\n>>> fortimngr.add_meta_data(name=\"Meta_Data_1\", \n                            status=1)\n```\n\n## Parameters\n* :param name: name of the meta tag\n* :param status: status of meta tag whether it should be active(1) or disabled(0)\n\n### 22) Assign Meta Data to a FortiGate.\n```python\n>>> fortimngr.assign_meta_to_device(device=\"FortiGateVM64\", \n                                    meta_name=\"Meta_Data_1\", \n                                    meta_value=\"192.168.0.1/24\")\n```\n## Parameters\n\n* :param device: name of the device\n* :param meta_name: name of the meta tag\n* :param meta_value: value of the meta tag\n# User Operations : Policies\n\n### 23) Assign Meta Data to a FortiGate VDOM.\n```python\n>>> fortimngr.assign_meta_to_device_vdom(device=\"FortiGateVM64\",\n                                         vdom=\"vdom\",\n                                         meta_name=\"Meta_Data_1\", \n                                         meta_value=\"192.168.0.1/24\")\n```\n## Parameters\n\n* :param device: name of the device\n* :param vdom: Specify the Vdom\n* :param meta_name: name of the meta tag\n* :param meta_value: value of the meta tag\n# User Operations : Policies\n\n### 24) Get all the policies in your Policy Package.\n\n```python\n>>> fortimngr.get_firewall_policies(policy_package_name=\"YourPolicyPackageName\")\n```\n\n- ## Parameters\n\n* policy_package_name: Enter the policy package name.\n\n### 25) Get specific policiy in your Policy Package using PolicyID filter.\n\n```python\n>>> fortimngr.get_firewall_policies(policy_package_name=\"YourPolicyPackageName\", policyid=3)\n```\n\n- ## Parameters\n\n* policy_package_name: Enter the policy package name.\n* policyid: Can filter and get the policy you want using policyID\n\n### 26) Get global header policy\n\nfortimngr.get_global_header_policies\n\n### 27) Get header policy\n\nfortimngr.get_firewall_header_policies\n\n### 28) Get global footer policy\n\nfortimngr.get_global_footer_policies\n\n### 29) Get footer policy\n\nfortimngr.get_firewall_footer_policies\n\n### 30) Create your own policy in your Policy Package.\n\n```python\n>>> fortimngr.add_firewall_policy(policy_package_name=\"YourPolicyPackageName\",\n                                  name=\"YourPolicyName\",\n                                  source_interface=\"port1\",\n                                  source_address=\"all\",\n                                  destination_interface=\"port2\",\n                                  destination_address=\"all\",\n                                  service=\"ALL_TCP\",\n                                  logtraffic=2\n                                  )\n>>> fortimngr.add_firewall_policy_with_v6(policy_package_name=\"YourPolicyPackageName\",\n                                  name=\"YourPolicyName\",\n                                  source_interface=\"port1\",\n                                  source_address=\"all\",\n                                  source_address6=\"all\",\n                                  destination_interface=\"port2\",\n                                  destination_address=\"all\",\n                                  destination_address6=\"all\",\n                                  service=\"ALL_TCP\",\n                                  logtraffic=2\n                                  )\n\n```\n\n- ## Parameters\n\n* policy_package_name: Enter the name of the policy package eg. \"default\"\n* name: Enter the policy name in a string format eg. \"Test Policy\"\n* source_interface: Enter the source interface in a string format eg. \"port1\"\n* source_address: Enter the src. address object name in string format or list\n* source_address6: Enter the src. address v6 object name in string format or list\n* destination_interface: Enter the source interface in a string format eg. \"port2\"\n* destination_address: Enter the dst. address object name eg. \"WAN_100.25.1.63_32\"\n* destination_address6: Enter the dst. address v6 object name in string format or list\n* service: Enter the service you want to permit or deny in string eg. \"ALL_UDP\"\n* schedule: Schedule time is kept 'always' as default.\n* action: Permit(1) or Deny(0) the traffic. Default is set to Permit.\n* logtraffic: Specify if you need to log all traffic or specific in int format.\n*                  logtraffic=0  Means No Log\n                   logtraffic=1  Means Log Security Events\n                   logtraffic=2  Means Log All Sessions\n\n\n### 31) Update the policy in your Policy Package.\n\n```python\n>>> fortimngr.update_firewall_policy(policy_package_name=\"YourPolicyPackageName\",\n                                     policyid=10,\n                                     source_interface=\"port2\",\n                                     action=1,\n                                     )\n```\n\n- ## Parameters\n\n* policy_package_name: Enter the policy package name in which you policy belongs.\n* policyid: Enter the Policy ID you want to edit\n* data: You can get the **kwargs parameters with \"show_params_for_policy_update()\" method\n\n\n### 32) Delete the policy in your Policy Package.\n\n```python\n>>> fortimngr.delete_firewall_policy(policy_package_name=\"YourPolicyPackageName\",\n                                     policyid=10)\n```\n\n- ## Parameters\n\n* policy_package_name: Enter the policy package name in which you policy belongs\n* policyid: Enter the policy ID of the policy you want to delete\n\n\n\n\n### 33) Move Firewall Policy.\n\n```python\n>>> fortimngr.move_firewall_policy(policy_package_name=\"LocalLab\",\n                                   move_policyid=10, \n                                   option=\"after\", \n                                   policyid=2)\n```\n- ## Parameters\n*  policy_package_name: Enter the policy package name in which you policy belongs.\n*  move_policyid: Enter the policy ID of the policy you want to move.\n*  option: Specify if you want to move the policy above(\"before\") the target policy or below(\"after\") {default: before}.\n*  policyid: Specify the target policy.\n---\n\n\n# User Operations : Installing the Policy Package.\n\n### 34) Installing the Policy Package.\n\n```python\n>>> fortimngr.install_policy_package(package_name=\"Your Policy Package name\")\n\n```\n\n### 35) Adding Installation Targets to a Policy Package.\n\n```python\n>>> fortimngr.add_install_target(device_name=\"FortiGateVM64\", \n                                 pkg_name=\"Test_Policy_Pakage\", \n                                 vdom=\"root\")\n```\n- ## Parameters\n\n* :param device_name: name of the device\n* :param pkg_name: name of the policy package\n* :param vdom: name of the vdom (default=root)\n\n---\n\n# Show Params for updation of Policies and Objects.\n\n### 36) Parameters for updating Address Object.\n\n```python\n>>> fortimngr.show_params_for_object_update()\n```\n        Parameters to create/update address object:\n\n        PARAMETERS                   FIREWALL OBJECT SETTINGS\n        allow_routing(int)          : Static Route Configuration\n        associated_interface(str)   : Interface\n        comment(str)                : Comments\n        object_name(str)            : Address Name\n        subnet[list]                : IP/Netmask\n        object_type(int)            : Type\n\n### 37) Parameters for updating Policy.\n\n```python\n>>> fortimngr.show_params_for_policy_update()\n```\n        Parameters to create/update Policy:\n\n        PARAMETERS                       FIREWALL POLICY SETTINGS\n        name(str)                       : Name\n        source_interface(str)           : Incoming Interface\n        source_address(str)             : Source Address\n        destination_interface(str)      : Destination Interface\n        destination_address(str)        : Destination Address\n        service(str)                    : Service\n        schedule(str)                   : Schedule\n        action(int)                     : Action\n        logtraffic(int)                 : Log Traffic\n        comment(str)                    : Comments\n\n# User Operations : Adding scripts in Fortimanager.\n\n### 38) Add a script in FortiManager's Database.\n\n```python\n>>> fortimngr.create_script(name=\"Test Script Template\", \n                            script_content=\"config system interface \\n edit port 1 \\n set ip 1.1.1.1/24\", \n                            target=0)\n```\n- ## Parameters\n\n* :param name: Specify a name for the script\n* :param script_content: write the cli commands\n* :param target: Set the target\n```\n      If Target = 0 than script runs on Device database\n      If Target = 1 than script runs on Remote FortiGate CLI\n      If Target = 2 than script runs on Policy package or Adom Database\n      Default value is set to 0\n```\n\n\n### 39) Get all scripts from FortiManager's Database.\n\n```python\n>>> fortimngr.get_all_scripts()\n```\n\n### 40) Delete a script from FortiManager's Database.\n\n```python\n>>> fortimngr.delete_script(name=\"Test Script Template\")\n```\n- ## Parameters\n\n* :param name: Specify a name for the script tha need to be deleted.\n\n### 41) Run a script on FortiManager's Database/ FortiGate's Remote CLI.\n\n```python\n>>> fortimngr.run_script_on_single_device(script_name=\"test_script\", \n                                          device_name=\"FortiGate-VM64\", \n                                          vdom=\"root\")\n```\n- ## Parameters\n\n* :param device_name: Specify device name.\n* :param vdom: Specify the Vdom\n* :param script_name: Specify the script name that should be executed on the specified devices\n\n\n```python\n>>> fortimngr.run_script_on_multiple_devices(script_name=\"test_script\", \n                                             devices=[{\"name\":\"FortiGate-VM64\", \"vdom\": \"root\"},\n                                                      {\"name\":\"Test-FortiGate-VM64\", \"vdom\": \"global\"},\n                                                      {\"name\":\"Test-2-FortiGate-VM64\", \"vdom\": \"Test\"}])\n```\n- ## Parameters\n\n* :param devices: Specify devices in a list of dictionaries.\n```\n              eg. devices=[{\"name\": \"FortiGateVM64-1\", \"vdom\": \"root\"},\n                           {\"name\": \"FortiGateVM64-2\", \"vdom\": \"test\"}\n                           {\"name\": \"FortiGateVM64-3\", \"vdom\": \"root\"}]\n\n```  \n* :param script_name: Specify the script name that should be executed on the specified devices\n\n### 42) Backup FortiGate's configuration from FortiManager and store it in TFTP server.\n\n```python\n>>> fortimngr.backup_config_of_fortiGate_to_tftp(tftp_ip=\"1.1.1.1\", \n                                                 path=\"/FortiGate_backups\", \n                                                 filename=\"FortiGate.conf\", \n                                                 device_name=\"FortiGate-VM64\", vdom=\"root\")\n\n```\n####A small function to back up configuration on FortiGates from FortiManager and store it in TFTP Server.\nThis function leverages **_create_script()_** and **_run_script_on_single_device()_** methods from this package to backup the config.\n- ## Parameters\n\n* :param tftp_ip: Specify TFTP Server IP\n* :param path: Specify the path to store the config\n* :param filename: Specify the name of the backup file\n* :param device_name: Specify the name of the device\n* :param vdom: Specify the Vdom\n\n## Contributing\n- Being new to Python and this being my first publish, to get this module fully working for all of us, the Pull requests are welcome.\n\n## License\n[MIT](https://github.com/akshaymane920/pyFortiManagerAPI/blob/master/LICENSE.txt)\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A Python wrapper for the FortiManager REST API",
    "version": "0.2.3",
    "project_urls": {
        "Homepage": "https://github.com/akshaymane920/pyFortiManagerAPI"
    },
    "split_keywords": [
        "fortimanager",
        "restapi",
        "api",
        "fortigate",
        "fortinet",
        "python",
        "fortimanager api",
        "fortimanager api python",
        "python examples"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9b06ddea1b06063b345f45abf1f722ec591fe4c74cc59a915c96cb0efc44a173",
                "md5": "ec66edaa1b6a2d99b7c162e8ef0b2b52",
                "sha256": "b1cad025b8df603b85ad21ef392b3cb3c63a429cc1eaa4dfdb86157fa697eac0"
            },
            "downloads": -1,
            "filename": "pyFortiManagerAPI-0.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ec66edaa1b6a2d99b7c162e8ef0b2b52",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 16244,
            "upload_time": "2023-10-15T13:33:34",
            "upload_time_iso_8601": "2023-10-15T13:33:34.814719Z",
            "url": "https://files.pythonhosted.org/packages/9b/06/ddea1b06063b345f45abf1f722ec591fe4c74cc59a915c96cb0efc44a173/pyFortiManagerAPI-0.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "80e2c7e531a8fefbbe5ac1e3162fdca02b190e8050738bf56b25bce9506ba3f5",
                "md5": "0921d62cb1fdd82a653da2a1da7f05c2",
                "sha256": "85bc3afffb94b8a72ee4e19de3331f9a519f58505de2a89a829793de6b39a14c"
            },
            "downloads": -1,
            "filename": "pyFortiManagerAPI-0.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "0921d62cb1fdd82a653da2a1da7f05c2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 20098,
            "upload_time": "2023-10-15T13:33:35",
            "upload_time_iso_8601": "2023-10-15T13:33:35.958284Z",
            "url": "https://files.pythonhosted.org/packages/80/e2/c7e531a8fefbbe5ac1e3162fdca02b190e8050738bf56b25bce9506ba3f5/pyFortiManagerAPI-0.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-15 13:33:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "akshaymane920",
    "github_project": "pyFortiManagerAPI",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "pyfortimanagerapi"
}
        
Elapsed time: 0.12982s