akshaymane920 / pyFortimanagerAPI

A wrapper for FortiManager API
https://akshaymane920.github.io/pyFortimanagerAPI/
MIT License
31 stars 34 forks source link

Git version broken? #37

Closed svde closed 11 months ago

svde commented 1 year ago

I noticed that the API for global header & footer policies has changed between v6 and v7 fortimanager. I thought I'd take the current (git) as the starting point for my changes. Issue is that I'm not able to make a connection with the fortimanager with the current git version.

Steps to reproduce: 1/ install new venv: python -m venv venv-20231001-git / python -m venv venv-20231001-pip 2/ activate the venv and install

source venv-20231001-git/bin/activate / source venv-20231001-pip/bin/activate
pip install pip-upgrade-tool
deactivate
source venv-20231001-git/bin/activate / source venv-20231001-pip/bin/activate
pip-upgrade -y
pip install git+https://github.com/akshaymane920/pyFortimanagerAPI.git / pip install pyFortiManagerAPI

3/ start python and run the same commands. Output of the git version:

>>> from os import environ
>>> import pyFortiManagerAPI
>>>
>>> lfws = pyFortiManagerAPI.FortiManager(host=environ.get('lfws_host'),
...                                            username=environ.get('lfws_username'),
...                                            password=environ.get('lfws_password'),
...                                            verify=False)
>>>
>>> print(lfws.get_adoms())
[{'status': {'code': -11, 'message': 'No permission for the resource'}, 'url': 'dvmdb/adom'}]

Output of the pip version:

>>> from os import environ
>>> import pyFortiManagerAPI
>>>
>>> lfws = pyFortiManagerAPI.FortiManager(host=environ.get('lfws_host'),
...                                            username=environ.get('lfws_username'),
...                                            password=environ.get('lfws_password'),
...                                            verify=False)
>>>
>>> print(lfws.get_adoms())
[{'data': [{'create_time': 1601388171, 'desc': 'Devices managed by the local firewall service'

The screen fills up with data, truncated, as the point is made that it gets data.

Has something changed with the login process in the current git version?

akshaymane920 commented 1 year ago

Adom Lock with Context Manager was introduced with @icovada., For time being I have reverted that Commit. Can you check?

moustic999 commented 1 year ago

I think the latest version was not pushed to PIP. That's the reason. There is also a missing return for which I created a merge request ( still there ). It's a pitty you reverted the Lock, we are using it here and it is very usefull. I have also extednted the librardy with a Device class which allow to work easily with devices. Here at work we intend to use your library in our production environment. If possible I will contribute as much as possible with all extends we need. I need to know what are the direction you want for this lib, to know if I push the merge request or if it is better to fork and continue on our own track ?

svde commented 1 year ago

Perhaps it would help if the documentation is updated so I understand how to use the new method.