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
use serde::Serialize;

use crate::client::{rpc::ExecutionLocationProvider, DecthingsParameterProvider};

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DebugSessionOptions {
    /// Will automatically terminate the session if no method is called on the debug session for this amount of time.
    /// Default: 1800.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub terminate_after_inactive_seconds: Option<u32>,
    /// Whether to run the process in remote debugger mode, allowing you to place breakpoints and step through the
    /// code. Default: true.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub remote_inspector: Option<bool>,
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct LaunchDebugSessionParams<'a> {
    /// The model's id.
    pub model_id: &'a str,
    /// Which launcher to use for running the session.
    pub execution_location: ExecutionLocationProvider<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub options: Option<DebugSessionOptions>,
    /// If true, immediately subscribes you to events "exit", "stdout", "stderr", "initialized" and
    /// "remoteInspectorData" for the debug session. Default: true.
    #[cfg(feature = "events")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub subscribe_to_events: Option<bool>,
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct GetDebugSessionsParams<'a, S: AsRef<str>> {
    /// Which sessions to fetch. If unspecified, all sessions will be fetched.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub debug_session_ids: Option<&'a [S]>,
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TerminateDebugSessionParams<'a> {
    /// The debug session's id.
    pub debug_session_id: &'a str,
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CallCreateModelStateParams<'a> {
    /// The debug session's id.
    pub debug_session_id: &'a str,
    /// Parameters to provide to the function.
    pub params: Vec<DecthingsParameterProvider<'a>>,
}

#[derive(Debug, Clone)]
pub struct StateData<'a, D: AsRef<[u8]>> {
    pub key: &'a str,
    pub data: D,
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase", tag = "type")]
pub enum StateDataProvider<'a, D: AsRef<[u8]>> {
    #[serde(rename_all = "camelCase")]
    Data {
        #[serde(skip_serializing)]
        data: &'a [StateData<'a, D>],
    },
    #[serde(rename_all = "camelCase")]
    DataId { data_id: &'a str },
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
#[serde(bound(serialize = ""))]
pub struct CallInstantiateModelParams<'a, D: AsRef<[u8]>> {
    /// The debug session's id.
    pub debug_session_id: &'a str,
    /// Data to use as model state.
    pub state_data: StateDataProvider<'a, D>,
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CallTrainParams<'a> {
    /// The debug session's id.
    pub debug_session_id: &'a str,
    /// Identifier of the instantiated model to use, as returned by the 'callInstantiateModel' function.
    pub instantiated_model_id: &'a str,
    /// Parameters to provide to the function.
    pub params: Vec<DecthingsParameterProvider<'a>>,
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DebugGetTrainingStatusParams<'a> {
    /// The debug session's id.
    pub debug_session_id: &'a str,
    /// Training session identifier, as returned by the 'callTrain' function.
    pub training_session_id: &'a str,
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DebugTrainingMetricsToFetch<'a> {
    pub name: &'a str,
    pub start_index: u32,
    pub amount: u32,
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DebugGetTrainingMetricsParams<'a> {
    /// The debug session's id.
    pub debug_session_id: &'a str,
    /// Training session identifier, as returned by the 'callTrain' function.
    pub training_session_id: &'a str,
    /// Which metrics to fetch.
    pub metrics: &'a [DebugTrainingMetricsToFetch<'a>],
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DebugCancelTrainingSessionParams<'a> {
    /// The debug session's id.
    pub debug_session_id: &'a str,
    /// Training session identifier, as returned by the 'callTrain' function.
    pub training_session_id: &'a str,
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CallEvaluateParams<'a> {
    /// The debug session's id.
    pub debug_session_id: &'a str,
    /// Identifier of the instantiated model to use, as returned by the 'callInstantiateModel' function.
    pub instantiated_model_id: &'a str,
    /// Parameters to provide to the function.
    pub params: Vec<DecthingsParameterProvider<'a>>,
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CallGetModelStateParams<'a> {
    /// The debug session's id.
    pub debug_session_id: &'a str,
    /// Identifier of the instantiated model to use, as returned by the 'callInstantiateModel' function.
    pub instantiated_model_id: &'a str,
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DownloadStateDataParams<'a, S: AsRef<str>> {
    /// The debug session's id.
    pub debug_session_id: &'a str,
    /// The data's id, as returned by 'callCreateModelState' or 'callGetModelState'.
    pub data_id: &'a str,
    /// Which state keys to fetch. Defaults to all keys.
    #[serde(serialize_with = "super::super::serialize_option_asref_str_seq")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub keys: Option<&'a [S]>,
}

#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SendToRemoteInspectorParams<'a, T: AsRef<[u8]>> {
    /// The debug session's id.
    pub debug_session_id: &'a str,
    #[serde(skip_serializing)]
    pub data: T,
}

#[cfg(feature = "events")]
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DebugSubscribeToEventsParams<'a> {
    /// The debug session's id.
    pub debug_session_id: &'a str,
}

#[cfg(feature = "events")]
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DebugUnsubscribeFromEventsParams<'a> {
    /// The debug session's id.
    pub debug_session_id: &'a str,
}