-
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.
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
74f36b7
commit 2f9cef5
Showing
3 changed files
with
45 additions
and
8 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
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 |
---|---|---|
|
@@ -13,17 +13,21 @@ Metadata can be manipulated by using the `metadata` header, see [here](protocol- | |
|
||
## 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 `metadata` header, see [here](protocol-specification.html#headers) for more information. | ||
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 | ||
|
||
``` | ||
|
@@ -33,8 +37,8 @@ The Format of the Json Array is | |
"value":{"issuedAt":someTimestamp,"issuedBy":{"name":"me","mail":"[email protected]"}} | ||
}, | ||
{ | ||
"key":"*/", | ||
"value":{"foo": bar"} | ||
"key":"*/foo", | ||
"value": "bar" | ||
}, | ||
... | ||
] | ||
|
@@ -43,16 +47,36 @@ The Format of the Json Array is | |
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 `*/` which means that all affected Json Leafs of the Modify Operation will | ||
get the Metadata Key `foo` with value `bar`. So if, for example, only the affected Json Leafes should | ||
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":"*/", | ||
"value":{"issuedAt": someTimestamp } | ||
"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