-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds examples for CreateThing and ModifyThing to demonstrate _copyPol…
…icyFrom Signed-off-by: Klem Yannic (INST/ECS1) <Yannic.Klem@bosch-si.com>
- Loading branch information
Showing
5 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...n/src/main/resources/pages/ditto/protocol/things/commands/modify/creatething.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...esources/pages/ditto/protocol/things/commands/modify/createthingalternatives.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
## Alternative CreateThing commands | ||
|
||
If you want to copy an Existing policy instead of creating a new one by yourself or reference an existing Policy, you | ||
can adjust the CreateThing command like demonstrated in the following examples. | ||
|
||
### CreateThing with copied Policy by Policy ID | ||
|
||
Creates a new Thing with ID ``com.acme:xdk_53`` with a Policy copied from the Policy with ID ``com.acme:the_policy_id_to_copy``. | ||
|
||
```json | ||
{ | ||
"topic": "com.acme/xdk_53/things/twin/commands/create", | ||
"headers": {}, | ||
"path": "/", | ||
"value": { | ||
"__schemaVersion": 2, | ||
"__lifecycle": "ACTIVE", | ||
"_revision": 1, | ||
"_namespace": "com.acme", | ||
"thingId": "com.acme:xdk_53", | ||
"policyId": "com.acme:the_policy_id", | ||
"_copyPolicyFrom": "com:acme:the_policy_id_to_copy" | ||
} | ||
} | ||
``` | ||
|
||
### CreateThing with copied Policy by Thing reference | ||
|
||
Creates a new Thing with ID ``com.acme:xdk_53`` with a Policy copied from a Thing with ID ``com.acme:xdk_52``. | ||
|
||
```json | ||
{ | ||
"topic": "com.acme/xdk_53/things/twin/commands/create", | ||
"headers": {}, | ||
"path": "/", | ||
"value": { | ||
"__schemaVersion": 2, | ||
"__lifecycle": "ACTIVE", | ||
"_revision": 1, | ||
"_namespace": "com.acme", | ||
"thingId": "com.acme:xdk_53", | ||
"policyId": "com.acme:the_policy_id", | ||
"_copyPolicyFrom": "{% raw %}{{ ref:things/com:acme:xdk_52/policyId }}{% endraw %}" | ||
} | ||
} | ||
``` |
50 changes: 50 additions & 0 deletions
50
...esources/pages/ditto/protocol/things/commands/modify/modifythingalternatives.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
## Alternative ModifyThing commands | ||
|
||
If you want to copy an Existing policy instead of creating a new one by yourself or reference an existing Policy, you | ||
can adjust the ModifyThing command like demonstrated in the following examples. | ||
This only works if a Thing with the given ``thingId`` does not exist, yet. If it exists the ``_copyPolicyFrom`` field | ||
will be ignored. | ||
|
||
### ModifyThing with copied Policy by Policy ID | ||
|
||
If no Thing with ID ``com.acme:xdk_53`` exists, this command will create a new Thing with ID ``com.acme:xdk_53`` with a | ||
Policy copied from the Policy with ID ``com.acme:the_policy_id_to_copy``. | ||
|
||
```json | ||
{ | ||
"topic": "com.acme/xdk_53/things/twin/commands/modify", | ||
"headers": {}, | ||
"path": "/", | ||
"value": { | ||
"__schemaVersion": 2, | ||
"__lifecycle": "ACTIVE", | ||
"_revision": 1, | ||
"_namespace": "com.acme", | ||
"thingId": "com.acme:xdk_53", | ||
"policyId": "com.acme:the_policy_id", | ||
"_copyPolicyFrom": "com:acme:the_policy_id_to_copy" | ||
} | ||
} | ||
``` | ||
|
||
### ModifyThing with copied Policy by Thing reference | ||
|
||
If no Thing with ID ``com.acme:xdk_53`` exists, this command will create a new Thing with ID ``com.acme:xdk_53`` with a | ||
Policy copied from a Thing with ID ``com.acme:xdk_52``. | ||
|
||
```json | ||
{ | ||
"topic": "com.acme/xdk_53/things/twin/commands/modify", | ||
"headers": {}, | ||
"path": "/", | ||
"value": { | ||
"__schemaVersion": 2, | ||
"__lifecycle": "ACTIVE", | ||
"_revision": 1, | ||
"_namespace": "com.acme", | ||
"thingId": "com.acme:xdk_53", | ||
"policyId": "com.acme:the_policy_id", | ||
"_copyPolicyFrom": "{% raw %}{{ ref:things/com:acme:xdk_52/policyId }}{% endraw %}" | ||
} | ||
} | ||
``` |