-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetOrgID
41 lines (33 loc) · 879 Bytes
/
getOrgID
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python3
import click
import os
import meraki
import logging
"""
Optional: export env vars to access Meraki dashboard
export APIKEY=myApiKey
"""
@click.command(help="List Organization ID accessible via API KEY")
@click.option(
"--apikey",
required=True,
prompt=True,
help="API Key",
default=os.environ.get("APIKEY", ""),
)
def main(apikey):
m = meraki.DashboardAPI(
api_key=apikey, print_console=False, output_log=False, suppress_logging=True
)
try:
orgs = m.organizations.getOrganizations()
for org in orgs:
click.echo(f"ORG ID: {org.get('id'):20}ORG NAME: {org.get('name')}")
except:
click.echo(
click.style(
f"\n❌ ❌ ❌ ERROR READING ORGS - Verify API KEY is valid ❌ ❌ ❌\n",
fg="red",
)
)
main()