hydrus_api/api_core/endpoints/
adding_files.rs

1use crate::api_core::common::{FileSelection, FileServiceSelection};
2use crate::api_core::endpoints::Endpoint;
3use serde::Serialize;
4
5pub static STATUS_IMPORT_SUCCESS: u8 = 1;
6pub static STATUS_IMPORT_ALREADY_EXISTS: u8 = 2;
7pub static STATUS_IMPORT_PREVIOUSLY_DELETED: u8 = 3;
8pub static STATUS_IMPORT_FAILED: u8 = 4;
9pub static STATUS_IMPORT_VETOED: u8 = 5;
10
11#[derive(Debug, Clone, Serialize)]
12pub struct AddFileRequest {
13    pub path: String,
14}
15
16#[derive(Debug, Clone, Deserialize)]
17pub struct AddFileResponse {
18    pub status: u8,
19    pub hash: String,
20    pub note: String,
21}
22
23pub struct AddFile;
24
25impl Endpoint for AddFile {
26    type Request = AddFileRequest;
27    type Response = AddFileResponse;
28
29    fn path() -> String {
30        String::from("add_files/add_file")
31    }
32}
33
34#[derive(Clone, Debug, Serialize)]
35pub struct DeleteFilesRequest {
36    #[serde(flatten)]
37    pub file_selection: FileSelection,
38    #[serde(flatten)]
39    pub service_selection: FileServiceSelection,
40    pub reason: Option<String>,
41}
42
43pub struct DeleteFiles;
44
45impl Endpoint for DeleteFiles {
46    type Request = DeleteFilesRequest;
47    type Response = ();
48
49    fn path() -> String {
50        String::from("add_files/delete_files")
51    }
52}
53
54#[derive(Clone, Debug, Serialize)]
55pub struct UndeleteFilesRequest {
56    #[serde(flatten)]
57    pub file_selection: FileSelection,
58    #[serde(flatten)]
59    pub service_selection: FileServiceSelection,
60}
61
62pub struct UndeleteFiles;
63
64impl Endpoint for UndeleteFiles {
65    type Request = UndeleteFilesRequest;
66    type Response = ();
67
68    fn path() -> String {
69        String::from("add_files/undelete_files")
70    }
71}
72
73#[derive(Clone, Debug, Serialize)]
74pub struct ArchiveFilesRequest {
75    #[serde(flatten)]
76    pub file_selection: FileSelection,
77    #[serde(flatten)]
78    pub service_selection: FileServiceSelection,
79}
80
81pub struct ArchiveFiles;
82
83impl Endpoint for ArchiveFiles {
84    type Request = ArchiveFilesRequest;
85    type Response = ();
86
87    fn path() -> String {
88        String::from("add_files/archive_files")
89    }
90}
91
92#[derive(Clone, Debug, Serialize)]
93pub struct UnarchiveFilesRequest {
94    #[serde(flatten)]
95    pub file_selection: FileSelection,
96    #[serde(flatten)]
97    pub service_selection: FileServiceSelection,
98}
99
100pub struct UnarchiveFiles;
101
102impl Endpoint for UnarchiveFiles {
103    type Request = UnarchiveFilesRequest;
104    type Response = ();
105
106    fn path() -> String {
107        String::from("add_files/unarchive_files")
108    }
109}