-
Notifications
You must be signed in to change notification settings - Fork 235
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 new wot-models definition update endpoint #1843 #2103
add new wot-models definition update endpoint #1843 #2103
Conversation
aed41df
to
5d5b2f8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @hu-ahmed and thanks a lot for providing this PR.
Looks already really promising .. I did a quick check and left a few comments before going deeper :)
documentation/src/main/resources/openapi/sources/api-2-index.yml
Outdated
Show resolved
Hide resolved
documentation/src/main/resources/openapi/sources/api-2-index.yml
Outdated
Show resolved
Hide resolved
documentation/src/main/resources/openapi/sources/paths/things/thing.yml
Outdated
Show resolved
Hide resolved
...entation/src/main/resources/openapi/sources/schemas/things/migrateThingDefinitionRequest.yml
Outdated
Show resolved
Hide resolved
documentation/src/main/resources/pages/ditto/httpapi-concepts.md
Outdated
Show resolved
Hide resolved
...main/java/org/eclipse/ditto/things/model/signals/commands/modify/MigrateThingDefinition.java
Outdated
Show resolved
Hide resolved
...main/java/org/eclipse/ditto/things/model/signals/commands/modify/MigrateThingDefinition.java
Outdated
Show resolved
Hide resolved
...main/java/org/eclipse/ditto/things/model/signals/commands/modify/MigrateThingDefinition.java
Outdated
Show resolved
Hide resolved
...main/java/org/eclipse/ditto/things/model/signals/commands/modify/MigrateThingDefinition.java
Outdated
Show resolved
Hide resolved
...to/things/service/persistence/actors/strategies/commands/MigrateThingDefinitionStrategy.java
Outdated
Show resolved
Hide resolved
...to/things/service/persistence/actors/strategies/commands/MigrateThingDefinitionStrategy.java
Outdated
Show resolved
Hide resolved
...to/things/service/persistence/actors/strategies/commands/MigrateThingDefinitionStrategy.java
Outdated
Show resolved
Hide resolved
...to/things/service/persistence/actors/strategies/commands/MigrateThingDefinitionStrategy.java
Outdated
Show resolved
Hide resolved
...to/things/service/persistence/actors/strategies/commands/MigrateThingDefinitionStrategy.java
Outdated
Show resolved
Hide resolved
...to/things/service/persistence/actors/strategies/commands/MigrateThingDefinitionStrategy.java
Outdated
Show resolved
Hide resolved
...to/things/service/persistence/actors/strategies/commands/MigrateThingDefinitionStrategy.java
Outdated
Show resolved
Hide resolved
...to/things/service/persistence/actors/strategies/commands/MigrateThingDefinitionStrategy.java
Outdated
Show resolved
Hide resolved
...to/things/service/persistence/actors/strategies/commands/MigrateThingDefinitionStrategy.java
Outdated
Show resolved
Hide resolved
...to/things/service/persistence/actors/strategies/commands/MigrateThingDefinitionStrategy.java
Outdated
Show resolved
Hide resolved
...to/things/service/persistence/actors/strategies/commands/MigrateThingDefinitionStrategy.java
Outdated
Show resolved
Hide resolved
...to/things/service/persistence/actors/strategies/commands/MigrateThingDefinitionStrategy.java
Show resolved
Hide resolved
...to/things/service/persistence/actors/strategies/commands/MigrateThingDefinitionStrategy.java
Outdated
Show resolved
Hide resolved
...main/java/org/eclipse/ditto/things/model/signals/commands/modify/MigrateThingDefinition.java
Outdated
Show resolved
Hide resolved
...to/things/service/persistence/actors/strategies/commands/MigrateThingDefinitionStrategy.java
Outdated
Show resolved
Hide resolved
things/model/src/main/java/org/eclipse/ditto/things/model/signals/events/ThingMigrated.java
Outdated
Show resolved
Hide resolved
things/model/src/main/java/org/eclipse/ditto/things/model/signals/events/ThingMigrated.java
Outdated
Show resolved
Hide resolved
...n/java/org/eclipse/ditto/protocol/mappingstrategies/ThingMigratedEventMappingStrategies.java
Outdated
Show resolved
Hide resolved
things/model/src/main/java/org/eclipse/ditto/things/model/signals/events/ThingMigrated.java
Outdated
Show resolved
Hide resolved
things/model/src/main/java/org/eclipse/ditto/things/model/signals/events/ThingMigrated.java
Outdated
Show resolved
Hide resolved
...main/java/org/eclipse/ditto/things/model/signals/commands/modify/MigrateThingDefinition.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/eclipse/ditto/things/model/signals/events/ThingEventToThingConverter.java
Outdated
Show resolved
Hide resolved
things/model/src/main/java/org/eclipse/ditto/things/model/signals/events/ThingMigrated.java
Outdated
Show resolved
Hide resolved
things/model/src/main/java/org/eclipse/ditto/things/model/signals/events/ThingMigrated.java
Outdated
Show resolved
Hide resolved
...to/things/service/persistence/actors/strategies/commands/MigrateThingDefinitionStrategy.java
Outdated
Show resolved
Hide resolved
...to/things/service/persistence/actors/strategies/commands/MigrateThingDefinitionStrategy.java
Outdated
Show resolved
Hide resolved
...to/things/service/persistence/actors/strategies/commands/MigrateThingDefinitionStrategy.java
Outdated
Show resolved
Hide resolved
...to/things/service/persistence/actors/strategies/commands/MigrateThingDefinitionStrategy.java
Outdated
Show resolved
Hide resolved
581c93e
to
900b291
Compare
protocol/src/main/java/org/eclipse/ditto/protocol/adapter/MigrateCommandResponseAdapter.java
Outdated
Show resolved
Hide resolved
44384ae
to
6f4f59d
Compare
6f4f59d
to
89232f0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All review remarks were addressed.
Thanks for squashing into a single commit 👍
And thanks a lot for this great addition to the Ditto WoT integration @hu-ahmed
Resolves: #1843
The migrateThingDefinition endpoint introduces a comprehensive mechanism for migrating a Thing's definition while ensuring data consistency and applying necessary migrations. This endpoint is designed to facilitate seamless updates by incorporating a structured approach to definition changes and migration payloads.
Key Features:
Definition Update with Skeleton Generation:
The provided Thing definition URL is used to generate a new skeleton Thing, which serves as the baseline for the update.
The skeleton includes a hierarchical representation of the Thing, ensuring consistency with the WoT model.
Patch Condition Evaluation:
The migration payload can include multiple patch conditions, evaluated using RQL-based expressions to determine whether specific updates should be applied.
This allows for conditional updates based on existing Thing attributes or feature values.
Merging Strategy:
The update process merges the newly generated skeleton with the existing Thing while preserving essential attributes and properties.
An optional initialization step applies default values from the skeleton to fill in missing or incomplete properties.
Migration Payload Application:
The provided migration payload is selectively merged into the updated Thing, allowing for targeted modifications without overriding all properties.
Ensures data integrity by applying only necessary changes based on predefined rules.
Dry-Run Mode:
The API supports a dry-run option (dryRun: true), allowing users to simulate the migration without persisting changes.
Validation and Persistence:
Before finalizing the update, the modified Thing undergoes WoT model validation based on the current configuration, so either it will be rejected or logged as warning in case of inconsistency.
Ditto Protocols supported:
this command is also available for other ditto protocols
API Usage:
Endpoint:
POST /api/2/things/{thingId}/migrateDefinition
Request Body: