#![allow(
clippy::too_many_arguments,
clippy::wildcard_imports,
clippy::doc_markdown
)]
use crate::client::AccountClient;
use crate::error::Error;
use crate::generated::routes;
#[allow(unused_imports)]
use crate::generated::types::*;
#[derive(Debug, Clone, Copy)]
pub struct ToolsService<'a> {
client: &'a AccountClient,
}
impl<'a> ToolsService<'a> {
pub(crate) fn new(client: &'a AccountClient) -> Self {
Self { client }
}
pub fn client(&self) -> &'a AccountClient {
self.client
}
pub async fn create(
&self,
bucket_id: i64,
body: &CreateToolRequestContent,
) -> Result<CreateToolResponseContent, Error> {
let mut operation = self.client.operation(&routes::CREATE_TOOL, &[&bucket_id]);
operation.json(body)?;
self.client.send(operation).await
}
pub async fn delete(&self, tool_id: i64) -> Result<(), Error> {
let operation = self.client.operation(&routes::DELETE_TOOL, &[&tool_id]);
self.client.send_unit(operation).await
}
pub async fn disable(&self, tool_id: i64) -> Result<(), Error> {
let operation = self.client.operation(&routes::DISABLE_TOOL, &[&tool_id]);
self.client.send_unit(operation).await
}
pub async fn enable(&self, tool_id: i64) -> Result<(), Error> {
let operation = self.client.operation(&routes::ENABLE_TOOL, &[&tool_id]);
self.client.send_unit(operation).await
}
pub async fn get(&self, tool_id: i64) -> Result<GetToolResponseContent, Error> {
let operation = self.client.operation(&routes::GET_TOOL, &[&tool_id]);
self.client.send(operation).await
}
pub async fn reposition(
&self,
tool_id: i64,
body: &RepositionToolRequestContent,
) -> Result<(), Error> {
let mut operation = self.client.operation(&routes::REPOSITION_TOOL, &[&tool_id]);
operation.json(body)?;
self.client.send_unit(operation).await
}
pub async fn update(
&self,
tool_id: i64,
body: &UpdateToolRequestContent,
) -> Result<UpdateToolResponseContent, Error> {
let mut operation = self.client.operation(&routes::UPDATE_TOOL, &[&tool_id]);
operation.json(body)?;
self.client.send(operation).await
}
}