komodo_client 2.3.1

Client for the Komodo build and deployment system
Documentation
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
use mogh_resolver::Resolve;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;

use crate::entities::{
  I64, Timelength, U64,
  server::{
    PeripheryInformation, Server, ServerActionState, ServerListItem,
    ServerQuery, ServerSortBy, ServerState,
  },
  stats::{
    SystemInformation, SystemProcess, SystemStats, SystemStatsRecord,
  },
};

use super::KomodoReadRequest;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/GetServer",
  description = "Get a specific server.",
  request_body(content = GetServer),
  responses(
    (status = 200, description = "The server", body = crate::entities::server::ServerSchema),
  ),
)]
pub fn get_server() {}

/// Get a specific server. Response: [Server].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(Server)]
#[error(mogh_error::Error)]
pub struct GetServer {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub server: String,
}

#[typeshare]
pub type GetServerResponse = Server;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/ListServers",
  description = "List servers matching optional query.",
  request_body(content = ListServers),
  responses(
    (status = 200, description = "The list of servers", body = ListServersResponse),
  ),
)]
pub fn list_servers() {}

/// List servers matching optional query. Response: [ListServersResponse].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Default, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListServersResponse)]
#[error(mogh_error::Error)]
pub struct ListServers {
  /// optional structured query to filter servers.
  #[serde(default)]
  pub query: ServerQuery,

  /// Retrieve more results by incrementing the page.
  /// `page: 0` is default.
  #[serde(default)]
  pub page: U64,

  /// Set the limit for number of resources per-page.
  /// If not provided, uses the Core config
  /// `default_pagination_limit` (default: 30).
  ///
  /// Passing `limit: 0` returns all results (unlimited).
  ///
  /// Note: the page logic relies on this being consistent
  /// across queries for more pages.
  pub limit: Option<U64>,

  /// Sort the results by this field.
  /// Defaults to Name. Non-Name sorts are applied in memory
  /// after querying all matching resources.
  #[serde(default)]
  pub sort_by: ServerSortBy,

  /// Reverse the sort direction.
  #[serde(default)]
  pub sort_desc: bool,
}

#[typeshare]
pub type ListServersResponse = Vec<ServerListItem>;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/ListFullServers",
  description = "List servers matching optional query.",
  request_body(content = ListFullServers),
  responses(
    (status = 200, description = "The list of servers", body = ListFullServersResponse),
  ),
)]
pub fn list_full_servers() {}

/// List servers matching optional query. Response: [ListFullServersResponse].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Default, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListFullServersResponse)]
#[error(mogh_error::Error)]
pub struct ListFullServers {
  /// optional structured query to filter servers.
  #[serde(default)]
  pub query: ServerQuery,

  /// Retrieve more results by incrementing the page.
  /// `page: 0` is default.
  #[serde(default)]
  pub page: U64,

  /// Set the limit for number of resources per-page.
  /// If not provided, uses the Core config
  /// `default_pagination_limit` (default: 30).
  ///
  /// Passing `limit: 0` returns all results (unlimited).
  ///
  /// Note: the page logic relies on this being consistent
  /// across queries for more pages.
  pub limit: Option<U64>,
}

#[typeshare]
pub type ListFullServersResponse = Vec<Server>;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/GetServerState",
  description = "Get the state of the target server.",
  request_body(content = GetServerState),
  responses(
    (status = 200, description = "The server state", body = GetServerStateResponse),
  ),
)]
pub fn get_server_state() {}

/// Get the state of the target server. Response: [GetServerStateResponse].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetServerStateResponse)]
#[error(mogh_error::Error)]
pub struct GetServerState {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub server: String,
}

/// The response for [GetServerState].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct GetServerStateResponse {
  /// The server status.
  pub status: ServerState,
}

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/GetServerActionState",
  description = "Get current action state for the servers.",
  request_body(content = GetServerActionState),
  responses(
    (status = 200, description = "The server action state", body = GetServerActionStateResponse),
  ),
)]
pub fn get_server_action_state() {}

/// Get current action state for the servers. Response: [ServerActionState].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ServerActionState)]
#[error(mogh_error::Error)]
pub struct GetServerActionState {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub server: String,
}

#[typeshare]
pub type GetServerActionStateResponse = ServerActionState;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/GetPeripheryInformation",
  description = "Get the Periphery information of the target server, including the Periphery version and public key.",
  request_body(content = GetPeripheryInformation),
  responses(
    (status = 200, description = "The periphery information", body = GetPeripheryInformationResponse),
  ),
)]
pub fn get_periphery_information() {}

/// Get the Periphery information of the target server,
/// including the Periphery version and public key.
/// Response: [PeripheryInformation].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetPeripheryInformationResponse)]
#[error(mogh_error::Error)]
pub struct GetPeripheryInformation {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub server: String,
}

#[typeshare]
pub type GetPeripheryInformationResponse = PeripheryInformation;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/GetSystemInformation",
  description = "Get the system information of the target server.",
  request_body(content = GetSystemInformation),
  responses(
    (status = 200, description = "The system information", body = GetSystemInformationResponse),
  ),
)]
pub fn get_system_information() {}

/// Get the system information of the target server.
/// Response: [SystemInformation].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetSystemInformationResponse)]
#[error(mogh_error::Error)]
pub struct GetSystemInformation {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub server: String,
}

#[typeshare]
pub type GetSystemInformationResponse = SystemInformation;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/GetSystemStats",
  description = "Get the system stats on the target server.",
  request_body(content = GetSystemStats),
  responses(
    (status = 200, description = "The system stats", body = GetSystemStatsResponse),
  ),
)]
pub fn get_system_stats() {}

/// Get the system stats on the target server. Response: [SystemStats].
///
/// Note. This does not hit the server directly. The stats come from an
/// in memory cache on the core, which hits the server periodically
/// to keep it up to date.
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetSystemStatsResponse)]
#[error(mogh_error::Error)]
pub struct GetSystemStats {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub server: String,
}

#[typeshare]
pub type GetSystemStatsResponse = SystemStats;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/ListSystemProcesses",
  description = "List the processes running on the target server.",
  request_body(content = ListSystemProcesses),
  responses(
    (status = 200, description = "The list of processes", body = ListSystemProcessesResponse),
  ),
)]
pub fn list_system_processes() {}

/// List the processes running on the target server.
/// Response: [ListSystemProcessesResponse].
///
/// Note. This does not hit the server directly. The procedures come from an
/// in memory cache on the core, which hits the server periodically
/// to keep it up to date.
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(ListSystemProcessesResponse)]
#[error(mogh_error::Error)]
pub struct ListSystemProcesses {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub server: String,
}

#[typeshare]
pub type ListSystemProcessesResponse = Vec<SystemProcess>;

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/GetHistoricalServerStats",
  description = "Paginated endpoint serving historical (timeseries) server stats for graphing.",
  request_body(content = GetHistoricalServerStats),
  responses(
    (status = 200, description = "The historical server stats", body = GetHistoricalServerStatsResponse),
  ),
)]
pub fn get_historical_server_stats() {}

/// Paginated endpoint serving historical (timeseries) server stats for graphing.
/// Response: [GetHistoricalServerStatsResponse].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetHistoricalServerStatsResponse)]
#[error(mogh_error::Error)]
pub struct GetHistoricalServerStats {
  /// Id or name
  #[serde(alias = "id", alias = "name")]
  pub server: String,
  /// The granularity of the data.
  pub granularity: Timelength,
  /// Page of historical data. Default is 0, which is the most recent data.
  /// Use with the `next_page` field of the response.
  #[serde(default)]
  pub page: u32,
}

/// Response to [GetHistoricalServerStats].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct GetHistoricalServerStatsResponse {
  /// The timeseries page of data.
  pub stats: Vec<SystemStatsRecord>,
  /// If there is a next page of data, pass this to `page` to get it.
  pub next_page: Option<u32>,
}

//

#[cfg(feature = "utoipa")]
#[utoipa::path(
  post,
  path = "/GetServersSummary",
  description = "Gets a summary of data relating to all servers.",
  request_body(content = GetServersSummary),
  responses(
    (status = 200, description = "The servers summary", body = GetServersSummaryResponse),
  ),
)]
pub fn get_servers_summary() {}

/// Gets a summary of data relating to all servers.
/// Response: [GetServersSummaryResponse].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Resolve)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
#[empty_traits(KomodoReadRequest)]
#[response(GetServersSummaryResponse)]
#[error(mogh_error::Error)]
pub struct GetServersSummary {}

/// Response for [GetServersSummary].
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
pub struct GetServersSummaryResponse {
  /// The total number of servers.
  pub total: I64,
  /// The number of healthy (`status: OK`) servers.
  pub healthy: I64,
  /// The number of servers with warnings (e.g., version mismatch).
  pub warning: I64,
  /// The number of unhealthy servers.
  pub unhealthy: I64,
  /// The number of disabled servers.
  pub disabled: I64,
}