mbed_cloud.client.client module

Client Interface

This provides direct access the Pelion Device Management API.

Warning

It is not recommended that this is used directly, instead please use this class from an SDK instance (mbed_cloud.sdk.sdk).

from mbed_cloud import SDK
pelion_dm_sdk = SDK()
response = pelion_dm_sdk.client.call_api(method="GET", path="/...")

class mbed_cloud.client.client.Client(config)

Bases: object

Client Interface to give direct access to the Pelion Device Management API.

call_api(method, path, headers=None, path_params=None, query_params=None, body_params=None, stream_params=None, binary_data=None, content_type=None, unpack=None, **kwargs)

Make an HTTP request handling to the Pelion Device Management REST API.

This method uses the Requests HTTP Library. to interact with the Pelion Device Management REST API. For more information on request and response objects please the third party documentation.

from mbed_cloud import SDK
pelion_dm_sdk = SDK()
api_client = pelion_dm_sdk.client()

response = api_client.call_api(
    method="put",
    path="/v3/path-to-resource/{an_id}",
    path_params={
        "an_id": "0123456789"
    },
    body_params={
        "a_field": "field value",
    },
    query_params={
        "a_query_param": "query_param_value",
    }
 )
Parameters:
  • method (str) – HTTP Method
  • path (str) – Path relative to the configured host (with variable substitution using {format} syntax)
  • headers (dict) – (optional) HTTP Headers (Auth is not required, Content-Type can be provided via content_type)
  • path_params (dict) – (optional) Path parameters (substituted into the path parameter)
  • query_params (dict) – (optional) Query Parameters
  • body_params (dict) – (optional) JSON-compatible Message Body
  • stream_params (dict) – (optional) Files for multipart encoding uploading, see ‘requests.request.files` for more information.
  • binary_data (str/byte) – (optional) Binary data suitable for binary/octet-stream content type.
  • content_type (str) – (optional) Content-Type of the request, if defined this will be added to the HTTP Headers.
  • unpack (mbed_cloud.foundation.common.entity_base.Entity) – (optional) Unpack the response into this Entity
  • kwargs – (optional) Addition parameters to be passed to requests.Session().request
Returns:

Either a response object or an Entity instance

Return type:

mbed_cloud.foundation.common.entity_base.Entity requests.Response