Read data

Read schema

The schema is read with the read-schema operation.

Read schema examples

Example request

<iq xml:lang="en" to="testsource@xmpphost.clayster.com/sourcetest" 
    from="testcontroller@xmpphost.clayster.com/controllertest" 
    type="get" id="729c49a6-4dfb-4f56-8e0f-56fbbbfd8501">
  <read-schema xmlns="urn:clayster:lwtsd" 
    format="simplified" 
    startindex="0" 
    maxitems="500">
    <accesstoken name="urn:clayster:cdo:sessionid">dummysession</accesstoken>
  </read-schema>
</iq>    

Example response

<iq xml:lang="en" 
  to="testcontroller@xmpphost.clayster.com/controllertest" 
  from="testsource@xmpphost.clayster.com/sourcetest" 
  type="result" 
  id="729c49a6-4dfb-4f56-8e0f-56fbbbfd8501">
  <simplified-schema xmlns="urn:clayster:lwtsd" 
    returnedresources="6" 
    totalresources="6" 
    version="455D046E">
    <resource path="thermometers/temp2" description="A temperature">
      <type base="integer" minexclusive="3"/>
      <supports read="true" write="false"/>
    </resource>
    <resource path="writables/item1" description="A writable thingy">
      <type base="integer" minexclusive="0" maxexclusive="10"/>
      <supports read="true" write="true"/>
    </resource>
    <resource path="writables/item0" description="A writable thingy">
      <type base="integer" minexclusive="0" maxexclusive="10"/>
      <supports read="true" write="true"/>
    </resource>
    <resource path="writables/item2" description="A writable thingy">
      <type base="integer" minexclusive="0" maxexclusive="10"/>
      <supports read="true" write="true"/>
    </resource>
    <resource path="thermometers/temp0" description="A temperature">
      <type base="integer" minexclusive="3"/>
      <supports read="true" write="false"/>
    </resource>
    <resource path="thermometers/temp1" description="A temperature">
      <type base="integer" minexclusive="3"/>
      <supports read="true" write="false"/>
    </resource>
  </simplified-schema>
</iq>

Read data

Reading data is accomplished with the read-data operation. This operation requires you to specify what resources you wish to read. The response will include the paginated data and the current schema version.

Read data process

If the current schema version missmatches with a previously known schema version it is recommended to request a new schema.

It can be described in the following pseudo code:

    while knownschema <> readdata.schema
        getschema
        if knownschema <> readdata.schema
            readdata

Read data examples

Example request

<iq xml:lang="en" 
  to="testsource@xmpphost.clayster.com/sourcetest" 
  from="testcontroller@xmpphost.clayster.com/controllertest" 
  type="get" 
  id="d6837102-a116-4eb4-a606-b121e758a7c5">
  <read-data xmlns="urn:clayster:lwtsd" 
    maxpoints="500" 
    startindex="0" 
    relativetimeout="10">
    <accesstoken name="urn:clayster:cdo:sessionid">dummysession</accesstoken>
    <read resource="thermometers/temp2" maxpoints="1"/>
    <read resource="writables/item1" maxpoints="1"/>
    <read resource="writables/item0" maxpoints="1"/>
    <read resource="writables/item2" maxpoints="1"/>
    <read resource="thermometers/temp0" maxpoints="1"/>
    <read resource="thermometers/temp1" maxpoints="1"/>
  </read-data>
</iq>

Example response

<iq xml:lang="en" to="testcontroller@xmpphost.clayster.com/controllertest" 
  from="testsource@xmpphost.clayster.com/sourcetest" 
  type="result" 
  id="d6837102-a116-4eb4-a606-b121e758a7c5">
  <data xmlns="urn:clayster:lwtsd" 
    schemaversion="455D046E" 
    returnedpoints="6" 
    totalpoints="6">
    <resource path="thermometers/temp2" returnedpoints="1" totalpoints="1">
      <point timestamp="2017-10-23T18:01:03.497037Z">22</point>
    </resource>
    <resource path="writables/item1" returnedpoints="1" totalpoints="1">
      <point timestamp="2017-10-23T18:01:03.497108Z">2</point>
    </resource>
    <resource path="writables/item0" returnedpoints="1" totalpoints="1">
      <point timestamp="2017-10-23T18:01:03.497052Z">1</point>
    </resource>
    <resource path="writables/item2" returnedpoints="1" totalpoints="1">
      <point timestamp="2017-10-23T18:01:03.497114Z">3</point>
    </resource>
    <resource path="thermometers/temp0" returnedpoints="1" totalpoints="1">
      <point timestamp="2017-10-23T18:01:03.494067Z">20</point>
    </resource>
    <resource path="thermometers/temp1" returnedpoints="1" totalpoints="1">
      <point timestamp="2017-10-23T18:01:03.497028Z">21</point>
    </resource>
  </data>
</iq>