Compare commits
No commits in common. "96402420c13b45fc7e8a4c36e76e4e0d5ffe5cff" and "8413131ed453ef548882ced12561380f5c8cbec3" have entirely different histories.
96402420c1
...
8413131ed4
@ -1,44 +0,0 @@
|
|||||||
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!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -17,7 +17,7 @@ pub struct Group {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Group {
|
impl Group {
|
||||||
pub fn new(name: String, alias: String) -> Self {
|
fn new(name: String, alias: String) -> Self {
|
||||||
Self { name, alias }
|
Self { name, alias }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -29,7 +29,7 @@ pub struct GroupAlias {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl GroupAlias {
|
impl GroupAlias {
|
||||||
pub fn new(alias: String) -> Self {
|
fn new(alias: String) -> Self {
|
||||||
Self { alias }
|
Self { alias }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ pub struct BulkGroupUpdate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BulkGroupUpdate {
|
impl BulkGroupUpdate {
|
||||||
pub fn new(name: String, alias: String) -> Self {
|
fn new(name: String, alias: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
name,
|
name,
|
||||||
attributes: GroupAlias::new(alias)
|
attributes: GroupAlias::new(alias)
|
||||||
@ -65,7 +65,7 @@ macro_rules! domain_group {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl $id {
|
impl $id {
|
||||||
pub fn new(name: String, alias: String) -> Self {
|
fn new(name: String, alias: String) -> Self {
|
||||||
Self(Group::new(name, alias))
|
Self(Group::new(name, alias))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
pub mod activations;
|
|
||||||
pub mod folders;
|
pub mod folders;
|
||||||
pub mod hosts;
|
pub mod hosts;
|
||||||
pub mod groups;
|
pub mod groups;
|
||||||
pub(crate) mod rules;
|
pub(crate) mod rules;
|
||||||
pub mod tags;
|
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
@ -18,7 +16,6 @@ pub enum DomainType {
|
|||||||
ContactGroupConfig,
|
ContactGroupConfig,
|
||||||
HostGroupConfig,
|
HostGroupConfig,
|
||||||
ServiceGroupConfig,
|
ServiceGroupConfig,
|
||||||
HostTagGroup
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for DomainType {
|
impl fmt::Display for DomainType {
|
||||||
@ -30,7 +27,6 @@ impl fmt::Display for DomainType {
|
|||||||
DomainType::ContactGroupConfig => write!(f, "contact_group_config"),
|
DomainType::ContactGroupConfig => write!(f, "contact_group_config"),
|
||||||
DomainType::HostGroupConfig => write!(f, "host_group_config"),
|
DomainType::HostGroupConfig => write!(f, "host_group_config"),
|
||||||
DomainType::ServiceGroupConfig => write!(f, "service_group_config"),
|
DomainType::ServiceGroupConfig => write!(f, "service_group_config"),
|
||||||
DomainType::HostTagGroup => write!(f, "host_tag_group"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
160
src/api/tags.rs
160
src/api/tags.rs
@ -1,160 +0,0 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
|
||||||
#[cfg(feature = "schemars")]
|
|
||||||
use schemars::JsonSchema;
|
|
||||||
|
|
||||||
use crate::api::{BulkReadDomainExtension, DomainExtension, DomainType};
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
|
|
||||||
pub struct ExtendedTagGroup {
|
|
||||||
pub id: String,
|
|
||||||
pub title: String,
|
|
||||||
#[serde(flatten, default)]
|
|
||||||
pub inner: TagGroup
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
|
||||||
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
|
|
||||||
pub struct TagGroup {
|
|
||||||
#[serde(default, skip_serializing_if = "String::is_empty")]
|
|
||||||
pub topic: String,
|
|
||||||
#[serde(default, skip_serializing_if = "String::is_empty")]
|
|
||||||
pub help: String,
|
|
||||||
pub tags: Vec<Tag>
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
||||||
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
|
|
||||||
pub struct Tag {
|
|
||||||
pub id: Option<String>,
|
|
||||||
pub title: String,
|
|
||||||
pub aux_tags: Vec<String>
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ExtendedTagGroup {
|
|
||||||
pub fn new(id: String, title: String) -> Self {
|
|
||||||
Self { id, title, inner: Default::default() }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_topic(&mut self, topic: String) {
|
|
||||||
self.inner.topic = topic;
|
|
||||||
}
|
|
||||||
pub fn with_topic(mut self, topic: String) -> Self {
|
|
||||||
self.set_topic(topic);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
pub fn set_help(&mut self, help: String) {
|
|
||||||
self.inner.help = help;
|
|
||||||
}
|
|
||||||
pub fn with_help(mut self, help: String) -> Self {
|
|
||||||
self.set_help(help);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
pub fn add_tag(&mut self, tag: Tag) {
|
|
||||||
self.inner.tags.push(tag);
|
|
||||||
}
|
|
||||||
pub fn with_tag(mut self, tag: Tag) -> Self {
|
|
||||||
self.add_tag(tag);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Tag {
|
|
||||||
pub fn new(id: String, title: String) -> Self {
|
|
||||||
Self {
|
|
||||||
id: Some(id),
|
|
||||||
title,
|
|
||||||
aux_tags: Vec::new()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn new_default(title: String) -> Self {
|
|
||||||
Self {
|
|
||||||
id: None,
|
|
||||||
title,
|
|
||||||
aux_tags: Vec::new()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn add_aux_tag(&mut self, tag: String) {
|
|
||||||
self.aux_tags.push(tag);
|
|
||||||
}
|
|
||||||
pub fn with_aux_tag(mut self, tag: String) -> Self {
|
|
||||||
self.add_aux_tag(tag);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
|
||||||
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
|
|
||||||
pub struct TagUpdateRequest {
|
|
||||||
title: String,
|
|
||||||
#[serde(flatten, default)]
|
|
||||||
inner: TagGroup,
|
|
||||||
repair: bool
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TagUpdateRequest {
|
|
||||||
pub fn new(title: String, repair: bool) -> Self {
|
|
||||||
Self { title, repair, inner: Default::default() }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_topic(&mut self, topic: String) {
|
|
||||||
self.inner.topic = topic;
|
|
||||||
}
|
|
||||||
pub fn with_topic(mut self, topic: String) -> Self {
|
|
||||||
self.set_topic(topic);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
pub fn set_help(&mut self, help: String) {
|
|
||||||
self.inner.help = help;
|
|
||||||
}
|
|
||||||
pub fn with_help(mut self, help: String) -> Self {
|
|
||||||
self.set_help(help);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
pub fn add_tag(&mut self, tag: Tag) {
|
|
||||||
self.inner.tags.push(tag);
|
|
||||||
}
|
|
||||||
pub fn with_tag(mut self, tag: Tag) -> Self {
|
|
||||||
self.add_tag(tag);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize)]
|
|
||||||
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
|
|
||||||
pub struct TagDeleteQuery {
|
|
||||||
repair: bool,
|
|
||||||
mode: Option<TagDeleteMode>
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TagDeleteQuery {
|
|
||||||
pub fn new(repair: bool, mode: Option<TagDeleteMode>) -> Self {
|
|
||||||
Self { repair, mode }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize)]
|
|
||||||
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
|
|
||||||
pub enum TagDeleteMode {
|
|
||||||
Abort,
|
|
||||||
#[default] Delete,
|
|
||||||
Remove,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl DomainExtension for TagGroup {
|
|
||||||
const DOMAIN_TYPE: super::DomainType = DomainType::HostTagGroup;
|
|
||||||
|
|
||||||
type CreationRequest = ExtendedTagGroup;
|
|
||||||
type CreationQuery = ();
|
|
||||||
type ReadQuery = ();
|
|
||||||
type UpdateRequest = TagUpdateRequest;
|
|
||||||
type DeleteQuery = ();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: id and title are in the "DomainObject".
|
|
||||||
// should be added to during query?
|
|
||||||
// maybe add "with_title_and_id" to DomainExtension, defaulting to no-op?
|
|
||||||
impl BulkReadDomainExtension for TagGroup {
|
|
||||||
type BulkReadQuery = ();
|
|
||||||
}
|
|
||||||
@ -433,23 +433,17 @@ impl Display for BulkAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ApiClient<D> {
|
pub struct ApiClient<D: DomainExtension> {
|
||||||
pub(crate) inner: Arc<InnerClient>,
|
pub(crate) inner: Arc<InnerClient>,
|
||||||
_marker: PhantomData<D>,
|
_marker: PhantomData<D>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <D> ApiClient<D> {
|
|
||||||
pub(crate) fn new(inner: &Client) -> Self {
|
|
||||||
Self {
|
|
||||||
inner: inner.0.clone(),
|
|
||||||
_marker: Default::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<D: DomainExtension> From<&Client> for ApiClient<D> {
|
impl<D: DomainExtension> From<&Client> for ApiClient<D> {
|
||||||
fn from(value: &Client) -> Self {
|
fn from(value: &Client) -> Self {
|
||||||
Self::new(value)
|
Self {
|
||||||
|
inner: value.0.clone(),
|
||||||
|
_marker: Default::default(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user