Skip to content

Commit 2c6628a

Browse files
authored
report_statuses: Added support for env var API key
1 parent bd81b3a commit 2c6628a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

report_statuses.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,27 @@
1919
import argparse
2020
import csv
2121
import meraki
22+
import os
2223

2324

2425
def parse_arguments(parser):
25-
parser.add_argument('-k', '--key', help='Dashboard API key')
26+
parser.add_argument('-k', '--key', help='Dashboard API key. If omitted, will use environment variable MERAKI_DASHBOARD_API_KEY')
2627
parser.add_argument('-o', '--org', help='Organization ID. Use "-o /all" to iterate through all organizations')
2728
parser.exit
2829
args = parser.parse_args()
2930
return args.key, args.org
3031

32+
def getApiKey(argument):
33+
if not argument is None:
34+
return str(argument)
35+
return os.environ.get("MERAKI_DASHBOARD_API_KEY", None)
3136

3237
def main():
3338
# Check if all required parameters have been specified
3439
parser = argparse.ArgumentParser()
35-
api_key, arg_org_id = parse_arguments(parser)
40+
tmp_api_key, arg_org_id = parse_arguments(parser)
41+
42+
api_key = getApiKey(tmp_api_key)
3643

3744
if not(api_key and arg_org_id):
3845
parser.exit(2, parser.print_help())

0 commit comments

Comments
 (0)