Try this..
#! /usr/bin/env python3
from datetime import datetime
import asyncio
import meraki
import meraki.aio
async def GetWirelessUsageHistory(p_dashboard: meraki.aio.AsyncDashboardAPI,p_network_id,p_client):
"""https://developer.cisco.com/meraki/api-v1/#!get-network-client-policy"""
try:
ClientPolicy = await p_dashboard.networks.getNetworkClientPolicy(
p_network_id, p_client['id']
)
except meraki.AsyncAPIError as e:
print(f"Meraki API error {e}")
return -1
except Exception as e:
print(f"Some other exception {e}")
return -2
if ClientPolicy['devicePolicy'] == "Group policy":
p_client['groupPolicyId'] = ClientPolicy['groupPolicyId']
else:
p_client['groupPolicyId'] = None
return p_client
async def main():
"""Main function routine"""
network_id = ""
AllNetworkClients = []
dashboard = meraki.DashboardAPI(
suppress_logging=True
)
GetAllNetworkClients = dashboard.networks.getNetworkClients(
network_id, total_pages='all'
)
async with meraki.aio.AsyncDashboardAPI(
maximum_retries=5,
suppress_logging=True
) as aiodashboard:
GetGroupPolicyTasks = [GetWirelessUsageHistory(aiodashboard,network_id,client) for client in GetAllNetworkClients]
for task in asyncio.as_completed(GetGroupPolicyTasks):
ClientData = await task
AllNetworkClients.append(ClientData)
return 0
if __name__ == "__main__":
ScriptStart = datetime.now()
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
print("\n$Time Elapsed:",datetime.now()-ScriptStart)
LinkedIn :::
https://blog.rhbirkelund.dk/Like what you see? - Give a Kudo ## Did it answer your question? - Mark it as a Solution
🙂All code examples are provided as is. Responsibility for Code execution lies solely your own.