backend_dispatcher/
contracts.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
use std::collections::HashMap;

use serde_json::Value;

use crate::{
    error::Error,
    types::{BootParameters, HsmGroup},
};

pub trait BackendTrait {
    fn test_backend_trait(&self) -> String;

    // AUTHORIZATION
    fn get_api_token(
        &self,
        _site_name: &str,
    ) -> impl std::future::Future<Output = Result<String, Error>> + Send;
    /* fn get_api_token(
        &self,
        _site_name: &str,
    ) -> impl std::future::Future<Output = Result<String, Error>> + Send {
        async {
            Err(Error::Message(
                "Authentication command not implemented for this backend".to_string(),
            ))
        }
    } */

    // AUTHORIZATION : HSM/GROUP
    fn get_hsm_name_available(
        &self,
        _jwt_token: &str,
    ) -> impl std::future::Future<Output = Result<Vec<String>, Error>> + Send;
    /* fn get_hsm_name_available(
        &self,
        _jwt_token: &str,
    ) -> impl std::future::Future<Output = Result<Vec<String>, Error>> + Send {
        async {
            Err(Error::Message(
                "Get HSM name available command not implemented for this backend".to_string(),
            ))
        }
    } */

    // HSM/GROUP
    // FIXME: rename function to 'get_hsm_group_members'
    fn get_member_vec_from_hsm_name_vec(
        &self,
        _auth_token: &str,
        _hsm_group_name_vec: Vec<String>,
    ) -> impl std::future::Future<Output = Result<Vec<String>, Error>> + Send;
    /* fn get_member_vec_from_hsm_name_vec(
        &self,
        _auth_token: &str,
        _hsm_group_name_vec: Vec<String>,
    ) -> impl std::future::Future<Output = Result<Vec<String>, Error>> + Send {
        async {
            Err(Error::Message(
                "Get group members command not implemented for this backend".to_string(),
            ))
        }
    } */

    // HSM/GROUP
    fn get_hsm_map_and_filter_by_hsm_name_vec(
        &self,
        _auth_token: &str,
        _hsm_name_vec: Vec<&str>,
    ) -> impl std::future::Future<Output = Result<HashMap<String, Vec<String>>, Error>> + Send;
    /* fn get_hsm_map_and_filter_by_hsm_name_vec(
        &self,
        _auth_token: &str,
        _hsm_name_vec: Vec<&str>,
    ) -> impl std::future::Future<Output = Result<HashMap<String, Vec<String>>, Error>> + Send {
        async {
            Err(Error::Message(
                "Get HSM map and filter by HSM name command not implemented for this backend"
                    .to_string(),
            ))
        }
    } */

    // HSM/GROUP
    fn get_all_hsm_group(
        &self,
        _auth_token: &str,
    ) -> impl std::future::Future<Output = Result<Vec<HsmGroup>, Error>> + Send;
    /* fn get_all_hsm_group(
        &self,
        _auth_token: &str,
    ) -> impl std::future::Future<Output = Result<Vec<HsmGroup>, Error>> + Send {
        async {
            Err(Error::Message(
                "Get all HSM command not implemented for this backend".to_string(),
            ))
        }
    } */

    // HSM/GROUP
    fn get_hsm_group(
        &self,
        _auth_token: &str,
        _hsm_name: &str,
    ) -> impl std::future::Future<Output = Result<HsmGroup, Error>> + Send;
    /* fn get_hsm_group(
        &self,
        _auth_token: &str,
        _hsm_name: &str,
    ) -> impl std::future::Future<Output = Result<Vec<HsmGroup>, Error>> + Send {
        async {
            Err(Error::Message(
                "Get HSM command not implemented for this backend".to_string(),
            ))
        }
    } */

    // HSM/GROUP
    fn add_hsm_group(
        &self,
        _auth_token: &str,
        _hsm_name: HsmGroup,
    ) -> impl std::future::Future<Output = Result<HsmGroup, Error>> + Send;
    /* fn add_hsm_group(
        &self,
        _auth_token: &str,
        _hsm_name: HsmGroup,
    ) -> impl std::future::Future<Output = Result<Vec<HsmGroup>, Error>> + Send {
        async {
            Err(Error::Message(
                "Create HSM command not implemented for this backend".to_string(),
            ))
        }
    } */

    // HSM/GROUP
    fn delete_hsm_group(
        &self,
        _auth_token: &str,
        _hsm_group_label: &str,
    ) -> impl std::future::Future<Output = Result<Value, Error>> + Send;
    /* fn delete_hsm_group(
        &self,
        _auth_token: &str,
        _hsm_name: HsmGroup,
    ) -> impl std::future::Future<Output = Result<Vec<HsmGroup>, Error>> + Send {
        async {
            Err(Error::Message(
                "Delete HSM command not implemented for this backend".to_string(),
            ))
        }
    } */

    // PCS
    // FIXME: Create a new type PowerStatus and return Result<PowerStatus, Error>
    fn power_on_sync(
        &self,
        _auth_token: &str,
        _nodes: &[String],
    ) -> impl std::future::Future<Output = Result<Value, Error>> + Send {
        async {
            Err(Error::Message(
                "Power on command not implemented for this backend".to_string(),
            ))
        }
    }

    // PCS
    // FIXME: Create a new type PowerStatus and return Result<PowerStatus, Error>
    fn power_off_sync(
        &self,
        _auth_token: &str,
        _nodes: &[String],
        _force: bool,
    ) -> impl std::future::Future<Output = Result<Value, Error>> + Send {
        async {
            Err(Error::Message(
                "Power off command not implemented for this backend".to_string(),
            ))
        }
    }

    // PCS
    // FIXME: Create a new type PowerStatus and return Result<PowerStatus, Error>
    fn power_reset_sync(
        &self,
        _auth_token: &str,
        _nodes: &[String],
        _force: bool,
    ) -> impl std::future::Future<Output = Result<Value, Error>> + Send {
        async {
            Err(Error::Message(
                "Power reset command not implemented for this backend".to_string(),
            ))
        }
    }

    // BSS/BOOTPARAMETERS
    fn get_bootparameters(
        &self,
        _auth_token: &str,
        _nodes: &[String],
    ) -> impl std::future::Future<Output = Result<Vec<BootParameters>, Error>> + Send {
        async {
            Err(Error::Message(
                "Get boot parameters command not implemented for this backend".to_string(),
            ))
        }
    }

    // BSS/BOOTPARAMETERS
    fn update_bootparameters(
        &self,
        _auth_token: &str,
        _boot_parameters: &BootParameters,
    ) -> impl std::future::Future<Output = Result<(), Error>> + Send {
        async {
            Err(Error::Message(
                "Update boot parameters command not implemented for this backend".to_string(),
            ))
        }
    }

    // BSS/BOOTPARAMETERS
    fn add_kernel_params(&mut self, _new_kernel_params: &str) -> Result<bool, Error> {
        Err(Error::Message(
            "Add kernel parameters command not implemented for this backend".to_string(),
        ))
    }

    /* // BSS/BOOTPARAMETERS
    fn delete_kernel_params(&mut self, _new_kernel_params: &str) -> Result<bool, Error> {
        Err(Error::Message(
            "Delete kernel parameters command not implemented for this backend".to_string(),
        ))
    } */
}