add move api call
This commit is contained in:
parent
0b0fa24078
commit
38c21b0b7e
@ -4,7 +4,7 @@ use std::fmt::Display;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::Client;
|
||||
use crate::{Client, Result};
|
||||
use crate::api::{BulkReadDomainExtention, BulkUpdateDomainExtention, DomainExtention};
|
||||
use crate::api::rules::contactgroups::HostContactGroups;
|
||||
use crate::api::rules::snmp::SnmpCommunity;
|
||||
@ -250,3 +250,32 @@ impl FolderBulkUpdateRequest {
|
||||
Self { folder, update_request }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct MoveFolderRequest {
|
||||
destination: String
|
||||
}
|
||||
|
||||
impl MoveFolderRequest {
|
||||
pub fn new(destination: String) -> Self {
|
||||
Self { destination }
|
||||
}
|
||||
}
|
||||
|
||||
impl ApiClient<FolderConfig> {
|
||||
pub async fn move_folder(&self, id: impl Display, request: &MoveFolderRequest) -> Result<()> {
|
||||
let url = format!(
|
||||
"{}/actions/move/invoke",
|
||||
self.inner.object_url(FolderConfig::DOMAIN_TYPE, id)
|
||||
);
|
||||
let request = self.inner.http
|
||||
.post(url)
|
||||
.json(request)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
self.inner.invoke_api(request).await
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: add show hosts api call
|
||||
|
||||
@ -17,10 +17,10 @@ use crate::api::{
|
||||
use crate::{Error, Result};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Client(Arc<InnerClient>);
|
||||
struct InnerClient {
|
||||
http: reqwest::Client,
|
||||
url: String,
|
||||
pub struct Client(pub(crate) Arc<InnerClient>);
|
||||
pub(crate) struct InnerClient {
|
||||
pub(crate) http: reqwest::Client,
|
||||
pub(crate) url: String,
|
||||
semaphore: Semaphore,
|
||||
}
|
||||
|
||||
@ -424,7 +424,7 @@ impl Display for BulkAction {
|
||||
}
|
||||
|
||||
pub struct ApiClient<D: DomainExtention> {
|
||||
inner: Arc<InnerClient>,
|
||||
pub(crate) inner: Arc<InnerClient>,
|
||||
_marker: PhantomData<D>,
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user