1use crate::{error::SzResult, flags::SzFlags, types::*};
7use std::collections::HashSet;
8
9pub trait SzEnvironment {
14 fn destroy(&mut self) -> SzResult<()>;
16
17 fn is_destroyed(&self) -> bool;
19
20 fn reinitialize(&self, config_id: ConfigId) -> SzResult<()>;
23
24 fn get_active_config_id(&self) -> SzResult<ConfigId>;
26
27 fn get_product(&self) -> SzResult<Box<dyn SzProduct>>;
29
30 fn get_engine(&self) -> SzResult<Box<dyn SzEngine>>;
32
33 fn get_config_manager(&self) -> SzResult<Box<dyn SzConfigManager>>;
35
36 fn get_diagnostic(&self) -> SzResult<Box<dyn SzDiagnostic>>;
38}
39
40pub trait SzEngine {
45 fn prime_engine(&self) -> SzResult<()>;
47
48 fn get_stats(&self) -> SzResult<JsonString>;
50
51 fn add_record(
53 &self,
54 data_source_code: &str,
55 record_id: &str,
56 record_definition: &str,
57 flags: Option<SzFlags>,
58 ) -> SzResult<JsonString>;
59
60 fn get_record_preview(
62 &self,
63 record_definition: &str,
64 flags: Option<SzFlags>,
65 ) -> SzResult<JsonString>;
66
67 fn delete_record(
69 &self,
70 data_source_code: &str,
71 record_id: &str,
72 flags: Option<SzFlags>,
73 ) -> SzResult<JsonString>;
74
75 fn reevaluate_record(
77 &self,
78 data_source_code: &str,
79 record_id: &str,
80 flags: Option<SzFlags>,
81 ) -> SzResult<JsonString>;
82
83 fn reevaluate_entity(
85 &self,
86 entity_id: EntityId,
87 flags: Option<SzFlags>,
88 ) -> SzResult<JsonString>;
89
90 fn search_by_attributes(
92 &self,
93 attributes: &str,
94 search_profile: Option<&str>,
95 flags: Option<SzFlags>,
96 ) -> SzResult<JsonString>;
97
98 fn why_search(
100 &self,
101 attributes: &str,
102 entity_id: EntityId,
103 search_profile: Option<&str>,
104 flags: Option<SzFlags>,
105 ) -> SzResult<JsonString>;
106
107 fn get_entity(&self, entity_id: EntityId, flags: Option<SzFlags>) -> SzResult<JsonString>;
109
110 fn get_entity_by_record(
112 &self,
113 data_source_code: &str,
114 record_id: &str,
115 flags: Option<SzFlags>,
116 ) -> SzResult<JsonString>;
117
118 fn get_record(
120 &self,
121 data_source_code: &str,
122 record_id: &str,
123 flags: Option<SzFlags>,
124 ) -> SzResult<JsonString>;
125
126 fn find_interesting_entities_by_entity_id(
128 &self,
129 entity_id: EntityId,
130 flags: Option<SzFlags>,
131 ) -> SzResult<JsonString>;
132
133 fn find_interesting_entities_by_record(
135 &self,
136 data_source_code: &str,
137 record_id: &str,
138 flags: Option<SzFlags>,
139 ) -> SzResult<JsonString>;
140
141 fn find_path(
143 &self,
144 start_entity_id: EntityId,
145 end_entity_id: EntityId,
146 max_degrees: i64,
147 avoid_entity_ids: Option<&HashSet<EntityId>>,
148 required_data_sources: Option<&HashSet<String>>,
149 flags: Option<SzFlags>,
150 ) -> SzResult<JsonString>;
151
152 fn find_network(
154 &self,
155 entity_list: &[EntityId],
156 max_degrees: i64,
157 build_out_degree: i64,
158 max_entities: i64,
159 flags: Option<SzFlags>,
160 ) -> SzResult<JsonString>;
161
162 fn why_entity(
164 &self,
165 entity_id1: EntityId,
166 entity_id2: EntityId,
167 flags: Option<SzFlags>,
168 ) -> SzResult<JsonString>;
169
170 fn why_records(
172 &self,
173 data_source_code1: &str,
174 record_id1: &str,
175 data_source_code2: &str,
176 record_id2: &str,
177 flags: Option<SzFlags>,
178 ) -> SzResult<JsonString>;
179
180 fn why_record_in_entity(
182 &self,
183 data_source_code: &str,
184 record_id: &str,
185 flags: Option<SzFlags>,
186 ) -> SzResult<JsonString>;
187
188 fn how_entity(&self, entity_id: EntityId, flags: Option<SzFlags>) -> SzResult<JsonString>;
190
191 fn get_virtual_entity(
193 &self,
194 record_keys: &[(String, String)],
195 flags: Option<SzFlags>,
196 ) -> SzResult<JsonString>;
197
198 fn process_redo_record(
200 &self,
201 redo_record: &str,
202 flags: Option<SzFlags>,
203 ) -> SzResult<JsonString>;
204
205 fn get_redo_record(&self) -> SzResult<JsonString>;
207
208 fn count_redo_records(&self) -> SzResult<i64>;
210
211 fn export_json_entity_report(&self, flags: Option<SzFlags>) -> SzResult<ExportHandle>;
213
214 fn export_csv_entity_report(
216 &self,
217 csv_column_list: &str,
218 flags: Option<SzFlags>,
219 ) -> SzResult<ExportHandle>;
220
221 fn fetch_next(&self, export_handle: ExportHandle) -> SzResult<JsonString>;
223
224 fn close_export(&self, export_handle: ExportHandle) -> SzResult<()>;
226}
227
228pub trait SzConfig {
232 fn export(&self) -> SzResult<JsonString>;
234
235 fn get_data_source_registry(&self) -> SzResult<JsonString>;
237
238 fn register_data_source(&self, data_source_code: &str) -> SzResult<JsonString>;
240
241 fn unregister_data_source(&self, data_source_code: &str) -> SzResult<()>;
243}
244
245pub trait SzConfigManager {
250 fn create_config(&self) -> SzResult<Box<dyn SzConfig>>;
252
253 fn create_config_from_id(&self, config_id: ConfigId) -> SzResult<Box<dyn SzConfig>>;
255
256 fn create_config_from_definition(&self, config_definition: &str)
258 -> SzResult<Box<dyn SzConfig>>;
259
260 fn get_config_registry(&self) -> SzResult<JsonString>;
262
263 fn get_default_config_id(&self) -> SzResult<ConfigId>;
265
266 fn register_config(
268 &self,
269 config_definition: &str,
270 config_comment: Option<&str>,
271 ) -> SzResult<ConfigId>;
272
273 fn replace_default_config_id(
275 &self,
276 current_default_config_id: ConfigId,
277 new_default_config_id: ConfigId,
278 ) -> SzResult<()>;
279
280 fn set_default_config(
282 &self,
283 config_definition: &str,
284 config_comment: Option<&str>,
285 ) -> SzResult<ConfigId>;
286
287 fn set_default_config_id(&self, config_id: ConfigId) -> SzResult<()>;
289}
290
291pub trait SzDiagnostic {
296 fn check_repository_performance(&self, seconds_to_run: i64) -> SzResult<JsonString>;
298
299 fn get_feature(&self, feature_id: FeatureId) -> SzResult<JsonString>;
301
302 fn get_repository_info(&self) -> SzResult<JsonString>;
304
305 fn purge_repository(&self) -> SzResult<()>;
307}
308
309pub trait SzProduct {
314 fn get_license(&self) -> SzResult<JsonString>;
316
317 fn get_version(&self) -> SzResult<JsonString>;
319}