akshaymane920 / pyFortimanagerAPI

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

Add meta data parameter to get_devices. #26

Open iunderwood opened 1 year ago

iunderwood commented 1 year ago

This is to add a toggle to return all the metadata fields with a device when getting the devices.

   def get_devices(self, metadata=False):
        """
        :return: returns list of devices added in FortiManager
        """
        session = self.login()
        payload = \
            {
                "method": "get",
                "params": 
                    [
                        {
                            "url": f"/dvmdb/adom/{self.adom}/device/"
                        }
                    ]
            }
        if metadata is True:
            payload['params'][0].update({"meta fields": ["*"]})

        payload.update({"session": self.sessionid})
        get_devices = session.post(
            url=self.base_url, json=payload, verify=False)
        return get_devices.json()

According to the FNDN, metadata is not returned by default.

akshaymane920 commented 1 year ago

I didn't knew this because unfortunately I don't have the access to FNDN 🥲, let me update the method by this week, Thanks!!. Or would you like to do it?, I shall merge the PR.🙂

iunderwood commented 1 year ago

I'll do a PR this week. Thanks!