|
15 | 15 | wait_for_resource_async,
|
16 | 16 | )
|
17 | 17 | from .types import (
|
| 18 | + BlocklistType, |
18 | 19 | DomainStatus,
|
19 | 20 | EmailFlag,
|
20 | 21 | EmailStatus,
|
| 22 | + ListBlocklistsRequestOrderBy, |
21 | 23 | ListEmailsRequestOrderBy,
|
22 | 24 | ListWebhookEventsRequestOrderBy,
|
23 | 25 | ListWebhooksRequestOrderBy,
|
24 | 26 | WebhookEventStatus,
|
25 | 27 | WebhookEventType,
|
| 28 | + Blocklist, |
| 29 | + BulkCreateBlocklistsRequest, |
| 30 | + BulkCreateBlocklistsResponse, |
26 | 31 | CreateDomainRequest,
|
27 | 32 | CreateEmailRequest,
|
28 | 33 | CreateEmailRequestAddress,
|
|
33 | 38 | Domain,
|
34 | 39 | DomainLastStatus,
|
35 | 40 | Email,
|
| 41 | + ListBlocklistsResponse, |
36 | 42 | ListDomainsResponse,
|
37 | 43 | ListEmailsResponse,
|
38 | 44 | ListWebhookEventsResponse,
|
|
54 | 60 | unmarshal_Email,
|
55 | 61 | unmarshal_Domain,
|
56 | 62 | unmarshal_Webhook,
|
| 63 | + unmarshal_BulkCreateBlocklistsResponse, |
57 | 64 | unmarshal_CreateEmailResponse,
|
58 | 65 | unmarshal_DomainLastStatus,
|
| 66 | + unmarshal_ListBlocklistsResponse, |
59 | 67 | unmarshal_ListDomainsResponse,
|
60 | 68 | unmarshal_ListEmailsResponse,
|
61 | 69 | unmarshal_ListWebhookEventsResponse,
|
62 | 70 | unmarshal_ListWebhooksResponse,
|
63 | 71 | unmarshal_ProjectSettings,
|
64 | 72 | unmarshal_Statistics,
|
| 73 | + marshal_BulkCreateBlocklistsRequest, |
65 | 74 | marshal_CreateDomainRequest,
|
66 | 75 | marshal_CreateEmailRequest,
|
67 | 76 | marshal_CreateWebhookRequest,
|
@@ -1277,3 +1286,187 @@ async def update_project_settings(
|
1277 | 1286 |
|
1278 | 1287 | self._throw_on_error(res)
|
1279 | 1288 | return unmarshal_ProjectSettings(res.json())
|
| 1289 | + |
| 1290 | + async def list_blocklists( |
| 1291 | + self, |
| 1292 | + *, |
| 1293 | + domain_id: str, |
| 1294 | + region: Optional[Region] = None, |
| 1295 | + order_by: Optional[ListBlocklistsRequestOrderBy] = None, |
| 1296 | + page: Optional[int] = None, |
| 1297 | + page_size: Optional[int] = None, |
| 1298 | + email: Optional[str] = None, |
| 1299 | + type_: Optional[BlocklistType] = None, |
| 1300 | + custom: Optional[bool] = None, |
| 1301 | + ) -> ListBlocklistsResponse: |
| 1302 | + """ |
| 1303 | + List blocklists. |
| 1304 | + Retrieve the list of blocklists. |
| 1305 | + :param domain_id: (Optional) Filter by a domain ID. |
| 1306 | + :param region: Region to target. If none is passed will use default region from the config. |
| 1307 | + :param order_by: (Optional) List blocklist corresponding to specific criteria. |
| 1308 | + :param page: (Optional) Requested page number. Value must be greater or equal to 1. |
| 1309 | + :param page_size: (Optional) Requested page size. Value must be between 1 and 100. |
| 1310 | + :param email: (Optional) Filter by an email address. |
| 1311 | + :param type_: (Optional) Filter by a blocklist type. |
| 1312 | + :param custom: (Optional) Filter by custom blocklist (true) or automatic Transactional Email blocklist (false). |
| 1313 | + :return: :class:`ListBlocklistsResponse <ListBlocklistsResponse>` |
| 1314 | +
|
| 1315 | + Usage: |
| 1316 | + :: |
| 1317 | +
|
| 1318 | + result = await api.list_blocklists( |
| 1319 | + domain_id="example", |
| 1320 | + ) |
| 1321 | + """ |
| 1322 | + |
| 1323 | + param_region = validate_path_param( |
| 1324 | + "region", region or self.client.default_region |
| 1325 | + ) |
| 1326 | + |
| 1327 | + res = self._request( |
| 1328 | + "GET", |
| 1329 | + f"/transactional-email/v1alpha1/regions/{param_region}/blocklists", |
| 1330 | + params={ |
| 1331 | + "custom": custom, |
| 1332 | + "domain_id": domain_id, |
| 1333 | + "email": email, |
| 1334 | + "order_by": order_by, |
| 1335 | + "page": page, |
| 1336 | + "page_size": page_size or self.client.default_page_size, |
| 1337 | + "type": type_, |
| 1338 | + }, |
| 1339 | + ) |
| 1340 | + |
| 1341 | + self._throw_on_error(res) |
| 1342 | + return unmarshal_ListBlocklistsResponse(res.json()) |
| 1343 | + |
| 1344 | + async def list_blocklists_all( |
| 1345 | + self, |
| 1346 | + *, |
| 1347 | + domain_id: str, |
| 1348 | + region: Optional[Region] = None, |
| 1349 | + order_by: Optional[ListBlocklistsRequestOrderBy] = None, |
| 1350 | + page: Optional[int] = None, |
| 1351 | + page_size: Optional[int] = None, |
| 1352 | + email: Optional[str] = None, |
| 1353 | + type_: Optional[BlocklistType] = None, |
| 1354 | + custom: Optional[bool] = None, |
| 1355 | + ) -> List[Blocklist]: |
| 1356 | + """ |
| 1357 | + List blocklists. |
| 1358 | + Retrieve the list of blocklists. |
| 1359 | + :param domain_id: (Optional) Filter by a domain ID. |
| 1360 | + :param region: Region to target. If none is passed will use default region from the config. |
| 1361 | + :param order_by: (Optional) List blocklist corresponding to specific criteria. |
| 1362 | + :param page: (Optional) Requested page number. Value must be greater or equal to 1. |
| 1363 | + :param page_size: (Optional) Requested page size. Value must be between 1 and 100. |
| 1364 | + :param email: (Optional) Filter by an email address. |
| 1365 | + :param type_: (Optional) Filter by a blocklist type. |
| 1366 | + :param custom: (Optional) Filter by custom blocklist (true) or automatic Transactional Email blocklist (false). |
| 1367 | + :return: :class:`List[Blocklist] <List[Blocklist]>` |
| 1368 | +
|
| 1369 | + Usage: |
| 1370 | + :: |
| 1371 | +
|
| 1372 | + result = await api.list_blocklists_all( |
| 1373 | + domain_id="example", |
| 1374 | + ) |
| 1375 | + """ |
| 1376 | + |
| 1377 | + return await fetch_all_pages_async( |
| 1378 | + type=ListBlocklistsResponse, |
| 1379 | + key="blocklists", |
| 1380 | + fetcher=self.list_blocklists, |
| 1381 | + args={ |
| 1382 | + "domain_id": domain_id, |
| 1383 | + "region": region, |
| 1384 | + "order_by": order_by, |
| 1385 | + "page": page, |
| 1386 | + "page_size": page_size, |
| 1387 | + "email": email, |
| 1388 | + "type_": type_, |
| 1389 | + "custom": custom, |
| 1390 | + }, |
| 1391 | + ) |
| 1392 | + |
| 1393 | + async def bulk_create_blocklists( |
| 1394 | + self, |
| 1395 | + *, |
| 1396 | + domain_id: str, |
| 1397 | + region: Optional[Region] = None, |
| 1398 | + emails: Optional[List[str]] = None, |
| 1399 | + type_: Optional[BlocklistType] = None, |
| 1400 | + reason: Optional[str] = None, |
| 1401 | + ) -> BulkCreateBlocklistsResponse: |
| 1402 | + """ |
| 1403 | + Bulk create blocklists. |
| 1404 | + Create multiple blocklists in a specific Project or Organization using the `region` parameter. |
| 1405 | + :param domain_id: Domain ID linked to the blocklist. |
| 1406 | + :param region: Region to target. If none is passed will use default region from the config. |
| 1407 | + :param emails: Email blocked by the blocklist. |
| 1408 | + :param type_: Type of blocklist. |
| 1409 | + :param reason: Reason to block the email. |
| 1410 | + :return: :class:`BulkCreateBlocklistsResponse <BulkCreateBlocklistsResponse>` |
| 1411 | +
|
| 1412 | + Usage: |
| 1413 | + :: |
| 1414 | +
|
| 1415 | + result = await api.bulk_create_blocklists( |
| 1416 | + domain_id="example", |
| 1417 | + ) |
| 1418 | + """ |
| 1419 | + |
| 1420 | + param_region = validate_path_param( |
| 1421 | + "region", region or self.client.default_region |
| 1422 | + ) |
| 1423 | + |
| 1424 | + res = self._request( |
| 1425 | + "POST", |
| 1426 | + f"/transactional-email/v1alpha1/regions/{param_region}/blocklists", |
| 1427 | + body=marshal_BulkCreateBlocklistsRequest( |
| 1428 | + BulkCreateBlocklistsRequest( |
| 1429 | + domain_id=domain_id, |
| 1430 | + region=region, |
| 1431 | + emails=emails, |
| 1432 | + type_=type_, |
| 1433 | + reason=reason, |
| 1434 | + ), |
| 1435 | + self.client, |
| 1436 | + ), |
| 1437 | + ) |
| 1438 | + |
| 1439 | + self._throw_on_error(res) |
| 1440 | + return unmarshal_BulkCreateBlocklistsResponse(res.json()) |
| 1441 | + |
| 1442 | + async def delete_blocklist( |
| 1443 | + self, |
| 1444 | + *, |
| 1445 | + blocklist_id: str, |
| 1446 | + region: Optional[Region] = None, |
| 1447 | + ) -> None: |
| 1448 | + """ |
| 1449 | + Delete a blocklist. |
| 1450 | + You must specify the blocklist you want to delete by the `region` and `blocklist_id`. |
| 1451 | + :param blocklist_id: ID of the blocklist to delete. |
| 1452 | + :param region: Region to target. If none is passed will use default region from the config. |
| 1453 | +
|
| 1454 | + Usage: |
| 1455 | + :: |
| 1456 | +
|
| 1457 | + result = await api.delete_blocklist( |
| 1458 | + blocklist_id="example", |
| 1459 | + ) |
| 1460 | + """ |
| 1461 | + |
| 1462 | + param_region = validate_path_param( |
| 1463 | + "region", region or self.client.default_region |
| 1464 | + ) |
| 1465 | + param_blocklist_id = validate_path_param("blocklist_id", blocklist_id) |
| 1466 | + |
| 1467 | + res = self._request( |
| 1468 | + "DELETE", |
| 1469 | + f"/transactional-email/v1alpha1/regions/{param_region}/blocklists/{param_blocklist_id}", |
| 1470 | + ) |
| 1471 | + |
| 1472 | + self._throw_on_error(res) |
0 commit comments