1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
//! This module defines the API query, request body and response body
//! schema for this crate and its server by means of serde serializable
//! and deserializable rust structs.
use ;
use Duration;
pub const VERSION: &str = env!;
/// The json-response schema for `GET /api/info`.
///
/// # Serialized Example
/// ```
/// # let ser = r#"
/// {
/// "os_type": "Unix",
/// "computer_name": "GLaDOS",
/// "api_version": "2.0.0"
/// }
/// # "#;
/// # let deser: rusty_runner_api::api::InfoResponse
/// # = serde_json::from_str(ser).expect("failed parsing");
/// # assert_eq!(deser.computer_name, "GLaDOS");
/// # assert_eq!(deser.api_version, rusty_runner_api::api::VERSION);
/// ```
/// The OS type as given by `#[cfg(windows)]` and `#[cfg(unix)]`.
/// The json-body schema for `POST /api/run`.
///
/// # Serialized Example
/// ```
/// # let ser = r#"
/// {
/// "command": "echo",
/// "arguments": [
/// "Hello",
/// "World"
/// ],
/// "return_stderr": true,
/// "return_stdout": false
///}
/// # "#;
/// # let deser: rusty_runner_api::api::RunRequest
/// # = serde_json::from_str(ser).expect("failed parsing");
/// # assert_eq!(deser.command, "echo");
/// ```
/// The query schema for `POST /api/runscript`.
///
/// # Serialized Example
/// ```
/// # let ser = r#"
/// interpreter=bash&return_stderr=true
/// # "#;
/// # let deser: rusty_runner_api::api::RunScriptQuery
/// # = serde_urlencoded::from_str(ser.trim()).expect("failed parsing");
/// # assert!(matches!(deser.interpreter, rusty_runner_api::api::ScriptInterpreter::Bash));
/// ```
/// The interpreter that the script will be called with.
///
/// Not all interpreters may be supported by any runner.
/// The json response format for `/api/run` and `/api/runscript`.
///
/// # Serialized Examples
/// A completed command:
/// ```
/// # let ser = r#"
/// {
/// "id": 73001,
/// "status": "Completed",
/// "exit_code": 1,
/// "time_taken": {
/// "secs": 21,
/// "nanos": 800000
/// }
/// }
/// # "#;
/// # let deser: rusty_runner_api::api::RunResponse
/// # = serde_json::from_str(ser).expect("failed parsing");
/// # assert!(matches!(deser.status, rusty_runner_api::api::RunStatus::Completed { .. }));
/// ```
/// A command that could not be executed:
/// ```
/// # let ser = r#"
/// {
/// "id": 1234567890,
/// "status": "Failure",
/// "reason": "Not supported"
/// }
/// # "#;
/// # let deser: rusty_runner_api::api::RunResponse
/// # = serde_json::from_str(ser).expect("failed parsing");
/// # assert!(matches!(deser.status, rusty_runner_api::api::RunStatus::Failure { .. }));
/// ```
/// The outcome of a command.
///
/// If the command could be started, then this is a [`Completed`](RunStatus::Completed)
/// even if the command itself exited non-successfully.
/// Otherwise this is [`Failure`](RunStatus::Failure).