Esempio n. 1
0
def valid_api_key(api_key):
    """Call the Pelion Account Management API to validate an API key.

    :param str api_key: API key to validate.
    """
    api = AccountManagementAPI({"api_key": api_key})
    try:
        # We need to make a call to the api for the key to be validated.
        api.get_account()
    except CloudApiException:
        return False
    return True
def _main():
    api = AccountManagementAPI()

    header = "Account details"
    print("%s\n%s" % (header, len(header) * "-"))
    account = api.get_account()
    print(account)
 def test_configuration(self):
     with self.assertRaises(CloudApiException):
         # an example: configuring the SDK
         from mbed_cloud import AccountManagementAPI
         config = dict(api_key='ak_1234abc')
         # alternatively, configuration can be loaded from json files or environment variables
         # if the host is not the default Pelion Device Management, it needs to be specified
         config['host'] = 'https://custom-mbed-cloud-host.com'
         # create an instance of one of the SDK modules
         api = AccountManagementAPI(params=config)
         # do something with the SDK
         print(api.get_account())