Skip to content

Commit

Permalink
docs: key & IdMap schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
kuzyn committed Feb 15, 2018
1 parent 4dc4acc commit 619b111
Show file tree
Hide file tree
Showing 2 changed files with 183 additions and 3 deletions.
115 changes: 113 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@
</li>

<li>
<a href="#idmap-schema" class="toc-h2 toc-link" data-title="Schema">Schema</a>
<a href="#idmap-schema" class="toc-h2 toc-link" data-title="IdMap">IdMap</a>

</li>

Expand Down Expand Up @@ -4300,7 +4300,118 @@ <h3 id="modified-values">Modified Values</h3>
</table>
<h2 id="sensor-schema">Sensor</h2>
<h2 id="key-schema">Key</h2>
<h2 id="idmap-schema">Schema</h2>
<p>Keys objects are generated when creating entities and are the most direct way to reference (or retrieve) them. They are passed as integer to the API which turns it into an object or are created when a new entity is added</p>
<blockquote>
<p>Request Payload</p>
</blockquote>
<pre class="highlight tab tab-json"><code>[...]
<span class="hljs-string">"event_sensor"</span>: <span class="hljs-number">678967896789</span>
[...]
</code></pre>
<blockquote>
<p>Return Payload</p>
</blockquote>
<pre class="highlight tab tab-json"><code>[...]
<span class="hljs-string">"event_sensor"</span>: {
<span class="hljs-attr">"id"</span>: <span class="hljs-string">"678967896789"</span>,
<span class="hljs-attr">"kind"</span>: <span class="hljs-string">"Sensor"</span>,
<span class="hljs-attr">"path"</span>: [
<span class="hljs-string">"Sensor"</span>,
<span class="hljs-string">"678967896789"</span>
]
}
[...]
</code></pre>
<h3 id="properties">Properties</h3>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Required</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>id</td>
<td>Integer</td>
<td>true</td>
<td>This is the entity Id</td>
</tr>
</tbody>
</table>
<h3 id="appended-values">Appended Values</h3>
<table>
<thead>
<tr>
<th>Property</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>kind</td>
<td>Entity type</td>
</tr>
<tr>
<td>path</td>
<td>Entity hiearchy path</td>
</tr>
</tbody>
</table>
<h3 id="modified-values">Modified Values</h3>
<table>
<thead>
<tr>
<th>Property</th>
<th>From</th>
<th>To</th>
</tr>
</thead>
<tbody>
<tr>
<td>id</td>
<td>Interger</td>
<td>String</td>
</tr>
</tbody>
</table>
<h2 id="idmap-schema">IdMap</h2>
<p>IdMap object are simple value maps of entities ids assigned an integer timestamp as their only properties. Effectively, we're using this to keep track of dependent entities and to enable or disable them. A non-zero timestamp enable an entity, while a zero value disable it. We are using timestamp rather than boolean because it allows us to make complex queries without the need to compile indexes (see <a href="https://cloud.google.com/firestore/docs/solutions/arrays">this</a> GCP documentation for more details)</p>
<blockquote>
<p>Request Payload</p>
</blockquote>
<pre class="highlight tab tab-json"><code>[...]
<span class="hljs-string">"1234123412341234"</span>: <span class="hljs-number">15432324324</span>
[...]
</code></pre>
<blockquote>
<p>Return Payload</p>
</blockquote>
<pre class="highlight tab tab-json"><code>[...]
<span class="hljs-string">"1234123412341234"</span>: <span class="hljs-number">15432324324</span>
[...]
</code></pre>
<h3 id="properties">Properties</h3>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Required</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>Timestamp</td>
<td>Integer</td>
<td>true</td>
<td>Epoch timestamp to enable, zero value to disable</td>
</tr>
</tbody>
</table>
<h1 id="errors">Errors</h1>
<p>The <code>ox</code> API uses the following error codes:</p>
<table>
Expand Down
71 changes: 70 additions & 1 deletion source/includes/_schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,5 +296,74 @@ There is also table with _Appended Values_ and _Modified Values_. _Appended Valu
|org_owner|Integer|Object([Key](#key-schema))|

<h2 id="sensor-schema">Sensor</h2>

<h2 id="key-schema">Key</h2>
<h2 id="idmap-schema">Schema</h2>

Keys objects are generated when creating entities and are the most direct way to reference (or retrieve) them. They are passed as integer to the API which turns it into an object or are created when a new entity is added

> Request Payload
```json
[...]
"event_sensor": 678967896789
[...]
```

> Return Payload
```json
[...]
"event_sensor": {
"id": "678967896789",
"kind": "Sensor",
"path": [
"Sensor",
"678967896789"
]
}
[...]
```

### Properties

|Name|Type|Required|Description|
|-|-|-|-|
|id|Integer|true|This is the entity Id|

### Appended Values

|Property|Description|
|-|-|
|kind|Entity type|
|path|Entity hiearchy path|

### Modified Values

|Property|From|To|
|-|-|-|
|id|Interger|String|

<h2 id="idmap-schema">IdMap</h2>

IdMap object are simple value maps of entities ids assigned an integer timestamp as their only properties. Effectively, we're using this to keep track of dependent entities and to enable or disable them. A non-zero timestamp enable an entity, while a zero value disable it. We are using timestamp rather than boolean because it allows us to make complex queries without the need to compile indexes (see [this](https://cloud.google.com/firestore/docs/solutions/arrays) GCP documentation for more details)

> Request Payload
```json
[...]
"1234123412341234": 15432324324
[...]
```

> Return Payload
```json
[...]
"1234123412341234": 15432324324
[...]
```

### Properties

|Name|Type|Required|Description|
|-|-|-|-|
Timestamp|Integer|true|Epoch timestamp to enable; zero value to disable|

0 comments on commit 619b111

Please sign in to comment.