Skip to content

Commit 350c5f0

Browse files
authored
feat(tem): add email list order (#183)
1 parent 944c41d commit 350c5f0

File tree

8 files changed

+268
-92
lines changed

8 files changed

+268
-92
lines changed

scaleway-async/scaleway_async/tem/v1alpha1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from .types import DomainStatus
44
from .types import EmailRcptType
55
from .types import EmailStatus
6+
from .types import ListEmailsRequestOrderBy
67
from .types import CreateEmailRequestAddress
78
from .types import CreateEmailRequestAttachment
89
from .types import CreateEmailResponse
@@ -21,6 +22,7 @@
2122
"DomainStatus",
2223
"EmailRcptType",
2324
"EmailStatus",
25+
"ListEmailsRequestOrderBy",
2426
"CreateEmailRequestAddress",
2527
"CreateEmailRequestAttachment",
2628
"CreateEmailResponse",

scaleway-async/scaleway_async/tem/v1alpha1/api.py

Lines changed: 67 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from .types import (
1818
DomainStatus,
1919
EmailStatus,
20+
ListEmailsRequestOrderBy,
2021
CreateEmailRequestAddress,
2122
CreateEmailRequestAttachment,
2223
CreateEmailResponse,
@@ -196,28 +197,46 @@ async def list_emails(
196197
project_id: Optional[str] = None,
197198
domain_id: Optional[str] = None,
198199
message_id: Optional[str] = None,
199-
subject: Optional[str] = None,
200200
since: Optional[datetime] = None,
201201
until: Optional[datetime] = None,
202202
mail_from: Optional[str] = None,
203203
mail_to: Optional[str] = None,
204+
mail_rcpt: Optional[str] = None,
204205
statuses: Optional[List[EmailStatus]] = None,
206+
subject: Optional[str] = None,
207+
order_by: ListEmailsRequestOrderBy = ListEmailsRequestOrderBy.CREATED_AT_DESC,
205208
) -> ListEmailsResponse:
206209
"""
207210
List emails.
208211
Retrieve the list of emails sent from a specific domain or for a specific Project or Organization. You must specify the `region`.
212+
You can filter your emails in ascending or descending order using:
213+
- created_at
214+
- updated_at
215+
- status
216+
- mail_from
217+
- mail_rcpt
218+
- subject
209219
:param region: Region to target. If none is passed will use default region from the config.
210220
:param page:
211221
:param page_size:
212-
:param project_id: ID of the Project in which to list the emails (optional).
213-
:param domain_id: ID of the domain for which to list the emails (optional).
214-
:param message_id: ID of the message for which to list the emails (optional).
215-
:param subject: Subject of the email.
216-
:param since: List emails created after this date (optional).
217-
:param until: List emails created before this date (optional).
218-
:param mail_from: List emails sent with this `mail_from` sender's address (optional).
219-
:param mail_to: List emails sent with this `mail_to` recipient's address (optional).
220-
:param statuses: List emails having any of this status (optional).
222+
:param project_id: (Optional) ID of the Project in which to list the emails.
223+
:param domain_id: (Optional) ID of the domain for which to list the emails.
224+
:param message_id: (Optional) ID of the message for which to list the emails.
225+
:param since: (Optional) List emails created after this date.
226+
:param until: (Optional) List emails created before this date.
227+
:param mail_from: (Optional) List emails sent with this sender's email address.
228+
:param mail_to: (Deprecated) List emails sent to this recipient's email address.
229+
:param mail_rcpt: (Optional) List emails sent to this recipient's email address.
230+
:param statuses: (Optional) List emails with any of these statuses.
231+
:param subject: (Optional) List emails with this subject.
232+
:param order_by: (Optional) List emails corresponding to specific criteria.
233+
You can filter your emails in ascending or descending order using:
234+
- created_at
235+
- updated_at
236+
- status
237+
- mail_from
238+
- mail_rcpt
239+
- subject.
221240
:return: :class:`ListEmailsResponse <ListEmailsResponse>`
222241
223242
Usage:
@@ -236,8 +255,10 @@ async def list_emails(
236255
params={
237256
"domain_id": domain_id,
238257
"mail_from": mail_from,
258+
"mail_rcpt": mail_rcpt,
239259
"mail_to": mail_to,
240260
"message_id": message_id,
261+
"order_by": order_by,
241262
"page": page,
242263
"page_size": page_size or self.client.default_page_size,
243264
"project_id": project_id or self.client.default_project_id,
@@ -260,28 +281,46 @@ async def list_emails_all(
260281
project_id: Optional[str] = None,
261282
domain_id: Optional[str] = None,
262283
message_id: Optional[str] = None,
263-
subject: Optional[str] = None,
264284
since: Optional[datetime] = None,
265285
until: Optional[datetime] = None,
266286
mail_from: Optional[str] = None,
267287
mail_to: Optional[str] = None,
288+
mail_rcpt: Optional[str] = None,
268289
statuses: Optional[List[EmailStatus]] = None,
290+
subject: Optional[str] = None,
291+
order_by: Optional[ListEmailsRequestOrderBy] = None,
269292
) -> List[Email]:
270293
"""
271294
List emails.
272295
Retrieve the list of emails sent from a specific domain or for a specific Project or Organization. You must specify the `region`.
296+
You can filter your emails in ascending or descending order using:
297+
- created_at
298+
- updated_at
299+
- status
300+
- mail_from
301+
- mail_rcpt
302+
- subject
273303
:param region: Region to target. If none is passed will use default region from the config.
274304
:param page:
275305
:param page_size:
276-
:param project_id: ID of the Project in which to list the emails (optional).
277-
:param domain_id: ID of the domain for which to list the emails (optional).
278-
:param message_id: ID of the message for which to list the emails (optional).
279-
:param subject: Subject of the email.
280-
:param since: List emails created after this date (optional).
281-
:param until: List emails created before this date (optional).
282-
:param mail_from: List emails sent with this `mail_from` sender's address (optional).
283-
:param mail_to: List emails sent with this `mail_to` recipient's address (optional).
284-
:param statuses: List emails having any of this status (optional).
306+
:param project_id: (Optional) ID of the Project in which to list the emails.
307+
:param domain_id: (Optional) ID of the domain for which to list the emails.
308+
:param message_id: (Optional) ID of the message for which to list the emails.
309+
:param since: (Optional) List emails created after this date.
310+
:param until: (Optional) List emails created before this date.
311+
:param mail_from: (Optional) List emails sent with this sender's email address.
312+
:param mail_to: (Deprecated) List emails sent to this recipient's email address.
313+
:param mail_rcpt: (Optional) List emails sent to this recipient's email address.
314+
:param statuses: (Optional) List emails with any of these statuses.
315+
:param subject: (Optional) List emails with this subject.
316+
:param order_by: (Optional) List emails corresponding to specific criteria.
317+
You can filter your emails in ascending or descending order using:
318+
- created_at
319+
- updated_at
320+
- status
321+
- mail_from
322+
- mail_rcpt
323+
- subject.
285324
:return: :class:`List[ListEmailsResponse] <List[ListEmailsResponse]>`
286325
287326
Usage:
@@ -301,12 +340,14 @@ async def list_emails_all(
301340
"project_id": project_id,
302341
"domain_id": domain_id,
303342
"message_id": message_id,
304-
"subject": subject,
305343
"since": since,
306344
"until": until,
307345
"mail_from": mail_from,
308346
"mail_to": mail_to,
347+
"mail_rcpt": mail_rcpt,
309348
"statuses": statuses,
349+
"subject": subject,
350+
"order_by": order_by,
310351
},
311352
)
312353

@@ -324,11 +365,11 @@ async def get_statistics(
324365
Email statuses.
325366
Get information on your emails' statuses.
326367
:param region: Region to target. If none is passed will use default region from the config.
327-
:param project_id: Number of emails for this Project (optional).
328-
:param domain_id: Number of emails sent from this domain (must be coherent with the `project_id` and the `organization_id`) (optional).
329-
:param since: Number of emails created after this date (optional).
330-
:param until: Number of emails created before this date (optional).
331-
:param mail_from: Number of emails sent with this `mail_from` sender's address (optional).
368+
:param project_id: (Optional) Number of emails for this Project.
369+
:param domain_id: (Optional) Number of emails sent from this domain (must be coherent with the `project_id` and the `organization_id`).
370+
:param since: (Optional) Number of emails created after this date.
371+
:param until: (Optional) Number of emails created before this date.
372+
:param mail_from: (Optional) Number of emails sent with this sender's email address.
332373
:return: :class:`Statistics <Statistics>`
333374
334375
Usage:

scaleway-async/scaleway_async/tem/v1alpha1/marshalling.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ def unmarshal_Email(data: Any) -> Email:
142142
field = data.get("mail_from")
143143
args["mail_from"] = field
144144

145+
field = data.get("mail_rcpt")
146+
args["mail_rcpt"] = field
147+
145148
field = data.get("message_id")
146149
args["message_id"] = field
147150

scaleway-async/scaleway_async/tem/v1alpha1/types.py

Lines changed: 62 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,24 @@ def __str__(self) -> str:
4747
return str(self.value)
4848

4949

50+
class ListEmailsRequestOrderBy(str, Enum):
51+
CREATED_AT_DESC = "created_at_desc"
52+
CREATED_AT_ASC = "created_at_asc"
53+
UPDATED_AT_DESC = "updated_at_desc"
54+
UPDATED_AT_ASC = "updated_at_asc"
55+
STATUS_DESC = "status_desc"
56+
STATUS_ASC = "status_asc"
57+
MAIL_FROM_DESC = "mail_from_desc"
58+
MAIL_FROM_ASC = "mail_from_asc"
59+
MAIL_RCPT_DESC = "mail_rcpt_desc"
60+
MAIL_RCPT_ASC = "mail_rcpt_asc"
61+
SUBJECT_DESC = "subject_desc"
62+
SUBJECT_ASC = "subject_asc"
63+
64+
def __str__(self) -> str:
65+
return str(self.value)
66+
67+
5068
@dataclass
5169
class CreateEmailRequestAddress:
5270
"""
@@ -209,7 +227,13 @@ class Email:
209227
Email address of the sender.
210228
"""
211229

212-
rcpt_to: str
230+
rcpt_to: Optional[str]
231+
"""
232+
(Deprecated) Email address of the recipient.
233+
:deprecated
234+
"""
235+
236+
mail_rcpt: str
213237
"""
214238
Email address of the recipient.
215239
"""
@@ -304,7 +328,7 @@ class ListEmailsResponse:
304328

305329
total_count: int
306330
"""
307-
Count of all emails matching the requested criteria.
331+
Number of emails matching the requested criteria.
308332
"""
309333

310334
emails: List[Email]
@@ -434,47 +458,65 @@ class ListEmailsRequest:
434458

435459
project_id: Optional[str]
436460
"""
437-
ID of the Project in which to list the emails (optional).
461+
(Optional) ID of the Project in which to list the emails.
438462
"""
439463

440464
domain_id: Optional[str]
441465
"""
442-
ID of the domain for which to list the emails (optional).
466+
(Optional) ID of the domain for which to list the emails.
443467
"""
444468

445469
message_id: Optional[str]
446470
"""
447-
ID of the message for which to list the emails (optional).
448-
"""
449-
450-
subject: Optional[str]
451-
"""
452-
Subject of the email.
471+
(Optional) ID of the message for which to list the emails.
453472
"""
454473

455474
since: Optional[datetime]
456475
"""
457-
List emails created after this date (optional).
476+
(Optional) List emails created after this date.
458477
"""
459478

460479
until: Optional[datetime]
461480
"""
462-
List emails created before this date (optional).
481+
(Optional) List emails created before this date.
463482
"""
464483

465484
mail_from: Optional[str]
466485
"""
467-
List emails sent with this `mail_from` sender's address (optional).
486+
(Optional) List emails sent with this sender's email address.
468487
"""
469488

470489
mail_to: Optional[str]
471490
"""
472-
List emails sent with this `mail_to` recipient's address (optional).
491+
(Deprecated) List emails sent to this recipient's email address.
492+
:deprecated
493+
"""
494+
495+
mail_rcpt: Optional[str]
496+
"""
497+
(Optional) List emails sent to this recipient's email address.
473498
"""
474499

475500
statuses: Optional[List[EmailStatus]]
476501
"""
477-
List emails having any of this status (optional).
502+
(Optional) List emails with any of these statuses.
503+
"""
504+
505+
subject: Optional[str]
506+
"""
507+
(Optional) List emails with this subject.
508+
"""
509+
510+
order_by: Optional[ListEmailsRequestOrderBy]
511+
"""
512+
(Optional) List emails corresponding to specific criteria.
513+
You can filter your emails in ascending or descending order using:
514+
- created_at
515+
- updated_at
516+
- status
517+
- mail_from
518+
- mail_rcpt
519+
- subject.
478520
"""
479521

480522

@@ -487,27 +529,27 @@ class GetStatisticsRequest:
487529

488530
project_id: Optional[str]
489531
"""
490-
Number of emails for this Project (optional).
532+
(Optional) Number of emails for this Project.
491533
"""
492534

493535
domain_id: Optional[str]
494536
"""
495-
Number of emails sent from this domain (must be coherent with the `project_id` and the `organization_id`) (optional).
537+
(Optional) Number of emails sent from this domain (must be coherent with the `project_id` and the `organization_id`).
496538
"""
497539

498540
since: Optional[datetime]
499541
"""
500-
Number of emails created after this date (optional).
542+
(Optional) Number of emails created after this date.
501543
"""
502544

503545
until: Optional[datetime]
504546
"""
505-
Number of emails created before this date (optional).
547+
(Optional) Number of emails created before this date.
506548
"""
507549

508550
mail_from: Optional[str]
509551
"""
510-
Number of emails sent with this `mail_from` sender's address (optional).
552+
(Optional) Number of emails sent with this sender's email address.
511553
"""
512554

513555

scaleway/scaleway/tem/v1alpha1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from .types import DomainStatus
44
from .types import EmailRcptType
55
from .types import EmailStatus
6+
from .types import ListEmailsRequestOrderBy
67
from .types import CreateEmailRequestAddress
78
from .types import CreateEmailRequestAttachment
89
from .types import CreateEmailResponse
@@ -21,6 +22,7 @@
2122
"DomainStatus",
2223
"EmailRcptType",
2324
"EmailStatus",
25+
"ListEmailsRequestOrderBy",
2426
"CreateEmailRequestAddress",
2527
"CreateEmailRequestAttachment",
2628
"CreateEmailResponse",

0 commit comments

Comments
 (0)