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
use serde_json::Value;

use crate::{error::Error, types::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;

    // 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 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/INVENTORY/HARDWARE
    fn post_inventory_hardware(
        &self,
        auth_token: &str,
        hardware: HWInventoryByLocationList,
    ) -> 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;

    /// 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;
}