Skip to content

Commit 7b718fd

Browse files
authored
rust: Some MessageAttempt API cleanup (#1568)
Prepare for auto-generating this.
2 parents e9703bd + a3aeb84 commit 7b718fd

File tree

3 files changed

+90
-51
lines changed

3 files changed

+90
-51
lines changed

ChangeLog.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Changelog
22

33
## Next
4-
*
4+
* Libs/Rust: Add `api::MessageAttemptListAttemptedMessagesOptions` and use it for
5+
`MessageAttempt::list_attempted_messages`, replacing `MessageAttemptListOptions` which contained
6+
some extra parameters never used with this method / endpoint ([#1568])
7+
8+
[#1568]: https://github.com/svix/svix-webhooks/pull/1568
59

610
## Version 1.44.0
711
* Libs/JavaScript: Revert packaging-related change because it broke for some users ([#1556])

rust/src/api/message_attempt.rs

Lines changed: 83 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::ListOptions;
22
use crate::{apis::message_attempt_api, error::Result, models::*, Configuration};
33

44
#[derive(Default)]
5-
pub struct MessageAttemptListOptions {
5+
pub struct MessageAttemptListByEndpointOptions {
66
/// Limit the number of returned items
77
pub limit: Option<i32>,
88

@@ -22,9 +22,6 @@ pub struct MessageAttemptListOptions {
2222
/// Filter response based on the tag
2323
pub tag: Option<String>,
2424

25-
/// Filter the attempts based on the attempted endpoint
26-
pub endpoint_id: Option<String>,
27-
2825
/// Only include items created before a certain date
2926
///
3027
/// RFC3339 date string.
@@ -38,12 +35,15 @@ pub struct MessageAttemptListOptions {
3835
/// When `true` attempt content is included in the response
3936
pub with_content: Option<bool>,
4037

38+
/// When `true`, the message information is included in the response
39+
pub with_msg: Option<bool>,
40+
4141
/// Filter response based on the event type
4242
pub event_types: Option<Vec<String>>,
4343
}
4444

4545
#[derive(Default)]
46-
pub struct MessageAttemptListByEndpointOptions {
46+
pub struct MessageAttemptListOptions {
4747
/// Limit the number of returned items
4848
pub limit: Option<i32>,
4949

@@ -63,6 +63,9 @@ pub struct MessageAttemptListByEndpointOptions {
6363
/// Filter response based on the tag
6464
pub tag: Option<String>,
6565

66+
/// Filter the attempts based on the attempted endpoint
67+
pub endpoint_id: Option<String>,
68+
6669
/// Only include items created before a certain date
6770
///
6871
/// RFC3339 date string.
@@ -76,8 +79,40 @@ pub struct MessageAttemptListByEndpointOptions {
7679
/// When `true` attempt content is included in the response
7780
pub with_content: Option<bool>,
7881

79-
/// When `true`, the message information is included in the response
80-
pub with_msg: Option<bool>,
82+
/// Filter response based on the event type
83+
pub event_types: Option<Vec<String>>,
84+
}
85+
86+
#[derive(Default)]
87+
pub struct MessageAttemptListAttemptedMessagesOptions {
88+
/// Limit the number of returned items
89+
pub limit: Option<i32>,
90+
91+
/// The iterator returned from a prior invocation
92+
pub iterator: Option<String>,
93+
94+
/// Filter response based on the channel
95+
pub channel: Option<String>,
96+
97+
/// Filter response based on the message tags
98+
pub tag: Option<String>,
99+
100+
/// Filter response based on the status of the attempt: Success (0), Pending
101+
/// (1), Failed (2), or Sending (3)
102+
pub status: Option<MessageStatus>,
103+
104+
/// Only include items created before a certain date
105+
///
106+
/// RFC3339 date string.
107+
pub before: Option<String>,
108+
109+
/// Only include items created after a certain date
110+
///
111+
/// RFC3339 date string.
112+
pub after: Option<String>,
113+
114+
/// When `true` message payloads are included in the response
115+
pub with_content: Option<bool>,
81116

82117
/// Filter response based on the event type
83118
pub event_types: Option<Vec<String>>,
@@ -92,96 +127,96 @@ impl<'a> MessageAttempt<'a> {
92127
Self { cfg }
93128
}
94129

95-
/// List attempts by message id
130+
/// List attempts by endpoint id
96131
///
97132
/// Note that by default this endpoint is limited to retrieving 90 days'
98133
/// worth of data relative to now or, if an iterator is provided, 90
99134
/// days before/after the time indicated by the iterator ID. If you
100135
/// require data beyond those time ranges, you will need to explicitly
101136
/// set the `before` or `after` parameter as appropriate.
102-
pub async fn list_by_msg(
137+
pub async fn list_by_endpoint(
103138
&self,
104139
app_id: String,
105-
msg_id: String,
106-
options: Option<MessageAttemptListOptions>,
140+
endpoint_id: String,
141+
options: Option<MessageAttemptListByEndpointOptions>,
107142
) -> Result<ListResponseMessageAttemptOut> {
108-
let MessageAttemptListOptions {
143+
let MessageAttemptListByEndpointOptions {
109144
limit,
110145
iterator,
111146
status,
112147
status_code_class,
113148
channel,
114149
tag,
115-
endpoint_id,
116150
before,
117151
after,
118152
with_content,
153+
with_msg,
119154
event_types,
120155
} = options.unwrap_or_default();
121156

122-
message_attempt_api::v1_period_message_attempt_period_list_by_msg(
157+
message_attempt_api::v1_period_message_attempt_period_list_by_endpoint(
123158
self.cfg,
124-
message_attempt_api::V1PeriodMessageAttemptPeriodListByMsgParams {
159+
message_attempt_api::V1PeriodMessageAttemptPeriodListByEndpointParams {
125160
app_id,
126-
msg_id,
161+
endpoint_id,
127162
limit,
128163
iterator,
129164
status,
130165
status_code_class,
131166
channel,
132167
tag,
133-
endpoint_id,
134168
before,
135169
after,
136170
with_content,
171+
with_msg,
137172
event_types,
138173
},
139174
)
140175
.await
141176
}
142177

143-
/// List attempts by endpoint id
178+
/// List attempts by message id
144179
///
145180
/// Note that by default this endpoint is limited to retrieving 90 days'
146181
/// worth of data relative to now or, if an iterator is provided, 90
147182
/// days before/after the time indicated by the iterator ID. If you
148183
/// require data beyond those time ranges, you will need to explicitly
149184
/// set the `before` or `after` parameter as appropriate.
150-
pub async fn list_by_endpoint(
185+
pub async fn list_by_msg(
151186
&self,
152187
app_id: String,
153-
endpoint_id: String,
154-
options: Option<MessageAttemptListByEndpointOptions>,
188+
msg_id: String,
189+
options: Option<MessageAttemptListOptions>,
155190
) -> Result<ListResponseMessageAttemptOut> {
156-
let MessageAttemptListByEndpointOptions {
191+
let MessageAttemptListOptions {
157192
limit,
158193
iterator,
159194
status,
160195
status_code_class,
161196
channel,
162197
tag,
198+
endpoint_id,
163199
before,
164200
after,
165201
with_content,
166-
with_msg,
167202
event_types,
168203
} = options.unwrap_or_default();
169204

170-
message_attempt_api::v1_period_message_attempt_period_list_by_endpoint(
205+
message_attempt_api::v1_period_message_attempt_period_list_by_msg(
171206
self.cfg,
172-
message_attempt_api::V1PeriodMessageAttemptPeriodListByEndpointParams {
207+
message_attempt_api::V1PeriodMessageAttemptPeriodListByMsgParams {
173208
app_id,
174-
endpoint_id,
209+
msg_id,
175210
limit,
176211
iterator,
177212
status,
178213
status_code_class,
179214
channel,
180215
tag,
216+
endpoint_id,
181217
before,
182218
after,
183219
with_content,
184-
with_msg,
185220
event_types,
186221
},
187222
)
@@ -203,20 +238,18 @@ impl<'a> MessageAttempt<'a> {
203238
&self,
204239
app_id: String,
205240
endpoint_id: String,
206-
options: Option<MessageAttemptListOptions>,
241+
options: Option<MessageAttemptListAttemptedMessagesOptions>,
207242
) -> Result<ListResponseEndpointMessageOut> {
208-
let MessageAttemptListOptions {
209-
iterator,
243+
let MessageAttemptListAttemptedMessagesOptions {
210244
limit,
211-
event_types,
212-
before,
213-
after,
245+
iterator,
214246
channel,
215247
tag,
216248
status,
217-
status_code_class: _,
249+
before,
250+
after,
218251
with_content,
219-
endpoint_id: _,
252+
event_types,
220253
} = options.unwrap_or_default();
221254

222255
message_attempt_api::v1_period_message_attempt_period_list_attempted_messages(
@@ -260,6 +293,7 @@ impl<'a> MessageAttempt<'a> {
260293
.await
261294
}
262295

296+
#[deprecated = "Use `list_by_msg` instead, setting the `endpoint_id` in `options`."]
263297
pub async fn list_attempts_for_endpoint(
264298
&self,
265299
app_id: String,
@@ -317,20 +351,6 @@ impl<'a> MessageAttempt<'a> {
317351
.await
318352
}
319353

320-
/// Resend a message to the specified endpoint.
321-
pub async fn resend(&self, app_id: String, msg_id: String, endpoint_id: String) -> Result<()> {
322-
message_attempt_api::v1_period_message_attempt_period_resend(
323-
self.cfg,
324-
message_attempt_api::V1PeriodMessageAttemptPeriodResendParams {
325-
app_id,
326-
msg_id,
327-
endpoint_id,
328-
idempotency_key: None,
329-
},
330-
)
331-
.await
332-
}
333-
334354
/// Deletes the given attempt's response body. Useful when an endpoint
335355
/// accidentally returned sensitive content.
336356
pub async fn expunge_content(
@@ -349,4 +369,18 @@ impl<'a> MessageAttempt<'a> {
349369
)
350370
.await
351371
}
372+
373+
/// Resend a message to the specified endpoint.
374+
pub async fn resend(&self, app_id: String, msg_id: String, endpoint_id: String) -> Result<()> {
375+
message_attempt_api::v1_period_message_attempt_period_resend(
376+
self.cfg,
377+
message_attempt_api::V1PeriodMessageAttemptPeriodResendParams {
378+
app_id,
379+
msg_id,
380+
endpoint_id,
381+
idempotency_key: None,
382+
},
383+
)
384+
.await
385+
}
352386
}

rust/src/api/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ pub use self::{
4444
integration::{Integration, IntegrationListOptions},
4545
message::{Message, MessageListOptions},
4646
message_attempt::{
47-
MessageAttempt, MessageAttemptListByEndpointOptions, MessageAttemptListOptions,
47+
MessageAttempt, MessageAttemptListAttemptedMessagesOptions,
48+
MessageAttemptListByEndpointOptions, MessageAttemptListOptions,
4849
},
4950
operational_webhook_endpoint::{
5051
OperationalWebhookEndpoint, OperationalWebhookEndpointListOptions,

0 commit comments

Comments
 (0)