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