Skip to content

feat(tem): add support for UpdateDomain #631

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

Merged
merged 1 commit into from
Sep 2, 2024
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
2 changes: 2 additions & 0 deletions scaleway-async/scaleway_async/tem/v1alpha1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from .types import ListWebhooksResponse
from .types import RevokeDomainRequest
from .types import Statistics
from .types import UpdateDomainRequest
from .types import UpdateWebhookRequest
from .api import TemV1Alpha1API

Expand Down Expand Up @@ -106,6 +107,7 @@
"ListWebhooksResponse",
"RevokeDomainRequest",
"Statistics",
"UpdateDomainRequest",
"UpdateWebhookRequest",
"TemV1Alpha1API",
]
46 changes: 46 additions & 0 deletions scaleway-async/scaleway_async/tem/v1alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
ListWebhookEventsResponse,
ListWebhooksResponse,
Statistics,
UpdateDomainRequest,
UpdateWebhookRequest,
Webhook,
WebhookEvent,
Expand All @@ -60,6 +61,7 @@
marshal_CreateDomainRequest,
marshal_CreateEmailRequest,
marshal_CreateWebhookRequest,
marshal_UpdateDomainRequest,
marshal_UpdateWebhookRequest,
)

Expand Down Expand Up @@ -761,6 +763,50 @@ async def get_domain_last_status(
self._throw_on_error(res)
return unmarshal_DomainLastStatus(res.json())

async def update_domain(
self,
*,
domain_id: str,
region: Optional[Region] = None,
autoconfig: Optional[bool] = None,
) -> Domain:
"""
Update a domain.
Update a domain auto-configuration.
:param domain_id: ID of the domain to update.
:param region: Region to target. If none is passed will use default region from the config.
:param autoconfig: (Optional) If set to true, activate auto-configuration of the domain's DNS zone.
:return: :class:`Domain <Domain>`

Usage:
::

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

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

res = self._request(
"PATCH",
f"/transactional-email/v1alpha1/regions/{param_region}/domains/{param_domain_id}",
body=marshal_UpdateDomainRequest(
UpdateDomainRequest(
domain_id=domain_id,
region=region,
autoconfig=autoconfig,
),
self.client,
),
)

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

async def create_webhook(
self,
*,
Expand Down
13 changes: 13 additions & 0 deletions scaleway-async/scaleway_async/tem/v1alpha1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
CreateEmailRequestHeader,
CreateEmailRequest,
CreateWebhookRequest,
UpdateDomainRequest,
UpdateWebhookRequest,
)

Expand Down Expand Up @@ -869,6 +870,18 @@ def marshal_CreateWebhookRequest(
return output


def marshal_UpdateDomainRequest(
request: UpdateDomainRequest,
defaults: ProfileDefaults,
) -> Dict[str, Any]:
output: Dict[str, Any] = {}

if request.autoconfig is not None:
output["autoconfig"] = request.autoconfig

return output


def marshal_UpdateWebhookRequest(
request: UpdateWebhookRequest,
defaults: ProfileDefaults,
Expand Down
18 changes: 18 additions & 0 deletions scaleway-async/scaleway_async/tem/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,24 @@ class Statistics:
"""


@dataclass
class UpdateDomainRequest:
domain_id: str
"""
ID of the domain to update.
"""

region: Optional[Region]
"""
Region to target. If none is passed will use default region from the config.
"""

autoconfig: Optional[bool]
"""
(Optional) If set to true, activate auto-configuration of the domain's DNS zone.
"""


@dataclass
class UpdateWebhookRequest:
webhook_id: str
Expand Down
2 changes: 2 additions & 0 deletions scaleway/scaleway/tem/v1alpha1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from .types import ListWebhooksResponse
from .types import RevokeDomainRequest
from .types import Statistics
from .types import UpdateDomainRequest
from .types import UpdateWebhookRequest
from .api import TemV1Alpha1API

Expand Down Expand Up @@ -106,6 +107,7 @@
"ListWebhooksResponse",
"RevokeDomainRequest",
"Statistics",
"UpdateDomainRequest",
"UpdateWebhookRequest",
"TemV1Alpha1API",
]
46 changes: 46 additions & 0 deletions scaleway/scaleway/tem/v1alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
ListWebhookEventsResponse,
ListWebhooksResponse,
Statistics,
UpdateDomainRequest,
UpdateWebhookRequest,
Webhook,
WebhookEvent,
Expand All @@ -60,6 +61,7 @@
marshal_CreateDomainRequest,
marshal_CreateEmailRequest,
marshal_CreateWebhookRequest,
marshal_UpdateDomainRequest,
marshal_UpdateWebhookRequest,
)

Expand Down Expand Up @@ -761,6 +763,50 @@ def get_domain_last_status(
self._throw_on_error(res)
return unmarshal_DomainLastStatus(res.json())

def update_domain(
self,
*,
domain_id: str,
region: Optional[Region] = None,
autoconfig: Optional[bool] = None,
) -> Domain:
"""
Update a domain.
Update a domain auto-configuration.
:param domain_id: ID of the domain to update.
:param region: Region to target. If none is passed will use default region from the config.
:param autoconfig: (Optional) If set to true, activate auto-configuration of the domain's DNS zone.
:return: :class:`Domain <Domain>`

Usage:
::

result = api.update_domain(
domain_id="example",
)
"""

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

res = self._request(
"PATCH",
f"/transactional-email/v1alpha1/regions/{param_region}/domains/{param_domain_id}",
body=marshal_UpdateDomainRequest(
UpdateDomainRequest(
domain_id=domain_id,
region=region,
autoconfig=autoconfig,
),
self.client,
),
)

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

def create_webhook(
self,
*,
Expand Down
13 changes: 13 additions & 0 deletions scaleway/scaleway/tem/v1alpha1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
CreateEmailRequestHeader,
CreateEmailRequest,
CreateWebhookRequest,
UpdateDomainRequest,
UpdateWebhookRequest,
)

Expand Down Expand Up @@ -869,6 +870,18 @@ def marshal_CreateWebhookRequest(
return output


def marshal_UpdateDomainRequest(
request: UpdateDomainRequest,
defaults: ProfileDefaults,
) -> Dict[str, Any]:
output: Dict[str, Any] = {}

if request.autoconfig is not None:
output["autoconfig"] = request.autoconfig

return output


def marshal_UpdateWebhookRequest(
request: UpdateWebhookRequest,
defaults: ProfileDefaults,
Expand Down
18 changes: 18 additions & 0 deletions scaleway/scaleway/tem/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,24 @@ class Statistics:
"""


@dataclass
class UpdateDomainRequest:
domain_id: str
"""
ID of the domain to update.
"""

region: Optional[Region]
"""
Region to target. If none is passed will use default region from the config.
"""

autoconfig: Optional[bool]
"""
(Optional) If set to true, activate auto-configuration of the domain's DNS zone.
"""


@dataclass
class UpdateWebhookRequest:
webhook_id: str
Expand Down