Skip to main content

atlassian_rust_api/jira/endpoints/cluster/
set_node_offline.rs

1use std::sync::Arc;
2
3use crate::{Jira, Result, rest_client::RestClient, web::Endpoint};
4
5#[derive(Debug, Clone)]
6pub struct SetNodeOfflineBuilder {
7	client: Arc<RestClient>,
8	request: SetNodeOfflineRequest,
9}
10
11#[derive(Debug, Clone, Default)]
12struct SetNodeOfflineRequest {
13	node_id: String,
14}
15
16impl Endpoint for SetNodeOfflineRequest {
17	fn endpoint(&self) -> std::borrow::Cow<'static, str> {
18		format!("cluster/node/{}/offline", &self.node_id).into()
19	}
20}
21
22impl SetNodeOfflineBuilder {
23	fn new(client: Arc<RestClient>) -> SetNodeOfflineBuilder {
24		SetNodeOfflineBuilder { client, request: SetNodeOfflineRequest::default() }
25	}
26
27	fn node_id(mut self, node_id: impl Into<String>) -> SetNodeOfflineBuilder {
28		self.request.node_id = node_id.into();
29		self
30	}
31
32	pub async fn send(self) -> Result<()> {
33		self.client.put_ignore(self.request).await
34	}
35}
36
37impl Jira {
38	/// Change the node's state to offline if the node is reporting as active, but is not alive. 
39	/// 
40	/// Don't use this method as an equivalent of running ./stop-jira.sh. This method doesn't shut down 
41	/// a node, but only changes its state, so that other nodes don't communicate with it.
42	pub fn set_node_offline(&self, node_id: impl Into<String>) -> SetNodeOfflineBuilder {
43		SetNodeOfflineBuilder::new(Arc::clone(&self.client)).node_id(node_id)
44	}
45}