Skip to content
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 @@ -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
76 changes: 75 additions & 1 deletion scaleway-async/scaleway_async/tem/v1alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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,
Expand All @@ -28,6 +30,10 @@
CreateEmailRequest,
CreateDomainRequest,
)
from .content import (
DOMAIN_TRANSIENT_STATUSES,
EMAIL_TRANSIENT_STATUSES,
)
from .marshalling import (
marshal_CreateDomainRequest,
marshal_CreateEmailRequest,
Expand Down Expand Up @@ -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 <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 <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,
Expand Down Expand Up @@ -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 <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 <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,
Expand Down
24 changes: 24 additions & 0 deletions scaleway-async/scaleway_async/tem/v1alpha1/content.py
Original file line number Diff line number Diff line change
@@ -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 <DomainStatus>`.
"""

EMAIL_TRANSIENT_STATUSES: List[EmailStatus] = [
EmailStatus.NEW,
EmailStatus.SENDING,
]
"""
Lists transient statutes of the enum :class:`EmailStatus <EmailStatus>`.
"""
2 changes: 2 additions & 0 deletions scaleway/scaleway/tem/v1alpha1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
74 changes: 74 additions & 0 deletions scaleway/scaleway/tem/v1alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -28,6 +30,10 @@
CreateEmailRequest,
CreateDomainRequest,
)
from .content import (
DOMAIN_TRANSIENT_STATUSES,
EMAIL_TRANSIENT_STATUSES,
)
from .marshalling import (
marshal_CreateDomainRequest,
marshal_CreateEmailRequest,
Expand Down Expand Up @@ -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 <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 <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,
Expand Down Expand Up @@ -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 <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 <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,
Expand Down
24 changes: 24 additions & 0 deletions scaleway/scaleway/tem/v1alpha1/content.py
Original file line number Diff line number Diff line change
@@ -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 <DomainStatus>`.
"""

EMAIL_TRANSIENT_STATUSES: List[EmailStatus] = [
EmailStatus.NEW,
EmailStatus.SENDING,
]
"""
Lists transient statutes of the enum :class:`EmailStatus <EmailStatus>`.
"""