Giter Site home page Giter Site logo

fortipy's Introduction

fortipy's People

Contributors

dependabot[bot] avatar erikruiter2 avatar incand avatar pschmitt avatar pyup-bot avatar robertpenz avatar thushjandan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fortipy's Issues

forti._request() session attribute gets set 2 times

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
            })

Fortimanager lock_adom() does not work

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?

fortipy._get() result parsing changed

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']

request_id numbering schema?

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)

Creating webfilter

Hi,

I could not figure out how can I post a webfilter with a list of URL filters

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.