hydrus_api/api_core/endpoints/
access_management.rs

1use crate::api_core::common::{BasicServiceInfo, ServiceItem};
2use crate::api_core::endpoints::Endpoint;
3use std::collections::HashMap;
4
5pub static SERVICE_TYPE_LOCAL_TAGS: &str = "local_tags";
6pub static SERVICE_TYPE_TAG_REPOSITORIES: &str = "tag_repositories";
7pub static SERVICE_TYPE_LOCAL_FILES: &str = "local_files";
8pub static SERVICE_TYPE_FILE_REPOSITORIES: &str = "file_repositories";
9pub static SERVICE_TYPE_ALL_LOCAL_FILES: &str = "all_local_files";
10pub static SERVICE_TYPE_ALL_KNOWN_FILES: &str = "all_known_files";
11pub static SERVICE_TYPE_ALL_KNOWN_TAGS: &str = "all_known_tags";
12pub static SERVICE_TYPE_TRASH: &str = "trash";
13
14#[derive(Debug, Clone, Deserialize)]
15pub struct ApiVersionResponse {
16    pub version: u32,
17    pub hydrus_version: u32,
18}
19
20pub struct ApiVersion;
21
22impl Endpoint for ApiVersion {
23    type Request = ();
24    type Response = ApiVersionResponse;
25
26    fn path() -> String {
27        String::from("api_version")
28    }
29}
30
31#[derive(Debug, Clone, Deserialize)]
32pub struct SessionKeyResponse {
33    pub session_key: String,
34}
35
36pub struct SessionKey;
37
38impl Endpoint for SessionKey {
39    type Request = ();
40    type Response = SessionKeyResponse;
41
42    fn path() -> String {
43        String::from("session_key")
44    }
45}
46
47#[derive(Debug, Clone, Deserialize)]
48pub struct VerifyAccessKeyResponse {
49    pub basic_permissions: Vec<u32>,
50    pub human_description: String,
51}
52
53pub struct VerifyAccessKey;
54
55impl Endpoint for VerifyAccessKey {
56    type Request = ();
57    type Response = VerifyAccessKeyResponse;
58
59    fn path() -> String {
60        String::from("verify_access_key")
61    }
62}
63
64#[derive(Debug, Clone, Deserialize)]
65pub struct GetServicesResponse {
66    pub services: HashMap<String, ServiceItem>,
67    pub version: u64,
68    pub hydrus_version: u64,
69    #[serde(flatten)]
70    pub other: HashMap<String, Vec<BasicServiceInfo>>,
71}
72
73pub struct GetServices;
74
75impl Endpoint for GetServices {
76    type Request = ();
77    type Response = GetServicesResponse;
78
79    fn path() -> String {
80        String::from("get_services")
81    }
82}