Skip to content

Latest commit

 

History

History
151 lines (112 loc) · 5.87 KB

File metadata and controls

151 lines (112 loc) · 5.87 KB

2.0.0 Migration Guide

The 2.0 release of the clearblade-cloud-iot client is a significant upgrade based on the addition of two new classes in iot_v1:

  • DeviceCredential
  • PublicKeyCredential

The release also includes enhancements to these classes already present in iot_v1:

  • DeviceConfig
  • DeviceState

The version was made with the intent of minimizing the required code changes. However, these changes should be considered breaking changes.

  1. If device is an object of class Device.

    Before: device.credentials is of type [dict] (i.e. list of dicts).

    After: device.credentials is of type [DeviceCredential] (i.e. list of objects of class DeviceCredential).

    The DeviceCredential class has these usability features:

    • A get method that mimics the dict get method.
    • Allows accessing attributes using dot notation OR square-brackets.
    • Supports camel-case and snake-case for accessing attributes:

    e.g., All these are valid for retrieving the public key:

    • public_key = device.credentials[0]['publicKey']
    • public_key = device.credentials[0]['public_key']
    • public_key = device.credentials[0].get('publicKey')
    • public_key = device.credentials[0].get('public_key')
    • public_key = device.credentials[0].publicKey
    • public_key = device.credentials[0].public_key

  1. This refers to pub_key mentioned in the previous section:

    Before: public_key was of type dict.

    After: public_key is an object of class PublicKeyCredential.

    The PublicKeyCredential class has these usability features:

    • A get method that mimics the dict get method.
    • Allows accessing attributes using dot notation OR square-brackets.

    e.g., All these are valid for retrieving the public key format:

    • format = public_key['format']
    • format = public_key.get('format')
    • format = public_key.format

  1. This section refers to dev_config which holds device config.

    Before: dev_config is of type dict.

    After: dev_config is an object of class DeviceConfig.

    The DeviceConfig class has these usability features:

    • A get method that mimics the dict get method.
    • Allows accessing attributes using dot notation OR square-brackets.
    • Supports camel-case and snake-case for accessing attributes:

    e.g., All these are valid for retrieving the cloud_update_time:

    • cloud_update_time = device.credentials[0]['cloudUpdateTime']
    • cloud_update_time = device.credentials[0]['cloud_update_time']
    • cloud_update_time = device.credentials[0].get('cloudUpdateTime')
    • cloud_update_time = device.credentials[0].get('cloud_update_time')
    • cloud_update_time = device.credentials[0].cloudUpdateTime
    • cloud_update_time = device.credentials[0].cloud_update_time

  1. This section refers to dev_state which contains device state.

    Before: dev_state is of type dict.

    After: dev_state is an object of class DeviceState.

    The DeviceState class has these usability features:

    • A get method that mimics the dict get method.
    • Allows accessing attributes using dot notation OR square-brackets.
    • Supports camel-case and snake-case for accessing attributes:

    e.g., All these are valid for retrieving the binary_data:

    • binary_data = device.credentials[0]['binaryData']
    • binary_data = device.credentials[0]['binary_data']
    • binary_data = device.credentials[0].get('binaryData')
    • binary_data = device.credentials[0].get('binary_data')
    • binary_data = device.credentials[0].binaryData
    • binary_data = device.credentials[0].binary_data