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 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
use std::collections::HashMap;
use serde_json::Value;
use crate::{
error::Error,
types::{BootParameters, ComponentArrayPostArray, Group, HWInventoryByLocationList},
};
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_group_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
fn get_member_vec_from_group_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_group_map_and_filter_by_group_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 post_member(
&self,
auth_token: &str,
group_label: &str,
members: &str,
) -> impl std::future::Future<Output = Result<Value, Error>> + Send;
// HSM/GROUP
fn add_members_to_group(
&self,
auth_token: &str,
group_label: &str,
members: Vec<&str>,
) -> impl std::future::Future<Output = Result<Vec<String>, Error>> + Send;
// HSM/GROUP
fn delete_member_from_group(
&self,
auth_token: &str,
group_label: &str,
xname: &str,
) -> impl std::future::Future<Output = Result<(), Error>> + Send;
// HSM/GROUP
fn update_group_members(
&self,
auth_token: &str,
group_name: &str,
members_to_remove: &Vec<String>,
members_to_add: &Vec<String>,
) -> impl std::future::Future<Output = Result<(), Error>> + Send;
// HSM/GROUP
fn get_all_groups(
&self,
_auth_token: &str,
) -> impl std::future::Future<Output = Result<Vec<Group>, Error>> + Send;
// HSM/GROUP
fn get_group(
&self,
_auth_token: &str,
_hsm_name: &str,
) -> impl std::future::Future<Output = Result<Group, 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_group(
&self,
_auth_token: &str,
_hsm_name: Group,
) -> impl std::future::Future<Output = Result<Group, 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_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(),
))
}
} */
// HSM/GROUP
fn migrate_group_members(
&self,
shasta_token: &str,
target_hsm_group_name: &str,
parent_hsm_group_name: &str,
new_target_hsm_members: Vec<&str>,
) -> impl std::future::Future<Output = Result<(Vec<String>, Vec<String>), Error>> + Send;
// HSM/COMPONENT
fn post_nodes(
&self,
auth_token: &str,
component: ComponentArrayPostArray,
) -> impl std::future::Future<Output = Result<(), Error>> + Send;
// HSM/COMPONENT
fn delete_node(
&self,
auth_token: &str,
id: &str,
) -> impl std::future::Future<Output = Result<Value, Error>> + Send;
// HSM/INVENTORY/HARDWARE
fn get_inventory_hardware_query(
&self,
auth_token: &str,
xname: &str,
r#type: Option<&str>,
children: Option<bool>,
parents: Option<bool>,
partition: Option<&str>,
format: Option<&str>,
) -> impl std::future::Future<Output = Result<Value, Error>> + Send;
// HSM/INVENTORY/HARDWARE
fn post_inventory_hardware(
&self,
auth_token: &str,
hardware: HWInventoryByLocationList,
) -> impl std::future::Future<Output = Result<Value, Error>> + Send;
// 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(),
))
} */
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;
/// Get list of xnames from NIDs
/// The list of NIDs can be:
/// - comma separated list of NIDs (eg: nid000001,nid000002,nid000003)
/// - regex (eg: nid00000.*)
/// - hostlist (eg: nid0000[01-15])
fn nid_to_xname(
&self,
auth_token: &str,
user_input_nid: &str,
is_regex: bool,
) -> impl std::future::Future<Output = Result<Vec<String>, Error>> + Send;
}