Skip to content

Commit b598153

Browse files
feat(tem): improve ListEmails endpoint (#3132)
Co-authored-by: Jules Castéran <jcasteran@scaleway.com>
1 parent 14b7712 commit b598153

File tree

4 files changed

+92
-50
lines changed

4 files changed

+92
-50
lines changed

cmd/scw/testdata/test-all-usage-tem-email-get-statistics-usage.golden

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ USAGE:
66
scw tem email get-statistics [arg=value ...]
77

88
ARGS:
9-
[project-id] Number of emails for this Project (optional)
10-
[domain-id] Number of emails sent from this domain (must be coherent with the `project_id` and the `organization_id`) (optional)
11-
[since] Number of emails created after this date (optional)
12-
[until] Number of emails created before this date (optional)
13-
[mail-from] Number of emails sent with this `mail_from` sender's address (optional)
9+
[project-id] (Optional) Number of emails for this Project
10+
[domain-id] (Optional) Number of emails sent from this domain (must be coherent with the `project_id` and the `organization_id`)
11+
[since] (Optional) Number of emails created after this date
12+
[until] (Optional) Number of emails created before this date
13+
[mail-from] (Optional) Number of emails sent with this sender's email address
1414
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par)
1515

1616
FLAGS:

cmd/scw/testdata/test-all-usage-tem-email-list-usage.golden

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
22
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
33
Retrieve the list of emails sent from a specific domain or for a specific Project or Organization. You must specify the `region`.
4+
You can filter your emails in ascending or descending order using:
5+
- created_at
6+
- updated_at
7+
- status
8+
- mail_from
9+
- mail_rcpt
10+
- subject.
411

512
USAGE:
613
scw tem email list [arg=value ...]
714

815
ARGS:
9-
[project-id] ID of the Project in which to list the emails (optional)
10-
[domain-id] ID of the domain for which to list the emails (optional)
11-
[message-id] ID of the message for which to list the emails (optional)
12-
[subject] Subject of the email
13-
[since] List emails created after this date (optional)
14-
[until] List emails created before this date (optional)
15-
[mail-from] List emails sent with this `mail_from` sender's address (optional)
16-
[mail-to] List emails sent with this `mail_to` recipient's address (optional)
17-
[statuses.{index}] List emails having any of this status (optional) (unknown | new | sending | sent | failed | canceled)
16+
[project-id] (Optional) ID of the Project in which to list the emails
17+
[domain-id] (Optional) ID of the domain for which to list the emails
18+
[message-id] (Optional) ID of the message for which to list the emails
19+
[since] (Optional) List emails created after this date
20+
[until] (Optional) List emails created before this date
21+
[mail-from] (Optional) List emails sent with this sender's email address
22+
[mail-rcpt] (Optional) List emails sent to this recipient's email address
23+
[statuses.{index}] (Optional) List emails with any of these statuses (unknown | new | sending | sent | failed | canceled)
24+
[subject] (Optional) List emails with this subject
25+
[order-by] (Optional) List emails corresponding to specific criteria (created_at_desc | created_at_asc | updated_at_desc | updated_at_asc | status_desc | status_asc | mail_from_desc | mail_from_asc | mail_rcpt_desc | mail_rcpt_asc | subject_desc | subject_asc)
1826
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | all)
1927

28+
DEPRECATED ARGS:
29+
[mail-to] (Deprecated) List emails sent to this recipient's email address
30+
2031
FLAGS:
2132
-h, --help help for list
2233

docs/commands/tem.md

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -221,18 +221,25 @@ scw tem email get-statistics [arg=value ...]
221221

222222
| Name | | Description |
223223
|------|---|-------------|
224-
| project-id | | Number of emails for this Project (optional) |
225-
| domain-id | | Number of emails sent from this domain (must be coherent with the `project_id` and the `organization_id`) (optional) |
226-
| since | | Number of emails created after this date (optional) |
227-
| until | | Number of emails created before this date (optional) |
228-
| mail-from | | Number of emails sent with this `mail_from` sender's address (optional) |
224+
| project-id | | (Optional) Number of emails for this Project |
225+
| domain-id | | (Optional) Number of emails sent from this domain (must be coherent with the `project_id` and the `organization_id`) |
226+
| since | | (Optional) Number of emails created after this date |
227+
| until | | (Optional) Number of emails created before this date |
228+
| mail-from | | (Optional) Number of emails sent with this sender's email address |
229229
| region | Default: `fr-par`<br />One of: `fr-par` | Region to target. If none is passed will use default region from the config |
230230

231231

232232

233233
### List emails
234234

235235
Retrieve the list of emails sent from a specific domain or for a specific Project or Organization. You must specify the `region`.
236+
You can filter your emails in ascending or descending order using:
237+
- created_at
238+
- updated_at
239+
- status
240+
- mail_from
241+
- mail_rcpt
242+
- subject.
236243

237244
**Usage:**
238245

@@ -245,15 +252,17 @@ scw tem email list [arg=value ...]
245252

246253
| Name | | Description |
247254
|------|---|-------------|
248-
| project-id | | ID of the Project in which to list the emails (optional) |
249-
| domain-id | | ID of the domain for which to list the emails (optional) |
250-
| message-id | | ID of the message for which to list the emails (optional) |
251-
| subject | | Subject of the email |
252-
| since | | List emails created after this date (optional) |
253-
| until | | List emails created before this date (optional) |
254-
| mail-from | | List emails sent with this `mail_from` sender's address (optional) |
255-
| mail-to | | List emails sent with this `mail_to` recipient's address (optional) |
256-
| statuses.{index} | One of: `unknown`, `new`, `sending`, `sent`, `failed`, `canceled` | List emails having any of this status (optional) |
255+
| project-id | | (Optional) ID of the Project in which to list the emails |
256+
| domain-id | | (Optional) ID of the domain for which to list the emails |
257+
| message-id | | (Optional) ID of the message for which to list the emails |
258+
| since | | (Optional) List emails created after this date |
259+
| until | | (Optional) List emails created before this date |
260+
| mail-from | | (Optional) List emails sent with this sender's email address |
261+
| ~~mail-to~~ | Deprecated | (Deprecated) List emails sent to this recipient's email address |
262+
| mail-rcpt | | (Optional) List emails sent to this recipient's email address |
263+
| statuses.{index} | One of: `unknown`, `new`, `sending`, `sent`, `failed`, `canceled` | (Optional) List emails with any of these statuses |
264+
| subject | | (Optional) List emails with this subject |
265+
| order-by | One of: `created_at_desc`, `created_at_asc`, `updated_at_desc`, `updated_at_asc`, `status_desc`, `status_asc`, `mail_from_desc`, `mail_from_asc`, `mail_rcpt_desc`, `mail_rcpt_asc`, `subject_desc`, `subject_asc` | (Optional) List emails corresponding to specific criteria |
257266
| region | Default: `fr-par`<br />One of: `fr-par`, `all` | Region to target. If none is passed will use default region from the config |
258267

259268

internal/namespaces/tem/v1alpha1/tem_cli.go

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,15 @@ func temEmailGet() *core.Command {
221221

222222
func temEmailList() *core.Command {
223223
return &core.Command{
224-
Short: `List emails`,
225-
Long: `Retrieve the list of emails sent from a specific domain or for a specific Project or Organization. You must specify the ` + "`" + `region` + "`" + `.`,
224+
Short: `List emails`,
225+
Long: `Retrieve the list of emails sent from a specific domain or for a specific Project or Organization. You must specify the ` + "`" + `region` + "`" + `.
226+
You can filter your emails in ascending or descending order using:
227+
- created_at
228+
- updated_at
229+
- status
230+
- mail_from
231+
- mail_rcpt
232+
- subject.`,
226233
Namespace: "tem",
227234
Resource: "email",
228235
Verb: "list",
@@ -231,68 +238,83 @@ func temEmailList() *core.Command {
231238
ArgSpecs: core.ArgSpecs{
232239
{
233240
Name: "project-id",
234-
Short: `ID of the Project in which to list the emails (optional)`,
241+
Short: `(Optional) ID of the Project in which to list the emails`,
235242
Required: false,
236243
Deprecated: false,
237244
Positional: false,
238245
},
239246
{
240247
Name: "domain-id",
241-
Short: `ID of the domain for which to list the emails (optional)`,
248+
Short: `(Optional) ID of the domain for which to list the emails`,
242249
Required: false,
243250
Deprecated: false,
244251
Positional: false,
245252
},
246253
{
247254
Name: "message-id",
248-
Short: `ID of the message for which to list the emails (optional)`,
249-
Required: false,
250-
Deprecated: false,
251-
Positional: false,
252-
},
253-
{
254-
Name: "subject",
255-
Short: `Subject of the email`,
255+
Short: `(Optional) ID of the message for which to list the emails`,
256256
Required: false,
257257
Deprecated: false,
258258
Positional: false,
259259
},
260260
{
261261
Name: "since",
262-
Short: `List emails created after this date (optional)`,
262+
Short: `(Optional) List emails created after this date`,
263263
Required: false,
264264
Deprecated: false,
265265
Positional: false,
266266
},
267267
{
268268
Name: "until",
269-
Short: `List emails created before this date (optional)`,
269+
Short: `(Optional) List emails created before this date`,
270270
Required: false,
271271
Deprecated: false,
272272
Positional: false,
273273
},
274274
{
275275
Name: "mail-from",
276-
Short: `List emails sent with this ` + "`" + `mail_from` + "`" + ` sender's address (optional)`,
276+
Short: `(Optional) List emails sent with this sender's email address`,
277277
Required: false,
278278
Deprecated: false,
279279
Positional: false,
280280
},
281281
{
282282
Name: "mail-to",
283-
Short: `List emails sent with this ` + "`" + `mail_to` + "`" + ` recipient's address (optional)`,
283+
Short: `(Deprecated) List emails sent to this recipient's email address`,
284+
Required: false,
285+
Deprecated: true,
286+
Positional: false,
287+
},
288+
{
289+
Name: "mail-rcpt",
290+
Short: `(Optional) List emails sent to this recipient's email address`,
284291
Required: false,
285292
Deprecated: false,
286293
Positional: false,
287294
},
288295
{
289296
Name: "statuses.{index}",
290-
Short: `List emails having any of this status (optional)`,
297+
Short: `(Optional) List emails with any of these statuses`,
291298
Required: false,
292299
Deprecated: false,
293300
Positional: false,
294301
EnumValues: []string{"unknown", "new", "sending", "sent", "failed", "canceled"},
295302
},
303+
{
304+
Name: "subject",
305+
Short: `(Optional) List emails with this subject`,
306+
Required: false,
307+
Deprecated: false,
308+
Positional: false,
309+
},
310+
{
311+
Name: "order-by",
312+
Short: `(Optional) List emails corresponding to specific criteria`,
313+
Required: false,
314+
Deprecated: false,
315+
Positional: false,
316+
EnumValues: []string{"created_at_desc", "created_at_asc", "updated_at_desc", "updated_at_asc", "status_desc", "status_asc", "mail_from_desc", "mail_from_asc", "mail_rcpt_desc", "mail_rcpt_asc", "subject_desc", "subject_asc"},
317+
},
296318
core.RegionArgSpec(scw.RegionFrPar, scw.Region(core.AllLocalities)),
297319
},
298320
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
@@ -327,35 +349,35 @@ func temEmailGetStatistics() *core.Command {
327349
ArgSpecs: core.ArgSpecs{
328350
{
329351
Name: "project-id",
330-
Short: `Number of emails for this Project (optional)`,
352+
Short: `(Optional) Number of emails for this Project`,
331353
Required: false,
332354
Deprecated: false,
333355
Positional: false,
334356
},
335357
{
336358
Name: "domain-id",
337-
Short: `Number of emails sent from this domain (must be coherent with the ` + "`" + `project_id` + "`" + ` and the ` + "`" + `organization_id` + "`" + `) (optional)`,
359+
Short: `(Optional) Number of emails sent from this domain (must be coherent with the ` + "`" + `project_id` + "`" + ` and the ` + "`" + `organization_id` + "`" + `)`,
338360
Required: false,
339361
Deprecated: false,
340362
Positional: false,
341363
},
342364
{
343365
Name: "since",
344-
Short: `Number of emails created after this date (optional)`,
366+
Short: `(Optional) Number of emails created after this date`,
345367
Required: false,
346368
Deprecated: false,
347369
Positional: false,
348370
},
349371
{
350372
Name: "until",
351-
Short: `Number of emails created before this date (optional)`,
373+
Short: `(Optional) Number of emails created before this date`,
352374
Required: false,
353375
Deprecated: false,
354376
Positional: false,
355377
},
356378
{
357379
Name: "mail-from",
358-
Short: `Number of emails sent with this ` + "`" + `mail_from` + "`" + ` sender's address (optional)`,
380+
Short: `(Optional) Number of emails sent with this sender's email address`,
359381
Required: false,
360382
Deprecated: false,
361383
Positional: false,

0 commit comments

Comments
 (0)