use crate::{error::Result, models::*, Configuration};
#[derive(Default)]
pub struct EventTypeListOptions {
pub limit: Option<i32>,
pub iterator: Option<String>,
pub order: Option<Ordering>,
pub include_archived: Option<bool>,
pub with_content: Option<bool>,
}
#[derive(Default)]
pub struct EventTypeCreateOptions {
pub idempotency_key: Option<String>,
}
#[derive(Default)]
pub struct EventTypeImportOpenapiOptions {
pub idempotency_key: Option<String>,
}
#[derive(Default)]
pub struct EventTypeDeleteOptions {
pub expunge: Option<bool>,
}
pub struct EventType<'a> {
cfg: &'a Configuration,
}
impl<'a> EventType<'a> {
pub(super) fn new(cfg: &'a Configuration) -> Self {
Self { cfg }
}
pub async fn list(
&self,
options: Option<EventTypeListOptions>,
) -> Result<ListResponseEventTypeOut> {
let EventTypeListOptions {
limit,
iterator,
order,
include_archived,
with_content,
} = options.unwrap_or_default();
crate::request::Request::new(http1::Method::GET, "/api/v1/event-type")
.with_optional_query_param("limit", limit)
.with_optional_query_param("iterator", iterator)
.with_optional_query_param("order", order)
.with_optional_query_param("include_archived", include_archived)
.with_optional_query_param("with_content", with_content)
.execute(self.cfg)
.await
}
pub async fn create(
&self,
event_type_in: EventTypeIn,
options: Option<EventTypeCreateOptions>,
) -> Result<EventTypeOut> {
let EventTypeCreateOptions { idempotency_key } = options.unwrap_or_default();
crate::request::Request::new(http1::Method::POST, "/api/v1/event-type")
.with_optional_header_param("idempotency-key", idempotency_key)
.with_body_param(event_type_in)
.execute(self.cfg)
.await
}
pub async fn import_openapi(
&self,
event_type_import_open_api_in: EventTypeImportOpenApiIn,
options: Option<EventTypeImportOpenapiOptions>,
) -> Result<EventTypeImportOpenApiOut> {
let EventTypeImportOpenapiOptions { idempotency_key } = options.unwrap_or_default();
crate::request::Request::new(http1::Method::POST, "/api/v1/event-type/import/openapi")
.with_optional_header_param("idempotency-key", idempotency_key)
.with_body_param(event_type_import_open_api_in)
.execute(self.cfg)
.await
}
pub async fn get(&self, event_type_name: String) -> Result<EventTypeOut> {
crate::request::Request::new(http1::Method::GET, "/api/v1/event-type/{event_type_name}")
.with_path_param("event_type_name", event_type_name)
.execute(self.cfg)
.await
}
pub async fn update(
&self,
event_type_name: String,
event_type_update: EventTypeUpdate,
) -> Result<EventTypeOut> {
crate::request::Request::new(http1::Method::PUT, "/api/v1/event-type/{event_type_name}")
.with_path_param("event_type_name", event_type_name)
.with_body_param(event_type_update)
.execute(self.cfg)
.await
}
pub async fn delete(
&self,
event_type_name: String,
options: Option<EventTypeDeleteOptions>,
) -> Result<()> {
let EventTypeDeleteOptions { expunge } = options.unwrap_or_default();
crate::request::Request::new(
http1::Method::DELETE,
"/api/v1/event-type/{event_type_name}",
)
.with_path_param("event_type_name", event_type_name)
.with_optional_query_param("expunge", expunge)
.returns_nothing()
.execute(self.cfg)
.await
}
pub async fn patch(
&self,
event_type_name: String,
event_type_patch: EventTypePatch,
) -> Result<EventTypeOut> {
crate::request::Request::new(http1::Method::PATCH, "/api/v1/event-type/{event_type_name}")
.with_path_param("event_type_name", event_type_name)
.with_body_param(event_type_patch)
.execute(self.cfg)
.await
}
}