add bones for change activations

This commit is contained in:
Vincent Stuyck 2026-01-11 22:33:03 +01:00
parent ae7643193a
commit 96402420c1
4 changed files with 57 additions and 7 deletions

44
src/api/activations.rs Normal file
View File

@ -0,0 +1,44 @@
use serde::{Deserialize, Serialize};
use crate::{ApiClient, Client, Result};
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
pub struct ChangeActivation;
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
pub struct PendingChange;
impl From<&Client> for ApiClient<ChangeActivation> {
fn from(value: &Client) -> Self {
Self::new(value)
}
}
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
pub struct ActivateChangeRequest {
redirect: bool,
sites: Vec<String>,
force_foreign_changes: bool
}
impl ApiClient<ChangeActivation> {
pub async fn activate(&self) -> Result<()> {
todo!()
}
pub async fn await_activation(&self, activation_id: &str) -> Result<()> {
todo!()
}
pub async fn read_current_activations(&self) -> Result<Vec<ChangeActivation>> {
todo!()
}
pub async fn bulk_read_pending_changes(&self) -> Result<Vec<PendingChange>> {
todo!()
}
pub async fn read_activation_status(&self, activation_id: &str) -> Result<ChangeActivation> {
todo!()
}
}

View File

@ -1,3 +1,4 @@
pub mod activations;
pub mod folders; pub mod folders;
pub mod hosts; pub mod hosts;
pub mod groups; pub mod groups;

View File

@ -125,11 +125,11 @@ impl TagUpdateRequest {
#[cfg_attr(feature = "schemars", derive(JsonSchema))] #[cfg_attr(feature = "schemars", derive(JsonSchema))]
pub struct TagDeleteQuery { pub struct TagDeleteQuery {
repair: bool, repair: bool,
mode: TagDeleteMode mode: Option<TagDeleteMode>
} }
impl TagDeleteQuery { impl TagDeleteQuery {
pub fn new(repair: bool, mode: TagDeleteMode) -> Self { pub fn new(repair: bool, mode: Option<TagDeleteMode>) -> Self {
Self { repair, mode } Self { repair, mode }
} }
} }
@ -140,7 +140,6 @@ pub enum TagDeleteMode {
Abort, Abort,
#[default] Delete, #[default] Delete,
Remove, Remove,
Null
} }
impl DomainExtension for TagGroup { impl DomainExtension for TagGroup {

View File

@ -433,20 +433,26 @@ impl Display for BulkAction {
} }
} }
pub struct ApiClient<D: DomainExtension> { pub struct ApiClient<D> {
pub(crate) inner: Arc<InnerClient>, pub(crate) inner: Arc<InnerClient>,
_marker: PhantomData<D>, _marker: PhantomData<D>,
} }
impl<D: DomainExtension> From<&Client> for ApiClient<D> { impl <D> ApiClient<D> {
fn from(value: &Client) -> Self { pub(crate) fn new(inner: &Client) -> Self {
Self { Self {
inner: value.0.clone(), inner: inner.0.clone(),
_marker: Default::default(), _marker: Default::default(),
} }
} }
} }
impl<D: DomainExtension> From<&Client> for ApiClient<D> {
fn from(value: &Client) -> Self {
Self::new(value)
}
}
impl<D: DomainExtension> ApiClient<D> { impl<D: DomainExtension> ApiClient<D> {
pub async fn create( pub async fn create(
&self, &self,