Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add placeholder for accessing thing values in connections #1727

Closed
thjaeckle opened this issue Aug 24, 2023 · 0 comments · Fixed by #1749
Closed

Add placeholder for accessing thing values in connections #1727

thjaeckle opened this issue Aug 24, 2023 · 0 comments · Fixed by #1749
Assignees
Milestone

Comments

@thjaeckle
Copy link
Member

thjaeckle commented Aug 24, 2023

Currently, connections can make use of various placeholders to e.g. construct the "address" (e.g. a URL) to invoke.

Example of a "http-push" connection target:

{
  ...
  "targets": [{
    "address": "POST:/my-endpoint/{{thing:name}}/foo/{{header:bar}}",
    "topics": ["_/_/things/live/messages"],
    "authorizationContext": ["integration:ditto"],
    "issuedAcknowledgementLabel": "live-response",
    "headerMapping": {}
  }],
  ...
}

What however is not yet possible (without specifying a custom JavaScript payload mapper), is to access e.g. metadata of the thing to construct the endpoint.

For example, if the current weather for a "thing" shall be retrievable by sending a message to the digital twin, it would be very convenient to just be able to configure:

{
  ...
  "targets": [{
    "address": "GET:/weather?longitude={{thing-json:attributes/location/lon}}&latitude={{thing-json:attributes/location/lat}}",
    "topics": ["_/_/things/live/messages?filter=eq(topic:subject,'retrieve-weather')&extraFields=attributes/location"],
    "authorizationContext": ["integration:ditto"],
    "issuedAcknowledgementLabel": "live-response",
    "headerMapping": {}
  }],
  ...
}

Assuming the thing contains the longitude and latitude in its attributes like:

{
  "thingId": "bum:lux",
  "attributes": {
    "location": {
      "lon": -77.0364,
      "lat": 38.8951
    }
  }
}

One could simply retrieve the weather of the twin by invoking:

POST /api/2/things/bum:lux/inbox/messages/retrieve-weather

In order to achieve that, we "simply" need a new Placeholder resolver, being able to access the thing's payload (also via extraFields).

thjaeckle added a commit that referenced this issue Sep 12, 2023
* purpose: resolve placeholders in e.g. the "address" based on either the payload of a changed thing or the "extraFields" of changed thing / dispatched message

Signed-off-by: Thomas Jäckle <thomas.jaeckle@beyonnex.io>
@thjaeckle thjaeckle added this to the 3.4.0 milestone Sep 12, 2023
@thjaeckle thjaeckle self-assigned this Sep 14, 2023
thjaeckle added a commit that referenced this issue Sep 14, 2023
Signed-off-by: Thomas Jäckle <thomas.jaeckle@beyonnex.io>
thjaeckle added a commit that referenced this issue Sep 15, 2023
* fn:trim()
* fn:url-encode()
* fn:url-decode()
* fn:base64-encode()
* fn:base64-decode()

Signed-off-by: Thomas Jäckle <thomas.jaeckle@beyonnex.io>
thjaeckle added a commit that referenced this issue Sep 15, 2023
…functions

Signed-off-by: Thomas Jäckle <thomas.jaeckle@beyonnex.io>
thjaeckle added a commit that referenced this issue Sep 15, 2023
Signed-off-by: Thomas Jäckle <thomas.jaeckle@beyonnex.io>
thjaeckle added a commit that referenced this issue Sep 18, 2023
…older

#1727 add new "thing-json" placeholder to be used in connections
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant