diff --git a/ChangeLog.md b/ChangeLog.md index 87356a2f8..d4243890d 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,7 +1,11 @@ # Changelog ## Next -* +* Libs/Rust: Add `api::MessageAttemptListAttemptedMessagesOptions` and use it for + `MessageAttempt::list_attempted_messages`, replacing `MessageAttemptListOptions` which contained + some extra parameters never used with this method / endpoint ([#1568]) + +[#1568]: https://github.com/svix/svix-webhooks/pull/1568 ## Version 1.44.0 * Libs/JavaScript: Revert packaging-related change because it broke for some users ([#1556]) diff --git a/rust/src/api/message_attempt.rs b/rust/src/api/message_attempt.rs index 24b4cc60a..a9f2646ba 100644 --- a/rust/src/api/message_attempt.rs +++ b/rust/src/api/message_attempt.rs @@ -2,7 +2,7 @@ use super::ListOptions; use crate::{apis::message_attempt_api, error::Result, models::*, Configuration}; #[derive(Default)] -pub struct MessageAttemptListOptions { +pub struct MessageAttemptListByEndpointOptions { /// Limit the number of returned items pub limit: Option, @@ -22,9 +22,6 @@ pub struct MessageAttemptListOptions { /// Filter response based on the tag pub tag: Option, - /// Filter the attempts based on the attempted endpoint - pub endpoint_id: Option, - /// Only include items created before a certain date /// /// RFC3339 date string. @@ -38,12 +35,15 @@ pub struct MessageAttemptListOptions { /// When `true` attempt content is included in the response pub with_content: Option, + /// When `true`, the message information is included in the response + pub with_msg: Option, + /// Filter response based on the event type pub event_types: Option>, } #[derive(Default)] -pub struct MessageAttemptListByEndpointOptions { +pub struct MessageAttemptListOptions { /// Limit the number of returned items pub limit: Option, @@ -63,6 +63,9 @@ pub struct MessageAttemptListByEndpointOptions { /// Filter response based on the tag pub tag: Option, + /// Filter the attempts based on the attempted endpoint + pub endpoint_id: Option, + /// Only include items created before a certain date /// /// RFC3339 date string. @@ -76,8 +79,40 @@ pub struct MessageAttemptListByEndpointOptions { /// When `true` attempt content is included in the response pub with_content: Option, - /// When `true`, the message information is included in the response - pub with_msg: Option, + /// Filter response based on the event type + pub event_types: Option>, +} + +#[derive(Default)] +pub struct MessageAttemptListAttemptedMessagesOptions { + /// Limit the number of returned items + pub limit: Option, + + /// The iterator returned from a prior invocation + pub iterator: Option, + + /// Filter response based on the channel + pub channel: Option, + + /// Filter response based on the message tags + pub tag: Option, + + /// Filter response based on the status of the attempt: Success (0), Pending + /// (1), Failed (2), or Sending (3) + pub status: Option, + + /// Only include items created before a certain date + /// + /// RFC3339 date string. + pub before: Option, + + /// Only include items created after a certain date + /// + /// RFC3339 date string. + pub after: Option, + + /// When `true` message payloads are included in the response + pub with_content: Option, /// Filter response based on the event type pub event_types: Option>, @@ -92,96 +127,96 @@ impl<'a> MessageAttempt<'a> { Self { cfg } } - /// List attempts by message id + /// List attempts by endpoint id /// /// Note that by default this endpoint is limited to retrieving 90 days' /// worth of data relative to now or, if an iterator is provided, 90 /// days before/after the time indicated by the iterator ID. If you /// require data beyond those time ranges, you will need to explicitly /// set the `before` or `after` parameter as appropriate. - pub async fn list_by_msg( + pub async fn list_by_endpoint( &self, app_id: String, - msg_id: String, - options: Option, + endpoint_id: String, + options: Option, ) -> Result { - let MessageAttemptListOptions { + let MessageAttemptListByEndpointOptions { limit, iterator, status, status_code_class, channel, tag, - endpoint_id, before, after, with_content, + with_msg, event_types, } = options.unwrap_or_default(); - message_attempt_api::v1_period_message_attempt_period_list_by_msg( + message_attempt_api::v1_period_message_attempt_period_list_by_endpoint( self.cfg, - message_attempt_api::V1PeriodMessageAttemptPeriodListByMsgParams { + message_attempt_api::V1PeriodMessageAttemptPeriodListByEndpointParams { app_id, - msg_id, + endpoint_id, limit, iterator, status, status_code_class, channel, tag, - endpoint_id, before, after, with_content, + with_msg, event_types, }, ) .await } - /// List attempts by endpoint id + /// List attempts by message id /// /// Note that by default this endpoint is limited to retrieving 90 days' /// worth of data relative to now or, if an iterator is provided, 90 /// days before/after the time indicated by the iterator ID. If you /// require data beyond those time ranges, you will need to explicitly /// set the `before` or `after` parameter as appropriate. - pub async fn list_by_endpoint( + pub async fn list_by_msg( &self, app_id: String, - endpoint_id: String, - options: Option, + msg_id: String, + options: Option, ) -> Result { - let MessageAttemptListByEndpointOptions { + let MessageAttemptListOptions { limit, iterator, status, status_code_class, channel, tag, + endpoint_id, before, after, with_content, - with_msg, event_types, } = options.unwrap_or_default(); - message_attempt_api::v1_period_message_attempt_period_list_by_endpoint( + message_attempt_api::v1_period_message_attempt_period_list_by_msg( self.cfg, - message_attempt_api::V1PeriodMessageAttemptPeriodListByEndpointParams { + message_attempt_api::V1PeriodMessageAttemptPeriodListByMsgParams { app_id, - endpoint_id, + msg_id, limit, iterator, status, status_code_class, channel, tag, + endpoint_id, before, after, with_content, - with_msg, event_types, }, ) @@ -203,20 +238,18 @@ impl<'a> MessageAttempt<'a> { &self, app_id: String, endpoint_id: String, - options: Option, + options: Option, ) -> Result { - let MessageAttemptListOptions { - iterator, + let MessageAttemptListAttemptedMessagesOptions { limit, - event_types, - before, - after, + iterator, channel, tag, status, - status_code_class: _, + before, + after, with_content, - endpoint_id: _, + event_types, } = options.unwrap_or_default(); message_attempt_api::v1_period_message_attempt_period_list_attempted_messages( @@ -260,6 +293,7 @@ impl<'a> MessageAttempt<'a> { .await } + #[deprecated = "Use `list_by_msg` instead, setting the `endpoint_id` in `options`."] pub async fn list_attempts_for_endpoint( &self, app_id: String, @@ -317,20 +351,6 @@ impl<'a> MessageAttempt<'a> { .await } - /// Resend a message to the specified endpoint. - pub async fn resend(&self, app_id: String, msg_id: String, endpoint_id: String) -> Result<()> { - message_attempt_api::v1_period_message_attempt_period_resend( - self.cfg, - message_attempt_api::V1PeriodMessageAttemptPeriodResendParams { - app_id, - msg_id, - endpoint_id, - idempotency_key: None, - }, - ) - .await - } - /// Deletes the given attempt's response body. Useful when an endpoint /// accidentally returned sensitive content. pub async fn expunge_content( @@ -349,4 +369,18 @@ impl<'a> MessageAttempt<'a> { ) .await } + + /// Resend a message to the specified endpoint. + pub async fn resend(&self, app_id: String, msg_id: String, endpoint_id: String) -> Result<()> { + message_attempt_api::v1_period_message_attempt_period_resend( + self.cfg, + message_attempt_api::V1PeriodMessageAttemptPeriodResendParams { + app_id, + msg_id, + endpoint_id, + idempotency_key: None, + }, + ) + .await + } } diff --git a/rust/src/api/mod.rs b/rust/src/api/mod.rs index f768ea312..39cbf65fb 100644 --- a/rust/src/api/mod.rs +++ b/rust/src/api/mod.rs @@ -44,7 +44,8 @@ pub use self::{ integration::{Integration, IntegrationListOptions}, message::{Message, MessageListOptions}, message_attempt::{ - MessageAttempt, MessageAttemptListByEndpointOptions, MessageAttemptListOptions, + MessageAttempt, MessageAttemptListAttemptedMessagesOptions, + MessageAttemptListByEndpointOptions, MessageAttemptListOptions, }, operational_webhook_endpoint::{ OperationalWebhookEndpoint, OperationalWebhookEndpointListOptions,