Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tem): generate blocklist sdk #829

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions scaleway-async/scaleway_async/tem/v1alpha1/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This file was automatically generated. DO NOT EDIT.
# If you have any remark or suggestion do not hesitate to open an issue.
from .types import BlocklistType
from .types import DomainLastStatusAutoconfigStateReason
from .types import DomainLastStatusRecordStatus
from .types import DomainReputationStatus
Expand All @@ -9,6 +10,7 @@
from .types import EmailRcptType
from .types import EmailStatus
from .content import EMAIL_TRANSIENT_STATUSES
from .types import ListBlocklistsRequestOrderBy
from .types import ListEmailsRequestOrderBy
from .types import ListWebhookEventsRequestOrderBy
from .types import ListWebhooksRequestOrderBy
Expand All @@ -20,6 +22,7 @@
from .types import DomainRecords
from .types import DomainReputation
from .types import DomainStatistics
from .types import Blocklist
from .types import CreateEmailRequestAddress
from .types import CreateEmailRequestAttachment
from .types import CreateEmailRequestHeader
Expand All @@ -33,12 +36,15 @@
from .types import Webhook
from .types import ProjectSettingsPeriodicReport
from .types import UpdateProjectSettingsRequestUpdatePeriodicReport
from .types import BulkCreateBlocklistsRequest
from .types import BulkCreateBlocklistsResponse
from .types import CancelEmailRequest
from .types import CheckDomainRequest
from .types import CreateDomainRequest
from .types import CreateEmailRequest
from .types import CreateEmailResponse
from .types import CreateWebhookRequest
from .types import DeleteBlocklistRequest
from .types import DeleteWebhookRequest
from .types import DomainLastStatus
from .types import GetDomainLastStatusRequest
Expand All @@ -47,6 +53,8 @@
from .types import GetProjectSettingsRequest
from .types import GetStatisticsRequest
from .types import GetWebhookRequest
from .types import ListBlocklistsRequest
from .types import ListBlocklistsResponse
from .types import ListDomainsRequest
from .types import ListDomainsResponse
from .types import ListEmailsRequest
Expand All @@ -64,6 +72,7 @@
from .api import TemV1Alpha1API

__all__ = [
"BlocklistType",
"DomainLastStatusAutoconfigStateReason",
"DomainLastStatusRecordStatus",
"DomainReputationStatus",
Expand All @@ -73,6 +82,7 @@
"EmailRcptType",
"EmailStatus",
"EMAIL_TRANSIENT_STATUSES",
"ListBlocklistsRequestOrderBy",
"ListEmailsRequestOrderBy",
"ListWebhookEventsRequestOrderBy",
"ListWebhooksRequestOrderBy",
Expand All @@ -84,6 +94,7 @@
"DomainRecords",
"DomainReputation",
"DomainStatistics",
"Blocklist",
"CreateEmailRequestAddress",
"CreateEmailRequestAttachment",
"CreateEmailRequestHeader",
Expand All @@ -97,12 +108,15 @@
"Webhook",
"ProjectSettingsPeriodicReport",
"UpdateProjectSettingsRequestUpdatePeriodicReport",
"BulkCreateBlocklistsRequest",
"BulkCreateBlocklistsResponse",
"CancelEmailRequest",
"CheckDomainRequest",
"CreateDomainRequest",
"CreateEmailRequest",
"CreateEmailResponse",
"CreateWebhookRequest",
"DeleteBlocklistRequest",
"DeleteWebhookRequest",
"DomainLastStatus",
"GetDomainLastStatusRequest",
Expand All @@ -111,6 +125,8 @@
"GetProjectSettingsRequest",
"GetStatisticsRequest",
"GetWebhookRequest",
"ListBlocklistsRequest",
"ListBlocklistsResponse",
"ListDomainsRequest",
"ListDomainsResponse",
"ListEmailsRequest",
Expand Down
193 changes: 193 additions & 0 deletions scaleway-async/scaleway_async/tem/v1alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@
wait_for_resource_async,
)
from .types import (
BlocklistType,
DomainStatus,
EmailFlag,
EmailStatus,
ListBlocklistsRequestOrderBy,
ListEmailsRequestOrderBy,
ListWebhookEventsRequestOrderBy,
ListWebhooksRequestOrderBy,
WebhookEventStatus,
WebhookEventType,
Blocklist,
BulkCreateBlocklistsRequest,
BulkCreateBlocklistsResponse,
CreateDomainRequest,
CreateEmailRequest,
CreateEmailRequestAddress,
Expand All @@ -33,6 +38,7 @@
Domain,
DomainLastStatus,
Email,
ListBlocklistsResponse,
ListDomainsResponse,
ListEmailsResponse,
ListWebhookEventsResponse,
Expand All @@ -54,14 +60,17 @@
unmarshal_Email,
unmarshal_Domain,
unmarshal_Webhook,
unmarshal_BulkCreateBlocklistsResponse,
unmarshal_CreateEmailResponse,
unmarshal_DomainLastStatus,
unmarshal_ListBlocklistsResponse,
unmarshal_ListDomainsResponse,
unmarshal_ListEmailsResponse,
unmarshal_ListWebhookEventsResponse,
unmarshal_ListWebhooksResponse,
unmarshal_ProjectSettings,
unmarshal_Statistics,
marshal_BulkCreateBlocklistsRequest,
marshal_CreateDomainRequest,
marshal_CreateEmailRequest,
marshal_CreateWebhookRequest,
Expand Down Expand Up @@ -1277,3 +1286,187 @@ async def update_project_settings(

self._throw_on_error(res)
return unmarshal_ProjectSettings(res.json())

async def list_blocklists(
self,
*,
domain_id: str,
region: Optional[Region] = None,
order_by: Optional[ListBlocklistsRequestOrderBy] = None,
page: Optional[int] = None,
page_size: Optional[int] = None,
email: Optional[str] = None,
type_: Optional[BlocklistType] = None,
custom: Optional[bool] = None,
) -> ListBlocklistsResponse:
"""
List blocklists.
Retrieve the list of blocklists.
:param domain_id: (Optional) Filter by a domain ID.
:param region: Region to target. If none is passed will use default region from the config.
:param order_by: (Optional) List blocklist corresponding to specific criteria.
:param page: (Optional) Requested page number. Value must be greater or equal to 1.
:param page_size: (Optional) Requested page size. Value must be between 1 and 100.
:param email: (Optional) Filter by an email address.
:param type_: (Optional) Filter by a blocklist type.
:param custom: (Optional) Filter by custom blocklist (true) or automatic Transactional Email blocklist (false).
:return: :class:`ListBlocklistsResponse <ListBlocklistsResponse>`

Usage:
::

result = await api.list_blocklists(
domain_id="example",
)
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)

res = self._request(
"GET",
f"/transactional-email/v1alpha1/regions/{param_region}/blocklists",
params={
"custom": custom,
"domain_id": domain_id,
"email": email,
"order_by": order_by,
"page": page,
"page_size": page_size or self.client.default_page_size,
"type": type_,
},
)

self._throw_on_error(res)
return unmarshal_ListBlocklistsResponse(res.json())

async def list_blocklists_all(
self,
*,
domain_id: str,
region: Optional[Region] = None,
order_by: Optional[ListBlocklistsRequestOrderBy] = None,
page: Optional[int] = None,
page_size: Optional[int] = None,
email: Optional[str] = None,
type_: Optional[BlocklistType] = None,
custom: Optional[bool] = None,
) -> List[Blocklist]:
"""
List blocklists.
Retrieve the list of blocklists.
:param domain_id: (Optional) Filter by a domain ID.
:param region: Region to target. If none is passed will use default region from the config.
:param order_by: (Optional) List blocklist corresponding to specific criteria.
:param page: (Optional) Requested page number. Value must be greater or equal to 1.
:param page_size: (Optional) Requested page size. Value must be between 1 and 100.
:param email: (Optional) Filter by an email address.
:param type_: (Optional) Filter by a blocklist type.
:param custom: (Optional) Filter by custom blocklist (true) or automatic Transactional Email blocklist (false).
:return: :class:`List[Blocklist] <List[Blocklist]>`

Usage:
::

result = await api.list_blocklists_all(
domain_id="example",
)
"""

return await fetch_all_pages_async(
type=ListBlocklistsResponse,
key="blocklists",
fetcher=self.list_blocklists,
args={
"domain_id": domain_id,
"region": region,
"order_by": order_by,
"page": page,
"page_size": page_size,
"email": email,
"type_": type_,
"custom": custom,
},
)

async def bulk_create_blocklists(
self,
*,
domain_id: str,
region: Optional[Region] = None,
emails: Optional[List[str]] = None,
type_: Optional[BlocklistType] = None,
reason: Optional[str] = None,
) -> BulkCreateBlocklistsResponse:
"""
Bulk create blocklists.
Create multiple blocklists in a specific Project or Organization using the `region` parameter.
:param domain_id: Domain ID linked to the blocklist.
:param region: Region to target. If none is passed will use default region from the config.
:param emails: Email blocked by the blocklist.
:param type_: Type of blocklist.
:param reason: Reason to block the email.
:return: :class:`BulkCreateBlocklistsResponse <BulkCreateBlocklistsResponse>`

Usage:
::

result = await api.bulk_create_blocklists(
domain_id="example",
)
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)

res = self._request(
"POST",
f"/transactional-email/v1alpha1/regions/{param_region}/blocklists",
body=marshal_BulkCreateBlocklistsRequest(
BulkCreateBlocklistsRequest(
domain_id=domain_id,
region=region,
emails=emails,
type_=type_,
reason=reason,
),
self.client,
),
)

self._throw_on_error(res)
return unmarshal_BulkCreateBlocklistsResponse(res.json())

async def delete_blocklist(
self,
*,
blocklist_id: str,
region: Optional[Region] = None,
) -> None:
"""
Delete a blocklist.
You must specify the blocklist you want to delete by the `region` and `blocklist_id`.
:param blocklist_id: ID of the blocklist to delete.
:param region: Region to target. If none is passed will use default region from the config.

Usage:
::

result = await api.delete_blocklist(
blocklist_id="example",
)
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)
param_blocklist_id = validate_path_param("blocklist_id", blocklist_id)

res = self._request(
"DELETE",
f"/transactional-email/v1alpha1/regions/{param_region}/blocklists/{param_blocklist_id}",
)

self._throw_on_error(res)
Loading
Loading