@@ -739,6 +739,101 @@ paths:
739
739
$ref : ' #/components/responses/PreconditionFailed'
740
740
' 424 ' :
741
741
$ref : ' #/components/responses/DependencyFailed'
742
+ ' /api/2/things/{thingId}/migrateDefinition ' :
743
+ post :
744
+ summary : Update the definition of an existing Thing
745
+ description : |-
746
+ Updates the definition of the specified thing by providing a new definition URL along with an optional migration payload.
747
+
748
+ The request body allows specifying:
749
+ - A new Thing definition URL.
750
+ - A migration payload containing updates to attributes and features.
751
+ - Patch conditions to ensure consistent updates.
752
+ - Whether properties should be initialized if missing.
753
+
754
+ If the `dry-run` query parameter or header is set to `true`, the request will return the calculated migration result without applying any changes.
755
+
756
+ ### Example:
757
+ ```json
758
+ {
759
+ "thingDefinitionUrl": "https://example.com/new-thing-definition.json",
760
+ "migrationPayload": {
761
+ "attributes": {
762
+ "manufacturer": "New Corp"
763
+ },
764
+ "features": {
765
+ "sensor": {
766
+ "properties": {
767
+ "status": {
768
+ "temperature": {
769
+ "value": 25.0
770
+ }
771
+ }
772
+ }
773
+ }
774
+ }
775
+ },
776
+ "patchConditions": {
777
+ "thing:/features/sensor": "not(exists(/features/sensor))"
778
+ },
779
+ "initializeMissingPropertiesFromDefaults": true
780
+ }
781
+ ```
782
+ tags :
783
+ - Things
784
+ parameters :
785
+ - $ref : ' #/components/parameters/ThingIdPathParam'
786
+ - name : dry-run
787
+ in : query
788
+ description : ' If set to `true`, performs a dry-run and returns the migration result without applying changes.'
789
+ required : false
790
+ schema :
791
+ type : boolean
792
+ default : false
793
+ requestBody :
794
+ description : ' JSON payload containing the new definition URL, migration payload, patch conditions, and initialization flag.'
795
+ required : true
796
+ content :
797
+ application/json :
798
+ schema :
799
+ $ref : ' #/components/requestBodies/MigrateThingDefinitionRequest/content/application~1json/schema'
800
+ responses :
801
+ ' 200 ' :
802
+ description : ' The thing definition was successfully updated, and the updated Thing is returned.'
803
+ content :
804
+ application/json :
805
+ schema :
806
+ $ref : ' #/components/responses/MigrateThingDefinitionResponse/content/application~1json/schema'
807
+ ' 202 ' :
808
+ description : Dry-run successful. The migration result is returned without applying changes.
809
+ content :
810
+ application/json :
811
+ schema :
812
+ $ref : ' #/components/responses/MigrateThingDefinitionResponse/content/application~1json/schema'
813
+ ' 400 ' :
814
+ description : The request could not be processed due to invalid input.
815
+ content :
816
+ application/json :
817
+ schema :
818
+ $ref : ' #/components/schemas/AdvancedError'
819
+ ' 401 ' :
820
+ description : Unauthorized request due to missing authentication.
821
+ content :
822
+ application/json :
823
+ schema :
824
+ $ref : ' #/components/schemas/AdvancedError'
825
+ ' 404 ' :
826
+ description : The specified thing could not be found.
827
+ content :
828
+ application/json :
829
+ schema :
830
+ $ref : ' #/components/schemas/AdvancedError'
831
+ ' 412 ' :
832
+ description : The update conditions were not met.
833
+ content :
834
+ application/json :
835
+ schema :
836
+ $ref : ' #/components/schemas/AdvancedError'
742
837
' /api/2/things/{thingId}/definition ' :
743
838
get :
744
839
summary : Retrieve the definition of a specific thing
@@ -8212,6 +8307,59 @@ components:
8212
8307
randomizationInterval : 5m
8213
8308
description : Optional request payload for `activateTokenIntegration` policy action.
8214
8309
required : false
8310
+ MigrateThingDefinitionRequest :
8311
+ content :
8312
+ application/json :
8313
+ schema :
8314
+ type : object
8315
+ description : JSON payload to migrate the definition of a Thing.
8316
+ properties :
8317
+ thingDefinitionUrl :
8318
+ type : string
8319
+ format : uri
8320
+ description : The URL of the new Thing definition to be applied.
8321
+ example : ' https://models.example.com/thing-definition-1.0.0.tm.jsonld'
8322
+ migrationPayload :
8323
+ type : object
8324
+ description : Optional migration payload with updates to attributes and features.
8325
+ properties :
8326
+ attributes :
8327
+ type : object
8328
+ additionalProperties : true
8329
+ description : Attributes to be updated in the thing.
8330
+ example :
8331
+ manufacturer : New Corp
8332
+ location : ' Berlin, main floor'
8333
+ features :
8334
+ type : object
8335
+ additionalProperties :
8336
+ type : object
8337
+ properties :
8338
+ properties :
8339
+ type : object
8340
+ additionalProperties : true
8341
+ description : Features to be updated in the thing.
8342
+ example :
8343
+ thermostat :
8344
+ properties :
8345
+ status :
8346
+ temperature :
8347
+ value : 23.5
8348
+ unit : DEGREE_CELSIUS
8349
+ patchConditions :
8350
+ type : object
8351
+ description : Optional conditions to apply the migration only if the existing thing matches the specified values.
8352
+ additionalProperties :
8353
+ type : string
8354
+ example :
8355
+ ' thing:/features/thermostat ' : not(exists(/features/thermostat))
8356
+ initializeMissingPropertiesFromDefaults :
8357
+ type : boolean
8358
+ description : Flag indicating whether missing properties should be initialized with default values.
8359
+ example : true
8360
+ default : false
8361
+ required :
8362
+ - thingDefinitionUrl
8215
8363
responses :
8216
8364
EntityTooLarge :
8217
8365
description : The created or modified entity is larger than the accepted limit of 100 kB.
@@ -8300,6 +8448,41 @@ components:
8300
8448
application/json :
8301
8449
schema :
8302
8450
$ref : ' #/components/schemas/ModuleUpdatedLogLevel'
8451
+ MigrateThingDefinitionResponse :
8452
+ description : ' The thing definition was successfully updated, and the updated Thing is returned.'
8453
+ content :
8454
+ application/json :
8455
+ schema :
8456
+ type : object
8457
+ description : Response payload after applying or simulating a migration to a Thing.
8458
+ properties :
8459
+ thingId :
8460
+ type : string
8461
+ description : Unique identifier representing the migrated Thing.
8462
+ patch :
8463
+ type : object
8464
+ description : The patch containing updates to the Thing.
8465
+ properties :
8466
+ definition :
8467
+ $ref : ' #/components/schemas/Definition'
8468
+ attributes :
8469
+ $ref : ' #/components/schemas/Attributes'
8470
+ features :
8471
+ $ref : ' #/components/schemas/Features'
8472
+ mergeStatus :
8473
+ type : string
8474
+ description : |
8475
+ Indicates the result of the migration process.
8476
+ - `APPLIED`: The migration was successfully applied.
8477
+ - `DRY_RUN`: The migration result was calculated but not applied.
8478
+ enum :
8479
+ - APPLIED
8480
+ - DRY_RUN
8481
+ example : APPLIED
8482
+ required :
8483
+ - thingId
8484
+ - patch
8485
+ - mergeStatus
8303
8486
parameters :
8304
8487
AllowPolicyLockoutParam :
8305
8488
name : allow-policy-lockout
0 commit comments