feat: allow operation handlers to match on json payloads#3144
Conversation
Codecov ReportAttention: Patch coverage is Additional details and impacted files📢 Thoughts on this report? Let us know! |
844609b to
55446c8
Compare
Robot Results
|
55446c8 to
af45393
Compare
...RobotFramework/tests/cumulocity/custom_operation/custom_operation_command/command_handler.sh
Outdated
Show resolved
Hide resolved
didier-wenzek
left a comment
There was a problem hiding this comment.
Still some required work.
| /// Operations are derived by reading files subdirectories per cloud /etc/tedge/operations directory | ||
| /// Each operation is a file name in one of the subdirectories | ||
| /// The file name is the operation name | ||
|
|
||
| #[derive(Debug, Clone, Deserialize, Eq, PartialEq)] | ||
| #[serde(rename_all = "snake_case")] | ||
| pub struct OnMessageExec { |
There was a problem hiding this comment.
This doc comment is attached to the wrong struct.
I would move the struct Operation declaration here. i.e. before the struct OnMessageExec definition.
Even better: Operations first.
OperationsOperationOnMessageExec
There was a problem hiding this comment.
I agree, but I prefer to do as you suggested after this PR, otherwise moving struct and changes will be mixed. Or really before merging this PR with a single dedicated commit for the refactoring.
There was a problem hiding this comment.
This would help. The file is currently organized upside down, from the details to the main point.
The extension of custom operation handler makes easy to use c8y custom operations in thin-edge. Users no longer have to create custom SmartREST templates. Changes: - custom operation handler can accept JSON over MQTT topic - command field accepts arguments from JSON payload, same format as operation workflow Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
Signed-off-by: Krzysztof Piotrowski <krzysztof.piotrowski@inetum.com>
If this key is set to `true` (default `false`), c8y-mapper will execute the command, but it'll not send operation status update messages to c8y Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
024813d to
9262b33
Compare
|
If there is a custom operation handlers with invalid contents, you may see multiple times of the same warning message as below. WARN c8y_api::smartrest::operations: ''command' is missing in the JSON custom operation handler mapping 'my_CustomOperation'This is caused by too many loadings of the |
|
Review done, implemented as described, the tests/RobotFramework/tests/cumulocity/custom_operation/custom_operation_command/custom_operation_command.robot |
Proposed changes
The extension of custom operation handler makes it easy to use c8y custom operations in thin-edge. Users no longer have to create custom SmartREST templates.
Changes:
504-506messages to update operation statusskip_status_update = trueoptionTodo:
skip_status_updateoptionWill be done in follow-up:
Example usage:
Install
c8y-command-pluginand modify/etc/tedge/operations/c8y/c8y_Commandas below.Then, try Shell tab in c8y.
Types of changes
Paste Link to the issue
#3095 "Drop 1"
Checklist
cargo fmtas mentioned in CODING_GUIDELINEScargo clippyas mentioned in CODING_GUIDELINESFurther comments