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

Support wildcard in "fields" selectors in order to receive all "desired" properties of all features of a thing #700

Closed
thjaeckle opened this issue Jun 18, 2020 · 1 comment

Comments

@thjaeckle
Copy link
Member

thjaeckle commented Jun 18, 2020

As part of #696, but also as a general useful enhancement of Ditto, the "fields" selector which can be used to perform partial requests with field selector shall support the wildcard _ (similarly to MQTT, targeting only 1 level) in order to define "anything" for a certain JSON pointer segment.

In scope of the "desired" project

Such queries are needed in order to get all the (unapplied) "desiredProperties" of a thing, e.g. with such a query:

GET /api/2/things/org.eclipse.ditto:my-thermostat-1?fields=features/_/desiredProperties

When using the search API, also all "desiredProperties" fields may be selected as result of the search:

GET /api/2/search/things?filter=like(attributes/manufacturer,"ACME*")&fields=features/_/desiredProperties

In general

That is very useful when feature names of a thing are unknown and special parts of all features shall be retrieved with one command.

Example: For the given thing JSON:

{
  "thingId": "org.eclipse.ditto:traffic-light",
  "policyId": "org.eclipse.ditto:traffic-light",
  "features": {
    "red-lamp": {
      "properties": {
        "on": true,
        "color": "red"
      }
    },
    "yellow-lamp": {
      "properties": {
        "on": true,
        "color": "yellow"
      }
    },
    "green-lamp": {
      "properties": {
        "on": false,
        "color": "green"
      }
    }
  }
}

The goal is to get only the "on" properties of all lamps of a traffic light.

That could be done with the following HTTP request:

GET /api/2/things/org.eclipse.ditto:traffic-light?fields=features/_/properties/on
@thjaeckle
Copy link
Member Author

This should be already available via the recently done PR #1277

Syntax:

GET /api/2/things/org.eclipse.ditto:my-thermostat-1?fields=features/*/desiredProperties

GET /api/2/things/org.eclipse.ditto:traffic-light?fields=features/*/properties/on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant