connection options
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);
});
The campaign to add
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
});
The campaign to add
A function that is passed the return arguments (error, update campaign)
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);
});
});
The image to add
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);
});
});
The image to add
A function that is passed the return arguments (error, firmware image)
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);
});
});
The manifest to add
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);
});
});
The manifest to add
A function that is passed the return arguments (error, firmware manifest)
Delete an update campaign
Example:
update.deleteCampaign('015baf607c250000000000010010003d')
.catch(error => {
console.log(error);
});
The ID of the update campaign to delete
Promise containing any error
Delete an update campaign
Example:
update.deleteCampaign('015baf607c250000000000010010003d', function(error) {
if (error) throw error;
});
The ID of the update campaign to delete
A function that is passed the return arguments (error, void)
Delete a firmware image
Example:
update.deleteFirmwareImage('015baf5f4f04000000000001001003d5')
.catch(error => {
console.log(error);
});
The ID of the firmware image to delete
Promise containing any error
Delete a firmware image
Example:
update.deleteFirmwareImage('015baf5f4f04000000000001001003d5', function(error) {
if (error) throw error;
});
The ID of the firmware image to delete
A function that is passed the return arguments (error, void)
Delete a firmware manifest
Example:
update.deleteFirmwareManifest('015baf60323d000000000001001003dd')
.catch(error => {
console.log(error);
});
The ID of the firmware manifest to delete
Promise containing any error
Delete a firmware manifest
Example:
update.deleteFirmwareManifest('015baf60323d000000000001001003dd', function(error) {
if (error) throw error;
});
The ID of the firmware manifest to delete
A function that is passed the return arguments (error, void)
Get details of an update campaign
Example:
update.getCampaign('015baf607c250000000000010010003d')
.then(campaign => {
// Utilize campaign here
})
.catch(error => {
console.log(error);
});
The update campaign ID
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
});
The update campaign ID
A function that is passed the return arguments (error, update campaign)
Get details of a firmware image
Example:
update.getFirmwareImage('015baf5f4f04000000000001001003d5')
.then(firmwareimage => {
// Utilize firmwareimage here
})
.catch(error => {
console.log(error);
});
The firmware image ID
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
});
The firmware image ID
A function that is passed the return arguments (error, firmware image)
Get details of a firmware manifest
Example:
update.getFirmwareManifest('015baf60323d000000000001001003dd')
.then(firmwaremanifest => {
// Utilize firmwaremanifest here
})
.catch(error => {
console.log(error);
});
The firmware manifest ID
Promise containing the firmware manifest
Get details of a firmware manifest
Example:
update.getFirmwareManifest('015baf60323d000000000001001003dd', function(error, firmwaremanifest) {
if (error) throw error;
// Utilize firmwaremanifest here
});
The firmware manifest ID
A function that is passed the return arguments (error, firmware manifest)
Get meta data for the last Pelion Device Management API call
Promise of meta data
Get meta data for the last Pelion Device Management API call
A function that is passed the arguments (error, meta data)
List campaign device states
Example:
update.listCampaignDeviceStates('015baf607c250000000000010010003d', {
limit: 5,
})
.then(devicestates => {
// Utilize devicestates here
})
.catch(error => {
console.log(error);
});
The ID of the update campaign
list options
Promise of listResponse
List campaign device states
Example:
update.listCampaignDeviceStates('015baf607c250000000000010010003d', {
limit: 5,
}, function(error, devicestates) {
if (error) throw error;
// Utilize devicestates here
});
The ID of the update campaign
list options
A function that is passed the return arguments (error, 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") }
}
})
.then(campaigns => {
// Utilize campaigns here
})
.catch(error => {
console.log(error);
});
list options
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
});
list options
A function that is passed the return arguments (error, 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") }
}
})
.then(firmwareimages => {
// Utilize firmwareimages here
})
.catch(error => {
console.log(error);
});
list options
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
});
list options
A function that is passed the return arguments (error, 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") }
}
})
.then(firmwaremanifests => {
// Utilize firmwaremanifests here
})
.catch(error => {
console.log(error);
});
list options
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
}
list options
A function that is passed the return arguments (error, listResponse)
Start an update campaign
Example:
update.startCampaign('015baf607c250000000000010010003d')
.then(data => {
// Utilize data here
})
.catch(error => {
console.log(error);
});
The ID of the update campaign
Promise containing campaign
Start an update campaign
Example:
update.startCampaign('015baf607c250000000000010010003d', function(error, data) {
if (error) throw error;
// Utilize data here
});
The ID of the update campaign
A function that is passed the return arguments (error, campaign)
Stop an update campaign
Example:
update.stopCampaign('015baf607c250000000000010010003d')
.then(data => {
// Utilize data here
})
.catch(error => {
console.log(error);
});
The ID of the update campaign
Promise containing campaign
Stop an update campaign
Example:
update.stopCampaign('015baf607c250000000000010010003d', function(error, data) {
if (error) throw error;
// Utilize data here
});
The ID of the update campaign
A function that is passed the return arguments (error, 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" },
}
}
})
.then(campaign => {
// Utilize campaign here
})
.catch(error => {
console.log(error);
});
The campaign to update
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
});
The campaign to update
A function that is passed the arguments (error, campaign)
Update API
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>