-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Corrections in basic-metadata.md and added changes to ditto-api-2.yml-Swagger Doc. Signed-off-by: julian <[email protected]>
- Loading branch information
1 parent
e491bd6
commit 5548ffa
Showing
3 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
documentation/src/main/resources/pages/ditto/basic-metadata.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
--- | ||
title: Metadata Support | ||
keywords: metadata, things | ||
tags: [model] | ||
permalink: basic-metadata.html | ||
--- | ||
|
||
Besides [features](basic-feature.html) a Thing in Ditto is also able to store Metadata information. | ||
These informations can be additional information for describing specific features or properties of the thing. | ||
A very simple example is the timestamp when the current value of the feature or property was set. | ||
|
||
Metadata can be manipulated by using the `metadata` header, see [here](protocol-specification.html#headers) for more information. | ||
|
||
## Predefined Metadata | ||
|
||
Currently, there are no pre-defined Metadata keys. | ||
|
||
<!-- | ||
Right now, the only fixed pre-defined Metadata key is `issuedAt`. | ||
### The `issuedAt` Metadata key | ||
The Metadata key `issuedAt` describes the timestamp when the current value of a feature property was _recorded_ (_not when it was set_). | ||
This means, that a client _can_ send this value by using the `metadata` header. If the client does not send | ||
this header the `issuedAt` field will be set by Ditto with the timestamp when the value was written. | ||
--> | ||
|
||
## Setting custom Metadata | ||
|
||
The only way to set arbitrary `Metadata` is by using the `put-metadata` header, see [here](protocol-specification.html#headers) for more information. | ||
The Format of the Json Array is | ||
|
||
``` | ||
[ | ||
{ | ||
"key":"/features/lamp/properties/color/r", | ||
"value":{"issuedAt":someTimestamp,"issuedBy":{"name":"me","mail":"[email protected]"}} | ||
}, | ||
{ | ||
"key":"*/foo", | ||
"value": "bar" | ||
}, | ||
... | ||
] | ||
``` | ||
|
||
where `key` describes the hierarchical position in the Thing where the metadata is placed and | ||
`value` is a map of Metadata keys to their respective values. | ||
|
||
A special Syntax for the key is `*/{key}` which means that all affected Json Leafs of the Modify Operation will | ||
get the Metadata Key `{key}` with the given value. So if, for example, only the affected Json Leafes should | ||
get the timestamp where the changed values were recorded, one would set the `metadata` header as shown in the | ||
following example: | ||
|
||
```json | ||
[ | ||
{ | ||
"key":"*/timestamp", | ||
"value": someTimestamp | ||
} | ||
] | ||
``` | ||
|
||
## Reading Metadata Information | ||
|
||
Currently, the only way to retrieve stored Metadata is by a full thing query, e.g. via the [HTTP API](http-api-doc.html). | ||
But, `get-metadata` has to be added to the queried fields together with `thingId,attributes,_metadata`. | ||
|
||
For example a `GET` request to `https://{ditto-instance}/api/2/things/{namespace}:{thing}?fields=thingId,attributes,_metadata` | ||
will yield the Metadata stored for the given Thing, in the following format: | ||
|
||
```json | ||
{ | ||
"thingId": ..., | ||
"attributes": { | ||
... | ||
}, | ||
"_metadata": { | ||
... | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters