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
use url::Url;
use crate::file::remote_file::RemoteFile;
pub struct UrlBuilder;
impl UrlBuilder {
pub fn download(file: &RemoteFile, secret: bool) -> Url {
let mut url = file.url().clone();
if secret && file.has_secret() {
url.set_fragment(Some(&file.secret()));
} else {
url.set_fragment(None);
}
url
}
fn api(endpoint: &str, file: &RemoteFile) -> Url {
let mut url = file.url().clone();
url.set_path(format!("/api/{}/{}", endpoint, file.id()).as_str());
url.set_fragment(None);
url
}
pub fn api_metadata(file: &RemoteFile) -> Url {
Self::api("metadata", file)
}
pub fn api_download(file: &RemoteFile) -> Url {
Self::api("download", file)
}
pub fn api_password(file: &RemoteFile) -> Url {
Self::api("password", file)
}
pub fn api_params(file: &RemoteFile) -> Url {
Self::api("params", file)
}
pub fn api_info(file: &RemoteFile) -> Url {
Self::api("info", file)
}
pub fn api_exists(file: &RemoteFile) -> Url {
Self::api("exists", file)
}
pub fn api_delete(file: &RemoteFile) -> Url {
Self::api("delete", file)
}
}