Skip to content

Commit 6411155

Browse files
authored
feat(webhosting): add domain api (#598)
1 parent b8610b2 commit 6411155

File tree

8 files changed

+172
-0
lines changed

8 files changed

+172
-0
lines changed

scaleway-async/scaleway_async/webhosting/v1alpha1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
from .types import ControlPanel
2020
from .types import Hosting
2121
from .types import Offer
22+
from .types import CheckUserOwnsDomainRequest
23+
from .types import CheckUserOwnsDomainResponse
2224
from .types import CreateHostingRequest
2325
from .types import CreateSessionRequest
2426
from .types import DeleteHostingRequest
@@ -58,6 +60,8 @@
5860
"ControlPanel",
5961
"Hosting",
6062
"Offer",
63+
"CheckUserOwnsDomainRequest",
64+
"CheckUserOwnsDomainResponse",
6165
"CreateHostingRequest",
6266
"CreateSessionRequest",
6367
"DeleteHostingRequest",

scaleway-async/scaleway_async/webhosting/v1alpha1/api.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
HostingStatus,
1818
ListHostingsRequestOrderBy,
1919
ListOffersRequestOrderBy,
20+
CheckUserOwnsDomainResponse,
2021
ControlPanel,
2122
CreateHostingRequest,
2223
CreateHostingRequestDomainConfiguration,
@@ -34,6 +35,7 @@
3435
)
3536
from .marshalling import (
3637
unmarshal_Hosting,
38+
unmarshal_CheckUserOwnsDomainResponse,
3739
unmarshal_DnsRecords,
3840
unmarshal_ListControlPanelsResponse,
3941
unmarshal_ListHostingsResponse,
@@ -457,6 +459,44 @@ async def get_domain_dns_records(
457459
self._throw_on_error(res)
458460
return unmarshal_DnsRecords(res.json())
459461

462+
async def check_user_owns_domain(
463+
self,
464+
*,
465+
domain: str,
466+
region: Optional[Region] = None,
467+
project_id: Optional[str] = None,
468+
) -> CheckUserOwnsDomainResponse:
469+
"""
470+
"Check whether you own this domain or not.".
471+
:param domain: Domain for which ownership is to be verified.
472+
:param region: Region to target. If none is passed will use default region from the config.
473+
:param project_id: ID of the project currently in use.
474+
:return: :class:`CheckUserOwnsDomainResponse <CheckUserOwnsDomainResponse>`
475+
476+
Usage:
477+
::
478+
479+
result = await api.check_user_owns_domain(
480+
domain="example",
481+
)
482+
"""
483+
484+
param_region = validate_path_param(
485+
"region", region or self.client.default_region
486+
)
487+
param_domain = validate_path_param("domain", domain)
488+
489+
res = self._request(
490+
"POST",
491+
f"/webhosting/v1/regions/{param_region}/domains/{param_domain}/check-ownership",
492+
params={
493+
"project_id": project_id or self.client.default_project_id,
494+
},
495+
)
496+
497+
self._throw_on_error(res)
498+
return unmarshal_CheckUserOwnsDomainResponse(res.json())
499+
460500
async def list_offers(
461501
self,
462502
*,

scaleway-async/scaleway_async/webhosting/v1alpha1/marshalling.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
HostingCpanelUrls,
1414
HostingOption,
1515
Hosting,
16+
CheckUserOwnsDomainResponse,
1617
DnsRecord,
1718
Nameserver,
1819
DnsRecords,
@@ -188,6 +189,21 @@ def unmarshal_Hosting(data: Any) -> Hosting:
188189
return Hosting(**args)
189190

190191

192+
def unmarshal_CheckUserOwnsDomainResponse(data: Any) -> CheckUserOwnsDomainResponse:
193+
if not isinstance(data, dict):
194+
raise TypeError(
195+
"Unmarshalling the type 'CheckUserOwnsDomainResponse' failed as data isn't a dictionary."
196+
)
197+
198+
args: Dict[str, Any] = {}
199+
200+
field = data.get("owns_domain", None)
201+
if field is not None:
202+
args["owns_domain"] = field
203+
204+
return CheckUserOwnsDomainResponse(**args)
205+
206+
191207
def unmarshal_DnsRecord(data: Any) -> DnsRecord:
192208
if not isinstance(data, dict):
193209
raise TypeError(

scaleway-async/scaleway_async/webhosting/v1alpha1/types.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,32 @@ class Offer:
431431
"""
432432

433433

434+
@dataclass
435+
class CheckUserOwnsDomainRequest:
436+
domain: str
437+
"""
438+
Domain for which ownership is to be verified.
439+
"""
440+
441+
region: Optional[Region]
442+
"""
443+
Region to target. If none is passed will use default region from the config.
444+
"""
445+
446+
project_id: Optional[str]
447+
"""
448+
ID of the project currently in use.
449+
"""
450+
451+
452+
@dataclass
453+
class CheckUserOwnsDomainResponse:
454+
owns_domain: bool
455+
"""
456+
Indicates whether the specified project owns the domain.
457+
"""
458+
459+
434460
@dataclass
435461
class CreateHostingRequest:
436462
offer_id: str

scaleway/scaleway/webhosting/v1alpha1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
from .types import ControlPanel
2020
from .types import Hosting
2121
from .types import Offer
22+
from .types import CheckUserOwnsDomainRequest
23+
from .types import CheckUserOwnsDomainResponse
2224
from .types import CreateHostingRequest
2325
from .types import CreateSessionRequest
2426
from .types import DeleteHostingRequest
@@ -58,6 +60,8 @@
5860
"ControlPanel",
5961
"Hosting",
6062
"Offer",
63+
"CheckUserOwnsDomainRequest",
64+
"CheckUserOwnsDomainResponse",
6165
"CreateHostingRequest",
6266
"CreateSessionRequest",
6367
"DeleteHostingRequest",

scaleway/scaleway/webhosting/v1alpha1/api.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
HostingStatus,
1818
ListHostingsRequestOrderBy,
1919
ListOffersRequestOrderBy,
20+
CheckUserOwnsDomainResponse,
2021
ControlPanel,
2122
CreateHostingRequest,
2223
CreateHostingRequestDomainConfiguration,
@@ -34,6 +35,7 @@
3435
)
3536
from .marshalling import (
3637
unmarshal_Hosting,
38+
unmarshal_CheckUserOwnsDomainResponse,
3739
unmarshal_DnsRecords,
3840
unmarshal_ListControlPanelsResponse,
3941
unmarshal_ListHostingsResponse,
@@ -457,6 +459,44 @@ def get_domain_dns_records(
457459
self._throw_on_error(res)
458460
return unmarshal_DnsRecords(res.json())
459461

462+
def check_user_owns_domain(
463+
self,
464+
*,
465+
domain: str,
466+
region: Optional[Region] = None,
467+
project_id: Optional[str] = None,
468+
) -> CheckUserOwnsDomainResponse:
469+
"""
470+
"Check whether you own this domain or not.".
471+
:param domain: Domain for which ownership is to be verified.
472+
:param region: Region to target. If none is passed will use default region from the config.
473+
:param project_id: ID of the project currently in use.
474+
:return: :class:`CheckUserOwnsDomainResponse <CheckUserOwnsDomainResponse>`
475+
476+
Usage:
477+
::
478+
479+
result = api.check_user_owns_domain(
480+
domain="example",
481+
)
482+
"""
483+
484+
param_region = validate_path_param(
485+
"region", region or self.client.default_region
486+
)
487+
param_domain = validate_path_param("domain", domain)
488+
489+
res = self._request(
490+
"POST",
491+
f"/webhosting/v1/regions/{param_region}/domains/{param_domain}/check-ownership",
492+
params={
493+
"project_id": project_id or self.client.default_project_id,
494+
},
495+
)
496+
497+
self._throw_on_error(res)
498+
return unmarshal_CheckUserOwnsDomainResponse(res.json())
499+
460500
def list_offers(
461501
self,
462502
*,

scaleway/scaleway/webhosting/v1alpha1/marshalling.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
HostingCpanelUrls,
1414
HostingOption,
1515
Hosting,
16+
CheckUserOwnsDomainResponse,
1617
DnsRecord,
1718
Nameserver,
1819
DnsRecords,
@@ -188,6 +189,21 @@ def unmarshal_Hosting(data: Any) -> Hosting:
188189
return Hosting(**args)
189190

190191

192+
def unmarshal_CheckUserOwnsDomainResponse(data: Any) -> CheckUserOwnsDomainResponse:
193+
if not isinstance(data, dict):
194+
raise TypeError(
195+
"Unmarshalling the type 'CheckUserOwnsDomainResponse' failed as data isn't a dictionary."
196+
)
197+
198+
args: Dict[str, Any] = {}
199+
200+
field = data.get("owns_domain", None)
201+
if field is not None:
202+
args["owns_domain"] = field
203+
204+
return CheckUserOwnsDomainResponse(**args)
205+
206+
191207
def unmarshal_DnsRecord(data: Any) -> DnsRecord:
192208
if not isinstance(data, dict):
193209
raise TypeError(

scaleway/scaleway/webhosting/v1alpha1/types.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,32 @@ class Offer:
431431
"""
432432

433433

434+
@dataclass
435+
class CheckUserOwnsDomainRequest:
436+
domain: str
437+
"""
438+
Domain for which ownership is to be verified.
439+
"""
440+
441+
region: Optional[Region]
442+
"""
443+
Region to target. If none is passed will use default region from the config.
444+
"""
445+
446+
project_id: Optional[str]
447+
"""
448+
ID of the project currently in use.
449+
"""
450+
451+
452+
@dataclass
453+
class CheckUserOwnsDomainResponse:
454+
owns_domain: bool
455+
"""
456+
Indicates whether the specified project owns the domain.
457+
"""
458+
459+
434460
@dataclass
435461
class CreateHostingRequest:
436462
offer_id: str

0 commit comments

Comments
 (0)