You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve logging and status reporting of actions (#155)
* Add operation field in log context of most actions logging
* Replace action execution status with typed Operation
* Document and add specific for actions return values
* Rewrite Operations enum with Graham's pattern
* Return True/False instead of operation
* Log level has to be set explicitly in tests
* Update action docs
Copy file name to clipboardExpand all lines: src/jbi/whiteboard_actions/README.md
+10-2Lines changed: 10 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,13 +7,21 @@ Let's create a `new_action`!
7
7
1. First, add a new Python file (eg. `my_team_action.py`) in the `src/jbi/whiteboard_actions/` directory.
8
8
1. Add the Python function `init` to the module, for example:
9
9
```python
10
+
from src.jbi import ActionResult, Operation
11
+
10
12
definit(jira_project_key, optional_param=42):
11
-
returnlambdapayload: print(f"{optional_param}, going to {jira_project_key}!")
13
+
14
+
defexecute(payload) -> ActionResult:
15
+
print(f"{optional_param}, going to {jira_project_key}!")
16
+
returnTrue, {"result": 42}
17
+
18
+
return execute
12
19
```
13
20
1. In the above example the `jira_project_key` parameter is required
14
21
1. `optional_param`, which has a default value, isnot required to run this action
15
22
1. `init()` returns a `__call__`able object that the system calls with the Bugzilla request payload
23
+
1. The returned `ActionResult` features a boolean to indicate whether something was performed ornot, along with a `Dict` (used as a response to the WebHook endpoint).
16
24
1. Use the `payload` to perform the desired processing!
17
-
1. Use the available service calls from`src/jbi/services.py' (or make new ones)
25
+
1. Use the available service calls from`src/jbi/services.py` (or make new ones)
18
26
1. Update the `README.md` to document your action
19
27
1. Now the action `src.jbi.whiteboard_actions.my_team_actions` can be used in the YAML configuration, under the `module` key.
0 commit comments