Search is not available for this dataset
text
stringlengths
75
104k
def create(self, deviceType): """ Register one or more new device types, each request can contain a maximum of 512KB. """ r = self._apiClient.post("api/v0002/device/types", deviceType) if r.status_code == 201: return DeviceType(apiClient=self._apiClient, **r.json())...
def publishEvent(self, event, msgFormat, data, qos=0, on_publish=None): """ Publish an event to Watson IoT Platform. # Parameters event (string): Name of this event msgFormat (string): Format of the data for this event data (dict): Data for this event qos (int): ...
def serviceStatus(self): """ Retrieve the organization-specific status of each of the services offered by the IBM Watson IoT Platform. In case of failure it throws APIException """ r = self._apiClient.get("api/v0002/service-status") if r.status_code == 200: ...
def create(self, devices): """ Register one or more new devices, each request can contain a maximum of 512KB. The response body will contain the generated authentication tokens for all devices. You must make sure to record these tokens when processing the response. We are not abl...
def update(self, deviceUid, metadata=None, deviceInfo=None, status=None): """ Update an existing device """ if not isinstance(deviceUid, DeviceUid) and isinstance(deviceUid, dict): deviceUid = DeviceUid(**deviceUid) deviceUrl = "api/v0002/device/types/%s/devices/%s"...
def delete(self, devices): """ Delete one or more devices, each request can contain a maximum of 512Kb It accepts accepts a list of devices (List of Dictionary of Devices) In case of failure it throws APIException """ if not isinstance(devices, list): listOfDe...
def find(self, status=None, connectedAfter=None): """ Iterate through all Connectors """ queryParms = {} if status: queryParms["status"] = status if connectedAfter: queryParms["connectedAfter"] = connectedAfter return IterableClientStatusL...
def list(self): """ List all device management extension packages """ url = "api/v0002/mgmt/custom/bundle" r = self._apiClient.get(url) if r.status_code == 200: return r.json() else: raise ApiException(r)
def create(self, dmeData): """ Create a new device management extension package In case of failure it throws APIException """ url = "api/v0002/mgmt/custom/bundle" r = self._apiClient.post(url, dmeData) if r.status_code == 201: return r.json() ...
def delete(self, bundleId): """ Delete a device management extension package It accepts bundleId (string) as parameters In case of failure it throws APIException """ url = "api/v0002/mgmt/custom/bundle/%s" % (bundleId) r = self._apiClient.delete(url) if r...
def update(self, bundleId, dmeData): """ Update a device management extension package It accepts bundleId (string) as parameters In case of failure it throws APIException """ url = "api/v0002/mgmt/custom/bundle/%s" % (bundleId) r = self._apiClient.put(url, dmeData...
def registerThing(self, thingTypeId, thingId, name = None, description = None, aggregatedObjects = None, metadata=None): """ Registers a new thing. It accepts thingTypeId (string), thingId (string), name (string), description (string), aggregatedObjects (JSON) and metadata (JSON) as parameters ...
def getThing(self, thingTypeId, thingId): """ Gets thing details. It accepts thingTypeId (string), thingId (string) In case of failure it throws APIException """ thingUrl = ApiClient.thingUrl % (self.host, thingTypeId, thingId) r = requests.get(thingUrl, auth=sel...
def getThingsForType(self, thingTypeId, parameters = None): """ Gets details for multiple things of a type It accepts thingTypeId (string) and parameters In case of failure it throws APIException """ thingsUrl = ApiClient.thingsUrl % (self.host, thingTypeId) r = ...
def removeThing(self, thingTypeId, thingId): """ Delete an existing thing. It accepts thingTypeId (string) and thingId (string) as parameters In case of failure it throws APIException """ thingUrl = ApiClient.thingUrl % (self.host, thingTypeId, thingId) r = reque...
def addDraftThingType(self, thingTypeId, name = None, description = None, schemaId = None, metadata = None): """ Creates a thing type. It accepts thingTypeId (string), name (string), description (string), schemaId(string) and metadata(dict) as parameter In case of failure it throws APIEx...
def updateDraftThingType(self, thingTypeId, name, description, schemaId, metadata = None): """ Updates a thing type. It accepts thingTypeId (string), name (string), description (string), schemaId (string) and metadata(JSON) as the parameters In case of failure it throws APIException ...
def getDraftThingTypes(self, parameters = None): """ Retrieves all existing draft thing types. It accepts accepts an optional query parameters (Dictionary) In case of failure it throws APIException """ draftThingTypesUrl = ApiClient.draftThingTypesUrl % (self.host) ...
def getDraftThingType(self, thingTypeId, parameters = None): """ Retrieves all existing draft thing types. It accepts accepts an optional query parameters (Dictionary) In case of failure it throws APIException """ draftThingTypeUrl = ApiClient.draftThingTypeUrl % (self.ho...
def deleteDraftThingType(self, thingTypeId): """ Deletes a Thing type. It accepts thingTypeId (string) as the parameter In case of failure it throws APIException """ draftThingTypeUrl = ApiClient.draftThingTypeUrl % (self.host, thingTypeId) r = requests.delete(dr...
def createSchema(self, schemaName, schemaFileName, schemaContents, description=None): """ Create a schema for the org. Returns: schemaId (string), response (object). Throws APIException on failure """ req = ApiClient.allSchemasUrl % (self.host, "/draft") fields={ ...
def deleteSchema(self, schemaId): """ Delete a schema. Parameter: schemaId (string). Throws APIException on failure. """ req = ApiClient.oneSchemaUrl % (self.host, "/draft", schemaId) resp = requests.delete(req, auth=self.credentials, verify=self.verify) if resp.status_c...
def updateSchema(self, schemaId, schemaDefinition): """ Update a schema. Throws APIException on failure. """ req = ApiClient.oneSchemaUrl % (self.host, "/draft", schemaId) body = {"schemaDefinition": schemaDefinition} resp = requests.put(req, auth=self.credentials, header...
def getSchemaContent(self, schemaId, draft=False): """ Get the content for a schema. Parameters: schemaId (string), draft (boolean). Throws APIException on failure. """ if draft: req = ApiClient.oneSchemaContentUrl % (self.host, "/draft", schemaId) else: ...
def updateSchemaContent(self, schemaId, schemaFile): """ Updates the content for a schema. Parameters: schemaId (string). Throws APIException on failure. """ req = ApiClient.oneSchemaContentUrl % (self.host, "/draft", schemaId) body = {"schemaFile": schemaFile} resp = re...
def updateEventType(self, eventTypeId, name, schemaId, description=None): """ Updates an event type. Parameters: eventTypeId (string), name (string), schemaId (string), description (string, optional). Throws APIException on failure. """ req = ApiClient.oneEventTypesUrl % ...
def deleteEventType(self, eventTypeId): """ Deletes an event type. Parameters: eventTypeId (string). Throws APIException on failure. """ req = ApiClient.oneEventTypeUrl % (self.host, "/draft", eventTypeId) resp = requests.delete(req, auth=self.credentials, verify=self.verify) ...
def getEventType(self, eventTypeId, draft=False): """ Gets an event type. Parameters: eventTypeId (string), draft (boolean). Throws APIException on failure. """ if draft: req = ApiClient.oneEventTypeUrl % (self.host, "/draft", eventTypeId) else: req = Ap...
def createPhysicalInterface(self, name, description=None): """ Create a physical interface. Parameters: - name (string) - description (string, optional) Returns: physical interface id, response. Throws APIException on failure. """ req = ApiClie...
def updatePhysicalInterface(self, physicalInterfaceId, name, schemaId, description=None): """ Update a physical interface. Parameters: - physicalInterfaceId (string) - name (string) - schemaId (string) - description (string, optional) Throws APIExc...
def deletePhysicalInterface(self, physicalInterfaceId): """ Delete a physical interface. Parameters: physicalInterfaceId (string). Throws APIException on failure. """ req = ApiClient.onePhysicalInterfaceUrl % (self.host, "/draft", physicalInterfaceId) resp = reque...
def getPhysicalInterface(self, physicalInterfaceId, draft=False): """ Get a physical interface. Parameters: - physicalInterfaceId (string) - draft (boolean) Throws APIException on failure. """ if draft: req = ApiClient.onePhysicalInterfaceU...
def createEvent(self, physicalInterfaceId, eventTypeId, eventId): """ Create an event mapping for a physical interface. Parameters: physicalInterfaceId (string) - value returned by the platform when creating the physical interface eventTypeId (string) - value returned by the ...
def deleteEvent(self, physicalInterfaceId, eventId): """ Delete an event mapping from a physical interface. Parameters: physicalInterfaceId (string), eventId (string). Throws APIException on failure. """ req = ApiClient.oneEventUrl % (self.host, "/draft", physicalInterfac...
def getLogicalInterfaces(self, draft=False, name=None, schemaId=None): """ Get all logical interfaces for an org. Parameters: draft (boolean). Returns: - list of ids - response object Throws APIException on failure. """ if draft: ...
def updateLogicalInterface(self, logicalInterfaceId, name, schemaId, description=None): """ Updates a logical interface. Parameters: logicalInterfaceId (string), name (string), schemaId (string), description (string, optional). Throws APIException on failure. """ req = Ap...
def deleteLogicalInterface(self, logicalInterfaceId): """ Deletes a logical interface. Parameters: logicalInterfaceId (string). Throws APIException on failure. """ req = ApiClient.oneLogicalInterfaceUrl % (self.host, "/draft", logicalInterfaceId) resp = requests.d...
def getLogicalInterface(self, logicalInterfaceId, draft=False): """ Gets a logical interface. Parameters: - logicalInterfaceId (string) - draft (boolean) Throws APIException on failure. """ if draft: req = ApiClient.oneLogicalInterfaceUrl %...
def getRuleForLogicalInterface(self, logicalInterfaceId, ruleId, draft=False): """ Gets a rule for a logical interface. Parameters: - logicalInterfaceId (string) - ruleId (string) - draft (boolean) Throws APIException on failure. """ if draft...
def addRuleToLogicalInterface(self, logicalInterfaceId, name, condition, description=None, alias=None): """ Adds a rule to a logical interface. Parameters: - logicalInterfaceId (string) - name (string) - condition (string) - (description (string, optional)...
def updateRuleOnLogicalInterface(self, logicalInterfaceId, ruleId, name, condition, description=None): """ Updates a rule on a logical interface.. Parameters: - logicalInterfaceId (string), - ruleId (string) - name (string) - condition (string) -...
def deleteRuleOnLogicalInterface(self, logicalInterfaceId, ruleId): """ Deletes a rule from a logical interface Parameters: - logicalInterfaceId (string), - ruleId (string) Returns: response (object) Throws APIException on failure """ req = Api...
def addPhysicalInterfaceToDeviceType(self, typeId, physicalInterfaceId): """ Adds a physical interface to a device type. Parameters: - typeId (string) - the device type - physicalInterfaceId (string) - the id returned by the platform on creation of the physical interface ...
def getPhysicalInterfaceOnDeviceType(self, typeId, draft=False): """ Gets the physical interface associated with a device type. Parameters: - typeId (string) - the device type - draft (boolean) Throws APIException on failure. """ if draft: ...
def getLogicalInterfacesOnDeviceType(self, typeId, draft=False): """ Get all logical interfaces for a device type. Parameters: - typeId (string) - draft (boolean) Returns: - list of logical interface ids - HTTP response object Throws AP...
def addLogicalInterfaceToDeviceType(self, typeId, logicalInterfaceId): """ Adds a logical interface to a device type. Parameters: - typeId (string) - the device type - logicalInterfaceId (string) - the id returned by the platform on creation of the logical interface ...
def removeLogicalInterfaceFromDeviceType(self, typeId, logicalInterfaceId): """ Removes a logical interface from a device type. Parameters: - typeId (string) - the device type - logicalInterfaceId (string) - the id returned by the platform on creation of the logical inter...
def getMappingsOnDeviceType(self, typeId, draft=False): """ Get all the mappings for a device type. Parameters: - typeId (string) - the device type - draft (boolean) - draft or active Throws APIException on failure. """ if draft: req = ...
def getMappingsOnDeviceTypeForLogicalInterface(self, typeId, logicalInterfaceId, draft=False): """ Gets the mappings for a logical interface from a device type. Parameters: - typeId (string) - the device type - logicalInterfaceId (string) - the platform returned id of the...
def validateDeviceTypeConfiguration(self, typeId): """ Validate the device type configuration. Parameters: - typeId (string) - the platform device type Throws APIException on failure. """ req = ApiClient.draftDeviceTypeUrl % (self.host, typeId) body = ...
def validateLogicalInterfaceConfiguration(self, logicalInterfaceId): """ Validate the logical interface configuration. Parameters: - logicalInterfaceId (string) Throws APIException on failure. """ req = ApiClient.oneLogicalInterfaceUrl % (self.host, "/draft", ...
def getDeviceStateForLogicalInterface(self, typeId, deviceId, logicalInterfaceId): """ Gets the state for a logical interface for a device. Parameters: - typeId (string) - the platform device type - deviceId (string) - the platform device id - logicalInterface...
def getThingStateForLogicalInterface(self, thingTypeId, thingId, logicalInterfaceId): """ Gets the state for a logical interface for a thing. Parameters: - thingTypeId (string) - the platform thing type - thingId (string) - the platform thing id - logicalInter...
def resetThingStateForLogicalInterface(self, thingTypeId, thingId , logicalInterfaceId): """ Perform an operation against the thing state for a logical interface Parameters: - thingTypeId (string) - thingId (string) - logicalInterfaceId (string) Throws AP...
def getLogicalInterfacesOnThingType(self, thingTypeId, draft=False): """ Get all logical interfaces for a thing type. Parameters: - thingTypeId (string) - draft (boolean) Returns: - list of logical interface ids - HTTP response object T...
def addLogicalInterfaceToThingType(self, thingTypeId, logicalInterfaceId, schemaId = None, name = None): """ Adds a logical interface to a thing type. Parameters: - thingTypeId (string) - the thing type - logicalInterfaceId (string) - the id returned by the platform on cr...
def removeLogicalInterfaceFromThingType(self, thingTypeId, logicalInterfaceId): """ Removes a logical interface from a thing type. Parameters: - thingTypeId (string) - the thing type - logicalInterfaceId (string) - the id returned by the platform on creation of the logica...
def getMappingsOnThingType(self, thingTypeId, draft=False): """ Get all the mappings for a thing type. Parameters: - thingTypeId (string) - the thing type - draft (boolean) - draft or active Throws APIException on failure. """ if draft: ...
def getMappingsOnThingTypeForLogicalInterface(self, thingTypeId, logicalInterfaceId, draft=False): """ Gets the mappings for a logical interface from a thing type. Parameters: - thingTypeId (string) - the thing type - logicalInterfaceId (string) - the platform returned id...
def updateMappingsOnDeviceType(self, thingTypeId, logicalInterfaceId, mappingsObject, notificationStrategy = "never"): """ Add mappings for a thing type. Parameters: - thingTypeId (string) - the thing type - logicalInterfaceId (string) - the id of the application interfac...
def connect(self): """ Connect the client to IBM Watson IoT Platform using the underlying Paho MQTT client # Raises ConnectionException: If there is a problem establishing the connection. """ self.logger.debug( "Connecting... (address = %s, port = %s,...
def disconnect(self): """ Disconnect the client from IBM Watson IoT Platform """ # self.logger.info("Closing connection to the IBM Watson IoT Platform") self.client.disconnect() # If we don't call loop_stop() it appears we end up with a zombie thread which continues to pr...
def _onLog(self, mqttc, obj, level, string): """ Called when the client has log information. See [paho.mqtt.python#on_log](https://github.com/eclipse/paho.mqtt.python#on_log) for more information # Parameters mqttc (paho.mqtt.client.Client): The client instanc...
def _onConnect(self, mqttc, userdata, flags, rc): """ Called when the broker responds to our connection request. The value of rc determines success or not: 0: Connection successful 1: Connection refused - incorrect protocol version 2: Connection refused - inv...
def _onDisconnect(self, mqttc, obj, rc): """ Called when the client disconnects from IBM Watson IoT Platform. See [paho.mqtt.python#on_disconnect](https://github.com/eclipse/paho.mqtt.python#on_disconnect) for more information # Parameters mqttc (paho.mqtt.clien...
def _onPublish(self, mqttc, obj, mid): """ Called when a message from the client has been successfully sent to IBM Watson IoT Platform. See [paho.mqtt.python#on_publish](https://github.com/eclipse/paho.mqtt.python#on_publish) for more information # Parameters mq...
def subscribeToDeviceEvents(self, typeId="+", deviceId="+", eventId="+", msgFormat="+", qos=0): """ Subscribe to device event messages # Parameters typeId (string): typeId for the subscription, optional. Defaults to all device types (MQTT `+` wildcard) deviceId (string): device...
def subscribeToDeviceStatus(self, typeId="+", deviceId="+"): """ Subscribe to device status messages # Parameters typeId (string): typeId for the subscription, optional. Defaults to all device types (MQTT `+` wildcard) deviceId (string): deviceId for the subscription, optional....
def subscribeToDeviceCommands(self, typeId="+", deviceId="+", commandId="+", msgFormat="+"): """ Subscribe to device command messages # Parameters typeId (string): typeId for the subscription, optional. Defaults to all device types (MQTT `+` wildcard) deviceId (string): deviceI...
def publishCommand(self, typeId, deviceId, commandId, msgFormat, data=None, qos=0, on_publish=None): """ Publish a command to a device # Parameters typeId (string) : The type of the device this command is to be published to deviceId (string): The id of the device this command is...
def _onUnsupportedMessage(self, client, userdata, message): """ Internal callback for messages that have not been handled by any of the specific internal callbacks, these messages are not passed on to any user provided callback """ self.logger.warning( "Received messa...
def _onDeviceEvent(self, client, userdata, pahoMessage): """ Internal callback for device event messages, parses source device from topic string and passes the information on to the registerd device event callback """ try: event = Event(pahoMessage, self._messageCodec...
def _onDeviceStatus(self, client, userdata, pahoMessage): """ Internal callback for device status messages, parses source device from topic string and passes the information on to the registerd device status callback """ try: status = Status(pahoMessage) s...
def _onAppStatus(self, client, userdata, pahoMessage): """ Internal callback for application command messages, parses source application from topic string and passes the information on to the registerd applicaion status callback """ try: status = Status(pahoMessage) ...
def parseEnvVars(): """ Parse environment variables into a Python dictionary suitable for passing to the device client constructor as the `options` parameter - `WIOTP_IDENTITY_ORGID` - `WIOTP_IDENTITY_TYPEID` - `WIOTP_IDENTITY_DEVICEID` - `WIOTP_AUTH_TOKEN` - `WIOTP_OPTIONS_DOMAIN` (opt...
def get(self, deviceUid, eventId): """ Retrieves the last cached message for specified event from a specific device. """ if not isinstance(deviceUid, DeviceUid) and isinstance(deviceUid, dict): deviceUid = DeviceUid(**deviceUid) url = "api/v0002/device/types/%s/devi...
def getAll(self, deviceUid): """ Retrieves a list of the last cached message for all events from a specific device. """ if not isinstance(deviceUid, DeviceUid) and isinstance(deviceUid, dict): deviceUid = DeviceUid(**deviceUid) url = "api/v0002/device/types/%s/devic...
def _makeApiCall(self, parameters=None): """ Retrieve bulk devices It accepts accepts a list of parameters In case of failure it throws Exception """ r = self._apiClient.get(self._url, parameters) if r.status_code == 200: return r.json() else: ...
def decode(message): """ Convert a generic JSON message * The entire message is converted to JSON and treated as the message data * The timestamp of the message is the time that the message is RECEIVED """ try: data = json.loads(message.payload.decode...
def decode(message): ''' The decoder understands the comma-seperated format produced by the encoder and allocates the two values to the correct keys: data['hello'] = 'world' data['x'] = 10 ''' (hello, x) = message.payload.split(",") data = {} ...
def dataTransfer(self, start, end, detail=False): """ Retrieve the organization-specific status of each of the services offered by the IBM Watson IoT Platform. In case of failure it throws APIException """ r = self._apiClient.get( "api/v0002/usage/data-traffic?start=...
def initiate(self, request): """ Initiates a device management request, such as reboot. In case of failure it throws APIException """ url = MgmtRequests.mgmtRequests r = self._apiClient.post(url, request) if r.status_code == 202: return r.json() ...
def delete(self, requestId): """ Clears the status of a device management request. You can use this operation to clear the status for a completed request, or for an in-progress request which may never complete due to a problem. It accepts requestId (string) as parameters In case ...
def get(self, requestId): """ Gets details of a device management request. It accepts requestId (string) as parameters In case of failure it throws APIException """ url = MgmtRequests.mgmtSingleRequest % (requestId) r = self._apiClient.get(url) if r.statu...
def getStatus(self, requestId, typeId=None, deviceId=None): """ Get a list of device management request device statuses. Get an individual device mangaement request device status. """ if typeId is None or deviceId is None: url = MgmtRequests.mgmtRequestStatus % (reque...
def close(self): """Force a flush of the index to storage. Renders index inaccessible.""" if self.handle: self.handle.destroy() self.handle = None else: raise IOError("Unclosable index")
def insert(self, id, coordinates, obj=None): """Inserts an item into the index with the given coordinates. :param id: long integer A long integer that is the identifier for this index entry. IDs need not be unique to be inserted into the index, and it is up to the u...
def count(self, coordinates): """Return number of objects that intersect the given coordinates. :param coordinates: sequence or array This may be an object that satisfies the numpy array protocol, providing the index's dimension * 2 coordinate pairs representing the ...
def intersection(self, coordinates, objects=False): """Return ids or objects in the index that intersect the given coordinates. :param coordinates: sequence or array This may be an object that satisfies the numpy array protocol, providing the index's dimension * 2 coordi...
def nearest(self, coordinates, num_results=1, objects=False): """Returns the ``k``-nearest objects to the given coordinates. :param coordinates: sequence or array This may be an object that satisfies the numpy array protocol, providing the index's dimension * 2 coordinate ...
def get_bounds(self, coordinate_interleaved=None): """Returns the bounds of the index :param coordinate_interleaved: If True, the coordinates are turned in the form [xmin, ymin, ..., kmin, xmax, ymax, ..., kmax], otherwise they are returned as [xmin, xmax, ymin, ymax...
def delete(self, id, coordinates): """Deletes items from the index with the given ``'id'`` within the specified coordinates. :param id: long integer A long integer that is the identifier for this index entry. IDs need not be unique to be inserted into the index, and it ...
def deinterleave(self, interleaved): """ [xmin, ymin, xmax, ymax] => [xmin, xmax, ymin, ymax] >>> Index.deinterleave([0, 10, 1, 11]) [0, 1, 10, 11] >>> Index.deinterleave([0, 1, 2, 10, 11, 12]) [0, 10, 1, 11, 2, 12] """ assert len(interleaved) % 2 == 0,...
def interleave(self, deinterleaved): """ [xmin, xmax, ymin, ymax, zmin, zmax] => [xmin, ymin, zmin, xmax, ymax, zmax] >>> Index.interleave([0, 1, 10, 11]) [0, 10, 1, 11] >>> Index.interleave([0, 10, 1, 11, 2, 12]) [0, 1, 2, 10, 11, 12] >>> Index.int...
def _create_idx_from_stream(self, stream): """This function is used to instantiate the index given an iterable stream of data.""" stream_iter = iter(stream) dimension = self.properties.dimension darray = ctypes.c_double * dimension mins = darray() maxs = darray()...
def destroy(self, context, returnError): """please override""" returnError.contents.value = self.IllegalStateError raise NotImplementedError("You must override this method.")
def loadByteArray(self, context, page, resultLen, resultData, returnError): """please override""" returnError.contents.value = self.IllegalStateError raise NotImplementedError("You must override this method.")
def storeByteArray(self, context, page, len, data, returnError): """please override""" returnError.contents.value = self.IllegalStateError raise NotImplementedError("You must override this method.")
def deleteByteArray(self, context, page, returnError): """please override""" returnError.contents.value = self.IllegalStateError raise NotImplementedError("You must override this method.")
def flush(self, context, returnError): """please override""" returnError.contents.value = self.IllegalStateError raise NotImplementedError("You must override this method.")