# 🚮 Archived!
If you're interested in maintaining this package please get in touch with me at:
FortiManger API bindings for Python
License: GNU General Public License v3.0
# 🚮 Archived!
If you're interested in maintaining this package please get in touch with me at:
session will be set 2 times, the first can be removed?
post_data = json.dumps({
'method': method,
'params': [{'url': url, 'data': data, 'option': option}],
'id': request_id,
'session': self.token,
'verbose': verbose,
'jsonrpc': '2.0',
'session': self.token if self.token else 1
# 'skip': skip
})
Hi!
fortimanager.lock_adom() calls return self._request(data)
, but _requests is defined as
def _request(self, method, url, option=None, data=None, request_id=1,
verbose=False):
which leads to TypeError: _request() takes at least 3 arguments (2 given)
. Should the data json dict split up and provided as parameters for the method?
The parsing of the result in _get(), didn't work in all cases for me. e.g. the original code did not work if result was an list and data a dict - the last return was used which through an exception. As I'm not sure which other cases are possible I'm not submitting a pull request, do show you my changes.
ps: the isinstance is just an habit as "is list" does not work for object that can be accessed like lists.
original code:
if type(res['result']) is list:
if 'data' in res['result'][0]:
if not res['result'][0]['data']:
return
if len(res['result'][0]['data']) > 0 and type(res['result'][0]['data']) is list:
if res['result'][0]['data']:
return [x for x in res['result'][0]['data']]
return res['result']['data']
my changed code:
if isinstance(res['result'], list):
if 'data' in res['result'][0]:
if isinstance(res['result'][0]['data'], list):
return [x for x in res['result'][0]['data']]
else:
# its a dict, just return it
return res['result'][0]['data']
else:
logger.warning("unhandled case - don't know if thats possible")
return res['result']['data']
I created an additional method which returns only one address group (could also be included in the main function, if name parameter is None you get everything, else only the specified group). Works so far, but where do I get the request_id number? I just added an 0 and it works, but there must be some schema. Can you please explain the request_id numbering please.
existing method:
@login_required
def get_firewall_address_groups(self, adom):
'''
Get all firewall adress groups defined for an ADOM
'''
request_id = 56227
url = 'pm/config/adom/{}/obj/firewall/addrgrp'.format(adom)
return self._get(url=url, request_id=request_id)
new method:
@login_required
def get_firewall_address_group(self, adom, addrgrp_name):
'''
Get all firewall adress groups defined for an ADOM
'''
request_id = 562270
url = 'pm/config/adom/{}/obj/firewall/addrgrp/{}'.format(adom, addrgrp_name)
return self._get(url=url, request_id=request_id)
Hi,
I could not figure out how can I post a webfilter with a list of URL filters
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.