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

Convenient creation of parent objects for modify commands with nested JSON paths #701

Open
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, it shall be supported to create/modify nested JSON fields inside a thing without the need that their parents in the JSON are create before.

Currently, when you have the following thing JSON (which you can do, this is valid):

{
  "thingId": "org.eclipse.ditto:my-thermostat-1",
  "policyId": "org.eclipse.ditto:my-thermostat-1",
  "features": {
    "Thermostat": {
      "definition": [ "org.eclipse.ditto:Thermostat:1.0.0" ]
    }
  }
}

it is not possible to "just" create the "on" property with the following HTTP PUT request:

PUT /api/2/things/org.eclipse.ditto:my-thermostat-1/features/Thermostat/properties/on
true

Up to now, you would get a HTTP error 404 (not found) as the properties object was not yet created.

This shall be simplified by automatically creating missing JSON objects, which also the desired properties API will benefit from.
There, when you want to create one single desired property, you would just have to make an HTTP call:

PUT /api/2/things/org.eclipse.ditto:my-thermostat-1/features/Thermostat/desired/configuration/target-temperature
22.0

This API call will be accepted and the thing JSON will look like:

{
  "thingId": "org.eclipse.ditto:my-thermostat-1",
  "policyId": "org.eclipse.ditto:my-thermostat-1",
  "features": {
    "Thermostat": {
      "definition": [ "org.eclipse.ditto:Thermostat:1.0.0" ],
      "desired": {
        "configuration": {
          "target-temperature": 22.0
        }
      }
    }
  }
}
@thjaeckle
Copy link
Member Author

When using the merge thing done in #950 the implicit convenient creation of parent objects already exists.

So we might also close this issue.

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