{"id":23975706,"url":"https://github.com/vladimirs-git/fortigate-api","last_synced_at":"2025-04-04T17:05:10.002Z","repository":{"id":37951561,"uuid":"424911355","full_name":"vladimirs-git/fortigate-api","owner":"vladimirs-git","description":"Python package for configuring Fortigate (Fortios) devices using REST API","archived":false,"fork":false,"pushed_at":"2025-01-07T12:13:28.000Z","size":3777,"stargazers_count":71,"open_issues_count":1,"forks_count":20,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-28T16:05:48.603Z","etag":null,"topics":["api","firewall","fortigate","fortigate-api","fortigate-automation","fortigate-firewall","fortinet","fortios","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vladimirs-git.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-05T10:37:19.000Z","updated_at":"2025-03-04T22:00:51.000Z","dependencies_parsed_at":"2024-01-13T03:51:50.998Z","dependency_job_id":"3ef4d9a1-067a-4074-bed3-0a0cd30d675e","html_url":"https://github.com/vladimirs-git/fortigate-api","commit_stats":{"total_commits":46,"total_committers":4,"mean_commits":11.5,"dds":"0.30434782608695654","last_synced_commit":"923b95d48c232ea8cb223e077e08fe6d5257d8a8"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladimirs-git%2Ffortigate-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladimirs-git%2Ffortigate-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladimirs-git%2Ffortigate-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladimirs-git%2Ffortigate-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vladimirs-git","download_url":"https://codeload.github.com/vladimirs-git/fortigate-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247217172,"owners_count":20903008,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","firewall","fortigate","fortigate-api","fortigate-automation","fortigate-firewall","fortinet","fortios","python"],"created_at":"2025-01-07T06:50:25.253Z","updated_at":"2025-04-04T17:05:09.981Z","avatar_url":"https://github.com/vladimirs-git.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n.. image:: https://img.shields.io/pypi/v/fortigate-api.svg\n   :target: https://pypi.python.org/pypi/fortigate-api\n.. image:: https://img.shields.io/badge/Python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11-blue.svg\n   :target: https://pypi.python.org/pypi/logger-color\n.. image:: https://img.shields.io/github/last-commit/vladimirs-git/fortigate-api\n   :target: https://pypi.python.org/pypi/fortigate-api\n\n\nfortigate-api\n=============\n\nPython package to configure Fortigate (Fortios) devices using REST API.\n\n    - FortiGateAPI - Python connector to Fortigate API endpoints.\n    - FortiGate - Python wrapper for the FortiOS REST API.\n\nChecked with FortiOS = v6.4.14.\nFully documented on `Read the Docs`_.\n\n\n----------------------------------------------------------------------------------------\n\nRequirements\n============\n\nPython \u003e=3.8,\u003c=3.13\n\n\nQuickstart\n==========\n\nInstall the package from pypi.org\n\n.. code:: bash\n\n    pip install fortigate-api\n\nor from github.com repository\n\n.. code:: bash\n\n    pip install git+https://github.com/vladimirs-git/fortigate-api\n\n----------------------------------------------------------------------------------------\n\n.. code:: python\n\n    \"\"\"Quickstart FortiGateAPI.\n\n    - Create address in the Fortigate\n    - Get all addresses from the Fortigate vdom root\n    - Get address by name (unique identifier)\n    - Filter address by operator contains `=@`\n    - Update address data in the Fortigate\n    - Delete address from the Fortigate\n    \"\"\"\n\n    from pprint import pprint\n\n    from fortigate_api import FortiGateAPI\n\n    HOST = \"host\"\n    USERNAME = \"username\"\n    PASSWORD = \"password\"\n\n    api = FortiGateAPI(host=HOST, username=USERNAME, password=PASSWORD)\n\n    # Create address in the Fortigate\n    data = {\n        \"name\": \"ADDRESS\",\n        \"obj-type\": \"ip\",\n        \"subnet\": \"127.0.0.100 255.255.255.252\",\n        \"type\": \"ipmask\",\n    }\n    response = api.cmdb.firewall.address.create(data)\n    print(f\"address.create {response}\")  # address.create \u003cResponse [200]\u003e\n\n    # Get all addresses from the Fortigate vdom root\n    items = api.cmdb.firewall.address.get()\n    print(f\"All addresses count={len(items)}\")  # All addresses count=14\n\n    # Get address by name (unique identifier)\n    items = api.cmdb.firewall.address.get(name=\"ADDRESS\")\n    print(f\"addresses count={len(items)}\")  # addresses count=1\n    pprint(items)\n    #  [{\"comment\": \"\",\n    #    \"name\": \"ADDRESS\",\n    #    \"subnet\": \"127.0.0.100 255.255.255.252\",\n    #    \"uuid\": \"a386e4b0-d6cb-51ec-1e28-01e0bc0de43c\",\n    #    ...\n    #    }]\n\n    # Filter address by operator contains `=@`\n    items = api.cmdb.firewall.address.get(filter=\"subnet=@127.0\")\n    print(f\"Filtered by `=@`, count={len(items)}\")  # Filtered by `=@`, count=2\n\n    # Update address data in the Fortigate\n    data = {\"name\": \"ADDRESS\", \"subnet\": \"127.0.0.255 255.255.255.255\"}\n    response = api.cmdb.firewall.address.update(data)\n    print(f\"address.update {response}\")  # address.update \u003cResponse [200]\u003e\n\n    # Delete address from the Fortigate\n    response = api.cmdb.firewall.address.delete(\"ADDRESS\")\n    print(f\"address.delete {response}\")  # address.delete \u003cResponse [200]\u003e\n\n    api.logout()\n\n\n.. code:: python\n\n    \"\"\"Quickstart FortiGate.\n\n    - Creates address in the Fortigate\n    - Get address by name (unique identifier)\n    - Updates address data in the Fortigate\n    - Delete address from the Fortigate\n    \"\"\"\n\n    from pprint import pprint\n\n    from fortigate_api import FortiGate\n\n    HOST = \"host\"\n    USERNAME = \"username\"\n    PASSWORD = \"password\"\n\n    fgt = FortiGate(host=HOST, username=USERNAME, password=PASSWORD)\n\n    # Creates address in the Fortigate\n    data = {\n        \"name\": \"ADDRESS\",\n        \"obj-type\": \"ip\",\n        \"subnet\": \"127.0.0.100 255.255.255.252\",\n        \"type\": \"ipmask\",\n    }\n    response = fgt.post(url=\"api/v2/cmdb/firewall/address/\", data=data)\n    print(f\"POST {response}\", )  # POST \u003cResponse [200]\u003e\n\n    # Get address by name (unique identifier)\n    response = fgt.get(url=\"api/v2/cmdb/firewall/address/ADDRESS\")\n    print(f\"GET {response}\", )  # POST \u003cResponse [200]\u003e\n    result = response.json()[\"results\"]\n    pprint(result)\n    #  [{\"name\": \"ADDRESS\",\n    #    \"subnet\": \"127.0.0.100 255.255.255.252\",\n    #    \"uuid\": \"a386e4b0-d6cb-51ec-1e28-01e0bc0de43c\",\n    #    ...\n    #    }]\n\n    # Updates address data in the Fortigate\n    data = {\"name\": \"ADDRESS\", \"subnet\": \"127.0.0.255 255.255.255.255\"}\n    response = fgt.put(url=\"api/v2/cmdb/firewall/address/ADDRESS\", data=data)\n    print(f\"PUT {response}\")  # PUT \u003cResponse [200]\u003e\n\n    # Delete address from the Fortigate\n    response = fgt.delete(url=\"api/v2/cmdb/firewall/address/ADDRESS\")\n    print(f\"DELETE {response}\", )  # DELETE \u003cResponse [200]\u003e\n\n    fgt.logout()\n\n\n\n----------------------------------------------------------------------------------------\n\n.. _`Read the Docs`: https://fortigate-api.readthedocs.io/en/latest/","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvladimirs-git%2Ffortigate-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvladimirs-git%2Ffortigate-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvladimirs-git%2Ffortigate-api/lists"}