use crate::channels::{FrameAddEntityType, FrameAddTagSchema};
use crate::client::Links;
use crate::errors::SemiontError;
use crate::types::{FrameAddEntityTypeCommand, FrameAddTagSchemaCommand, TagSchema};
pub struct FrameNamespace {
links: Links,
}
impl FrameNamespace {
pub(crate) fn new(links: Links) -> FrameNamespace {
FrameNamespace { links }
}
pub async fn add_entity_type(&self, entity_type: &str) -> Result<(), SemiontError> {
self.links
.request::<FrameAddEntityType>(&FrameAddEntityTypeCommand {
tag: entity_type.to_owned(),
_user_id: None,
})
.await?;
Ok(())
}
pub async fn add_entity_types(&self, entity_types: &[String]) -> Result<(), SemiontError> {
for entity_type in entity_types {
self.add_entity_type(entity_type).await?;
}
Ok(())
}
pub async fn add_tag_schema(&self, schema: TagSchema) -> Result<(), SemiontError> {
self.links
.request::<FrameAddTagSchema>(&FrameAddTagSchemaCommand {
schema,
_user_id: None,
})
.await?;
Ok(())
}
}