Skip to content

feat(webhosting): add domain api #598

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
Jul 19, 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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from .types import ControlPanel
from .types import Hosting
from .types import Offer
from .types import CheckUserOwnsDomainRequest
from .types import CheckUserOwnsDomainResponse
from .types import CreateHostingRequest
from .types import CreateSessionRequest
from .types import DeleteHostingRequest
Expand Down Expand Up @@ -58,6 +60,8 @@
"ControlPanel",
"Hosting",
"Offer",
"CheckUserOwnsDomainRequest",
"CheckUserOwnsDomainResponse",
"CreateHostingRequest",
"CreateSessionRequest",
"DeleteHostingRequest",
Expand Down
40 changes: 40 additions & 0 deletions scaleway-async/scaleway_async/webhosting/v1alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
HostingStatus,
ListHostingsRequestOrderBy,
ListOffersRequestOrderBy,
CheckUserOwnsDomainResponse,
ControlPanel,
CreateHostingRequest,
CreateHostingRequestDomainConfiguration,
Expand All @@ -34,6 +35,7 @@
)
from .marshalling import (
unmarshal_Hosting,
unmarshal_CheckUserOwnsDomainResponse,
unmarshal_DnsRecords,
unmarshal_ListControlPanelsResponse,
unmarshal_ListHostingsResponse,
Expand Down Expand Up @@ -457,6 +459,44 @@ async def get_domain_dns_records(
self._throw_on_error(res)
return unmarshal_DnsRecords(res.json())

async def check_user_owns_domain(
self,
*,
domain: str,
region: Optional[Region] = None,
project_id: Optional[str] = None,
) -> CheckUserOwnsDomainResponse:
"""
"Check whether you own this domain or not.".
:param domain: Domain for which ownership is to be verified.
:param region: Region to target. If none is passed will use default region from the config.
:param project_id: ID of the project currently in use.
:return: :class:`CheckUserOwnsDomainResponse <CheckUserOwnsDomainResponse>`

Usage:
::

result = await api.check_user_owns_domain(
domain="example",
)
"""

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

res = self._request(
"POST",
f"/webhosting/v1/regions/{param_region}/domains/{param_domain}/check-ownership",
params={
"project_id": project_id or self.client.default_project_id,
},
)

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

async def list_offers(
self,
*,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
HostingCpanelUrls,
HostingOption,
Hosting,
CheckUserOwnsDomainResponse,
DnsRecord,
Nameserver,
DnsRecords,
Expand Down Expand Up @@ -188,6 +189,21 @@ def unmarshal_Hosting(data: Any) -> Hosting:
return Hosting(**args)


def unmarshal_CheckUserOwnsDomainResponse(data: Any) -> CheckUserOwnsDomainResponse:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'CheckUserOwnsDomainResponse' failed as data isn't a dictionary."
)

args: Dict[str, Any] = {}

field = data.get("owns_domain", None)
if field is not None:
args["owns_domain"] = field

return CheckUserOwnsDomainResponse(**args)


def unmarshal_DnsRecord(data: Any) -> DnsRecord:
if not isinstance(data, dict):
raise TypeError(
Expand Down
26 changes: 26 additions & 0 deletions scaleway-async/scaleway_async/webhosting/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,32 @@ class Offer:
"""


@dataclass
class CheckUserOwnsDomainRequest:
domain: str
"""
Domain for which ownership is to be verified.
"""

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

project_id: Optional[str]
"""
ID of the project currently in use.
"""


@dataclass
class CheckUserOwnsDomainResponse:
owns_domain: bool
"""
Indicates whether the specified project owns the domain.
"""


@dataclass
class CreateHostingRequest:
offer_id: str
Expand Down
4 changes: 4 additions & 0 deletions scaleway/scaleway/webhosting/v1alpha1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from .types import ControlPanel
from .types import Hosting
from .types import Offer
from .types import CheckUserOwnsDomainRequest
from .types import CheckUserOwnsDomainResponse
from .types import CreateHostingRequest
from .types import CreateSessionRequest
from .types import DeleteHostingRequest
Expand Down Expand Up @@ -58,6 +60,8 @@
"ControlPanel",
"Hosting",
"Offer",
"CheckUserOwnsDomainRequest",
"CheckUserOwnsDomainResponse",
"CreateHostingRequest",
"CreateSessionRequest",
"DeleteHostingRequest",
Expand Down
40 changes: 40 additions & 0 deletions scaleway/scaleway/webhosting/v1alpha1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
HostingStatus,
ListHostingsRequestOrderBy,
ListOffersRequestOrderBy,
CheckUserOwnsDomainResponse,
ControlPanel,
CreateHostingRequest,
CreateHostingRequestDomainConfiguration,
Expand All @@ -34,6 +35,7 @@
)
from .marshalling import (
unmarshal_Hosting,
unmarshal_CheckUserOwnsDomainResponse,
unmarshal_DnsRecords,
unmarshal_ListControlPanelsResponse,
unmarshal_ListHostingsResponse,
Expand Down Expand Up @@ -457,6 +459,44 @@ def get_domain_dns_records(
self._throw_on_error(res)
return unmarshal_DnsRecords(res.json())

def check_user_owns_domain(
self,
*,
domain: str,
region: Optional[Region] = None,
project_id: Optional[str] = None,
) -> CheckUserOwnsDomainResponse:
"""
"Check whether you own this domain or not.".
:param domain: Domain for which ownership is to be verified.
:param region: Region to target. If none is passed will use default region from the config.
:param project_id: ID of the project currently in use.
:return: :class:`CheckUserOwnsDomainResponse <CheckUserOwnsDomainResponse>`

Usage:
::

result = api.check_user_owns_domain(
domain="example",
)
"""

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

res = self._request(
"POST",
f"/webhosting/v1/regions/{param_region}/domains/{param_domain}/check-ownership",
params={
"project_id": project_id or self.client.default_project_id,
},
)

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

def list_offers(
self,
*,
Expand Down
16 changes: 16 additions & 0 deletions scaleway/scaleway/webhosting/v1alpha1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
HostingCpanelUrls,
HostingOption,
Hosting,
CheckUserOwnsDomainResponse,
DnsRecord,
Nameserver,
DnsRecords,
Expand Down Expand Up @@ -188,6 +189,21 @@ def unmarshal_Hosting(data: Any) -> Hosting:
return Hosting(**args)


def unmarshal_CheckUserOwnsDomainResponse(data: Any) -> CheckUserOwnsDomainResponse:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'CheckUserOwnsDomainResponse' failed as data isn't a dictionary."
)

args: Dict[str, Any] = {}

field = data.get("owns_domain", None)
if field is not None:
args["owns_domain"] = field

return CheckUserOwnsDomainResponse(**args)


def unmarshal_DnsRecord(data: Any) -> DnsRecord:
if not isinstance(data, dict):
raise TypeError(
Expand Down
26 changes: 26 additions & 0 deletions scaleway/scaleway/webhosting/v1alpha1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,32 @@ class Offer:
"""


@dataclass
class CheckUserOwnsDomainRequest:
domain: str
"""
Domain for which ownership is to be verified.
"""

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

project_id: Optional[str]
"""
ID of the project currently in use.
"""


@dataclass
class CheckUserOwnsDomainResponse:
owns_domain: bool
"""
Indicates whether the specified project owns the domain.
"""


@dataclass
class CreateHostingRequest:
offer_id: str
Expand Down