|
19 | 19 | EmailFlag,
|
20 | 20 | EmailStatus,
|
21 | 21 | ListEmailsRequestOrderBy,
|
| 22 | + ListWebhookEventsRequestOrderBy, |
| 23 | + ListWebhooksRequestOrderBy, |
| 24 | + WebhookEventType, |
22 | 25 | CreateDomainRequest,
|
23 | 26 | CreateEmailRequest,
|
24 | 27 | CreateEmailRequestAddress,
|
|
30 | 33 | Email,
|
31 | 34 | ListDomainsResponse,
|
32 | 35 | ListEmailsResponse,
|
| 36 | + ListWebhookEventsResponse, |
| 37 | + ListWebhooksResponse, |
33 | 38 | Statistics,
|
| 39 | + UpdateWebhookRequest, |
| 40 | + Webhook, |
| 41 | + WebhookEvent, |
34 | 42 | )
|
35 | 43 | from .content import (
|
36 | 44 | DOMAIN_TRANSIENT_STATUSES,
|
|
39 | 47 | from .marshalling import (
|
40 | 48 | unmarshal_Email,
|
41 | 49 | unmarshal_Domain,
|
| 50 | + unmarshal_Webhook, |
42 | 51 | unmarshal_CreateEmailResponse,
|
43 | 52 | unmarshal_DomainLastStatus,
|
44 | 53 | unmarshal_ListDomainsResponse,
|
45 | 54 | unmarshal_ListEmailsResponse,
|
| 55 | + unmarshal_ListWebhookEventsResponse, |
| 56 | + unmarshal_ListWebhooksResponse, |
46 | 57 | unmarshal_Statistics,
|
47 | 58 | marshal_CreateDomainRequest,
|
48 | 59 | marshal_CreateEmailRequest,
|
| 60 | + marshal_UpdateWebhookRequest, |
49 | 61 | )
|
50 | 62 |
|
51 | 63 |
|
@@ -740,3 +752,246 @@ async def get_domain_last_status(
|
740 | 752 |
|
741 | 753 | self._throw_on_error(res)
|
742 | 754 | return unmarshal_DomainLastStatus(res.json())
|
| 755 | + |
| 756 | + async def list_webhooks( |
| 757 | + self, |
| 758 | + *, |
| 759 | + region: Optional[Region] = None, |
| 760 | + order_by: Optional[ListWebhooksRequestOrderBy] = None, |
| 761 | + page: Optional[int] = None, |
| 762 | + page_size: Optional[int] = None, |
| 763 | + project_id: Optional[str] = None, |
| 764 | + organization_id: Optional[str] = None, |
| 765 | + ) -> ListWebhooksResponse: |
| 766 | + """ |
| 767 | + :param region: Region to target. If none is passed will use default region from the config. |
| 768 | + :param order_by: (Optional) List Webhooks corresponding to specific criteria. |
| 769 | + :param page: (Optional) Requested page number. Value must be greater or equal to 1. |
| 770 | + :param page_size: (Optional) Requested page size. Value must be between 1 and 100. |
| 771 | + :param project_id: (Optional) ID of the Project for which to list the Webhooks. |
| 772 | + :param organization_id: (Optional) ID of the Organization for which to list the Webhooks. |
| 773 | + :return: :class:`ListWebhooksResponse <ListWebhooksResponse>` |
| 774 | +
|
| 775 | + Usage: |
| 776 | + :: |
| 777 | +
|
| 778 | + result = await api.list_webhooks() |
| 779 | + """ |
| 780 | + |
| 781 | + param_region = validate_path_param( |
| 782 | + "region", region or self.client.default_region |
| 783 | + ) |
| 784 | + |
| 785 | + res = self._request( |
| 786 | + "GET", |
| 787 | + f"/transactional-email/v1alpha1/regions/{param_region}/webhooks", |
| 788 | + params={ |
| 789 | + "order_by": order_by, |
| 790 | + "organization_id": organization_id |
| 791 | + or self.client.default_organization_id, |
| 792 | + "page": page, |
| 793 | + "page_size": page_size or self.client.default_page_size, |
| 794 | + "project_id": project_id or self.client.default_project_id, |
| 795 | + }, |
| 796 | + ) |
| 797 | + |
| 798 | + self._throw_on_error(res) |
| 799 | + return unmarshal_ListWebhooksResponse(res.json()) |
| 800 | + |
| 801 | + async def list_webhooks_all( |
| 802 | + self, |
| 803 | + *, |
| 804 | + region: Optional[Region] = None, |
| 805 | + order_by: Optional[ListWebhooksRequestOrderBy] = None, |
| 806 | + page: Optional[int] = None, |
| 807 | + page_size: Optional[int] = None, |
| 808 | + project_id: Optional[str] = None, |
| 809 | + organization_id: Optional[str] = None, |
| 810 | + ) -> List[Webhook]: |
| 811 | + """ |
| 812 | + :param region: Region to target. If none is passed will use default region from the config. |
| 813 | + :param order_by: (Optional) List Webhooks corresponding to specific criteria. |
| 814 | + :param page: (Optional) Requested page number. Value must be greater or equal to 1. |
| 815 | + :param page_size: (Optional) Requested page size. Value must be between 1 and 100. |
| 816 | + :param project_id: (Optional) ID of the Project for which to list the Webhooks. |
| 817 | + :param organization_id: (Optional) ID of the Organization for which to list the Webhooks. |
| 818 | + :return: :class:`List[Webhook] <List[Webhook]>` |
| 819 | +
|
| 820 | + Usage: |
| 821 | + :: |
| 822 | +
|
| 823 | + result = await api.list_webhooks_all() |
| 824 | + """ |
| 825 | + |
| 826 | + return await fetch_all_pages_async( |
| 827 | + type=ListWebhooksResponse, |
| 828 | + key="webhooks", |
| 829 | + fetcher=self.list_webhooks, |
| 830 | + args={ |
| 831 | + "region": region, |
| 832 | + "order_by": order_by, |
| 833 | + "page": page, |
| 834 | + "page_size": page_size, |
| 835 | + "project_id": project_id, |
| 836 | + "organization_id": organization_id, |
| 837 | + }, |
| 838 | + ) |
| 839 | + |
| 840 | + async def update_webhook( |
| 841 | + self, |
| 842 | + *, |
| 843 | + webhook_id: str, |
| 844 | + region: Optional[Region] = None, |
| 845 | + name: Optional[str] = None, |
| 846 | + event_types: Optional[List[WebhookEventType]] = None, |
| 847 | + sns_arn: Optional[str] = None, |
| 848 | + ) -> Webhook: |
| 849 | + """ |
| 850 | + :param webhook_id: ID of the Webhook to update. |
| 851 | + :param region: Region to target. If none is passed will use default region from the config. |
| 852 | + :param name: Name of the Webhook to update. |
| 853 | + :param event_types: List of event types to update. |
| 854 | + :param sns_arn: Scaleway SNS ARN topic to update. |
| 855 | + :return: :class:`Webhook <Webhook>` |
| 856 | +
|
| 857 | + Usage: |
| 858 | + :: |
| 859 | +
|
| 860 | + result = await api.update_webhook( |
| 861 | + webhook_id="example", |
| 862 | + ) |
| 863 | + """ |
| 864 | + |
| 865 | + param_region = validate_path_param( |
| 866 | + "region", region or self.client.default_region |
| 867 | + ) |
| 868 | + param_webhook_id = validate_path_param("webhook_id", webhook_id) |
| 869 | + |
| 870 | + res = self._request( |
| 871 | + "PATCH", |
| 872 | + f"/transactional-email/v1alpha1/regions/{param_region}/webhooks/{param_webhook_id}", |
| 873 | + body=marshal_UpdateWebhookRequest( |
| 874 | + UpdateWebhookRequest( |
| 875 | + webhook_id=webhook_id, |
| 876 | + region=region, |
| 877 | + name=name, |
| 878 | + event_types=event_types, |
| 879 | + sns_arn=sns_arn, |
| 880 | + ), |
| 881 | + self.client, |
| 882 | + ), |
| 883 | + ) |
| 884 | + |
| 885 | + self._throw_on_error(res) |
| 886 | + return unmarshal_Webhook(res.json()) |
| 887 | + |
| 888 | + async def delete_webhook( |
| 889 | + self, |
| 890 | + *, |
| 891 | + webhook_id: str, |
| 892 | + region: Optional[Region] = None, |
| 893 | + ) -> None: |
| 894 | + """ |
| 895 | + :param webhook_id: ID of the Webhook to delete. |
| 896 | + :param region: Region to target. If none is passed will use default region from the config. |
| 897 | +
|
| 898 | + Usage: |
| 899 | + :: |
| 900 | +
|
| 901 | + result = await api.delete_webhook( |
| 902 | + webhook_id="example", |
| 903 | + ) |
| 904 | + """ |
| 905 | + |
| 906 | + param_region = validate_path_param( |
| 907 | + "region", region or self.client.default_region |
| 908 | + ) |
| 909 | + param_webhook_id = validate_path_param("webhook_id", webhook_id) |
| 910 | + |
| 911 | + res = self._request( |
| 912 | + "DELETE", |
| 913 | + f"/transactional-email/v1alpha1/regions/{param_region}/webhooks/{param_webhook_id}", |
| 914 | + ) |
| 915 | + |
| 916 | + self._throw_on_error(res) |
| 917 | + |
| 918 | + async def list_webhook_events( |
| 919 | + self, |
| 920 | + *, |
| 921 | + webhook_id: str, |
| 922 | + region: Optional[Region] = None, |
| 923 | + order_by: Optional[ListWebhookEventsRequestOrderBy] = None, |
| 924 | + page: Optional[int] = None, |
| 925 | + page_size: Optional[int] = None, |
| 926 | + ) -> ListWebhookEventsResponse: |
| 927 | + """ |
| 928 | + :param webhook_id: ID of the Webhook linked to the events. |
| 929 | + :param region: Region to target. If none is passed will use default region from the config. |
| 930 | + :param order_by: (Optional) List Webhook events corresponding to specific criteria. |
| 931 | + :param page: Requested page number. Value must be greater or equal to 1. |
| 932 | + :param page_size: Requested page size. Value must be between 1 and 100. |
| 933 | + :return: :class:`ListWebhookEventsResponse <ListWebhookEventsResponse>` |
| 934 | +
|
| 935 | + Usage: |
| 936 | + :: |
| 937 | +
|
| 938 | + result = await api.list_webhook_events( |
| 939 | + webhook_id="example", |
| 940 | + ) |
| 941 | + """ |
| 942 | + |
| 943 | + param_region = validate_path_param( |
| 944 | + "region", region or self.client.default_region |
| 945 | + ) |
| 946 | + param_webhook_id = validate_path_param("webhook_id", webhook_id) |
| 947 | + |
| 948 | + res = self._request( |
| 949 | + "GET", |
| 950 | + f"/transactional-email/v1alpha1/regions/{param_region}/webhooks/{param_webhook_id}/events", |
| 951 | + params={ |
| 952 | + "order_by": order_by, |
| 953 | + "page": page, |
| 954 | + "page_size": page_size or self.client.default_page_size, |
| 955 | + }, |
| 956 | + ) |
| 957 | + |
| 958 | + self._throw_on_error(res) |
| 959 | + return unmarshal_ListWebhookEventsResponse(res.json()) |
| 960 | + |
| 961 | + async def list_webhook_events_all( |
| 962 | + self, |
| 963 | + *, |
| 964 | + webhook_id: str, |
| 965 | + region: Optional[Region] = None, |
| 966 | + order_by: Optional[ListWebhookEventsRequestOrderBy] = None, |
| 967 | + page: Optional[int] = None, |
| 968 | + page_size: Optional[int] = None, |
| 969 | + ) -> List[WebhookEvent]: |
| 970 | + """ |
| 971 | + :param webhook_id: ID of the Webhook linked to the events. |
| 972 | + :param region: Region to target. If none is passed will use default region from the config. |
| 973 | + :param order_by: (Optional) List Webhook events corresponding to specific criteria. |
| 974 | + :param page: Requested page number. Value must be greater or equal to 1. |
| 975 | + :param page_size: Requested page size. Value must be between 1 and 100. |
| 976 | + :return: :class:`List[WebhookEvent] <List[WebhookEvent]>` |
| 977 | +
|
| 978 | + Usage: |
| 979 | + :: |
| 980 | +
|
| 981 | + result = await api.list_webhook_events_all( |
| 982 | + webhook_id="example", |
| 983 | + ) |
| 984 | + """ |
| 985 | + |
| 986 | + return await fetch_all_pages_async( |
| 987 | + type=ListWebhookEventsResponse, |
| 988 | + key="webhook_events", |
| 989 | + fetcher=self.list_webhook_events, |
| 990 | + args={ |
| 991 | + "webhook_id": webhook_id, |
| 992 | + "region": region, |
| 993 | + "order_by": order_by, |
| 994 | + "page": page, |
| 995 | + "page_size": page_size, |
| 996 | + }, |
| 997 | + ) |
0 commit comments