Update

Usage

from mbed_cloud import UpdateAPI
updateApi = UpdateAPI()

# Get 5 latest firmware images
images = updateApi.list_firmware_images(limit=5)

Reference

class mbed_cloud.update.UpdateAPI(params=None)

Describing the public update API.

Exposing functionality from the following underlying services:

  • Update service
  • Update campaigns
  • Manifest management
add_campaign(name, device_filter, **kwargs)

Add new update campaign.

Add an update campaign with a name and device filtering. Example:

device_api, update_api = DeviceDirectoryAPI(), UpdateAPI()

# Get a filter to use for update campaign
query_obj = device_api.get_query(query_id="MYID")

# Create the campaign
new_campaign = update_api.add_campaign(
    name="foo",
    device_filter=query_obj.filter
)
Parameters:
  • name (str) – Name of the update campaign (Required)
  • device_filter (str) – The device filter to use (Required)
  • manifest_id (str) – ID of the manifest with description of the update
  • description (str) – Description of the campaign
  • scheduled_at (int) – The timestamp at which update campaign is scheduled to start
  • state (str) – The state of the campaign. Values: “draft”, “scheduled”, “devicefetch”, “devicecopy”, “publishing”, “deploying”, “deployed”, “manifestremoved”, “expired”
Returns:

newly created campaign object

Return type:

Campaign

add_firmware_image(name, datafile, **kwargs)

Add a new firmware reference.

Parameters:
  • name (str) – Firmware file short name (Required)
  • datafile (str) – The file object or path to the firmware image file (Required)
  • description (str) – Firmware file description
Returns:

the newly created firmware file object

Return type:

FirmwareImage

add_firmware_manifest(name, datafile, key_table_file=None, **kwargs)

Add a new manifest reference.

Parameters:
  • name (str) – Manifest file short name (Required)
  • datafile (str) – The file object or path to the manifest file (Required)
  • key_table_file (str) – The file object or path to the key_table file (Optional)
  • description (str) – Manifest file description
Returns:

the newly created manifest file object

Return type:

FirmwareManifest

delete_campaign(campaign_id)

Delete an update campaign.

Parameters:campaign_id (str) – Campaign ID to delete (Required)
Returns:void
delete_firmware_image(image_id)

Delete a firmware image.

Parameters:image_id (str) – image ID for the firmware to remove/delete (Required)
Returns:void
delete_firmware_manifest(manifest_id)

Delete an existing manifest.

Parameters:manifest_id (str) – Manifest file ID to delete (Required)
Returns:void
get_campaign(campaign_id)

Get existing update campaign.

Parameters:campaign_id (str) – Campaign ID to retrieve (Required)
Returns:Update campaign object matching provided ID
Return type:Campaign
get_firmware_image(image_id)

Get a firmware image with provided image_id.

Parameters:image_id (str) – The firmware ID for the image to retrieve (Required)
Returns:FirmwareImage
get_firmware_manifest(manifest_id)

Get manifest with provided manifest_id.

Parameters:manifest_id (str) – ID of manifest to retrieve (Required)
Returns:FirmwareManifest
list_campaign_device_states(campaign_id, **kwargs)

List campaign devices status.

Parameters:
  • campaign_id (str) – Id of the update campaign (Required)
  • limit (int) – number of devices state to retrieve
  • order (str) – sort direction of device state when ordered by creation time (desc|asc)
  • after (str) – get devices state after given id
Returns:

List of CampaignDeviceState objects

Return type:

PaginatedResponse

list_campaigns(**kwargs)

List all update campaigns.

Parameters:
  • limit (int) – number of campaigns to retrieve
  • order (str) – sort direction of campaigns when ordered by creation time (desc|asc)
  • after (str) – get campaigns after given campaign ID
  • filters (dict) – Dictionary of filters to apply
Returns:

List of Campaign objects

Return type:

PaginatedResponse

list_firmware_images(**kwargs)

List all firmware images.

Parameters:
  • limit (int) – number of firmware images to retrieve
  • order (str) – ordering of images when ordered by time. ‘desc’ or ‘asc’
  • after (str) – get firmware images after given image_id
  • filters (dict) – Dictionary of filters to apply
Returns:

list of FirmwareImage objects

Return type:

PaginatedResponse

list_firmware_manifests(**kwargs)

List all manifests.

Parameters:
  • limit (int) – number of manifests to retrieve
  • order (str) – sort direction of manifests when ordered by time. ‘desc’ or ‘asc’
  • after (str) – get manifests after given image_id
  • filters (dict) – Dictionary of filters to apply
Returns:

list of FirmwareManifest objects

Return type:

PaginatedResponse

start_campaign(campaign_object)

Start a draft update campaign.

Parameters:campaign_object (Campaign) – Campaign object to schedule for immediate start (Required)
Returns:newly edited campaign object
Return type:Campaign
update_campaign(campaign_object=None, campaign_id=None, **kwargs)

Update an update campaign.

:param Campaign campaign_object: Campaign object to update (Required) :return: updated campaign object :rtype: Campaign

class mbed_cloud.update.FirmwareImage(dictionary)

Describes firmware object.

created_at

The time the object was created (readonly).

Return type:datetime
datafile_checksum

The checksum generated for the datafile (readonly).

Return type:str
datafile_size

Size of the datafile (in bytes) (readonly).

Return type:int
description

Get the description of firmware image (readonly).

Return type:str
id

Get the ID of the firmware image (readonly).

Return type:str
name

Get the name of firmware image (readonly).

Return type:str
update_attributes(updates)

Update attributes.

updated_at

Get the time the object was updated (readonly).

Return type:datetime
url

The URL of the firmware image (readonly).

Return type:str
class mbed_cloud.update.FirmwareManifest(dictionary)

Describes firmware object.

created_at

Get the time the object was created (readonly).

Return type:datetime
datafile_size

Size of the datafile (in bytes) (readonly).

Return type:int
description

Get the description of firmware manifest (readonly).

Return type:str
device_class

The class of device (readonly).

Return type:str
id

The ID of the firmware manifest (readonly).

Return type:str
key_table_url

The URL of the key_table (readonly).

Return type:str
name

The name of the firmware manifest (readonly).

Return type:str
timestamp

The timestamp of the firmware manifest (readonly).

Return type:datetime
update_attributes(updates)

Update attributes.

updated_at

The time the object was updated (readonly).

Return type:datetime
url

Get the URL of the firmware manifest (readonly).

Return type:str
version

The time the object was updated (readonly).

Return type:str
class mbed_cloud.update.Campaign(dictionary)

Describes update campaign object.

created_at

The time the object was created (readonly).

Return type:datetime
description

The description of the campaign.

Return type:str
device_filter

The device filter to use.

Return type:dict
finished_at

The timestamp when the update campaign finished (readonly).

Return type:datetime
id

The ID of the campaign (readonly).

Return type:str
manifest_id

The ID of the manifest to use for update.

Return type:str
manifest_url

The URL of the manifest used (readonly).

Return type:str
name

The name for this campaign.

Return type:str
phase

The phase of this Campaign.

Returns:The phase of this Campaign.
Return type:str
scheduled_at

The time the object was created.

Return type:datetime
started_at

The timestamp at which update campaign is scheduled to start (readonly).

Return type:datetime
state

The state of the campaign (readonly).

values: draft, scheduled, devicefetch, devicecopy, devicecopycomplete, publishing, deploying, deployed, manifestremoved, expired

Return type:str
update_attributes(updates)

Update attributes.

updated_at

The time the object was last updated (readonly).

Return type:datetime