Skip to content

Commit f7804d6

Browse files
committed
CLI: update to latest codegen, add message-attempt support (and more)
1 parent 4e4da58 commit f7804d6

15 files changed

+541
-87
lines changed

svix-cli/src/cli_types/application.rs

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ impl From<ApplicationListOptions> for api::ApplicationListOptions {
2626
Self {
2727
limit,
2828
iterator,
29+
2930
order: order.map(Into::into),
3031
}
3132
}

svix-cli/src/cli_types/endpoint.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ impl From<EndpointListOptions> for api::EndpointListOptions {
2727
Self {
2828
limit,
2929
iterator,
30+
3031
order: order.map(Into::into),
3132
}
3233
}
3334
}
34-
3535
#[derive(Args, Clone)]
3636
pub struct EndpointStatsOptions {
3737
/// Filter the range to data ending by this date
@@ -42,6 +42,7 @@ pub struct EndpointStatsOptions {
4242
pub after: Option<DateTime<Utc>>,
4343
}
4444

45+
#[allow(deprecated)]
4546
impl From<EndpointStatsOptions> for api::EndpointStatsOptions {
4647
fn from(EndpointStatsOptions { after, before }: EndpointStatsOptions) -> Self {
4748
Self {

svix-cli/src/cli_types/event_type.rs

+23-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::cli_types::Ordering;
12
use clap::Args;
23
use svix::api;
34

@@ -9,14 +10,13 @@ pub struct EventTypeListOptions {
910
/// The iterator returned from a prior invocation
1011
#[arg(long)]
1112
pub iterator: Option<String>,
12-
// FIXME: This is missing from the Rust lib
13-
// /// The sorting order of the returned items
14-
// #[arg(long)]
15-
// pub order: Option<Ordering>,
16-
/// When `true` archived (deleted but not expunged) items are included in the response
13+
/// The sorting order of the returned items
14+
#[arg(long)]
15+
pub order: Option<Ordering>,
16+
/// When `true` archived (deleted but not expunged) items are included in the response.
1717
#[arg(long)]
1818
pub include_archived: Option<bool>,
19-
/// When `true` the full item (including the schema) is included in the response
19+
/// When `true` the full item (including the schema) is included in the response.
2020
#[arg(long)]
2121
pub with_content: Option<bool>,
2222
}
@@ -26,15 +26,32 @@ impl From<EventTypeListOptions> for api::EventTypeListOptions {
2626
EventTypeListOptions {
2727
limit,
2828
iterator,
29+
order,
2930
include_archived,
3031
with_content,
3132
}: EventTypeListOptions,
3233
) -> Self {
3334
Self {
3435
limit,
3536
iterator,
37+
38+
order: order.map(Into::into),
3639
include_archived,
3740
with_content,
3841
}
3942
}
4043
}
44+
45+
// FIXME: need to get the options happening in the SDK for this
46+
// #[derive(Args, Clone)]
47+
// pub struct EventTypeDeleteOptions {
48+
// /// By default event types are archived when "deleted". Passing this to `true` deletes them entirely.
49+
// #[arg(long)]
50+
// pub expunge: Option<bool>,
51+
// }
52+
//
53+
// impl From<EventTypeDeleteOptions> for api::EventTypeDeleteOptions {
54+
// fn from(EventTypeDeleteOptions { expunge }: EventTypeDeleteOptions) -> Self {
55+
// Self { expunge }
56+
// }
57+
// }

svix-cli/src/cli_types/message.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ pub struct MessageListOptions {
1010
/// The iterator returned from a prior invocation
1111
#[arg(long)]
1212
pub iterator: Option<String>,
13-
/// Filter response based on the channel
13+
/// Filter response based on the channel.
1414
#[arg(long)]
1515
pub channel: Option<String>,
16-
/// Only include items created before a certain date
16+
/// Only include items created before a certain date.
1717
#[arg(long)]
1818
pub before: Option<DateTime<Utc>>,
19-
/// Only include items created after a certain date
19+
/// Only include items created after a certain date.
2020
#[arg(long)]
2121
pub after: Option<DateTime<Utc>>,
22-
/// When `true` message payloads are included in the response
22+
/// When `true` message payloads are included in the response.
2323
#[arg(long)]
2424
pub with_content: Option<bool>,
25-
/// Filter messages matching the provided tag
25+
/// Filter messages matching the provided tag.
2626
#[arg(long)]
2727
pub tag: Option<String>,
2828
/// Filter response based on the event type
+250
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
use chrono::{DateTime, Utc};
2+
use clap::Args;
3+
use svix::api;
4+
use svix::api::{MessageStatus, StatusCodeClass};
5+
6+
#[derive(Args, Clone)]
7+
pub struct MessageAttemptListByEndpointOptions {
8+
/// Limit the number of returned items
9+
#[arg(long)]
10+
pub limit: Option<i32>,
11+
/// The iterator returned from a prior invocation
12+
#[arg(long)]
13+
pub iterator: Option<String>,
14+
/// Filter response based on the status of the attempt: Success (0), Pending (1), Failed (2), or Sending (3)
15+
#[arg(long)]
16+
pub status: Option<MessageStatus>,
17+
/// Filter response based on the HTTP status code
18+
#[arg(long)]
19+
pub status_code_class: Option<StatusCodeClass>,
20+
/// Filter response based on the channel
21+
#[arg(long)]
22+
pub channel: Option<String>,
23+
/// Filter response based on the tag
24+
#[arg(long)]
25+
pub tag: Option<String>,
26+
/// Only include items created before a certain date
27+
#[arg(long)]
28+
pub before: Option<DateTime<Utc>>,
29+
/// Only include items created after a certain date
30+
#[arg(long)]
31+
pub after: Option<DateTime<Utc>>,
32+
/// When `true` attempt content is included in the response
33+
#[arg(long)]
34+
pub with_content: Option<bool>,
35+
/// When `true`, the message information is included in the response
36+
#[arg(long)]
37+
pub with_msg: Option<bool>,
38+
/// Filter response based on the event type
39+
#[arg(long)]
40+
pub event_types: Option<Vec<String>>,
41+
}
42+
43+
impl From<MessageAttemptListByEndpointOptions> for api::MessageAttemptListByEndpointOptions {
44+
fn from(
45+
MessageAttemptListByEndpointOptions {
46+
limit,
47+
iterator,
48+
status,
49+
status_code_class,
50+
channel,
51+
tag,
52+
before,
53+
after,
54+
with_content,
55+
with_msg,
56+
event_types,
57+
}: MessageAttemptListByEndpointOptions,
58+
) -> Self {
59+
Self {
60+
limit,
61+
iterator,
62+
status,
63+
status_code_class,
64+
channel,
65+
tag,
66+
before: before.map(|dt| dt.to_rfc3339()),
67+
after: after.map(|dt| dt.to_rfc3339()),
68+
with_content,
69+
with_msg,
70+
event_types,
71+
}
72+
}
73+
}
74+
75+
#[derive(Args, Clone)]
76+
pub struct MessageAttemptCountByEndpointOptions {
77+
/// Filter response based on the status of the attempt: Success (0), Pending (1), Failed (2), or Sending (3)
78+
#[arg(long)]
79+
pub status: Option<MessageStatus>,
80+
/// Filter response based on the HTTP status code
81+
#[arg(long)]
82+
pub status_code_class: Option<StatusCodeClass>,
83+
/// Filter response based on the channel
84+
#[arg(long)]
85+
pub channel: Option<String>,
86+
/// Filter response based on the tag
87+
#[arg(long)]
88+
pub tag: Option<String>,
89+
/// Only include items created before a certain date
90+
#[arg(long)]
91+
pub before: Option<DateTime<Utc>>,
92+
/// Only include items created after a certain date
93+
#[arg(long)]
94+
pub after: Option<DateTime<Utc>>,
95+
/// Filter response based on the event type
96+
#[arg(long)]
97+
pub event_types: Option<Vec<String>>,
98+
}
99+
100+
#[derive(Args, Clone)]
101+
pub struct MessageAttemptListByMsgOptions {
102+
/// Limit the number of returned items
103+
#[arg(long)]
104+
pub limit: Option<i32>,
105+
/// The iterator returned from a prior invocation
106+
#[arg(long)]
107+
pub iterator: Option<String>,
108+
/// Filter response based on the status of the attempt: Success (0), Pending (1), Failed (2), or Sending (3)
109+
#[arg(long)]
110+
pub status: Option<MessageStatus>,
111+
/// Filter response based on the HTTP status code
112+
#[arg(long)]
113+
pub status_code_class: Option<StatusCodeClass>,
114+
/// Filter response based on the channel
115+
#[arg(long)]
116+
pub channel: Option<String>,
117+
/// Filter response based on the tag
118+
#[arg(long)]
119+
pub tag: Option<String>,
120+
/// Filter the attempts based on the attempted endpoint
121+
#[arg(long)]
122+
pub endpoint_id: Option<String>,
123+
/// Only include items created before a certain date
124+
#[arg(long)]
125+
pub before: Option<DateTime<Utc>>,
126+
/// Only include items created after a certain date
127+
#[arg(long)]
128+
pub after: Option<DateTime<Utc>>,
129+
/// When `true` attempt content is included in the response
130+
#[arg(long)]
131+
pub with_content: Option<bool>,
132+
/// Filter response based on the event type
133+
#[arg(long)]
134+
pub event_types: Option<Vec<String>>,
135+
}
136+
137+
impl From<MessageAttemptListByMsgOptions> for api::MessageAttemptListByMsgOptions {
138+
fn from(
139+
MessageAttemptListByMsgOptions {
140+
limit,
141+
iterator,
142+
status,
143+
status_code_class,
144+
channel,
145+
tag,
146+
endpoint_id,
147+
before,
148+
after,
149+
with_content,
150+
event_types,
151+
}: MessageAttemptListByMsgOptions,
152+
) -> Self {
153+
Self {
154+
limit,
155+
iterator,
156+
status,
157+
status_code_class,
158+
channel,
159+
tag,
160+
endpoint_id,
161+
before: before.map(|dt| dt.to_rfc3339()),
162+
after: after.map(|dt| dt.to_rfc3339()),
163+
with_content,
164+
event_types,
165+
}
166+
}
167+
}
168+
169+
#[derive(Args, Clone)]
170+
pub struct MessageAttemptListAttemptedMessagesOptions {
171+
/// Limit the number of returned items
172+
#[arg(long)]
173+
pub limit: Option<i32>,
174+
/// The iterator returned from a prior invocation
175+
#[arg(long)]
176+
pub iterator: Option<String>,
177+
/// Filter response based on the channel
178+
#[arg(long)]
179+
pub channel: Option<String>,
180+
/// Filter response based on the message tags
181+
#[arg(long)]
182+
pub tag: Option<String>,
183+
/// Filter response based on the status of the attempt: Success (0), Pending (1), Failed (2), or Sending (3)
184+
#[arg(long)]
185+
pub status: Option<MessageStatus>,
186+
/// Only include items created before a certain date
187+
#[arg(long)]
188+
pub before: Option<DateTime<Utc>>,
189+
/// Only include items created after a certain date
190+
#[arg(long)]
191+
pub after: Option<DateTime<Utc>>,
192+
/// When `true` message payloads are included in the response
193+
#[arg(long)]
194+
pub with_content: Option<bool>,
195+
/// Filter response based on the event type
196+
#[arg(long)]
197+
pub event_types: Option<Vec<String>>,
198+
}
199+
200+
impl From<MessageAttemptListAttemptedMessagesOptions>
201+
for api::MessageAttemptListAttemptedMessagesOptions
202+
{
203+
fn from(
204+
MessageAttemptListAttemptedMessagesOptions {
205+
limit,
206+
iterator,
207+
channel,
208+
tag,
209+
status,
210+
before,
211+
after,
212+
with_content,
213+
event_types,
214+
}: MessageAttemptListAttemptedMessagesOptions,
215+
) -> Self {
216+
Self {
217+
limit,
218+
iterator,
219+
channel,
220+
tag,
221+
status,
222+
before: before.map(|dt| dt.to_rfc3339()),
223+
after: after.map(|dt| dt.to_rfc3339()),
224+
with_content,
225+
event_types,
226+
}
227+
}
228+
}
229+
230+
#[derive(Args, Clone)]
231+
pub struct MessageAttemptListAttemptedDestinationsOptions {
232+
/// Limit the number of returned items
233+
#[arg(long)]
234+
pub limit: Option<i32>,
235+
/// The iterator returned from a prior invocation
236+
#[arg(long)]
237+
pub iterator: Option<String>,
238+
}
239+
240+
impl From<MessageAttemptListAttemptedDestinationsOptions>
241+
for api::MessageAttemptListAttemptedDestinationsOptions
242+
{
243+
fn from(
244+
MessageAttemptListAttemptedDestinationsOptions {
245+
limit,iterator,
246+
}: MessageAttemptListAttemptedDestinationsOptions,
247+
) -> Self {
248+
Self { limit, iterator }
249+
}
250+
}

svix-cli/src/cli_types/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub mod endpoint;
1111
pub mod event_type;
1212
pub mod integration;
1313
pub mod message;
14+
pub mod message_attempt;
1415

1516
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
1617
pub enum Ordering {

svix-cli/src/cmds/api/application.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1+
use crate::cli_types::application::ApplicationListOptions;
2+
use crate::cli_types::PostOptions;
3+
use crate::json::JsonOf;
14
use clap::{Args, Subcommand};
25
use colored_json::ColorMode;
36
use svix::api::{ApplicationIn, ApplicationPatch};
47

5-
use crate::{
6-
cli_types::{application::ApplicationListOptions, PostOptions},
7-
json::JsonOf,
8-
};
9-
108
#[derive(Args)]
119
#[command(args_conflicts_with_subcommands = true)]
1210
#[command(flatten_help = true)]

0 commit comments

Comments
 (0)