pyFortimanagerAPI icon indicating copy to clipboard operation
pyFortimanagerAPI copied to clipboard

Is it possible to Add FortiAP/FortiSwitch Device Model with this?

Open Nugeorge opened this issue 3 years ago • 2 comments

As per title, I'm wondering if it's possible to API call adding a FortiAP or FortiSW? Cheers.

Nugeorge avatar Aug 11 '22 04:08 Nugeorge

Hey @Nugeorge, Thanks for commenting. I haven't worked on FortiAP or FortiSwitch yet for the project. I will tag it as an Enhancement task But we can try using "custom_api_call" method, if you know the api call. If it is successful, you can create a method out of it. I shall work on it as well.

akshaymane920 avatar Aug 14 '22 10:08 akshaymane920

Hello, I managed to get the AP's and switches devices.

def get_fortiSwitch(self):
        session = self.login()
        payload = {
            "method":"get","params":[
                {
                    "url":f"pm/config/adom/{self.adom}/obj/fsp/managed-switch",
                    "scope member":[{"name":"All_FortiGate"}]
                }
            ]
        }

        payload.update({"session": self.sessionid})
        get_devices = session.post(
            url=self.base_url, json=payload, verify=False)
        return get_devices.json()
    def get_fortiAp(self):
        session = self.login()
        payload = {
            "method":"get","params":[
                {
                    "url":f"pm/config/adom/{self.adom}/obj/wireless-controller/wtp",
                    "scope member":[{"name":"All_FortiGate"}],
                    "expand datasrc":[{"name":"wtp-profile",
                    "datasrc":[{"obj type":"wireless-controller wtp-profile",
                    "sub fetch":{"platform":{"subfetch hidden":1},
                    "lan":{"subfetch hidden":1},
                    "lbs":{"subfetch hidden":1},
                    "radio-1":{},
                    "radio-2":{},
                    "radio-3":{}},
                    "subfetch filter":1}]}],"data":None
                }
            ]
        }

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

20012455 avatar Apr 04 '23 08:04 20012455