From 8dd0528de94fe9e2c476f2a4ccca2cbd94b6f88a Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Tue, 3 Jan 2023 15:16:15 +0000 Subject: [PATCH] feat: update generated APIs --- .../scaleway_async/tem/v1alpha1/__init__.py | 2 + .../scaleway_async/tem/v1alpha1/api.py | 76 ++++++++++++++++++- .../scaleway_async/tem/v1alpha1/content.py | 24 ++++++ scaleway/scaleway/tem/v1alpha1/__init__.py | 2 + scaleway/scaleway/tem/v1alpha1/api.py | 74 ++++++++++++++++++ scaleway/scaleway/tem/v1alpha1/content.py | 24 ++++++ 6 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 scaleway-async/scaleway_async/tem/v1alpha1/content.py create mode 100644 scaleway/scaleway/tem/v1alpha1/content.py diff --git a/scaleway-async/scaleway_async/tem/v1alpha1/__init__.py b/scaleway-async/scaleway_async/tem/v1alpha1/__init__.py index c4dbc5a20..7f8665fc9 100644 --- a/scaleway-async/scaleway_async/tem/v1alpha1/__init__.py +++ b/scaleway-async/scaleway_async/tem/v1alpha1/__init__.py @@ -13,4 +13,6 @@ from .types import ListDomainsResponse as ListDomainsResponse # noqa from .types import ListEmailsResponse as ListEmailsResponse # noqa from .types import Statistics as Statistics # noqa +from .content import DOMAIN_TRANSIENT_STATUSES as DOMAIN_TRANSIENT_STATUSES # noqa +from .content import EMAIL_TRANSIENT_STATUSES as EMAIL_TRANSIENT_STATUSES # noqa from .api import TemV1Alpha1API as TemV1Alpha1API # noqa diff --git a/scaleway-async/scaleway_async/tem/v1alpha1/api.py b/scaleway-async/scaleway_async/tem/v1alpha1/api.py index b138cbbc7..f4a007311 100644 --- a/scaleway-async/scaleway_async/tem/v1alpha1/api.py +++ b/scaleway-async/scaleway_async/tem/v1alpha1/api.py @@ -2,7 +2,7 @@ # If you have any remark or suggestion do not hesitate to open an issue. from datetime import datetime -from typing import List, Optional +from typing import Awaitable, List, Optional, Union from scaleway_core.api import API from scaleway_core.bridge import ( @@ -11,8 +11,10 @@ unmarshal_ServiceInfo, ) from scaleway_core.utils import ( + WaitForOptions, fetch_all_pages_async, validate_path_param, + wait_for_resource_async, ) from .types import ( DomainStatus, @@ -28,6 +30,10 @@ CreateEmailRequest, CreateDomainRequest, ) +from .content import ( + DOMAIN_TRANSIENT_STATUSES, + EMAIL_TRANSIENT_STATUSES, +) from .marshalling import ( marshal_CreateDomainRequest, marshal_CreateEmailRequest, @@ -169,6 +175,40 @@ async def get_email( self._throw_on_error(res) return unmarshal_Email(res.json()) + async def wait_for_email( + self, + email_id: str, + region: Optional[Region] = None, + options: Optional[WaitForOptions[Email, Union[bool, Awaitable[bool]]]] = None, + ) -> Email: + """ + Waits for :class:`Email ` to be in a final state. + :param region: Region to target. If none is passed will use default region from the config + :param email_id: ID of the email to retrieve + :param options: The options for the waiter + :return: :class:`Email ` + + Usage: + :: + + result = api.wait_for_email(email_id="example") + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in EMAIL_TRANSIENT_STATUSES + + return await wait_for_resource_async( + fetcher=self.get_email, + options=options, + args={ + "email_id": email_id, + "region": region, + }, + ) + async def list_emails( self, region: Optional[Region] = None, @@ -425,6 +465,40 @@ async def get_domain( self._throw_on_error(res) return unmarshal_Domain(res.json()) + async def wait_for_domain( + self, + domain_id: str, + region: Optional[Region] = None, + options: Optional[WaitForOptions[Domain, Union[bool, Awaitable[bool]]]] = None, + ) -> Domain: + """ + Waits for :class:`Domain ` to be in a final state. + :param region: Region to target. If none is passed will use default region from the config + :param domain_id: ID of the domain + :param options: The options for the waiter + :return: :class:`Domain ` + + Usage: + :: + + result = api.wait_for_domain(domain_id="example") + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in DOMAIN_TRANSIENT_STATUSES + + return await wait_for_resource_async( + fetcher=self.get_domain, + options=options, + args={ + "domain_id": domain_id, + "region": region, + }, + ) + async def list_domains( self, region: Optional[Region] = None, diff --git a/scaleway-async/scaleway_async/tem/v1alpha1/content.py b/scaleway-async/scaleway_async/tem/v1alpha1/content.py new file mode 100644 index 000000000..43d15b37d --- /dev/null +++ b/scaleway-async/scaleway_async/tem/v1alpha1/content.py @@ -0,0 +1,24 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from typing import List + +from .types import ( + DomainStatus, + EmailStatus, +) + + +DOMAIN_TRANSIENT_STATUSES: List[DomainStatus] = [ + DomainStatus.PENDING, +] +""" +Lists transient statutes of the enum :class:`DomainStatus `. +""" + +EMAIL_TRANSIENT_STATUSES: List[EmailStatus] = [ + EmailStatus.NEW, + EmailStatus.SENDING, +] +""" +Lists transient statutes of the enum :class:`EmailStatus `. +""" diff --git a/scaleway/scaleway/tem/v1alpha1/__init__.py b/scaleway/scaleway/tem/v1alpha1/__init__.py index c4dbc5a20..7f8665fc9 100644 --- a/scaleway/scaleway/tem/v1alpha1/__init__.py +++ b/scaleway/scaleway/tem/v1alpha1/__init__.py @@ -13,4 +13,6 @@ from .types import ListDomainsResponse as ListDomainsResponse # noqa from .types import ListEmailsResponse as ListEmailsResponse # noqa from .types import Statistics as Statistics # noqa +from .content import DOMAIN_TRANSIENT_STATUSES as DOMAIN_TRANSIENT_STATUSES # noqa +from .content import EMAIL_TRANSIENT_STATUSES as EMAIL_TRANSIENT_STATUSES # noqa from .api import TemV1Alpha1API as TemV1Alpha1API # noqa diff --git a/scaleway/scaleway/tem/v1alpha1/api.py b/scaleway/scaleway/tem/v1alpha1/api.py index bf306ea8c..05f40c272 100644 --- a/scaleway/scaleway/tem/v1alpha1/api.py +++ b/scaleway/scaleway/tem/v1alpha1/api.py @@ -11,8 +11,10 @@ unmarshal_ServiceInfo, ) from scaleway_core.utils import ( + WaitForOptions, fetch_all_pages, validate_path_param, + wait_for_resource, ) from .types import ( DomainStatus, @@ -28,6 +30,10 @@ CreateEmailRequest, CreateDomainRequest, ) +from .content import ( + DOMAIN_TRANSIENT_STATUSES, + EMAIL_TRANSIENT_STATUSES, +) from .marshalling import ( marshal_CreateDomainRequest, marshal_CreateEmailRequest, @@ -169,6 +175,40 @@ def get_email( self._throw_on_error(res) return unmarshal_Email(res.json()) + def wait_for_email( + self, + email_id: str, + region: Optional[Region] = None, + options: Optional[WaitForOptions[Email, bool]] = None, + ) -> Email: + """ + Waits for :class:`Email ` to be in a final state. + :param region: Region to target. If none is passed will use default region from the config + :param email_id: ID of the email to retrieve + :param options: The options for the waiter + :return: :class:`Email ` + + Usage: + :: + + result = api.wait_for_email(email_id="example") + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in EMAIL_TRANSIENT_STATUSES + + return wait_for_resource( + fetcher=self.get_email, + options=options, + args={ + "email_id": email_id, + "region": region, + }, + ) + def list_emails( self, region: Optional[Region] = None, @@ -425,6 +465,40 @@ def get_domain( self._throw_on_error(res) return unmarshal_Domain(res.json()) + def wait_for_domain( + self, + domain_id: str, + region: Optional[Region] = None, + options: Optional[WaitForOptions[Domain, bool]] = None, + ) -> Domain: + """ + Waits for :class:`Domain ` to be in a final state. + :param region: Region to target. If none is passed will use default region from the config + :param domain_id: ID of the domain + :param options: The options for the waiter + :return: :class:`Domain ` + + Usage: + :: + + result = api.wait_for_domain(domain_id="example") + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in DOMAIN_TRANSIENT_STATUSES + + return wait_for_resource( + fetcher=self.get_domain, + options=options, + args={ + "domain_id": domain_id, + "region": region, + }, + ) + def list_domains( self, region: Optional[Region] = None, diff --git a/scaleway/scaleway/tem/v1alpha1/content.py b/scaleway/scaleway/tem/v1alpha1/content.py new file mode 100644 index 000000000..43d15b37d --- /dev/null +++ b/scaleway/scaleway/tem/v1alpha1/content.py @@ -0,0 +1,24 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from typing import List + +from .types import ( + DomainStatus, + EmailStatus, +) + + +DOMAIN_TRANSIENT_STATUSES: List[DomainStatus] = [ + DomainStatus.PENDING, +] +""" +Lists transient statutes of the enum :class:`DomainStatus `. +""" + +EMAIL_TRANSIENT_STATUSES: List[EmailStatus] = [ + EmailStatus.NEW, + EmailStatus.SENDING, +] +""" +Lists transient statutes of the enum :class:`EmailStatus `. +"""