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
use crate::{
conn::{Headers, Payload},
models,
opts::PluginListOpts,
Result,
};
use containers_api::url::{construct_ep, encoded_pair};
use std::path::Path;
impl_api_ty!(Plugin => name);
impl Plugin {
impl_api_ep! {plug: Plugin, resp
Inspect -> &format!("/plugins/{}/json", plug.name), models::Plugin
ForceDelete -> &format!("/plugins/{}", plug.name), models::Plugin
}
api_doc! { Plugin => Enable
|
pub async fn enable(&self, timeout: Option<u64>) -> Result<()> {
let query = timeout.map(|timeout| encoded_pair("timeout", timeout));
self.docker
.post(
&construct_ep(format!("/plugins/{}/enable", self.name), query),
Payload::empty(),
Headers::none()
)
.await
.map(|_| ())
}}
api_doc! { Plugin => Disable
|
pub async fn disable(&self) -> Result<()> {
self.docker
.post(&format!("/plugins/{}/disable", self.name), Payload::empty(), Headers::none())
.await
.map(|_| ())
}}
api_doc! { Plugin => Push
|
pub async fn push(&self) -> Result<()> {
self.docker
.post(&format!("/plugins/{}/push", self.name), Payload::empty(), Headers::none())
.await
.map(|_| ())
}}
api_doc! { Plugin => Create
|
pub async fn create<P>(&self, path: P) -> Result<()>
where
P: AsRef<Path>,
{
self.docker
.post(
&format!("/plugins/{}/create", self.name),
Payload::Text(path.as_ref().to_string_lossy().to_string()),
Headers::none()
)
.await
.map(|_| ())
}}
}
impl Plugins {
impl_api_ep! {plug: Plugin, resp
List -> "/plugins", models::Plugin
}
}