Documentation

Mistake on this page? Email us

The API can be initalized with a .env file in the wroking directory with the following values

MBED_CLOUD_SDK_API_KEY=

and optionally

MBED_CLOUD_SDK_HOST= (defaults to https://api.us-east-1.mbedcloud.com)

OR

This API is initialized with ConnectionOptions.

To create an instance of this API in Node.js:

var PelionDMSDK = require("mbed-cloud-sdk");

var accounts = new PelionDMSDK.AccountManagementApi();

To create an instance of this API in the browser:

<script src="<pelion-dm-sdk>/bundles/account-management.min.js"></script>

<script>
    var accounts = new MbedCloudSDK.AccountManagementApi({
        apiKey: "<Pelion DM API Key>"
    });
</script>

Hierarchy

  • AccountManagementApi

Index

Constructors

constructor

Methods

addApiKey

  • Adds an API key

    Example:

    accounts.addApiKey({name: 'auto_generated_key'})
    .then(keyResult => {
        var key = keyResult.key;
        console.log('Save this signature as you only get it once: ' + key);
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    Returns Promise<ApiKey>

    Promise containing API key

  • Adds an API key

    Example:

    accounts.addApiKey({name: 'auto_generated_key'}, function(error, key) {
        if (error) throw error;
        var key = keyResult.key;
        console.log('Save this signature as you only get it once: ' + key);
    });

    Parameters

    Returns void

addUser

  • Adds a user

    Example:

    accounts.addUser({
        email: 'user@email.com',
        fullName: 'First Last',
        username: 'user123'
    })
    .then(user => {
        // Utilize user here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    Returns Promise<User>

    Promise containing user

  • Adds a user

    Example:

    accounts.addUser({
        email: 'user@email.com',
        fullName: 'First Last',
        username: 'user123'
    }, function(error, user) {
        if (error) throw error;
        // Utilize user here
    });

    Parameters

    Returns void

deleteApiKey

  • deleteApiKey(apiKeyId: string): Promise<void>
  • Deletes an API key

    Example:

    accounts.deleteApiKey('015c65119ed102420a01041200000000')
    .catch(error => {
        console.log(error);
    });

    Parameters

    • apiKeyId: string

      The API key ID

    Returns Promise<void>

    Promise containing any error

  • deleteApiKey(apiKeyId: string, callback: CallbackFn<void>): void
  • Deletes an API key

    Example:

    accounts.deleteApiKey('015c65119ed102420a01041200000000', function(error) {
        if (error) throw error;
    });

    Parameters

    • apiKeyId: string

      The API key ID

    • callback: CallbackFn<void>

      A function that is passed the return arguments (error, void)

    Returns void

deleteUser

  • deleteUser(userId: string): Promise<void>
  • Deletes a user

    Example:

    accounts.deleteUser('015c3c46514802420a010b1000000000')
    .catch(error => {
        console.log(error);
    });

    Parameters

    • userId: string

      The user ID

    Returns Promise<void>

    Promise containing any error

  • deleteUser(userId: string, callback: CallbackFn<void>): void
  • Deletes a user

    Example:

    accounts.deleteUser('015c3c46514802420a010b1000000000', function(error) {
        if (error) throw error;
    });

    Parameters

    • userId: string

      The user ID

    • callback: CallbackFn<void>

      A function that is passed the return arguments (error, void)

    Returns void

getAccount

  • Get details of account associated with current API key

    Example:

    accounts.getAccount()
    .then(account => {
        console.log("Account ID: " + account.id);
        // Utilize account here
    })
    .catch(error => {
        console.log(error);
    });

    Returns Promise<Account>

    Promise of account

  • Get details of account associated with current API key

    Example:

    accounts.getAccount(function(error, account) {
        if (error) throw error;
        console.log("Account ID: " + account.id);
        // Utilize account here
    });

    Parameters

    • Optional callback: CallbackFn<Account>

      A function that is passed the return arguments (error, account)

    Returns void

getApiKey

  • getApiKey(apiKeyId?: string): Promise<ApiKey>
  • Get details of an API key

    Example:

    accounts.getApiKey()
    .then(key => {
        console.log('Current user ID: ' + key.ownerId);
        // Utilize key here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    • Optional apiKeyId: string

      The API key ID (if not specified, returns current API key)

    Returns Promise<ApiKey>

    Promise containing the API key

  • Get details of an API key

    Example:

    accounts.getApiKey(function(error, key) {
        if (error) throw error;
        console.log('Current user ID: ' + key.ownerId);
        // Utilize key here
    });

    Parameters

    • Optional apiKeyId: string

      The API key ID (if not specified, returns current API key)

    • Optional callback: CallbackFn<ApiKey>

      A function that is passed the return arguments (error, API key)

    Returns void

getGroup

  • getGroup(groupId: string): Promise<Group>
  • Get details of a group

    Example:

    accounts.getGroup('015b5c9279ee02420a01041200000000')
    .then(group => {
        // Utilize group here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    • groupId: string

      The group ID

    Returns Promise<Group>

    Promise containing the group

  • Get details of a group

    Example:

    accounts.getGroup('015b5c9279ee02420a01041200000000', function(error, group) {
        if (error) throw error;
        // Utilize group here
    });

    Parameters

    • groupId: string

      The group ID

    • callback: CallbackFn<Group>

      A function that is passed the arguments (error, group)

    Returns void

getLastApiMetadata

  • getLastApiMetadata(): Promise<ApiMetadata>
  • Get meta data for the last Pelion Device Management API call

    Returns Promise<ApiMetadata>

    Promise of meta data

  • getLastApiMetadata(callback: CallbackFn<ApiMetadata>): void
  • Get meta data for the last Pelion Device Management API call

    Parameters

    • callback: CallbackFn<ApiMetadata>

      A function that is passed the arguments (error, meta data)

    Returns void

getUser

  • getUser(userId: string): Promise<User>
  • Get details of a user

    Example:

    accounts.getUser('015c3c46514802420a010b1000000000')
    .then(user => {
        // Utilize user here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    • userId: string

      The user ID

    Returns Promise<User>

    Promise containing the user

  • Get details of a user

    Example:

    accounts.getUser('015c3c46514802420a010b1000000000', function(error, user) {
        if (error) throw error;
        // Utilize user here
    });

    Parameters

    • userId: string

      The user ID

    • Optional callback: CallbackFn<User>

      A function that is passed the return arguments (error, user)

    Returns void

listApiKeys

  • List API keys

    Example:

    // Filter finds API keys that are owned by the specified user ID
    accounts.listApiKeys({
        filter: {
            ownerId: { $eq: '015c3c46514802420a010b1000000000' }
        }
    })
    .then(keys => {
        // Utilize keys here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    Returns Promise<ListResponse<ApiKey>>

    Promise of listResponse

  • List API keys

    Example:

    // Filter finds API keys that are owned by the specified user ID
    accounts.listApiKeys({
        filter: {
            ownerId: { $eq: '015c3c46514802420a010b1000000000' }
        }
    }, function(error, keys) {
        if (error) throw error;
        // Utilize keys here
    });

    Parameters

    Returns void

listGroupApiKeys

  • List API keys of a group

    Example:

    accounts.listGroupApiKeys({limit: 10}, '015b5c9279ee02420a01041200000000')
    .then(keys => {
        // Utilize keys here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    • groupId: string

      The group ID

    • Optional options: ListOptions

      filter options

    Returns Promise<ListResponse<ApiKey>>

    Promise of listResponse

  • List API keys of a group

    Example:

    accounts.listGroupApiKeys({limit: 10}, '015b5c9279ee02420a01041200000000', function(error, keys) {
        if (error) throw error;
        // Utilize keys here
    });

    Parameters

    Returns void

listGroupUsers

  • List users of a group

    Example:

    accounts.listGroupUsers({limit: 10}, '015b5c9279ee02420a01041200000000')
    .then(users => {
        // Utilize users here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    • groupId: string

      The group ID

    • Optional options: ListOptions

      filter options

    Returns Promise<ListResponse<User>>

    Promise of listResponse

  • List users of a group

    Example:

    accounts.listGroupUsers({limit: 10}, '015b5c9279ee02420a01041200000000', function(error, users) {
        if (error) throw error;
        // Utilize users here
    });

    Parameters

    Returns void

listGroups

  • List groups

    Example:

    accounts.listGroups({limit: 5})
    .then(groups => {
        // Utilize groups here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    Returns Promise<ListResponse<Group>>

    Promise of listResponse

  • List groups

    Example:

    accounts.listGroups({limit: 5}, function(error, groups) {
        if (error) throw error;
        // Utilize groups here
    });

    Parameters

    Returns void

listUsers

  • List users

    Example:

    accounts.listUsers({
        limit: 10,
        filter: {
            status: { $eq: 'ACTIVE' }
        }
    })
    .then(users => {
        // Utilize users here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    Returns Promise<ListResponse<User>>

    Promise of listResponse

  • List users

    Example:

    accounts.listUsers({
        limit: 10,
        filter: {
            status: { $eq: 'ACTIVE' }
        }
    }, function(error, users) {
        if (error) throw error;
        // Utilize users here
    });

    Parameters

    Returns void

updateAccount

  • Update details of account associated with current API key

    Example:

    accounts.updateAccount({
       state: 'Texas',
       city: 'Austin',
       country: 'USA'
    })
    .then(account => {
        // Utilize account here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    Returns Promise<Account>

    Promise of account

  • Update details of account associated with current API key

    Example:

    accounts.updateAccount({
        state: 'Texas',
        city: 'Austin',
        country: 'USA'
    }, function(error, account) {
        if (error) throw error;
        // Utilize account here
    });

    Parameters

    Returns void

updateApiKey

  • Updates an API key

    Example:

    accounts.updateApiKey({
        id: '015c65119ed102420a01041200000000',
        name: 'new API name'
    })
    .then(key => {
        // Utilize key here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    Returns Promise<ApiKey>

    Promise containing API key

  • Updates an API key

    Example:

    accounts.updateApiKey({
        id: '015c65119ed102420a01041200000000',
        name: 'new API name'
    }, updatefunction(error, key) {
        if (error) throw error;
        // Utilize key here
    });

    Parameters

    Returns void

updateUser

  • Updates a user

    Example:

    accounts.updateUser({
        id: '015c3c46514802420a010b1000000000',
        fullName: 'First Last',
        username: 'user123'
    })
    .then(user => {
        // Utilize user here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    Returns Promise<User>

    Promise containing user

  • Updates a user

    Example:

    accounts.updateUser({
        id: '015c3c46514802420a010b1000000000',
        fullName: 'First Last',
        username: 'user123'
    }, function(error, user) {
        if (error) throw error;
        // Utilize user here
    });

    Parameters

    Returns void