iotcs.client.model module

class iotcs.client.model.DeviceModelAction(name, description, argumentList=None)

Bases: object

A DeviceModel action model.

Create an instance of DeviceModelAction.

Parameters:
  • name – the action name
  • description – the action human readable description
  • argumentList – a list of Argument action arguments.
class Argument(name, argType, description=None, lowerBound=None, upperBound=None, defaultValue=None)

Bases: object

A DeviceModelAction argument model.

checkBounds(value)
classmethod fromJson(jsonObject)
getArgType()

Return the data type of the Argument action argument.

If the action does not take an argument, return None. :return: the DeviceModelAction Argument

DeviceModelAttribute.Type data type, or None
Returns:a DeviceModelAttribute.Type data type, or None
getDefaultValue()

Return the argument’s default value.

If a default value is defined in the DeviceModel, that value is returned. If there is no for the argument in the device model, then None is returned. The value None is not a default value.

Returns:the argument’s default value or None if no default value is

defined

getLowerBound()

Return the Argument lower bound.

Only NUMBER and INTEGER DeviceModelAttribute.Type arguments have a lower bound. For other attribute types None is returned.

Returns:a Number or None if no lower bound has been set, or

:method:`.getArgType` returns a type other than NUMBER or INTEGER

getName()

Return the Argument name.

Returns:the action argument name
getUpperBound()

Return the Argument upper bound.

Only NUMBER and INTEGER DeviceModelAttribute.Type arguments have an upper bound. For other attribute types None is returned.

Returns:a Number or None if no upper bound has been set, or

:method:`.getArgType` returns a type other than NUMBER or INTEGER

getArguments()

Return the action Argument arguments as list.

Returns:the action Argument arguments else None
getDescription()

Return the human readable description of this action.

If the model does not contain a description, this method will return an empty String.

Returns:the action description, or an empty string
getName()

Get the action name.

Returns:the action name from the device model
class iotcs.client.model.DeviceModelAttribute(urn, name, description, type, lowerBound, upperBound, access, alias, defaultValue=None)

Bases: object

DeviceModelAttribute is the model of an attribute in a DeviceModel.

class Access

Bases: enum.Enum

Access rules for an attribute.
  • READ_ONLY The attribute value can only be read.
  • WRITE_ONLY The attribute value can only be set.
  • READ_WRITE The attribute value can be set and can be read
  • EXECUTABLE The attribute is a action
EXECUTABLE = 3
READ_ONLY = 0
READ_WRITE = 2
WRITE_ONLY = 1
class Type

Bases: enum.Enum

An enumeration of the data types an attribute may contain.

BOOLEAN = 3
DATETIME = 5
INTEGER = 4
NUMBER = 0
STRING = 1
URI = 2
getAccess()

Return the access rules for the attribute. The default is READ-ONLY :return: the access rule for the attribute

getDefaultValue()

Get the default value of the attribute as defined by the device model. If there is no defaultValue for the attribute in the device model, then this method will return None. The value None is not a default value. :return: the default value of the attribute, or None if no default

is defined
getDescription()

A human friendly description of the attribute. If the model does not contain a description, this method will return an empty String. :return: the attribute description, or an empty string

getLowerBound()

For Type.NUMBER only, give the lower bound of the acceptable range of values. None is always returned for attributes other than NUMBER type. :return: a number, or None if no lower bound has been set

getName()

Get the attribute name. :return: the attribute name from the device model

getType()

The data type of the attribute. If the access type of the attribute is executable, this method will return None. :return: the attribute’s data type, or None

getUpperBound()

For ` Type.NUMBER` only, give the upper bound of the acceptable range of values. Null is always returned for attributes other than NUMBER type. :return: a number, or None if no upper bound has been set

getUrn()

Get the URN of the device type model this attribute comes from. :return: the URN of the device type model

validate(value)
class iotcs.client.model.DeviceModelFactory

Bases: object

DeviceModel Factory.

classmethod checkLocalStorePath(localStorePathname)

Verify the local store path.

If device_model_store is set, then make sure it is readable/writable, or try to create the directory if it does not exist.

Parameters:localStorePathname – the device model store directory path
Returns:the absolute path to the device model store directory else ‘None’ if the local storing of device models is not configured or the directory cannot be read or written
classmethod getDeviceModel(secureConnection, urn, aid=None)

Get a device model from the IoT server.

Parameters:
  • secureConnection – a iotcs.client.SecureConnection connection to the server.
  • urn – the URN of desired device model
  • aid – the IoT application identifier or None
Returns:

device model or null if not found

Raises:

NullPointerException if an argument is null

Raises:

IOException if the request failed

Raises:

GeneralSecurityException when key or signature algorithm class cannot be loaded, or the key is not in the trusted assets store, or the private key is invalid

classmethod getLogger()

Return a logger for DeviceModelFactory log messages.

classmethod getObject(secureConnection, uri, queryParams)

Get the model object from the server defined by the uri.

Parameters:
  • secureConnection – the iotcs.client.SecureConnection to make requests
  • uri – the device model resource uri
  • queryParamsdict of query parameters
Returns:

the device model as JSON

class iotcs.client.model.DeviceModelFormat(urn, name, description, formatType, fields)

Bases: object

DeviceModelFormat is the model of a message in a DeviceModel.

Create an instance of DeviceModelFormat.

Parameters:
  • urn – the urn of the message format
  • name – the message format name
  • description – a message format human readable description
  • type – the DeviceModelFormat.Type
  • fields – the fields of this message format.
Raises:

KeyError if type is not a valid DeviceModelFormat.Type

class Field(name, description, strType, optional)

Bases: object

Describes a field of a message.

Create a DeviceModelFormat.Field.

Parameters:
  • name – the Field name
  • description – the Field description
  • strType – the string name of a DeviceModelAttribute.Type
  • optional – if False the field must exist
getDescription()

Return the human readable description of this Field.

Returns:the human readable description of this Field.
getName()

Return the Field name.

Returns:the Field name
getType()

Return the DeviceModelAttribute.Type Field type.

Returns:the DeviceModelAttribute.Type Field type
isOptional()

Return True if this Field is not required.

Returns:True if this Field is not required else False.
class Type

Bases: enum.Enum

The message type.

Each type corresponds to one type of message.

ALERT = 2
DATA = (1,)
getDescription()

Return the human readable description of this device model format.

A human readable description of the message format. If the format does not contain a description, this method will return an empty String.

Returns:the message format description, or an empty string
getFields()

Get the format of fields.

Returns:list of field formats
getName()

Return the message format name.

Returns:the message format name
getType()

Return the :class:.`DeviceModelFormat.Type` of the message.

Eturn:the :class:.`DeviceModelFormat.Type` of the message
getURN()

Get the URN of the message format.

Returns:the message format URN
class iotcs.client.model.DeviceModelImpl(urn, name, description, attributes, actions, formats)

Bases: iotcs.client.client.DeviceModel

The implementation of DeviceModel.

Create a DeviceModel instance.

Parameters:
  • urn – the URN that identifies a DeviceModel
  • name – the name for this DeviceModel
  • description – the human readable description for this DeviceModel
  • attributes – a list of DeviceModelAttribute`s for this `DeviceModel
  • actions – a list of DeviceModelAction`s for this `DeviceModel
  • formats – a list of DeviceModelFormat`s for this `DeviceModel
getDescription()

Return the human readable description of this DeviceModel.

Returns:the human readable description of this DeviceModel.
getDeviceModelActions()

Return the DeviceModelAction`s of this :class:.DeviceModel`.

Returns:a dict of {actionname: :class:`.DeviceModelAction`}
getDeviceModelAttributes()

Return the DeviceModelAttribute`s of this :class:.DeviceModel`.

Returns:a dict of {attributename: :class:`.DeviceModelAttribute`}
getDeviceModelFormat(urn)

Return the DeviceModelFormat for urn.

Parameters:urn – the urn that identifies a DeviceModelFormat of this DeviceModel
Returns:the DeviceModelFormat for urn
getDeviceModelFormats()

Return the DeviceModelFormat’s of this DeviceModel.

Returns:a dict of {formaturn: :class:`.DeviceModelFormat`}
getName()

Return the name of this DeviceModel.

Returns:the name of this DeviceModel
getURN()

Return the URN that identified this DeviceModel.

Returns:the URN that identifies this DeviceModel
class iotcs.client.model.DeviceModelParser

Bases: object

Parse JSON into a iotcs.client.DeviceModel.

JSON in this context is a JSON formatted String or a readable stream

classmethod createDeviceModelAction(existingActionNames, jsonObject)

Create and return a DeviceModelAction instance.

Return a iotcs.client.impl.DeviceModelAction from a python json object :param existingActionNames: previously processed actions :param jsonObject: a python object representing a json iotib.client.impl.DeviceModelAction :return: a iotcs.client.impl.DeviceModelAction instance :raises: ValueError if the action exists in existingActionNames or jsonObject` has an invalid iotcs.client.impl.DeviceModelAction.Type argument type

classmethod createDeviceModelAttribute(urn, existingFieldNames, jsonObject)

Create and return a DeviceModelAttribute.

Return a iotcs.shared.DeviceModelAttribute from the json object `root :param urn: :param existingFieldNames: :param jsonObject: The device model attribute in json object format :return: a DeviceModelAttribute :raises: ValueError if required value is missing or value is invalid

classmethod createDeviceModelFormat(jsonObject)

Create and return a DeviceModelFormat instance.

Return a iotcs.client.impl.DeviceModelFormat from a python json object :param jsonObject: a python object representing a json iotcs.client.impl.DeviceModelFormat :return: a iotcs.client.impl.DeviceModelFormat instance

classmethod createMsgFormatField(jsonObject)

Create and return a DeviceModelFormat.Field.

Parameters:jsonObject – a python object representing a json iotcs.client.impl.DeviceModelFormat.Field
Returns:a iotcs.client.impl.DeviceModrlFormat.Field instance
classmethod fromJson(jsonObject)

Create a DeviceModel instance.

Return a iotcs.client.DeviceModel from a JSON formatted String :param jsonString: a JSON formatted String :return: a iotcs.client.DeviceModel instance :raises: json exceptions if jsonString cannot be decoded :raises: ValueError if required values are not present, or invalid