带Python的Meraki API

时间:2019-05-23 15:35:17

标签: python python-3.x network-programming

请参阅Github内容。 https://github.com/meraki/dashboard-api-python/blob/master/meraki.py

假设我只想列出组织中的网络。我已经确定了所需的样本模板。我如何以及在哪里执行此脚本?我是否只是将其放入文件中并将其重命名为.py,然后从终止处执行它?

> # List the networks in an organization
> # https://api.meraki.com/api_docs#list-the-networks-in-an-organization def getnetworklist(apikey, orgid, templateid=None,
> suppressprint=False):
>     #
>     # Confirm API Key has Admin Access Otherwise Raise Error
>     #
>     __hasorgaccess(apikey, orgid)
>     calltype = 'Network'
> 
>     geturl = '{0}/organizations/{1}/networks'.format(
>         str(base_url), str(orgid))
>     if templateid is not None:
>         geturl += '?configTemplateId=' + templateid
>     headers = {
>         'x-cisco-meraki-api-key': format(str(apikey)),
>         'Content-Type': 'application/json'
>     }
>     dashboard = requests.get(geturl, headers=headers)
>     #
>     # Call return handler function to parse Dashboard response
>     #
>     result = __returnhandler(
>         dashboard.status_code, dashboard.text, calltype, suppressprint)
>     return result

0 个答案:

没有答案