-
Notifications
You must be signed in to change notification settings - Fork 67
feat: allow operation handlers to match on json payloads #3144
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
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
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Operations
Operation
OnMessageExec
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would help. The file is currently organized upside down, from the details to the main point.
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.
Approved
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
-506
messages to update operation statusskip_status_update = true
optionTodo:
skip_status_update
optionWill be done in follow-up:
Example usage:
Install
c8y-command-plugin
and modify/etc/tedge/operations/c8y/c8y_Command
as below.Then, try Shell tab in c8y.
Types of changes
Paste Link to the issue
#3095 "Drop 1"
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments