Skip to content

Commit

Permalink
#1727 provided documentation of new "thing-json" placeholder + added …
Browse files Browse the repository at this point in the history
…functions

Signed-off-by: Thomas Jäckle <thomas.jaeckle@beyonnex.io>
  • Loading branch information
thjaeckle committed Sep 15, 2023
1 parent e94ca9f commit b4612b7
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions documentation/src/main/resources/pages/ditto/basic-placeholders.md
Expand Up @@ -27,6 +27,12 @@ Which placeholder values are available depends on the context where the placehol
| `{%raw%}{{ thing:namespace }}{%endraw%}` | the namespace (i.e. first part of an ID) of the related thing |
| `{%raw%}{{ thing:name }}{%endraw%}` | the name (i.e. second part of an ID ) of the related thing |

### Thing JSON Placeholder

| Placeholder | Description |
|----------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `{%raw%}{{ thing-json:<json-pointer> }}{%endraw%}` | Value (in string representation) of the JSON identified by the provided ''json-pointer'' in JsonPointer notation - e.g., `thing-json:attributes/location` for the "location" attribute or `thing-json:features/temperature/properties/value` for the temperature property. |

### Feature Placeholder

| Placeholder | Description |
Expand Down Expand Up @@ -188,7 +194,7 @@ When [declaring extra fields](basic-enrichment.html) which should be enriched to
* [time placeholder](#time-placeholder)

### Scope: SSE Signal Enrichment
When [declaring extra fields](basic-enrichment.html) which should be enriched to a published signal for a Websocket connection, the following placeholders are available in general:
When [declaring extra fields](basic-enrichment.html) which should be enriched to a published signal for an SSE subscription, the following placeholders are available in general:
* [entity placeholder](#entity-placeholder)
* [thing placeholder](#thing-placeholder)
* [policy placeholder](#policy-placeholder)
Expand All @@ -204,6 +210,7 @@ When [declaring extra fields](basic-enrichment.html) which should be enriched to
In [connections](basic-connections.html), the following placeholders are available in general:
* [entity placeholder](#entity-placeholder)
* [thing placeholder](#thing-placeholder)
* [thing-json placeholder](#thing-json-placeholder)
* [policy placeholder](#policy-placeholder)
* [connection placeholder](#connection-placeholder)
* [feature placeholder](#feature-placeholder)
Expand Down Expand Up @@ -268,17 +275,22 @@ be placeholders again.

The following functions are provided by Ditto out of the box:

| Name | Signature | Description | Examples |
|-----------------------|------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|
| Name | Signature | Description | Examples |
|-----------------------|------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------|
| `fn:filter` | `(String filterValue, String rqlFunction, String comparedValue)` | Removes the result of the previous expression in the pipeline unless the condition specified by the parameters is satisfied.<br/>The first parameter `filterValue` may also be omitted in which case the 2 passed parameters will be appplied on the previous pipeline expression. | `fn:filter('like','allowlist1|foobar|include')` <br/>`fn:filter(header:response-required,'eq','true')` <br/> `fn:filter(header:response-required,'exists')` <br/> `fn:filter(header:response-required,'exists','false')` |
| `fn:default` | `(String defaultValue)` | Provides the passed `defaultValue` when the previous expression in a pipeline resolved to `empty` (e.g. due to a non-defined `header` placeholder key).<br/>Another placeholder may be specified which is resolved to a String and inserted as `defaultValue`. | `fn:default('fallback')`<br/>`fn:default("fallback")`<br/>`fn:default(thing:id)` |
| `fn:substring-before` | `(String givenString)` | Parses the result of the previous expression and passes along only the characters _before_ the first occurrence of `givenString`.<br/>If `givenString` is not contained, this function will resolve to `empty`. | `fn:substring-before(':')`<br/>`fn:substring-before(":")` |
| `fn:substring-after` | `(String givenString)` | Parses the result of the previous expression and passes along only the characters _after_ the first occurrence of `givenString`.<br/>If `givenString` is not contained, this function will resolve to `empty`. | `fn:substring-after(':')`<br/>`fn:substring-after(":")` |
| `fn:lower` | `()` | Makes the String result of the previous expression lowercase in total. | `fn:lower()` |
| `fn:upper` | `()` | Makes the String result of the previous expression uppercase in total. | `fn:upper()` |
| `fn:delete` | `()` | Deletes the result of the previous pipeline expression unconditionally. Any following expressions are ignored. | `fn:delete()` |
| `fn:replace` | `(String from, String to)` | Replaces a string with another using Java's `String::replace` method. | `fn:replace('foo', 'bar')` |
| `fn:split` | `(String separator)` | Splits the previous pipeline using the passed `separator` resulting an "array" pipeline output containing several elements.<br/>May only be used in combination with the [JWT placeholder](#scope-openid-connect-configuration) as input placeholder. | `fn:split(' ')`<br/>`fn:split(',')` |
| `fn:default` | `(String defaultValue)` | Provides the passed `defaultValue` when the previous expression in a pipeline resolved to `empty` (e.g. due to a non-defined `header` placeholder key).<br/>Another placeholder may be specified which is resolved to a String and inserted as `defaultValue`. | `fn:default('fallback')`<br/>`fn:default("fallback")`<br/>`fn:default(thing:id)` |
| `fn:substring-before` | `(String givenString)` | Parses the result of the previous expression and passes along only the characters _before_ the first occurrence of `givenString`.<br/>If `givenString` is not contained, this function will resolve to `empty`. | `fn:substring-before(':')`<br/>`fn:substring-before(":")` |
| `fn:substring-after` | `(String givenString)` | Parses the result of the previous expression and passes along only the characters _after_ the first occurrence of `givenString`.<br/>If `givenString` is not contained, this function will resolve to `empty`. | `fn:substring-after(':')`<br/>`fn:substring-after(":")` |
| `fn:lower` | `()` | Makes the String result of the previous expression lowercase in total. | `fn:lower()` |
| `fn:upper` | `()` | Makes the String result of the previous expression uppercase in total. | `fn:upper()` |
| `fn:trim` | `()` | Trims the String result of the previous expression, removing leading and trailing whitespaces. | `fn:trim()` |
| `fn:url-encode` | `()` | Applies URL encoding to the String result of the previous expression. | `fn:url-encode()` |
| `fn:url-decode` | `()` | Applies URL decoding to the String result of the previous expression. | `fn:url-decode()` |
| `fn:base64-encode` | `()` | Applies Base64 encoding to the String result of the previous expression. | `fn:base64-encode()` |
| `fn:base64-decode` | `()` | Applies Base64 decoding to the String result of the previous expression. | `fn:base64-decode()` |
| `fn:delete` | `()` | Deletes the result of the previous pipeline expression unconditionally. Any following expressions are ignored. | `fn:delete()` |
| `fn:replace` | `(String from, String to)` | Replaces a string with another using Java's `String::replace` method. | `fn:replace('foo', 'bar')` |
| `fn:split` | `(String separator)` | Splits the previous pipeline using the passed `separator` resulting an "array" pipeline output containing several elements.<br/>May only be used in combination with the [JWT placeholder](#scope-openid-connect-configuration) as input placeholder. | `fn:split(' ')`<br/>`fn:split(',')` |

### RQL functions

Expand Down

0 comments on commit b4612b7

Please sign in to comment.