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
use super::Session;
use crate::session::session::SessionError;
use crate::session::RUNTIME;
use antimatter_api::apis::authentication_api::{self as auth_api};
use antimatter_api::apis::capsules_api::{self as cap_api};
use antimatter_api::apis::contexts_api::{self as ctx_api};
use antimatter_api::apis::general_api::{self as api};
use antimatter_api::apis::policy_api::{self as pol_api};
use antimatter_api::models::{
AccessLogResults, DomainControlLogResults, DomainHooksList, DomainPrivateInfo,
DomainPublicInfo, DomainResourceSummary, DomainSettings, DomainStatus, NewDomainSettings,
NewVendorSettings, VendorSettings,
};
impl Session {
/// Fetches session's domain's private information.
///
/// Returns:
///
/// A `Result` containing a `DomainPrivateInfo` with the private information
/// for the session's domain.
pub fn get_private_info(&mut self) -> Result<DomainPrivateInfo, SessionError> {
let conf = self.get_configuration()?;
let res = RUNTIME
.block_on(api::domain_get_private_info(
&conf,
self.get_domain_id().as_str(),
))
.map_err(|e| SessionError::APIError(format!("{}", e)))?;
Ok(res)
}
/// Fetches session's domain's public information.
///
/// Returns:
///
/// A `Result` containing a `DomainPublicInfo` with the public information
/// for the session's domain.
pub fn get_public_info(&mut self) -> Result<DomainPublicInfo, SessionError> {
let conf = self.get_configuration()?;
let res = RUNTIME
.block_on(api::domain_get_public_info(
&conf,
self.get_domain_id().as_str(),
))
.map_err(|e| SessionError::APIError(format!("{}", e)))?;
Ok(res)
}
/// Fetches session's domain's settings.
///
/// Returns:
///
/// A `Result` containing a `DomainSettings` with the settings for the
/// session's domain.
pub fn get_settings(&mut self) -> Result<DomainSettings, SessionError> {
let conf = self.get_configuration()?;
let res = RUNTIME
.block_on(api::domain_get_settings(
&conf,
self.get_domain_id().as_str(),
))
.map_err(|e| SessionError::APIError(format!("{}", e)))?;
Ok(res)
}
/// Update the domain's settings.
///
/// Returns:
///
/// A `Result` containing a `DomainSettings` with the settings for the
/// session's domain.
pub fn put_settings(
&mut self,
new_domain_settings: NewDomainSettings,
) -> Result<DomainSettings, SessionError> {
let conf = self.get_configuration()?;
let res = RUNTIME
.block_on(api::domain_put_settings(
&conf,
self.get_domain_id().as_str(),
new_domain_settings,
))
.map_err(|e| SessionError::APIError(format!("{}", e)))?;
Ok(res)
}
/// Fetches session's domain's status.
///
/// Returns:
///
/// A `Result` containing a `DomainStatus` with the status for the
/// session's domain.
pub fn get_status(&mut self) -> Result<DomainStatus, SessionError> {
let conf = self.get_configuration()?;
let res = RUNTIME
.block_on(api::domain_get_status(&conf, self.get_domain_id().as_str()))
.map_err(|e| SessionError::APIError(format!("{}", e)))?;
Ok(res)
}
/// Fetches a list of hooks for the session's domain.
///
/// Returns:
///
/// A `Result` containing a `DomainHooksList` with a vector of hooks in the
/// session's domain.
pub fn list_hooks(&mut self) -> Result<DomainHooksList, SessionError> {
let conf = self.get_configuration()?;
let res = RUNTIME
.block_on(ctx_api::domain_list_hooks(
&conf,
self.get_domain_id().as_str(),
))
.map_err(|e| SessionError::APIError(format!("{}", e)))?;
Ok(res)
}
/// Fetches a list of available resources for the session's domain.
///
/// Returns:
///
/// A `Result` containing a `DomainResourceSummary` with a vector of
/// available resources in the session's domain.
pub fn list_resources(&mut self) -> Result<DomainResourceSummary, SessionError> {
let conf = self.get_configuration()?;
let res = RUNTIME
.block_on(pol_api::domain_list_resources(
&conf,
self.get_domain_id().as_str(),
))
.map_err(|e| SessionError::APIError(format!("{}", e)))?;
Ok(res)
}
/// Gets the session's domain's access logs applying provided filtered.
///
/// Arguments:
///
/// * `start_date` - An Option<String> to retrieve capsule after
/// (format "YYYY-MM-DD HH:MM:SS").
/// * `end_date` - An Option<String> to retrieve capsule before
/// (format "YYYY-MM-DD HH:MM:SS").
/// * `num_results` - An Option<i32> indicating the number of capsules to
/// retrieve.
/// * `start_from_id` - An Option<&str> log ID to get results after/before.
/// * `session` - An Option<&str> contains the authenticated session's ID.
/// * `location` - An Option<&str> contains the location to filter on.
/// * `location_prefixed` - An Option<bool> contains a location prefix to
/// filter on.
/// * `operation_type` - An Option<&str> containing the operation type.
/// * `allowed_tag` - An Option<&str> containing the allowed tag name.
/// * `redacted_or_tokenized_tag` - An Option<&str> containing the redacted
/// or tokenized tag name. Both tag types will be filtered on this tag
/// name.
///
/// Returns:
///
/// A `Result` containing a `AccessLogResults` with a vector of access logs.
pub fn query_access_logs(
&mut self,
start_date: Option<String>,
end_date: Option<String>,
num_results: Option<i32>,
start_from_id: Option<&str>,
session: Option<&str>,
location: Option<&str>,
location_prefixed: Option<bool>,
operation_type: Option<&str>,
allowed_tag: Option<&str>,
redacted_or_tokenized_tag: Option<&str>,
) -> Result<AccessLogResults, SessionError> {
let conf = self.get_configuration()?;
let res = RUNTIME
.block_on(cap_api::domain_query_access_log(
&conf,
self.get_domain_id().as_str(),
start_date,
end_date,
num_results,
start_from_id,
session,
location,
location_prefixed,
operation_type,
allowed_tag,
redacted_or_tokenized_tag,
))
.map_err(|e| SessionError::APIError(format!("{}", e)))?;
Ok(res)
}
/// Gets the session's domain's control logs applying provided filtered.
///
/// Arguments:
///
/// * `start_date` - An Option<String> to retrieve capsule after
/// (format "YYYY-MM-DD HH:MM:SS").
/// * `end_date` - An Option<String> to retrieve capsule before
/// (format "YYYY-MM-DD HH:MM:SS").
/// * `num_results` - An Option<i32> indicating the number of capsules to
/// retrieve.
/// * `start_from_id` - An Option<&str> log ID to get results after/before.
/// * `session` - An Option<&str> contains the authenticated session's ID.
/// * `url` - An Option<&str> contains the URL to filter on.
/// * `description` - An Option<&str> contains a description to
/// filter on.
///
/// Returns:
///
/// A `Result` containing a `DomainControlLogResults` with a vector of
/// control logs.
pub fn query_control_log(
&mut self,
start_date: Option<String>,
end_date: Option<String>,
num_results: Option<i32>,
start_from_id: Option<&str>,
session: Option<&str>,
url: Option<&str>,
description: Option<&str>,
) -> Result<DomainControlLogResults, SessionError> {
let conf = self.get_configuration()?;
let res = RUNTIME
.block_on(api::domain_query_control_log(
&conf,
self.get_domain_id().as_str(),
start_date,
end_date,
num_results,
start_from_id,
session,
url,
description,
))
.map_err(|e| SessionError::APIError(format!("{}", e)))?;
Ok(res)
}
/// Get vendor settings for the session's domain
///
/// Returns:
/// A `Result` containing a `VendorSettings` with the vendor settings
pub fn get_vendor_settings(&mut self) -> Result<VendorSettings, SessionError> {
let conf = self.get_configuration()?;
let res = RUNTIME
.block_on(api::domain_get_vendor_settings(
&conf,
self.get_domain_id().as_str(),
))
.map_err(|e| SessionError::APIError(format!("{}", e)))?;
Ok(res)
}
/// Create or update vendor settings for the session's domain
///
/// Arguments:
/// - `vendor_settings` - A `NewVendorSettings` containing the vendor settings
pub fn put_vendor_settings(
&mut self,
vendor_settings: NewVendorSettings,
) -> Result<(), SessionError> {
let conf = self.get_configuration()?;
RUNTIME
.block_on(auth_api::domain_put_vendor_settings(
&conf,
self.get_domain_id().as_str(),
vendor_settings,
))
.map_err(|e| SessionError::APIError(format!("{}", e)))?;
Ok(())
}
}