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
82
83
#![cfg(feature = "swarm")]
pub mod data;
pub mod opts;
pub use data::*;
pub use opts::*;
use crate::{conn::Payload, Docker, Result};
api_doc! { Swarm
|
pub struct Swarm<'docker> {
docker: &'docker Docker,
}
}
impl<'docker> Swarm<'docker> {
pub fn new(docker: &'docker Docker) -> Self {
Self { docker }
}
impl_api_ep! {_swarm: Swarm, resp
Inspect -> "/swarm"
}
api_doc! { Swarm => Unlockkey
|
pub async fn get_unlock_key(&self) -> Result<UnlockKey> {
self.docker.get_json("/swarm/unlockkey").await
}}
api_doc! { Swarm => Unlock
|
pub async fn unlock_manager(&self, key: &UnlockKey) -> Result<()> {
self.docker
.post("/swarm/unlock", Payload::Json(serde_json::to_string(key)?))
.await
.map(|_| ())
}}
api_doc! { Swarm => Init
|
pub async fn initialize(&self, opts: &SwarmInitOpts) -> Result<()> {
self.docker
.post("/swarm/init", Payload::Json(opts.serialize()?))
.await
.map(|_| ())
}}
api_doc! { Swarm => Join
|
pub async fn join(&self, opts: &SwarmJoinOpts) -> Result<()> {
self.docker
.post("/swarm/join", Payload::Json(opts.serialize()?))
.await
.map(|_| ())
}}
api_doc! { Swarm => Leave
|
pub async fn leave(&self) -> Result<()> {
self.docker
.post("/swarm/leave?force=false", Payload::empty())
.await
.map(|_| ())
}}
api_doc! { Swarm => Leave
|
pub async fn force_leave(&self) -> Result<()> {
self.docker
.post("/swarm/leave?force=true", Payload::empty())
.await
.map(|_| ())
}}
}