commonsense-python-lib
senseapi.SenseAPI Class Reference

List of all members.

Public Member Functions

def __init__
def setVerbosity
def setServer
def __setAuthenticationMethod__
def getResponseStatus
def getResponseHeaders
def getResponse
def __SenseApiCall__
def SetSessionId
def AuthenticateSessionId
def LogoutSessionId
def Login
def Logout
def AuthenticateOauth
def OauthAuthorizeApplication
def __OauthGetTokExpir__
def SensorsGet_Parameters
def SensorsGet
def SensorsDelete
def SensorsPost_Parameters
def SensorsPost
def SensorDataGet_Parameters
def SensorDataGet
def SensorDataPost
def SensorsDataPost
def ServicesGet
def ServicesPost_Parameters
def ServicesPost
def ServicesDelete
def ServicesSet_Parameters
def ServicesSetExpression
def ServicesSetUseDataTimestamp
def UsersGetCurrent
def EventsNotificationsGet
def EventsNotificationsDelete
def EventsNotificationsPost_Parameters
def EventsNotificationsPost
def TriggersGet
def TriggersDelete
def TriggersPost_Parameters
def TriggersPost
def SensorsTriggersGet
def SensorsTriggersDelete
def SensorsTriggersPost_Parameters
def SensorsTriggersPost
def SensorsTriggersNotificationsGet
def SensorsTriggersNotificationsDelete
def SensorsTriggersNotificationsPost_Parameters
def SensorsTriggersNotificationsPost
def NotificationsGet
def NotificationsDelete
def NotificationsPost_Parameters
def NotificationsPost
def SensorAddToDevice_Parameters
def SensorAddToDevice

Static Public Attributes

tuple oauth_request = oauth.OAuthRequest.from_consumer_and_token(self.__oauth_consumer__, callback=oauth_callback, http_url='http://api.sense-os.nl/oauth/request_token')
list parameters = []
tuple response = urlparse.parse_qs(self.__response__)
dictionary parameters = {'oauth_token':self.__oauth_token__.key, 'tok_expir':self.__OauthGetTokExpir__(oauth_duration), 'action':'ALLOW', 'session_id':self.__session_id__}

Detailed Description

        Class for interacting with CommonSense Api. 
        
        Can be set to interact with either the live or test server.
        Can authenticate using session_id and oauth.

Constructor & Destructor Documentation

        Constructor function.

Member Function Documentation

def senseapi.SenseAPI.AuthenticateOauth (   self,
  oauth_token_key,
  oauth_token_secret,
  oauth_consumer_key,
  oauth_consumer_secret 
)
        Authenticate using Oauth
        
        @param oauth_token_key (string) - A valid oauth token key obtained from CommonSense
        @param oauth_token_secret (string) - A valid oauth token secret obtained from CommonSense
        @param oauth_consumer_key (string) - A valid oauth consumer key obtained from CommonSense
        @param oauth_consumer_secret (string) - A valid oauth consumer secret obtained from CommonSense
        
        @return (boolean) - Boolean indicating whether the provided credentials were successfully authenticated
def senseapi.SenseAPI.AuthenticateSessionId (   self,
  username,
  password 
)
        Authenticate using a username and password. 
        The SenseApi object will store the obtained session_id internally until a call to LogoutSessionId is performed.
        
        @param username (string) - CommonSense username
        @param password (string) - MD5Hash of CommonSense password
        
        @return (bool) - Boolean indicating whether AuthenticateSessionId was successful
def senseapi.SenseAPI.EventsNotificationsDelete (   self,
  event_notification_id 
)
        Delete an event-notification from CommonSense.
        
        @param event_notification_id (int) - Id of the event-notification to delete.
        
        @return (bool) - Boolean indicating whether EventsNotificationsDelete was successful.
def senseapi.SenseAPI.EventsNotificationsGet (   self,
  event_notification_id = -1 
)
        Retrieve either all notifications or the notifications attached to a specific event.
        If successful, result can be obtained by a call to getResponse(), and should be a json string.
        
        @param event_notification_id (int) (optional) - Id of the event-notification to retrieve details from.
        
        @return (bool) - Boolean indicating whether EventsNotificationsGet was successful.
def senseapi.SenseAPI.EventsNotificationsPost (   self,
  parameters 
)
        Create an event-notification in CommonSense.
        If EvensNotificationsPost was successful the result, including the event_notification_id can be obtained from getResponse(), and should be a json string.
        
        @param parameters (dictionary) - Parameters according to which to create the event notification.
        @note - 
        
        @return (bool) - Boolean indicating whether EventsNotificationsPost was successful. 
        Retrieve the response of the last api call
        
        @return (string) - The literal response body, which is likely to be in json format
        Retrieve the response headers of the last api call
        
        @return (dictionary) - Dictonary containing headers
        Retrieve the response status code of the last api call
        
        @return (integer) - Http status code
def senseapi.SenseAPI.Login (   self,
  username,
  password 
)
        Deprecated, use AuthenticateSessionId instead
def senseapi.SenseAPI.Logout (   self)
        Deprecated, use LogoutSessionId instead
        Logout the current session_id from CommonSense
        
        @return (bool) - Boolean indicating whether LogoutSessionId was successful
def senseapi.SenseAPI.NotificationsDelete (   self,
  notification_id 
)
        Delete a notification from CommonSense.
        
        @param notification_id (int) - Notification id of the notification to delete.
        
        @return (bool) - Boolean indicating whether NotificationsDelete was successful.
def senseapi.SenseAPI.NotificationsGet (   self,
  notification_id = -1 
)
        Obtain either all notifications from CommonSense, or the details of a specific notification.
        If successful, the result can be obtained from getResponse(), and should be a json string.
        
        @param notification_id (int) (optional) - Notification id of the notification to obtain details from.
        
        @return (bool) - Boolean indicating whether NotificationsGet was successful.
def senseapi.SenseAPI.NotificationsPost (   self,
  parameters 
)
        Create a notification on CommonSense.
        If successful the result, including the notification_id, can be obtained from getResponse(), and should be a json string.
        
        @param parameters (dictionary) - Dictionary containing the notification to create.
        @note - 
        
        @return (bool) - Boolean indicating whether NotificationsPost was successful.
def senseapi.SenseAPI.OauthAuthorizeApplication (   self,
  oauth_consumer_key,
  oauth_consumer_secret,
  oauth_duration = 'hour',
  oauth_callback = 'http://www.sense-os.nl' 
)
        Authorize an application using oauth. If this function returns True, the obtained oauth token can be retrieved using getResponse and will be in url-parameters format.
        TODO: allow the option to ask the user himself for permission, instead of doing this automatically. Especially important for web applications.
        
        @param oauth_consumer_key (string) - A valid oauth consumer key obtained from CommonSense
        @param oauth_consumer_secret (string) - A valid oauth consumer secret obtained from CommonSense
        @param oauth_duration (string) (optional) -'hour', 'day', 'week', 'year', 'forever'
        @param oauth_callback (string) (optional) - Oauth callback url
        
        @return (boolean) - Boolean indicating whether OauthAuthorizeApplication was successful
def senseapi.SenseAPI.SensorAddToDevice (   self,
  sensor_id,
  parameters 
)
        Add a sensor to a device in CommonSense. 
        If successful, the result, including the device_id, can be obtained from getResponse(), and should be a json string.
        
        @param sensor_id (int) - Sensor id of the sensor to add to a device.
        @param parameters (dictionary) - Dictionary containing the device to attach the sensor to.
        
        @return (bool) - Boolean indicating whether SensorAddToDevice was successful.
def senseapi.SenseAPI.SensorDataGet (   self,
  sensor_id,
  parameters 
)
        Retrieve sensor data for a specific sensor from CommonSense.
        If SensorDataGet is successful, the result can be obtained by a call to getResponse(), and should be a json string.
        
        @param sensor_id (int) - Sensor id of the sensor to retrieve data from.
        @param parameters (dictionary) - Dictionary containing the parameters for the api call.
        @note - http://www.sense-os.nl/52?nodeId=52&selectedId=11887
        
        @return (bool) - Boolean indicating whether SensorDataGet was successful.
def senseapi.SenseAPI.SensorDataPost (   self,
  sensor_id,
  parameters 
)
        Post sensor data to a specific sensor in CommonSense.
        
        @param sensor_id (int) - Sensor id of the sensor to post data to.
        @param parameters (dictionary) - Data to post to the sensor.
        @note - http://www.sense-os.nl/53?nodeId=53&selectedId=11887
def senseapi.SenseAPI.SensorsDataPost (   self,
  parameters 
)
        Post sensor data to multiple sensors in CommonSense simultaneously.
        
        @param parameters (dictionary) - Data to post to the sensors.
        @note - http://www.sense-os.nl/59?nodeId=59&selectedId=11887
        
        @return (bool) - Boolean indicating whether SensorsDataPost was successful.
def senseapi.SenseAPI.SensorsDelete (   self,
  sensor_id 
)
        Delete a sensor from CommonSense.
        
        @param sensor_id (int) - Sensor id of sensor to delete from CommonSense.
        
        @return (bool) - Boolean indicating whether SensorsDelete was successful.
def senseapi.SenseAPI.SensorsGet (   self,
  parameters = None,
  sensor_id = -1 
)
        Retrieve sensors from CommonSense, according to parameters, or by sensor id. 
        If successful, result can be obtained by a call to getResponse(), and should be a json string.
        
        @param parameters (dictionary) (optional) - Dictionary containing the parameters for the api-call.
        @note - http://www.sense-os.nl/45?nodeId=45&selectedId=11887
        @param sensor_id (int) (optional) - Sensor id of sensor to retrieve details from.
        
        @return (boolean) - Boolean indicating whether SensorsGet was successful.
def senseapi.SenseAPI.SensorsPost (   self,
  parameters 
)
        Create a sensor in CommonSense.
        If SensorsPost is successful, the sensor details, including its sensor_id, can be obtained by a call to getResponse(), and should be a json string.
        
        @param parameters (dictonary) - Dictionary containing the details of the sensor to be created. 
        @note - http://www.sense-os.nl/46?nodeId=46&selectedId=11887			
                                        
        @return (bool) - Boolean indicating whether SensorsPost was successful.
def senseapi.SenseAPI.SensorsTriggersDelete (   self,
  sensor_id,
  trigger_id 
)
        Disconnect a trigger from a sensor in CommonSense
        
        @param sensor_id (int) - Sensor id of the sensor to disconnect a trigger from.
        @param trigger_id (int) - Trigger id of the trigger to disconnect.
        
        @return (bool) - Boolean indicating whether SensorsTriggersDelete was successful.
def senseapi.SenseAPI.SensorsTriggersGet (   self,
  sensor_id,
  trigger_id = -1 
)
        Obtain either all triggers connected to a sensor, or the details of a specific trigger connected to a sensor.
        If successful, result can be obtained from getResponse(), and should be a json string.
        
        @param sensor_id (int) - Sensor id of the sensor to retrieve triggers from.
        @param trigger_id (int) (optional) - Trigger id of the trigger to retrieve details from.
        
        @return (bool) - Boolean indicating whether SensorsTriggersGet was successful.
def senseapi.SenseAPI.SensorsTriggersNotificationsDelete (   self,
  sensor_id,
  trigger_id,
  notification_id 
)
        Disconnect a notification from a sensor-trigger combination.
        
        @param sensor_id (int) - Sensor id if the sensor-trigger combination.
        @param trigger_id (int) - Trigger id of the sensor-trigger combination.
        @param notification_id (int) - Notification id of the notification to disconnect.
        
        @param (bool) - Boolean indicating whether SensorstriggersNotificationsDelete was successful.			
def senseapi.SenseAPI.SensorsTriggersNotificationsGet (   self,
  sensor_id,
  trigger_id 
)
        Obtain all notifications connected to a sensor-trigger combination.
        If successful, the result can be obtained from getResponse(), and should be a json string.
        
        @param sensor_id (int) - Sensor id if the sensor-trigger combination.
        @param trigger_id (int) - Trigger id of the sensor-trigger combination.
        
        @return (bool) - Boolean indicating whether SensorstriggersNoticiationsGet was successful.
def senseapi.SenseAPI.SensorsTriggersNotificationsPost (   self,
  sensor_id,
  trigger_id,
  parameters 
)
        Connect a notification to a sensor-trigger combination.
        
        @param sensor_id (int) - Sensor id if the sensor-trigger combination.
        @param trigger_id (int) - Trigger id of the sensor-trigger combination.
        @param parameters (dictionary) - Dictionary containing the notification to connect.
        @note - 
        
        @return (bool) - Boolean indicating whether SensorsTriggersNotificationsPost was successful.			
def senseapi.SenseAPI.SensorsTriggersPost (   self,
  sensor_id,
  parameters 
)
        Connect a trigger to a sensor in CommonSense.
        
        @param sensor_id (int) - Sensor id of the sensor to connect a trigger to.
        @param parameters (dictionary) - Dictionary containing the details of the trigger.
        @note - 
        
        @return (bool) - Boolean indicating whether SensorsTriggersPost was successeful.
def senseapi.SenseAPI.ServicesDelete (   self,
  sensor_id,
  service_id 
)
        Delete a service from CommonSense.
        
        @param sensor_id (int) - Sensor id of the sensor the service is connected to.
        @param service_id (int) - Sensor id of the service to delete.
        
        @return (bool) - Boolean indicating whether ServicesDelete was successful.
def senseapi.SenseAPI.ServicesGet (   self,
  sensor_id 
)
        Retrieve services connected to a sensor in CommonSense.
        If ServicesGet is successful, the result can be obtained by a call to getResponse() and should be a json string.
        
        @sensor_id (int) - Sensor id of sensor to retrieve services from.
        
        @return (bool) - Boolean indicating whether ServicesGet was successful.
def senseapi.SenseAPI.ServicesPost (   self,
  sensor_id,
  parameters 
)
        Create a new service in CommonSense, attached to a specific sensor. 
        If ServicesPost was successful, the service details, including its service_id, can be obtained from getResponse(), and should be a json string.
        
        @param sensor_id (int) - The sensor id of the sensor to connect the service to.
        @param parameters (dictionary) - The specifics of the service to create.
        @note: http://www.sense-os.nl/81?nodeId=81&selectedId=11887
        
        @return (bool) - Boolean indicating whether ServicesPost was successful.
def senseapi.SenseAPI.ServicesSetExpression (   self,
  sensor_id,
  service_id,
  parameters 
)
        Set expression for the math service.
        
        @param sensors_id (int) - Sensor id of the sensor the service is connected to.
        @param service_id (int) - Service id of the service for which to set the expression.
        @param parameters (dictonary) - Parameters to set the expression of the math service.
        @note - http://www.sense-os.nl/85?nodeId=85&selectedId=11887
        
        @return (bool) - Boolean indicating whether ServicesSetExpression was successful.
def senseapi.SenseAPI.ServicesSetUseDataTimestamp (   self,
  sensor_id,
  service_id,
  parameters 
)
        Indicate whether a math service should use the original timestamps of the incoming data, or let CommonSense timestamp the aggregated data.
        
        @param sensors_id (int) - Sensor id of the sensor the service is connected to.
        @param service_id (int) - Service id of the service for which to set the expression.
        @param parameters (dictonary) - Parameters to set the expression of the math service.
        @note - http://www.sense-os.nl/85?nodeId=85&selectedId=11887
        
        @return (bool) - Boolean indicating whether ServicesSetuseDataTimestamp was successful.
def senseapi.SenseAPI.setServer (   self,
  server 
)
        Set server to interact with.
        
        @param server (string) - 'live' for live server, 'dev' for test server
        
        @return (boolean) - Boolean indicating whether setServer succeeded
def senseapi.SenseAPI.SetSessionId (   self,
  session_id 
)
        Pass an existing session_id to SenseApi object. Use with care!
        
        @param session_id (string) - A valid session_id obtained by logging into CommonSense
def senseapi.SenseAPI.setVerbosity (   self,
  verbose 
)
        Set verbosity of the SenseApi object.
        
        @param verbose (boolean) - True of False
        
        @return (boolean) - Boolean indicating whether setVerbosity succeeded
def senseapi.SenseAPI.TriggersDelete (   self,
  trigger_id 
)
        Delete a trigger from CommonSense.
        
        @param trigger_id (int) - Trigger id of the trigger to delete.
        
        @return (bool) - Boolean indicating whether TriggersDelete was successful.
def senseapi.SenseAPI.TriggersGet (   self,
  trigger_id = -1 
)
        Retrieve either all triggers or the details of a specific trigger.
        If successful, result can be obtained by a call to getResponse(), and should be a json string.

        @param trigger_id (int) (optional) - Trigger id of the trigger to retrieve details from.
        
        @param (bool) - Boolean indicating whether TriggersGet was successful.
def senseapi.SenseAPI.TriggersPost (   self,
  parameters 
)
        Create a trigger on CommonSense.
        If TriggersPost was successful the result, including the trigger_id, can be obtained from getResponse().
        
        @param parameters (dictionary) - Parameters of the trigger to create.
        @note 
        
        @return (bool) - Boolean indicating whether TriggersPost was successful.
        Obtain details of current user. 
        If successful, result can be obtained by a call to getResponse(), and should be a json string.
        
        @return (bool) - Boolean indicating whether UsersGetCurrent was successful.

The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables