Documentation

Mistake on this page? Email us

The API can be initalized with a .env file in the working 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 update = new PelionDMSDK.UpdateApi({
    apiKey: "<Pelion DM API Key>"
});

To create an instance of this API in the browser:

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

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

Hierarchy

  • UpdateApi

Index

Constructors

constructor

Methods

addCampaign

  • Add an update campaign

    Example:

    update.addCampaign({
        name: 'testCampaign',
        deviceFilter: {
            state: { $eq: "bootstrapped" },
            createdAt: { $gte: new Date("01-01-2014"), $lte: new Date("01-01-2018") },
            updatedAt: { $gte: new Date("01-01-2014"), $lte: new Date("01-01-2018") },
            customAttributes: {
                attr1: { $eq: "custom_value_1" },
                attr2: { $eq: "custom_value_1" },
            }
        }
    })
    .then(campaign => {
        // Utilize campaign here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    Returns Promise<Campaign>

    Promise containing update campaign

  • Add an update campaign

    Example:

    update.addCampaign({
        name: 'testCampaign',
        deviceFilter: {
            state: { $eq: "bootstrapped" },
            createdAt: { $gte: new Date("01-01-2014"), $lte: new Date("01-01-2018") },
            updatedAt: { $gte: new Date("01-01-2014"), $lte: new Date("01-01-2018") },
            customAttributes: {
                attr1: { $eq: "custom_value_1" },
                attr2: { $eq: "custom_value_1" },
            }
        }
    }, function(error, campaign) {
        if (error) throw error;
        // Utilize campaign here
    });

    Parameters

    Returns void

addFirmwareImage

  • Add a firmware image

    Example (Node.js):

    var fs = require("fs");
    ...
    update.addFirmwareImage({
        name: "<FirmwareImage name>",
        dataFile: fs.createReadStream("<FirmwareImage file path>")
    })
    .then(image => {
        console.log(image.url);
    })
    .catch(error => {
        console.log(error);
    });

    Example (browser):

    <input type="file" id="file">
    ...
    document.getElementById("file").addEventListener("change", event => {
        let file = event.target.files[0];
    
        updateApi.addFirmwareImage({
            name: file.name,
            dataFile: file
        })
        .then(image => {
            alert(image.url);
        })
        .catch(error => {
            console.log(error);
        });
    });

    Parameters

    Returns Promise<FirmwareImage>

    Promise containing firmware image

  • Add a firmware image

    Example (Node.js):

    var fs = require("fs");
    ...
    update.addFirmwareImage({
        name: "<FirmwareImage name>",
        dataFile: fs.createReadStream("<FirmwareImage file path>")
    }, function(error, image) {
        if (error) return console.log(error);
        console.log(image.url);
    });

    Example (browser):

    <input type="file" id="file">
    ...
    document.getElementById("file").addEventListener("change", function(event) {
        var file = event.target.files[0];
    
        updateApi.addFirmwareImage({
            name: file.name,
            dataFile: file
        }, function(error, image) {
            if (error) return console.log(error);
            console.log(image.url);
        });
    });

    Parameters

    Returns void

addFirmwareManifest

  • Add a firmware manifest

    Example (Node.js):

    var fs = require("fs");
    ...
    update.addFirmwareManifest({
        name: "<FirmwareManifest name>",
        dataFile: fs.createReadStream("<FirmwareManifest file path>")
    })
    .then(manifest => {
        console.log(manifest.url);
    })
    .catch(error => {
        console.log(error);
    });

    Example (browser):

    <input type="file" id="file">
    ...
    document.getElementById("file").addEventListener("change", event => {
        let file = event.target.files[0];
    
        updateApi.addFirmwareManifest({
            name: file.name,
            dataFile: file
        })
        .then(manifest => {
            alert(manifest.url);
        })
        .catch(error => {
            console.log(error);
        });
    });

    Parameters

    Returns Promise<FirmwareManifest>

    Promise containing firmware manifest

  • Add a firmware manifest

    Example (Node.js):

    var fs = require("fs");
    ...
    update.addFirmwareManifest({
        name: "<FirmwareManifest name>",
        dataFile: fs.createReadStream("<FirmwareManifest file path>")
    }, function(error, manifest) {
        if (error) return console.log(error);
        console.log(manifest.url);
    });

    Example (browser):

    <input type="file" id="file">
    ...
    document.getElementById("file").addEventListener("change", function(event) {
        var file = event.target.files[0];
    
        updateApi.addFirmwareManifest({
            name: file.name,
            dataFile: file
        }, function(error, manifest) {
            if (error) return console.log(error);
            console.log(manifest.url);
        });
    });

    Parameters

    Returns void

deleteCampaign

  • deleteCampaign(campaignId: string): Promise<void>
  • Delete an update campaign

    Example:

    update.deleteCampaign('015baf607c250000000000010010003d')
    .catch(error => {
        console.log(error);
    });

    Parameters

    • campaignId: string

      The ID of the update campaign to delete

    Returns Promise<void>

    Promise containing any error

  • deleteCampaign(campaignId: string, callback: CallbackFn<void>): void
  • Delete an update campaign

    Example:

    update.deleteCampaign('015baf607c250000000000010010003d', function(error) {
        if (error) throw error;
    });

    Parameters

    • campaignId: string

      The ID of the update campaign to delete

    • callback: CallbackFn<void>

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

    Returns void

deleteFirmwareImage

  • deleteFirmwareImage(firmwareImageId: string): Promise<void>
  • Delete a firmware image

    Example:

    update.deleteFirmwareImage('015baf5f4f04000000000001001003d5')
    .catch(error => {
        console.log(error);
    });

    Parameters

    • firmwareImageId: string

      The ID of the firmware image to delete

    Returns Promise<void>

    Promise containing any error

  • deleteFirmwareImage(firmwareImageId: string, callback: CallbackFn<void>): void
  • Delete a firmware image

    Example:

    update.deleteFirmwareImage('015baf5f4f04000000000001001003d5', function(error) {
        if (error) throw error;
    });

    Parameters

    • firmwareImageId: string

      The ID of the firmware image to delete

    • callback: CallbackFn<void>

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

    Returns void

deleteFirmwareManifest

  • deleteFirmwareManifest(firmwareManifestId: string): Promise<void>
  • Delete a firmware manifest

    Example:

    update.deleteFirmwareManifest('015baf60323d000000000001001003dd')
    .catch(error => {
        console.log(error);
    });

    Parameters

    • firmwareManifestId: string

      The ID of the firmware manifest to delete

    Returns Promise<void>

    Promise containing any error

  • deleteFirmwareManifest(firmwareManifestId: string, callback: CallbackFn<void>): void
  • Delete a firmware manifest

    Example:

    update.deleteFirmwareManifest('015baf60323d000000000001001003dd', function(error) {
        if (error) throw error;
    });

    Parameters

    • firmwareManifestId: string

      The ID of the firmware manifest to delete

    • callback: CallbackFn<void>

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

    Returns void

getCampaign

  • getCampaign(campaignId: string): Promise<Campaign>
  • Get details of an update campaign

    Example:

    update.getCampaign('015baf607c250000000000010010003d')
    .then(campaign => {
        // Utilize campaign here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    • campaignId: string

      The update campaign ID

    Returns Promise<Campaign>

    Promise containing the update campaign

  • Get details of an update campaign

    Example:

    update.getCampaign('015baf607c250000000000010010003d', function(error, campaign) {
        if (error) throw error;
        // Utilize campaign here
    });

    Parameters

    • campaignId: string

      The update campaign ID

    • callback: CallbackFn<Campaign>

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

    Returns void

getFirmwareImage

  • getFirmwareImage(firmwareImageId: string): Promise<FirmwareImage>
  • Get details of a firmware image

    Example:

    update.getFirmwareImage('015baf5f4f04000000000001001003d5')
    .then(firmwareimage => {
        // Utilize firmwareimage here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    • firmwareImageId: string

      The firmware image ID

    Returns Promise<FirmwareImage>

    Promise containing the firmware image

  • Get details of a firmware image

    Example:

    update.getFirmwareImage('015baf5f4f04000000000001001003d5', function(error, firmwareimage) {
        if (error) throw error;
        // Utilize firmwareimage here
    });

    Parameters

    • firmwareImageId: string

      The firmware image ID

    • callback: CallbackFn<FirmwareImage>

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

    Returns void

getFirmwareManifest

  • getFirmwareManifest(firmwareManifestId: string): Promise<FirmwareManifest>
  • Get details of a firmware manifest

    Example:

    update.getFirmwareManifest('015baf60323d000000000001001003dd')
    .then(firmwaremanifest => {
        // Utilize firmwaremanifest here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    • firmwareManifestId: string

      The firmware manifest ID

    Returns Promise<FirmwareManifest>

    Promise containing the firmware manifest

  • getFirmwareManifest(firmwareManifestId: string, callback: CallbackFn<FirmwareManifest>): void
  • Get details of a firmware manifest

    Example:

    update.getFirmwareManifest('015baf60323d000000000001001003dd', function(error, firmwaremanifest) {
        if (error) throw error;
        // Utilize firmwaremanifest here
    });

    Parameters

    • firmwareManifestId: string

      The firmware manifest ID

    • callback: CallbackFn<FirmwareManifest>

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

    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

listCampaignDeviceStates

  • List campaign device states

    Example:

    update.listCampaignDeviceStates('015baf607c250000000000010010003d', {
        limit: 5,
    })
    .then(devicestates => {
        // Utilize devicestates here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    • campaignId: string

      The ID of the update campaign

    • Optional options: ListOptions

      list options

    Returns Promise<ListResponse<CampaignDeviceState>>

    Promise of listResponse

  • List campaign device states

    Example:

    update.listCampaignDeviceStates('015baf607c250000000000010010003d', {
        limit: 5,
    }, function(error, devicestates) {
        if (error) throw error;
        // Utilize devicestates here
    });

    Parameters

    Returns void

listCampaigns

  • List update campaigns

    Example:

    update.listCampaigns({
        limit: 5,
        filter: {
            name: { $eq: "blinky" },
            createdAt: { $gte: new Date("01-01-2014"), $lte: new Date("01-01-2018") },
            updatedAt: { $gte: new Date("01-01-2014"), $lte: new Date("01-01-2018") }
        }
    })
    .then(campaigns => {
        // Utilize campaigns here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    Returns Promise<ListResponse<Campaign>>

    Promise of listResponse

  • List update campaigns

    Example:

    update.listCampaigns({
        limit: 5,
        filter: {
            name: { $eq: "blinky" },
            createdAt: { $gte: new Date("01-01-2014"), $lte: new Date("01-01-2018") },
            updatedAt: { $gte: new Date("01-01-2014"), $lte: new Date("01-01-2018") }
        }
    }, function(error, campaigns) {
        if (error) throw error;
        // Utilize campaigns here
    });

    Parameters

    Returns void

listFirmwareImages

  • List firmware images

    Example:

    update.listFirmwareImages({
        limit: 5,
        filter: {
            name: { $eq: "blinky" },
            createdAt: { $gte: new Date("01-01-2014"), $lte: new Date("01-01-2018") },
            updatedAt: { $gte: new Date("01-01-2014"), $lte: new Date("01-01-2018") }
        }
    })
    .then(firmwareimages => {
        // Utilize firmwareimages here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    Returns Promise<ListResponse<FirmwareImage>>

    Promise of listResponse

  • List firmware images

    Example:

    update.listFirmwareImages({
        limit: 5,
        filter: {
            name: { $eq: "blinky" },
            createdAt: { $gte: new Date("01-01-2014"), $lte: new Date("01-01-2018") },
            updatedAt: { $gte: new Date("01-01-2014"), $lte: new Date("01-01-2018") }
    }},
    function(error, firmwareimages) {
        if (error) throw error;
        // Utilize firmwareimages here
    });

    Parameters

    Returns void

listFirmwareManifests

  • List firmware manifests

    Example:

    update.listFirmwareManifests({
        limit: 5,
        filter: {
            name: { $eq: "blinky" },
            createdAt: { $gte: new Date("01-01-2014"), $lte: new Date("01-01-2018") },
            updatedAt: { $gte: new Date("01-01-2014"), $lte: new Date("01-01-2018") }
        }
    })
    .then(firmwaremanifests => {
        // Utilize firmwaremanifests here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    Returns Promise<ListResponse<FirmwareManifest>>

    Promise of listResponse

  • List firmware manifests

    Example:

    update.listFirmwareManifests({
        limit: 5,
        filter: {
            name: { $eq: "blinky" },
            createdAt: { $gte: new Date("01-01-2014"), $lte: new Date("01-01-2018") },
            updatedAt: { $gte: new Date("01-01-2014"), $lte: new Date("01-01-2018") }
        }
    }, function(error, firmwaremanifests) {
        if (error) throw error;
        // Utilize firmwaremanifests here
    }

    Parameters

    Returns void

startCampaign

  • startCampaign(campaignId: string): Promise<Campaign>
  • Start an update campaign

    Example:

    update.startCampaign('015baf607c250000000000010010003d')
    .then(data => {
        // Utilize data here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    • campaignId: string

      The ID of the update campaign

    Returns Promise<Campaign>

    Promise containing campaign

  • Start an update campaign

    Example:

    update.startCampaign('015baf607c250000000000010010003d', function(error, data) {
        if (error) throw error;
        // Utilize data here
    });

    Parameters

    • campaignId: string

      The ID of the update campaign

    • callback: CallbackFn<Campaign>

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

    Returns void

stopCampaign

  • stopCampaign(campaignId: string): Promise<Campaign>
  • Stop an update campaign

    Example:

    update.stopCampaign('015baf607c250000000000010010003d')
    .then(data => {
        // Utilize data here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    • campaignId: string

      The ID of the update campaign

    Returns Promise<Campaign>

    Promise containing campaign

  • Stop an update campaign

    Example:

    update.stopCampaign('015baf607c250000000000010010003d', function(error, data) {
        if (error) throw error;
        // Utilize data here
    });

    Parameters

    • campaignId: string

      The ID of the update campaign

    • callback: CallbackFn<Campaign>

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

    Returns void

updateCampaign

  • Update an update campaign

    Example:

    update.updateCampaign({
        name: 'testCampaign',
        id: '015baf607c250000000000010010003d',
        deviceFilter: {
            state: { $eq: "bootstrapped" },
            createdAt: { $gte: new Date("01-01-2014"), $lte: new Date("01-01-2018") },
            updatedAt: { $gte: new Date("01-01-2014"), $lte: new Date("01-01-2018") },
            customAttributes: {
                attr1: { $eq: "custom_value_1" },
                attr2: { $eq: "custom_value_1" },
            }
        }
    })
    .then(campaign => {
        // Utilize campaign here
    })
    .catch(error => {
        console.log(error);
    });

    Parameters

    Returns Promise<Campaign>

    Promise of campaign

  • Update an update campaign

    Example:

    update.updateCampaign({
        name: 'testCampaign',
        id: '015baf607c250000000000010010003d',
        deviceFilter: {
            state: { $eq: "bootstrapped" },
            createdAt: { $gte: new Date("01-01-2014"), $lte: new Date("01-01-2018") },
            updatedAt: { $gte: new Date("01-01-2014"), $lte: new Date("01-01-2018") },
            customAttributes: {
                attr1: { $eq: "custom_value_1" },
                attr2: { $eq: "custom_value_1" },
            }
        }
    }, function(error, campaign) {
        if (error) throw error;
        // Utilize campaign here
    });

    Parameters

    Returns void