AT&T M2X MQTT Python Client Library

API Module

class m2x_mqtt.v2.api.MQTTAPIVersion2(key, client, timeout=600, keepalive=60, **kwargs)[source]

Bases: m2x_mqtt.api.MQTTAPIBase

Wrapper for AT&T M2X API

create_device(**params)[source]

Method for Create Device endpoint.

Parameters:params – Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters.
Returns:The newly created Device
Return type:Device
device(id)[source]

Method for View Device Details endpoint.

Parameters:id (str) – ID of the Device to retrieve
Returns:The matching Device
Return type:Device
devices(**params)[source]

Method for List Devices endpoint.

Parameters:params – Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters.
Returns:List of Device objects
Return type:list
distribution(id)[source]

Method for View Distribution Details endpoint.

Parameters:id (str) – ID of the Distribution to retrieve
Returns:The matching Distribution
Return type:Distribution

Commands Module

class m2x_mqtt.v2.commands.Command(api, device, **data)[source]

Bases: m2x_mqtt.v2.resource.Resource

Wrapper for AT&T M2X Commands API

process(**response_data)[source]

Method for Device Marks a Command as Processed endpoint.

Parameters:params – Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters.
Returns:The API response, see M2X API docs for details
Return type:dict
reject(**response_data)[source]

Method for Device Marks a Command as Rejected endpoint.

Parameters:params – Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters.
Returns:The API response, see M2X API docs for details
Return type:dict

Devices Module

class m2x_mqtt.v2.devices.Device(api, **data)[source]

Bases: m2x_mqtt.v2.resource.Resource

Wrapper for AT&T M2X Device API

command(id)[source]

Method for View Command Details endpoint.

Parameters:id (str) – ID of the Command to retrieve
Returns:The matching Command
Return type:Command
commands(**params)[source]

Method for List Sent Commands endpoint.

Parameters:params – Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters.
Returns:List of Command objects
Return type:list
create_stream(name, **params)[source]

Method for Create/Update Data Stream endpoint.

Parameters:
  • name – Name of the stream to be created
  • params – Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters.
Returns:

The newly created Stream

Return type:

Stream

post_device_update(**params)[source]

Method for Post Device Updates (Multiple Values to Multiple Streams) endpoint.

Parameters:params – Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters.
Returns:The API response, see M2X API docs for details
Return type:dict
post_updates(**values)[source]

Method for Post Device Updates (Multiple Values to Multiple Streams) endpoint.

Parameters:values (dict) – The values being posted, formatted according to the API docs
Returns:The API response, see M2X API docs for details
Return type:dict
stream(name)[source]

Method for View Data Stream endpoint.

Parameters:name – The name of the Stream being retrieved
Returns:The matching Stream
Return type:Stream
update_location(**params)[source]

Method for Update Device Location endpoint.

Parameters:params – Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters.
Returns:The API response, see M2X API docs for details
Return type:dict

Distributions Module

class m2x_mqtt.v2.distributions.Distribution(api, **data)[source]

Bases: m2x_mqtt.v2.resource.Resource

Wrapper for AT&T M2X Distribution API

add_device(serial)[source]

Method for Add Device to an Existing Distribution endpoint.

Parameters:serial – The unique (account-wide) serial for the DistributionDevice being added to the Distribution
Returns:The newly created DistributionDevice
Return type:DistributionDevice

Resource Module

class m2x_mqtt.v2.resource.Resource(api, **data)[source]

Bases: object

Generic methods for interacting with an M2X resource

remove()[source]

Generic method for a resource’s Delete endpoint.

Example endpoints:

Returns:The API response, see M2X API docs for details
Return type:dict
update(**attrs)[source]

Generic method for a resource’s Update endpoint.

Example endpoints:

Parameters:attrs – Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters.
Returns:The API response, see M2X API docs for details
Return type:dict

Streams Module

class m2x_mqtt.v2.streams.Stream(api, device, **data)[source]

Bases: m2x_mqtt.v2.resource.Resource

Methods for interacting AT&T M2X Device Streams

add_value(value, timestamp=None)[source]

Method for Update Data Stream Value endpoint.

Parameters:
  • value – The updated stream value
  • timestamp – The (optional) timestamp for the upadted value
Returns:

The API response, see M2X API docs for details

Return type:

dict

post_values(values)[source]

Method for Post Data Stream Values endpoint.

Parameters:values (dict) – Values to post, see M2X API docs for details
Returns:The API response, see M2X API docs for details
Return type:dict
update_value(value, timestamp=None)

Method for Update Data Stream Value endpoint.

Parameters:
  • value – The updated stream value
  • timestamp – The (optional) timestamp for the upadted value
Returns:

The API response, see M2X API docs for details

Return type:

dict

Time Module

class m2x_mqtt.v2.time.Time(api)[source]

Bases: m2x_mqtt.v2.resource.Resource

Wrapper for AT&T M2X Time API

get_time()[source]

Method for Get time endpoint.

Returns:The API response, see M2X API docs for details
Return type:dict