From fc06d28997f1f551559e756ca1359ec6a5fad5a9 Mon Sep 17 00:00:00 2001 From: Owen Nelson Date: Thu, 27 Feb 2025 18:24:54 -0800 Subject: [PATCH] WIP: hacking around issues with the rust lib Looks like we have to manually edit the mod.rs for models and api, also manually delete stuff that is removed from the spec. There's probably going to be another rev of fixes because I see a bunch of warnings about unreachable symbols/unused. --- rust/src/api/events_public.rs | 62 ++++++++++++++++++++++ rust/src/api/mod.rs | 1 + rust/src/models/expung_all_contents_out.rs | 22 -------- rust/src/models/mod.rs | 8 ++- 4 files changed, 69 insertions(+), 24 deletions(-) create mode 100644 rust/src/api/events_public.rs delete mode 100644 rust/src/models/expung_all_contents_out.rs diff --git a/rust/src/api/events_public.rs b/rust/src/api/events_public.rs new file mode 100644 index 0000000000..c0c11ef239 --- /dev/null +++ b/rust/src/api/events_public.rs @@ -0,0 +1,62 @@ +use crate::{error::Result, models::*, Configuration}; + +#[derive(Default)] +pub struct EventsPublicConsumerOptions { + /// Limit the number of returned items + pub limit: Option, + + /// The iterator returned from a prior invocation + pub iterator: Option, + + /// Filters messages sent with this event type (optional). + pub event_type: Option, + + /// Filters messages sent with this channel (optional). + pub channel: Option, + + pub after: Option, +} + +pub struct EventsPublic<'a> { + cfg: &'a Configuration, +} + +impl<'a> EventsPublic<'a> { + pub(super) fn new(cfg: &'a Configuration) -> Self { + Self { cfg } + } + + /// Reads the stream of created messages for an application, filtered on the + /// Sink's event types and Channels, using server-managed iterator + /// tracking. + pub async fn consumer( + &self, + app_id: String, + sink_id: String, + consumer_id: String, + options: Option, + ) -> Result { + let EventsPublicConsumerOptions { + limit, + iterator, + event_type, + channel, + after, + } = options.unwrap_or_default(); + + crate::request::Request::new( + http1::Method::GET, + "/api/v1/app/{app_id}/poller/{sink_id}/consumer/{consumer_id}", + ) + .with_path_param("app_id", app_id) + .with_path_param("sink_id", sink_id) + .with_path_param("consumer_id", consumer_id) + .with_optional_query_param("limit", limit) + .with_optional_query_param("iterator", iterator) + .with_optional_query_param("event_type", event_type) + .with_optional_query_param("channel", channel) + .with_optional_query_param("after", after) + .execute(self.cfg) + .await + } +} diff --git a/rust/src/api/mod.rs b/rust/src/api/mod.rs index e33977e985..9ef866b7a4 100644 --- a/rust/src/api/mod.rs +++ b/rust/src/api/mod.rs @@ -10,6 +10,7 @@ mod authentication; mod background_task; mod endpoint; mod event_type; +mod events_public; mod integration; mod message; mod message_attempt; diff --git a/rust/src/models/expung_all_contents_out.rs b/rust/src/models/expung_all_contents_out.rs deleted file mode 100644 index cddff475b6..0000000000 --- a/rust/src/models/expung_all_contents_out.rs +++ /dev/null @@ -1,22 +0,0 @@ -// this file is @generated -use serde::{Deserialize, Serialize}; - -use super::{ - background_task_status::BackgroundTaskStatus, background_task_type::BackgroundTaskType, -}; - -#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)] -pub struct ExpungAllContentsOut { - /// The QueueBackgroundTask's ID. - pub id: String, - - pub status: BackgroundTaskStatus, - - pub task: BackgroundTaskType, -} - -impl ExpungAllContentsOut { - pub fn new(id: String, status: BackgroundTaskStatus, task: BackgroundTaskType) -> Self { - Self { id, status, task } - } -} diff --git a/rust/src/models/mod.rs b/rust/src/models/mod.rs index 3d48911dcc..fc542ddf77 100644 --- a/rust/src/models/mod.rs +++ b/rust/src/models/mod.rs @@ -39,7 +39,7 @@ pub mod event_type_in; pub mod event_type_out; pub mod event_type_patch; pub mod event_type_update; -pub mod expung_all_contents_out; +pub mod expunge_all_contents_out; pub mod http_error_out; pub mod http_validation_error; pub mod integration_in; @@ -73,6 +73,8 @@ pub mod operational_webhook_endpoint_secret_in; pub mod operational_webhook_endpoint_secret_out; pub mod operational_webhook_endpoint_update; pub mod ordering; +pub mod polling_endpoint_message_out; +pub mod polling_endpoint_out; pub mod recover_in; pub mod recover_out; pub mod replay_in; @@ -122,7 +124,7 @@ pub use self::{ event_type_out::EventTypeOut, event_type_patch::EventTypePatch, event_type_update::EventTypeUpdate, - expung_all_contents_out::ExpungAllContentsOut, + expunge_all_contents_out::ExpungeAllContentsOut, http_error_out::HttpErrorOut, http_validation_error::HttpValidationError, integration_in::IntegrationIn, @@ -163,4 +165,6 @@ pub use self::{ status_code_class::StatusCodeClass, template_out::TemplateOut, validation_error::ValidationError, + polling_endpoint_message_out::PollingEndpointMessageOut, + polling_endpoint_out::PollingEndpointOut, };