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
14 changes: 14 additions & 0 deletions scaleway-async/scaleway_async/webhosting/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .types import BackupItemType
from .types import BackupStatus
from .content import BACKUP_TRANSIENT_STATUSES
from .types import CheckFreeDomainAvailabilityResponseUnavailableReason
from .types import DnsRecordStatus
from .types import DnsRecordType
from .types import DnsRecordsStatus
Expand Down Expand Up @@ -35,6 +36,7 @@
from .types import PlatformControlPanel
from .types import BackupItem
from .types import HostingDomain
from .types import FreeDomain
from .types import CreateDatabaseRequestUser
from .types import CreateHostingRequestDomainConfiguration
from .types import OfferOptionRequest
Expand All @@ -59,6 +61,7 @@
from .types import BackupApiListBackupsRequest
from .types import BackupApiRestoreBackupItemsRequest
from .types import BackupApiRestoreBackupRequest
from .types import CheckFreeDomainAvailabilityResponse
from .types import CheckUserOwnsDomainResponse
from .types import ControlPanelApiListControlPanelsRequest
from .types import DatabaseApiAssignDatabaseUserRequest
Expand All @@ -79,6 +82,8 @@
from .types import DnsApiSyncDomainDnsRecordsRequest
from .types import DnsRecords
from .types import Domain
from .types import FreeDomainApiCheckFreeDomainAvailabilityRequest
from .types import FreeDomainApiListFreeRootDomainsRequest
from .types import FtpAccountApiChangeFtpAccountPasswordRequest
from .types import FtpAccountApiCreateFtpAccountRequest
from .types import FtpAccountApiListFtpAccountsRequest
Expand All @@ -99,6 +104,7 @@
from .types import ListControlPanelsResponse
from .types import ListDatabaseUsersResponse
from .types import ListDatabasesResponse
from .types import ListFreeRootDomainsResponse
from .types import ListFtpAccountsResponse
from .types import ListHostingsResponse
from .types import ListMailAccountsResponse
Expand All @@ -122,6 +128,7 @@
from .api import WebhostingV1DnsAPI
from .api import WebhostingV1OfferAPI
from .api import WebhostingV1HostingAPI
from .api import WebhostingV1FreeDomainAPI
from .api import WebhostingV1FtpAccountAPI
from .api import WebhostingV1MailAccountAPI
from .api import WebhostingV1WebsiteAPI
Expand All @@ -130,6 +137,7 @@
"BackupItemType",
"BackupStatus",
"BACKUP_TRANSIENT_STATUSES",
"CheckFreeDomainAvailabilityResponseUnavailableReason",
"DnsRecordStatus",
"DnsRecordType",
"DnsRecordsStatus",
Expand Down Expand Up @@ -162,6 +170,7 @@
"PlatformControlPanel",
"BackupItem",
"HostingDomain",
"FreeDomain",
"CreateDatabaseRequestUser",
"CreateHostingRequestDomainConfiguration",
"OfferOptionRequest",
Expand All @@ -186,6 +195,7 @@
"BackupApiListBackupsRequest",
"BackupApiRestoreBackupItemsRequest",
"BackupApiRestoreBackupRequest",
"CheckFreeDomainAvailabilityResponse",
"CheckUserOwnsDomainResponse",
"ControlPanelApiListControlPanelsRequest",
"DatabaseApiAssignDatabaseUserRequest",
Expand All @@ -206,6 +216,8 @@
"DnsApiSyncDomainDnsRecordsRequest",
"DnsRecords",
"Domain",
"FreeDomainApiCheckFreeDomainAvailabilityRequest",
"FreeDomainApiListFreeRootDomainsRequest",
"FtpAccountApiChangeFtpAccountPasswordRequest",
"FtpAccountApiCreateFtpAccountRequest",
"FtpAccountApiListFtpAccountsRequest",
Expand All @@ -226,6 +238,7 @@
"ListControlPanelsResponse",
"ListDatabaseUsersResponse",
"ListDatabasesResponse",
"ListFreeRootDomainsResponse",
"ListFtpAccountsResponse",
"ListHostingsResponse",
"ListMailAccountsResponse",
Expand All @@ -249,6 +262,7 @@
"WebhostingV1DnsAPI",
"WebhostingV1OfferAPI",
"WebhostingV1HostingAPI",
"WebhostingV1FreeDomainAPI",
"WebhostingV1FtpAccountAPI",
"WebhostingV1MailAccountAPI",
"WebhostingV1WebsiteAPI",
Expand Down
122 changes: 122 additions & 0 deletions scaleway-async/scaleway_async/webhosting/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
AutoConfigDomainDns,
Backup,
BackupApiRestoreBackupItemsRequest,
CheckFreeDomainAvailabilityResponse,
CheckUserOwnsDomainResponse,
ControlPanel,
CreateDatabaseRequestUser,
Expand All @@ -41,6 +42,7 @@
DnsApiSyncDomainDnsRecordsRequest,
DnsRecords,
Domain,
FreeDomainApiCheckFreeDomainAvailabilityRequest,
FtpAccount,
FtpAccountApiChangeFtpAccountPasswordRequest,
FtpAccountApiCreateFtpAccountRequest,
Expand All @@ -54,6 +56,7 @@
ListControlPanelsResponse,
ListDatabaseUsersResponse,
ListDatabasesResponse,
ListFreeRootDomainsResponse,
ListFtpAccountsResponse,
ListHostingsResponse,
ListMailAccountsResponse,
Expand Down Expand Up @@ -86,6 +89,7 @@
unmarshal_FtpAccount,
unmarshal_HostingSummary,
unmarshal_MailAccount,
unmarshal_CheckFreeDomainAvailabilityResponse,
unmarshal_CheckUserOwnsDomainResponse,
unmarshal_DnsRecords,
unmarshal_Domain,
Expand All @@ -95,6 +99,7 @@
unmarshal_ListControlPanelsResponse,
unmarshal_ListDatabaseUsersResponse,
unmarshal_ListDatabasesResponse,
unmarshal_ListFreeRootDomainsResponse,
unmarshal_ListFtpAccountsResponse,
unmarshal_ListHostingsResponse,
unmarshal_ListMailAccountsResponse,
Expand All @@ -114,6 +119,7 @@
marshal_DatabaseApiUnassignDatabaseUserRequest,
marshal_DnsApiCheckUserOwnsDomainRequest,
marshal_DnsApiSyncDomainDnsRecordsRequest,
marshal_FreeDomainApiCheckFreeDomainAvailabilityRequest,
marshal_FtpAccountApiChangeFtpAccountPasswordRequest,
marshal_FtpAccountApiCreateFtpAccountRequest,
marshal_HostingApiAddCustomDomainRequest,
Expand Down Expand Up @@ -1938,6 +1944,122 @@ async def remove_custom_domain(
return unmarshal_HostingSummary(res.json())


class WebhostingV1FreeDomainAPI(API):
"""
This API allows you to list and check a free domain's validity.
"""

async def check_free_domain_availability(
self,
*,
slug: str,
root_domain: str,
region: Optional[ScwRegion] = None,
) -> CheckFreeDomainAvailabilityResponse:
"""
Check whether a given slug and free domain combination is available.
:param slug: Custom prefix used for the free domain.
:param root_domain: Free root domain provided by Web Hosting, selected from the list returned by `ListFreeRootDomains`.
:param region: Region to target. If none is passed will use default region from the config.
:return: :class:`CheckFreeDomainAvailabilityResponse <CheckFreeDomainAvailabilityResponse>`

Usage:
::

result = await api.check_free_domain_availability(
slug="example",
root_domain="example",
)
"""

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

res = self._request(
"POST",
f"/webhosting/v1/regions/{param_region}/free-domains/check-availability",
body=marshal_FreeDomainApiCheckFreeDomainAvailabilityRequest(
FreeDomainApiCheckFreeDomainAvailabilityRequest(
slug=slug,
root_domain=root_domain,
region=region,
),
self.client,
),
)

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

async def list_free_root_domains(
self,
*,
region: Optional[ScwRegion] = None,
page: Optional[int] = None,
page_size: Optional[int] = None,
) -> ListFreeRootDomainsResponse:
"""
Retrieve the list of free root domains available for a Web Hosting.
:param region: Region to target. If none is passed will use default region from the config.
:param page: Page number to return, from the paginated results (must be a positive integer).
:param page_size: Number of free root domains to return (must be a positive integer lower or equal to 100).
:return: :class:`ListFreeRootDomainsResponse <ListFreeRootDomainsResponse>`

Usage:
::

result = await api.list_free_root_domains()
"""

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

res = self._request(
"GET",
f"/webhosting/v1/regions/{param_region}/free-domains/root-domains",
params={
"page": page,
"page_size": page_size or self.client.default_page_size,
},
)

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

async def list_free_root_domains_all(
self,
*,
region: Optional[ScwRegion] = None,
page: Optional[int] = None,
page_size: Optional[int] = None,
) -> List[str]:
"""
Retrieve the list of free root domains available for a Web Hosting.
:param region: Region to target. If none is passed will use default region from the config.
:param page: Page number to return, from the paginated results (must be a positive integer).
:param page_size: Number of free root domains to return (must be a positive integer lower or equal to 100).
:return: :class:`List[str] <List[str]>`

Usage:
::

result = await api.list_free_root_domains_all()
"""

return await fetch_all_pages_async(
type=ListFreeRootDomainsResponse,
key="root_domains",
fetcher=self.list_free_root_domains,
args={
"region": region,
"page": page,
"page_size": page_size,
},
)


class WebhostingV1FtpAccountAPI(API):
"""
This API allows you to manage your FTP accounts for your Web Hosting services.
Expand Down
Loading