decthings_api/client/rpc/spawned/
request.rs

1use crate::client::rpc::ExecutionLocationProvider;
2use serde::Serialize;
3
4#[derive(Debug, Clone, Serialize)]
5#[serde(rename_all = "camelCase")]
6pub struct SpawnedCommandOptions {
7    /// Will automatically terminate the command after this amount of time. Default: 3600.
8    #[serde(skip_serializing_if = "Option::is_none")]
9    pub timeout_seconds: Option<u32>,
10    /// Will automatically terminate the command if no output is received from the process for this amount of time.
11    /// Default: 600.
12    #[serde(skip_serializing_if = "Option::is_none")]
13    pub timeout_after_inactive_seconds: Option<u32>,
14}
15
16#[derive(Debug, Clone, Serialize)]
17#[serde(rename_all = "camelCase")]
18pub struct SpawnCommandParams<'a, S: AsRef<str>> {
19    /// Which launcher to use for running the command.
20    pub execution_location: ExecutionLocationProvider<'a>,
21    /// Name of the command to run, without any arguments.
22    pub command: &'a str,
23    /// Arguments to pass to the command
24    #[serde(serialize_with = "super::super::serialize_asref_str_seq")]
25    pub args: &'a [S],
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub options: Option<SpawnedCommandOptions>,
28    /// If true, immediately subscribes you to events "stdout", "stderr" and "exit" for the spawned command. Default:
29    /// true.
30    #[cfg(feature = "events")]
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub subscribe_to_events: Option<bool>,
33}
34
35#[derive(Debug, Clone, Serialize)]
36#[serde(rename_all = "camelCase")]
37pub struct FilesystemAccess<'a> {
38    pub model_id: &'a str,
39}
40
41#[derive(Debug, Clone, Serialize)]
42#[serde(rename_all = "camelCase")]
43#[serde(bound(serialize = ""))]
44pub struct SpawnCommandForModelParams<'a, S: AsRef<str>> {
45    /// The model's id.
46    pub model_id: &'a str,
47    /// Which launcher to use for running the command.
48    pub execution_location: ExecutionLocationProvider<'a>,
49    /// Name of the command to run, without any arguments.
50    pub command: &'a str,
51    /// Arguments to pass to the command
52    #[serde(serialize_with = "super::super::serialize_asref_str_seq")]
53    pub args: &'a [S],
54    #[serde(skip_serializing_if = "Option::is_none")]
55    pub options: Option<SpawnedCommandOptions>,
56    /// If true, immediately subscribes you to events "stdout", "stderr" and "exit" for the spawned command. Default:
57    /// true.
58    #[cfg(feature = "events")]
59    #[serde(skip_serializing_if = "Option::is_none")]
60    pub subscribe_to_events: Option<bool>,
61}
62
63#[derive(Debug, Clone, Serialize)]
64#[serde(rename_all = "camelCase")]
65pub struct TerminateSpawnedCommandParams<'a> {
66    /// The spawned command's id.
67    pub spawned_command_id: &'a str,
68}
69
70#[derive(Debug, Clone, Serialize)]
71#[serde(rename_all = "camelCase")]
72pub struct GetSpawnedCommandsParams<'a, S: AsRef<str>> {
73    /// Which spawned commands to fetch. If unspecified, all running commands will be fetched.
74    #[serde(serialize_with = "super::super::serialize_option_asref_str_seq")]
75    #[serde(skip_serializing_if = "Option::is_none")]
76    pub spawned_command_ids: Option<&'a [S]>,
77}
78
79#[derive(Debug, Clone, Serialize)]
80#[serde(rename_all = "camelCase")]
81pub struct WriteToSpawnedCommandParams<'a, T: AsRef<[u8]>> {
82    /// The spawned command's id.
83    pub spawned_command_id: &'a str,
84    #[serde(skip_serializing)]
85    pub data: T,
86}
87
88#[cfg(feature = "events")]
89#[derive(Debug, Clone, Serialize)]
90#[serde(rename_all = "camelCase")]
91pub struct SpawnedSubscribeToEventsParams<'a> {
92    /// The spawned command's id.
93    pub spawned_command_id: &'a str,
94}
95
96#[cfg(feature = "events")]
97#[derive(Debug, Clone, Serialize)]
98#[serde(rename_all = "camelCase")]
99pub struct SpawnedUnsubscribeFromEventsParams<'a> {
100    /// The spawned command's id.
101    pub spawned_command_id: &'a str,
102}