vladimirs-git / fortigate-api

Python package for configuring Fortigate (Fortios) devices using REST API
Apache License 2.0
61 stars 18 forks source link

How to add new firewall ips inside vdom addresses using port 8443? #24

Closed datta-shitole closed 7 months ago

datta-shitole commented 7 months ago

Hi @vladimirs-git

Really appreciate your efforts to maintain this project.

I have query regarding adding new IPs under VDOM. We have below function which actually add IPs to firewall.

*response = api.cmdb.firewall.address.create(data)

Also, is it possible to use port 8443 for create firewall address operation?

Thanks!

vladimirs-git commented 7 months ago

To use another TCP port, initialize the FortigateAPI with the port parameter. Before adding an address to a specific VDOM, initialize the FortigateAPI with the vdom parameter and after that call create method


    from fortigate_api import FortiGateAPI

    api = FortiGateAPI(host="HOST", username="USERNAME", password="PASSWORD", port=8443, vdom="VDOM")
    data = {
        "name": "ADDRESS",
        "obj-type": "ip",
        "subnet": "127.0.0.100 255.255.255.252",
        "type": "ipmask",
    }
    response = api.cmdb.firewall.address.create(data)
    print(f"address.create {response}")

For usage examples, you can refer to the following links: https://github.com/vladimirs-git/fortigate-api/blob/main/examples/cmdb/firewall/address.py#L107 https://github.com/vladimirs-git/fortigate-api/blob/main/examples/fortigateapi.py#L28

The best thanks is to star this project

datta-shitole commented 7 months ago

Thanks!