Skip to content

Commit 77e0730

Browse files
author
Cruz Monrreal
authored
Merge pull request #8063 from theotherjimmy/mbed-dm-api-key
`mbed dm`: Accept api key and host on the command line
2 parents 836eec0 + e67a2c7 commit 77e0730

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

tools/device_management.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,23 @@ def inner(options):
8080

8181
def wrap_init(func):
8282
def inner(options):
83-
accounts = AccountManagementAPI()
84-
certs = CertificatesAPI()
83+
if getattr(options, 'api_key', None):
84+
api_key = options.api_key
85+
else:
86+
api_key = getenv("MBED_CLOUD_SDK_API_KEY")
87+
if getattr(options, 'server_address', None):
88+
host_addr = options.server_address
89+
else:
90+
host_addr = getenv("MBED_CLOUD_SDK_HOST",
91+
"https://api.us-east-1.mbedcloud.com/")
92+
config = {
93+
"api_key": api_key,
94+
"host": host_addr,
95+
}
96+
accounts = AccountManagementAPI(config)
97+
certs = CertificatesAPI(config)
8598
api_key = accounts.list_api_keys(filter={
86-
'key': getenv("MBED_CLOUD_SDK_API_KEY")
99+
'key': api_key
87100
}).next()
88101
certificates_owned = list(certs.list_certificates())
89102
dev_cert_info = None

0 commit comments

Comments
 (0)