backend_dispatcher/interfaces/
cfs.rs1use std::future::Future;
2
3use crate::types::cfs::cfs_configuration_request::CfsConfigurationRequest;
4use crate::types::cfs::component::Component;
5use crate::types::cfs::{CfsConfigurationResponse, CfsSessionPostRequest, Layer, LayerDetails};
6use crate::types::ims::Image;
7use crate::types::{bos::session_template::BosSessionTemplate, K8sDetails};
8use crate::{error::Error, types::cfs::CfsSessionGetResponse};
9
10pub trait CfsTrait {
11 type T: futures::AsyncBufRead + Send + Sized;
12
13 fn get_session_logs_stream(
14 &self,
15 _shasta_token: &str,
16 _site_name: &str,
17 _cfs_session_name: &str,
18 _k8s: &K8sDetails,
19 ) -> impl Future<Output = Result<Self::T, Error>> {
20 async {
21 Err::<Self::T, Error>(Error::Message(
22 "Get session logs stream command not implemented for this backend".to_string(),
23 ))
24 }
25 }
26
27 fn get_session_logs_stream_by_xname(
28 &self,
29 _auth_token: &str,
30 _site_name: &str,
31 _xname: &str,
32 _k8s: &K8sDetails,
33 ) -> impl Future<Output = Result<Self::T, Error>> {
34 async {
35 Err(Error::Message(
36 "Get session logs stream by xname command not implemented for this backend"
37 .to_string(),
38 ))
39 }
40 }
41
42 fn post_session(
43 &self,
44 _shasta_token: &str,
45 _shasta_base_url: &str,
46 _shasta_root_cert: &[u8],
47 _session: &CfsSessionPostRequest,
48 ) -> impl Future<Output = Result<CfsSessionGetResponse, Error>> + Send {
49 async {
50 Err(Error::Message(
51 "Post session command not implemented for this backend".to_string(),
52 ))
53 }
54 }
55
56 fn get_sessions(
57 &self,
58 _shasta_token: &str,
59 _shasta_base_url: &str,
60 _shasta_root_cert: &[u8],
61 _session_name_opt: Option<&String>,
62 _limit_opt: Option<u8>,
63 _after_id_opt: Option<String>,
64 _min_age_opt: Option<String>,
65 _max_age_opt: Option<String>,
66 _status_opt: Option<String>,
67 _name_contains_opt: Option<String>,
68 _is_succeded_opt: Option<bool>,
69 _tags_opt: Option<String>,
70 ) -> impl Future<Output = Result<Vec<CfsSessionGetResponse>, Error>> + Send {
71 async {
72 Err(Error::Message(
73 "Get sessions command not implemented for this backend".to_string(),
74 ))
75 }
76 }
77
78 fn get_sessions_by_xname(
79 &self,
80 _shasta_token: &str,
81 _shasta_base_url: &str,
82 _shasta_root_cert: &[u8],
83 _xname_vec: &[&str],
84 _limit_opt: Option<u8>,
85 _after_id_opt: Option<String>,
86 _min_age_opt: Option<String>,
87 _max_age_opt: Option<String>,
88 _status_opt: Option<String>,
89 _name_contains_opt: Option<String>,
90 _is_succeded_opt: Option<bool>,
91 _tags_opt: Option<String>,
92 ) -> impl Future<Output = Result<Vec<CfsSessionGetResponse>, Error>> + Send {
93 async {
94 Err(Error::Message(
95 "Get sessions by xname command not implemented for this backend".to_string(),
96 ))
97 }
98 }
99
100 fn get_and_filter_sessions(
101 &self,
102 _shasta_token: &str,
103 _shasta_base_url: &str,
104 _shasta_root_cert: &[u8],
105 _hsm_group_name_vec_opt: Option<Vec<String>>,
106 _xname_vec_opt: Option<Vec<&str>>,
107 _min_age_opt: Option<&String>,
108 _max_age_opt: Option<&String>,
109 _status_opt: Option<&String>,
110 _cfs_session_name_opt: Option<&String>,
111 _limit_number_opt: Option<&u8>,
112 _is_succeded_opt: Option<bool>,
113 ) -> impl Future<Output = Result<Vec<CfsSessionGetResponse>, Error>> + Send {
114 async {
115 Err(Error::Message(
116 "Get and filter sessions command not implemented for this backend".to_string(),
117 ))
118 }
119 }
120
121 fn delete_and_cancel_session(
122 &self,
123 _shasta_token: &str,
124 _shasta_base_url: &str,
125 _shasta_root_cert: &[u8],
126 _hsm_group_available_vec: Vec<String>,
127 _cfs_session_name: &str,
128 ) -> impl Future<Output = Result<(), Error>> + Send {
129 async {
130 Err(Error::Message(
131 "Delete and cancel session command not implemented for this backend".to_string(),
132 ))
133 }
134 }
135
136 fn get_configuration(
137 &self,
138 _auth_token: &str,
139 _base_url: &str,
140 _root_cert: &[u8],
141 _configuration_name_opt: Option<&String>,
142 ) -> impl Future<Output = Result<Vec<CfsConfigurationResponse>, Error>> + Send {
143 async {
144 Err(Error::Message(
145 "Get configuration command not implemented for this backend".to_string(),
146 ))
147 }
148 }
149
150 fn get_and_filter_configuration(
151 &self,
152 _shasta_token: &str,
153 _shasta_base_url: &str,
154 _shasta_root_cert: &[u8],
155 _configuration_name: Option<&str>,
156 _configuration_name_pattern: Option<&str>,
157 _hsm_group_name_vec: &[String],
158 _limit_number_opt: Option<&u8>,
159 ) -> impl Future<Output = Result<Vec<CfsConfigurationResponse>, Error>> + Send {
160 async {
161 Err(Error::Message(
162 "Get and filter configuration command not implemented for this backend".to_string(),
163 ))
164 }
165 }
166
167 fn get_configuration_layer_details(
168 &self,
169 _shasta_root_cert: &[u8],
170 _gitea_base_url: &str,
171 _gitea_token: &str,
172 _layer: Layer,
173 _site_name: &str, ) -> impl Future<Output = Result<LayerDetails, Error>> + Send {
175 async {
176 Err(Error::Message(
177 "Get configuration layer details command not implemented for this backend"
178 .to_string(),
179 ))
180 }
181 }
182
183 fn create_configuration_from_repos(
184 &self,
185 _gitea_token: &str,
186 _gitea_base_url: &str,
187 _shasta_root_cert: &[u8],
188 _repo_name_vec: Vec<String>,
189 _local_git_commit_vec: Vec<String>,
190 _playbook_file_name_opt: Option<&String>,
191 ) -> impl Future<Output = Result<CfsConfigurationRequest, Error>> {
192 async {
193 Err(Error::Message(
194 "Create configuration from repos command not implemented for this backend"
195 .to_string(),
196 ))
197 }
198 }
199
200 fn put_configuration(
204 &self,
205 _shasta_token: &str,
206 _shasta_base_url: &str,
207 _shasta_root_cert: &[u8],
208 _configuration: &CfsConfigurationRequest,
209 _configuration_name: &str,
210 ) -> impl Future<Output = Result<CfsConfigurationResponse, Error>> + Send {
211 async {
212 Err(Error::Message(
213 "Put configuration command not implemented for this backend".to_string(),
214 ))
215 }
216 }
217
218 fn update_runtime_configuration(
219 &self,
220 _shasta_token: &str,
221 _shasta_base_url: &str,
222 _shasta_root_cert: &[u8],
223 _xnames: Vec<String>,
224 _desired_configuration: &str,
225 _enabled: bool,
226 ) -> impl Future<Output = Result<(), Error>> + Send {
227 async {
228 Err(Error::Message(
229 "Update runtime configuration command not implemented for this backend".to_string(),
230 ))
231 }
232 }
233
234 fn get_derivatives(
236 &self,
237 _shasta_token: &str,
238 _shasta_base_url: &str,
239 _shasta_root_cert: &[u8],
240 _configuration_name: &str,
241 ) -> impl Future<
242 Output = Result<
243 (
244 Option<Vec<CfsSessionGetResponse>>,
245 Option<Vec<BosSessionTemplate>>,
246 Option<Vec<Image>>,
247 ),
248 Error,
249 >,
250 > + Send {
251 async {
252 Err(Error::Message(
253 "Get derivatives command not implemented for this backend".to_string(),
254 ))
255 }
256 }
257
258 fn get_cfs_component(
259 &self,
260 _shasta_token: &str,
261 _shasta_base_url: &str,
262 _shasta_root_cert: &[u8],
263 _components_ids: Option<&str>,
264 _status: Option<&str>,
265 ) -> impl Future<Output = Result<Vec<Component>, Error>> + Send {
266 async {
267 Err(Error::Message(
268 "Get derivatives command not implemented for this backend".to_string(),
269 ))
270 }
271 }
272}