pyFortimanagerAPI icon indicating copy to clipboard operation
pyFortimanagerAPI copied to clipboard

Add meta data parameter to get_devices.

Open iunderwood opened this issue 2 years ago • 2 comments

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.

iunderwood avatar Feb 24 '23 19:02 iunderwood