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
#![cfg(feature = "swarm")]
pub mod models;
pub mod opts;
pub use models::*;
pub use opts::*;
use crate::{
conn::Payload,
util::url::{construct_ep, encoded_pair},
Result,
};
use std::path::Path;
impl_api_ty!(Plugin => name);
impl<'docker> Plugin<'docker> {
impl_api_ep! {plug: Plugin, resp
Inspect -> &format!("/plugins/{}/json", plug.name)
ForceDelete -> &format!("/plugins/{}", plug.name), PluginInfo
}
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(),
)
.await
.map(|_| ())
}}
api_doc! { Plugin => Disable
|
pub async fn disable(&self) -> Result<()> {
self.docker
.post(&format!("/plugins/{}/disable", self.name), Payload::empty())
.await
.map(|_| ())
}}
api_doc! { Plugin => Push
|
pub async fn push(&self) -> Result<()> {
self.docker
.post(&format!("/plugins/{}/push", self.name), Payload::empty())
.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()),
)
.await
.map(|_| ())
}}
}
impl<'docker> Plugins<'docker> {
impl_api_ep! {plug: Plugin, resp
List -> "/plugins"
}
}