backend_dispatcher/interfaces/
cfs.rs

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