backend_dispatcher/interfaces/
cfs.rs

1use 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::{BosSessionTemplate, K8sDetails};
7use crate::{error::Error, types::cfs::CfsSessionGetResponse};
8use futures::AsyncBufRead;
9
10pub trait CfsTrait {
11    type T: AsyncBufRead;
12
13    fn post_session(
14        &self,
15        shasta_token: &str,
16        shasta_base_url: &str,
17        shasta_root_cert: &[u8],
18        session: &CfsSessionPostRequest,
19    ) -> impl Future<Output = Result<CfsSessionGetResponse, Error>> + Send;
20
21    fn get_sessions(
22        &self,
23        shasta_token: &str,
24        shasta_base_url: &str,
25        shasta_root_cert: &[u8],
26        session_name_opt: Option<&String>,
27        limit_opt: Option<u8>,
28        after_id_opt: Option<String>,
29        min_age_opt: Option<String>,
30        max_age_opt: Option<String>,
31        status_opt: Option<String>,
32        name_contains_opt: Option<String>,
33        is_succeded_opt: Option<bool>,
34        tags_opt: Option<String>,
35    ) -> impl Future<Output = Result<Vec<CfsSessionGetResponse>, Error>> + Send;
36
37    fn get_sessions_by_xname(
38        &self,
39        shasta_token: &str,
40        shasta_base_url: &str,
41        shasta_root_cert: &[u8],
42        xname_vec: &[&str],
43        limit_opt: Option<u8>,
44        after_id_opt: Option<String>,
45        min_age_opt: Option<String>,
46        max_age_opt: Option<String>,
47        status_opt: Option<String>,
48        name_contains_opt: Option<String>,
49        is_succeded_opt: Option<bool>,
50        tags_opt: Option<String>,
51    ) -> impl Future<Output = Result<Vec<CfsSessionGetResponse>, Error>> + Send;
52
53    fn get_and_filter_sessions(
54        &self,
55        shasta_token: &str,
56        shasta_base_url: &str,
57        shasta_root_cert: &[u8],
58        hsm_group_name_vec_opt: Option<Vec<String>>,
59        xname_vec_opt: Option<Vec<&str>>,
60        min_age_opt: Option<&String>,
61        max_age_opt: Option<&String>,
62        status_opt: Option<&String>,
63        cfs_session_name_opt: Option<&String>,
64        limit_number_opt: Option<&u8>,
65        is_succeded_opt: Option<bool>,
66    ) -> impl Future<Output = Result<Vec<CfsSessionGetResponse>, Error>> + Send;
67
68    fn get_session_logs_stream(
69        &self,
70        cfs_session_name: &str,
71        k8s_api_url: &str,
72        k8s: &K8sDetails,
73    ) -> impl Future<Output = Result<Self::T, Error>> + Send;
74
75    fn get_session_logs_stream_by_xname(
76        &self,
77        auth_token: &str,
78        xname: &str,
79        k8s_api_url: &str,
80        k8s: &K8sDetails,
81    ) -> impl Future<Output = Result<Self::T, Error>> + Send;
82
83    fn get_configuration(
84        &self,
85        auth_token: &str,
86        base_url: &str,
87        root_cert: &[u8],
88        configuration_name_opt: Option<&String>,
89    ) -> impl Future<Output = Result<Vec<CfsConfigurationResponse>, Error>> + Send;
90
91    fn get_and_filter_configuration(
92        &self,
93        shasta_token: &str,
94        shasta_base_url: &str,
95        shasta_root_cert: &[u8],
96        configuration_name: Option<&str>,
97        configuration_name_pattern: Option<&str>,
98        hsm_group_name_vec: &[String],
99        limit_number_opt: Option<&u8>,
100    ) -> impl Future<Output = Result<Vec<CfsConfigurationResponse>, Error>> + Send;
101
102    fn get_configuration_layer_details(
103        &self,
104        shasta_root_cert: &[u8],
105        gitea_base_url: &str,
106        gitea_token: &str,
107        layer: Layer,
108    ) -> impl Future<Output = Result<LayerDetails, Error>> + Send;
109
110    fn create_configuration_from_repos(
111        &self,
112        gitea_token: &str,
113        gitea_base_url: &str,
114        shasta_root_cert: &[u8],
115        // repos: Vec<PathBuf>,
116        repo_name_vec: Vec<String>,
117        local_git_commit_vec: Vec<String>,
118        playbook_file_name_opt: Option<&String>,
119    ) -> impl Future<Output = Result<CfsConfigurationRequest, Error>>;
120
121    // This function enforces a new CFS configuration to be created. First, checks if CFS configuration
122    // with same name already exists in CSM, if that is the case, it will return an error, otherwise
123    // creates a new CFS configuration
124    fn put_configuration(
125        &self,
126        shasta_token: &str,
127        shasta_base_url: &str,
128        shasta_root_cert: &[u8],
129        configuration: &CfsConfigurationRequest,
130        configuration_name: &str,
131    ) -> impl Future<Output = Result<CfsConfigurationResponse, Error>> + Send;
132
133    fn update_runtime_configuration(
134        &self,
135        shasta_token: &str,
136        shasta_base_url: &str,
137        shasta_root_cert: &[u8],
138        xnames: Vec<String>,
139        desired_configuration: &str,
140        enabled: bool,
141    ) -> impl Future<Output = Result<(), Error>> + Send;
142
143    // Get all CFS sessions, IMS images and BOS sessiontemplates related to a CFS configuration
144    fn get_derivatives(
145        &self,
146        shasta_token: &str,
147        shasta_base_url: &str,
148        shasta_root_cert: &[u8],
149        configuration_name: &str,
150    ) -> impl Future<
151        Output = Result<
152            (
153                Option<Vec<CfsSessionGetResponse>>,
154                Option<Vec<BosSessionTemplate>>,
155                Option<Vec<Image>>,
156            ),
157            Error,
158        >,
159    > + Send;
160}