|
29 | 29 | CreateEmailRequestAttachment,
|
30 | 30 | CreateEmailRequestHeader,
|
31 | 31 | CreateEmailResponse,
|
| 32 | + CreateWebhookRequest, |
32 | 33 | Domain,
|
33 | 34 | DomainLastStatus,
|
34 | 35 | Email,
|
|
58 | 59 | unmarshal_Statistics,
|
59 | 60 | marshal_CreateDomainRequest,
|
60 | 61 | marshal_CreateEmailRequest,
|
| 62 | + marshal_CreateWebhookRequest, |
61 | 63 | marshal_UpdateWebhookRequest,
|
62 | 64 | )
|
63 | 65 |
|
@@ -755,6 +757,60 @@ async def get_domain_last_status(
|
755 | 757 | self._throw_on_error(res)
|
756 | 758 | return unmarshal_DomainLastStatus(res.json())
|
757 | 759 |
|
| 760 | + async def create_webhook( |
| 761 | + self, |
| 762 | + *, |
| 763 | + domain_id: str, |
| 764 | + name: str, |
| 765 | + sns_arn: str, |
| 766 | + region: Optional[Region] = None, |
| 767 | + project_id: Optional[str] = None, |
| 768 | + event_types: Optional[List[WebhookEventType]] = None, |
| 769 | + ) -> Webhook: |
| 770 | + """ |
| 771 | + Create a Webhook. |
| 772 | + Create a new Webhook triggered by a list of event types and pushed to a Scaleway SNS ARN. |
| 773 | + :param domain_id: ID of the Domain to watch for triggering events. |
| 774 | + :param name: Name of the Webhook. |
| 775 | + :param sns_arn: Scaleway SNS ARN topic to push the events to. |
| 776 | + :param region: Region to target. If none is passed will use default region from the config. |
| 777 | + :param project_id: ID of the project to which the Webhook belongs. |
| 778 | + :param event_types: List of event types that will trigger an event. |
| 779 | + :return: :class:`Webhook <Webhook>` |
| 780 | +
|
| 781 | + Usage: |
| 782 | + :: |
| 783 | +
|
| 784 | + result = await api.create_webhook( |
| 785 | + domain_id="example", |
| 786 | + name="example", |
| 787 | + sns_arn="example", |
| 788 | + ) |
| 789 | + """ |
| 790 | + |
| 791 | + param_region = validate_path_param( |
| 792 | + "region", region or self.client.default_region |
| 793 | + ) |
| 794 | + |
| 795 | + res = self._request( |
| 796 | + "POST", |
| 797 | + f"/transactional-email/v1alpha1/regions/{param_region}/webhooks", |
| 798 | + body=marshal_CreateWebhookRequest( |
| 799 | + CreateWebhookRequest( |
| 800 | + domain_id=domain_id, |
| 801 | + name=name, |
| 802 | + sns_arn=sns_arn, |
| 803 | + region=region, |
| 804 | + project_id=project_id, |
| 805 | + event_types=event_types, |
| 806 | + ), |
| 807 | + self.client, |
| 808 | + ), |
| 809 | + ) |
| 810 | + |
| 811 | + self._throw_on_error(res) |
| 812 | + return unmarshal_Webhook(res.json()) |
| 813 | + |
758 | 814 | async def list_webhooks(
|
759 | 815 | self,
|
760 | 816 | *,
|
@@ -845,6 +901,39 @@ async def list_webhooks_all(
|
845 | 901 | },
|
846 | 902 | )
|
847 | 903 |
|
| 904 | + async def get_webhook( |
| 905 | + self, |
| 906 | + *, |
| 907 | + webhook_id: str, |
| 908 | + region: Optional[Region] = None, |
| 909 | + ) -> Webhook: |
| 910 | + """ |
| 911 | + Get information about a Webhook. |
| 912 | + :param webhook_id: ID of the Webhook to check. |
| 913 | + :param region: Region to target. If none is passed will use default region from the config. |
| 914 | + :return: :class:`Webhook <Webhook>` |
| 915 | +
|
| 916 | + Usage: |
| 917 | + :: |
| 918 | +
|
| 919 | + result = await api.get_webhook( |
| 920 | + webhook_id="example", |
| 921 | + ) |
| 922 | + """ |
| 923 | + |
| 924 | + param_region = validate_path_param( |
| 925 | + "region", region or self.client.default_region |
| 926 | + ) |
| 927 | + param_webhook_id = validate_path_param("webhook_id", webhook_id) |
| 928 | + |
| 929 | + res = self._request( |
| 930 | + "GET", |
| 931 | + f"/transactional-email/v1alpha1/regions/{param_region}/webhooks/{param_webhook_id}", |
| 932 | + ) |
| 933 | + |
| 934 | + self._throw_on_error(res) |
| 935 | + return unmarshal_Webhook(res.json()) |
| 936 | + |
848 | 937 | async def update_webhook(
|
849 | 938 | self,
|
850 | 939 | *,
|
|
0 commit comments