7
7
from ..views import View
8
8
9
9
10
+
10
11
class ActionQueueView (View ):
11
12
"""List of all actions from the session"""
12
13
13
14
def get (self ):
14
15
"""Action queue
15
- ---
16
- description: Queue of most recent actions in the session
17
- summary: Queue of most recent actions in the session
18
- responses:
19
- 200:
20
- content:
21
- application/json:
22
- schema: ActionSchema
16
+
17
+ This endpoint returns a list of all actions that have run since
18
+ the server was started, including ones that have completed and
19
+ actions that are still running. Each entry includes links to
20
+ manage and inspect that action.
23
21
"""
24
22
return ActionSchema (many = True ).dump (current_labthing ().actions .threads )
23
+ get .responses = {
24
+ "200" : {
25
+ "description" : "List of Action objects" ,
26
+ "content" : {
27
+ "application/json" : {
28
+ "schema" : ActionSchema (many = True )
29
+ }
30
+ }
31
+ }
32
+ }
25
33
26
34
27
35
class ActionObjectView (View ):
@@ -35,14 +43,10 @@ class ActionObjectView(View):
35
43
36
44
def get (self , task_id ):
37
45
"""Show the status of an Action
38
- ---
39
- description: Status of an Action
40
- summary: Status of an Action
41
- responses:
42
- 200:
43
- content:
44
- application/json:
45
- schema: ActionSchema
46
+
47
+ A `GET` request will return the current status
48
+ of an action, including logs. For completed
49
+ actions, it will include the return value.
46
50
"""
47
51
task_dict = current_labthing ().actions .to_dict ()
48
52
@@ -52,18 +56,25 @@ def get(self, task_id):
52
56
task = task_dict .get (task_id )
53
57
54
58
return ActionSchema ().dump (task )
59
+ get .responses = {
60
+ "200" : {
61
+ "description" : "Action object" ,
62
+ "content" : {
63
+ "application/json" : {
64
+ "schema" : ActionSchema
65
+ }
66
+ }
67
+ },
68
+ "404" : {
69
+ "description" : "Action not found"
70
+ }
71
+ }
55
72
56
73
@use_args ({"timeout" : fields .Int ()})
57
74
def delete (self , args , task_id ):
58
75
"""Cancel a running Action
59
- ---
60
- description: Cancel an Action
61
- summary: Cancel an Action
62
- responses:
63
- 200:
64
- content:
65
- application/json:
66
- schema: ActionSchema
76
+
77
+ A `DELETE` request will stop a running action.
67
78
"""
68
79
timeout = args .get ("timeout" , None )
69
80
task_dict = current_labthing ().actions .to_dict ()
@@ -74,3 +85,16 @@ def delete(self, args, task_id):
74
85
task = task_dict .get (task_id )
75
86
task .stop (timeout = timeout )
76
87
return ActionSchema ().dump (task )
88
+ delete .responses = {
89
+ "200" : {
90
+ "description" : "Action object that was cancelled" ,
91
+ "content" : {
92
+ "application/json" : {
93
+ "schema" : ActionSchema
94
+ }
95
+ }
96
+ },
97
+ "404" : {
98
+ "description" : "Action not found"
99
+ }
100
+ }
0 commit comments