use crate::{error::Result, models::*, Configuration};
#[derive(Default)]
pub struct IngestEndpointListOptions {
pub limit: Option<i32>,
pub iterator: Option<String>,
pub order: Option<Ordering>,
}
#[derive(Default)]
pub struct IngestEndpointCreateOptions {
pub idempotency_key: Option<String>,
}
#[derive(Default)]
pub struct IngestEndpointRotateSecretOptions {
pub idempotency_key: Option<String>,
}
pub struct IngestEndpoint<'a> {
cfg: &'a Configuration,
}
impl<'a> IngestEndpoint<'a> {
pub(super) fn new(cfg: &'a Configuration) -> Self {
Self { cfg }
}
pub async fn list(
&self,
source_id: String,
options: Option<IngestEndpointListOptions>,
) -> Result<ListResponseIngestEndpointOut> {
let IngestEndpointListOptions {
limit,
iterator,
order,
} = options.unwrap_or_default();
crate::request::Request::new(
http1::Method::GET,
"/ingest/api/v1/source/{source_id}/endpoint",
)
.with_path_param("source_id", source_id)
.with_optional_query_param("limit", limit)
.with_optional_query_param("iterator", iterator)
.with_optional_query_param("order", order)
.execute(self.cfg)
.await
}
pub async fn create(
&self,
source_id: String,
ingest_endpoint_in: IngestEndpointIn,
options: Option<IngestEndpointCreateOptions>,
) -> Result<IngestEndpointOut> {
let IngestEndpointCreateOptions { idempotency_key } = options.unwrap_or_default();
crate::request::Request::new(
http1::Method::POST,
"/ingest/api/v1/source/{source_id}/endpoint",
)
.with_path_param("source_id", source_id)
.with_optional_header_param("idempotency-key", idempotency_key)
.with_body_param(ingest_endpoint_in)
.execute(self.cfg)
.await
}
pub async fn get(&self, source_id: String, endpoint_id: String) -> Result<IngestEndpointOut> {
crate::request::Request::new(
http1::Method::GET,
"/ingest/api/v1/source/{source_id}/endpoint/{endpoint_id}",
)
.with_path_param("source_id", source_id)
.with_path_param("endpoint_id", endpoint_id)
.execute(self.cfg)
.await
}
pub async fn update(
&self,
source_id: String,
endpoint_id: String,
ingest_endpoint_update: IngestEndpointUpdate,
) -> Result<IngestEndpointOut> {
crate::request::Request::new(
http1::Method::PUT,
"/ingest/api/v1/source/{source_id}/endpoint/{endpoint_id}",
)
.with_path_param("source_id", source_id)
.with_path_param("endpoint_id", endpoint_id)
.with_body_param(ingest_endpoint_update)
.execute(self.cfg)
.await
}
pub async fn delete(&self, source_id: String, endpoint_id: String) -> Result<()> {
crate::request::Request::new(
http1::Method::DELETE,
"/ingest/api/v1/source/{source_id}/endpoint/{endpoint_id}",
)
.with_path_param("source_id", source_id)
.with_path_param("endpoint_id", endpoint_id)
.returns_nothing()
.execute(self.cfg)
.await
}
pub async fn get_headers(
&self,
source_id: String,
endpoint_id: String,
) -> Result<IngestEndpointHeadersOut> {
crate::request::Request::new(
http1::Method::GET,
"/ingest/api/v1/source/{source_id}/endpoint/{endpoint_id}/headers",
)
.with_path_param("source_id", source_id)
.with_path_param("endpoint_id", endpoint_id)
.execute(self.cfg)
.await
}
pub async fn update_headers(
&self,
source_id: String,
endpoint_id: String,
ingest_endpoint_headers_in: IngestEndpointHeadersIn,
) -> Result<()> {
crate::request::Request::new(
http1::Method::PUT,
"/ingest/api/v1/source/{source_id}/endpoint/{endpoint_id}/headers",
)
.with_path_param("source_id", source_id)
.with_path_param("endpoint_id", endpoint_id)
.with_body_param(ingest_endpoint_headers_in)
.returns_nothing()
.execute(self.cfg)
.await
}
pub async fn get_secret(
&self,
source_id: String,
endpoint_id: String,
) -> Result<IngestEndpointSecretOut> {
crate::request::Request::new(
http1::Method::GET,
"/ingest/api/v1/source/{source_id}/endpoint/{endpoint_id}/secret",
)
.with_path_param("source_id", source_id)
.with_path_param("endpoint_id", endpoint_id)
.execute(self.cfg)
.await
}
pub async fn rotate_secret(
&self,
source_id: String,
endpoint_id: String,
ingest_endpoint_secret_in: IngestEndpointSecretIn,
options: Option<IngestEndpointRotateSecretOptions>,
) -> Result<()> {
let IngestEndpointRotateSecretOptions { idempotency_key } = options.unwrap_or_default();
crate::request::Request::new(
http1::Method::POST,
"/ingest/api/v1/source/{source_id}/endpoint/{endpoint_id}/secret/rotate",
)
.with_path_param("source_id", source_id)
.with_path_param("endpoint_id", endpoint_id)
.with_optional_header_param("idempotency-key", idempotency_key)
.with_body_param(ingest_endpoint_secret_in)
.returns_nothing()
.execute(self.cfg)
.await
}
pub async fn get_transformation(
&self,
source_id: String,
endpoint_id: String,
) -> Result<IngestEndpointTransformationOut> {
crate::request::Request::new(
http1::Method::GET,
"/ingest/api/v1/source/{source_id}/endpoint/{endpoint_id}/transformation",
)
.with_path_param("source_id", source_id)
.with_path_param("endpoint_id", endpoint_id)
.execute(self.cfg)
.await
}
pub async fn set_transformation(
&self,
source_id: String,
endpoint_id: String,
ingest_endpoint_transformation_patch: IngestEndpointTransformationPatch,
) -> Result<()> {
crate::request::Request::new(
http1::Method::PATCH,
"/ingest/api/v1/source/{source_id}/endpoint/{endpoint_id}/transformation",
)
.with_path_param("source_id", source_id)
.with_path_param("endpoint_id", endpoint_id)
.with_body_param(ingest_endpoint_transformation_patch)
.returns_nothing()
.execute(self.cfg)
.await
}
}