带有Python的Meraki API

2024-06-06 12:17:44 发布

您现在位置:Python中文网/ 问答频道 /正文

引用Github内容。https://github.com/meraki/dashboard-api-python/blob/master/meraki.py

假设我只想列出我组织中的网络。我已经确定了所需的样本模板。如何在何处执行此脚本?我是不是把它放到一个文件中,然后重命名为.py,然后从我的terminate执行它?在

> # 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

Tags: theinpyhttpscomapidashboardheaders