Skip to content

Commit f182837

Browse files
authored
feat(webhosting): add public reset hosting password (#502)
1 parent 61d236b commit f182837

File tree

8 files changed

+156
-8
lines changed

8 files changed

+156
-8
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
from .types import ListHostingsResponse
3232
from .types import ListOffersRequest
3333
from .types import ListOffersResponse
34+
from .types import ResetHostingPasswordRequest
35+
from .types import ResetHostingPasswordResponse
3436
from .types import RestoreHostingRequest
3537
from .types import Session
3638
from .types import UpdateHostingRequest
@@ -68,6 +70,8 @@
6870
"ListHostingsResponse",
6971
"ListOffersRequest",
7072
"ListOffersResponse",
73+
"ResetHostingPasswordRequest",
74+
"ResetHostingPasswordResponse",
7175
"RestoreHostingRequest",
7276
"Session",
7377
"UpdateHostingRequest",

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

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
ListControlPanelsResponse,
2626
ListHostingsResponse,
2727
ListOffersResponse,
28+
ResetHostingPasswordResponse,
2829
Session,
2930
UpdateHostingRequest,
3031
)
@@ -37,6 +38,7 @@
3738
unmarshal_ListControlPanelsResponse,
3839
unmarshal_ListHostingsResponse,
3940
unmarshal_ListOffersResponse,
41+
unmarshal_ResetHostingPasswordResponse,
4042
unmarshal_Session,
4143
marshal_CreateHostingRequest,
4244
marshal_UpdateHostingRequest,
@@ -512,8 +514,7 @@ async def list_control_panels(
512514
page_size: Optional[int] = None,
513515
) -> ListControlPanelsResponse:
514516
"""
515-
List all control panels type.
516-
List the control panels type: cpanel or plesk.
517+
"List the control panels type: cpanel or plesk.".
517518
:param region: Region to target. If none is passed will use default region from the config.
518519
:param page: Page number to return, from the paginated results (must be a positive integer).
519520
:param page_size: Number of control panels to return (must be a positive integer lower or equal to 100).
@@ -549,8 +550,7 @@ async def list_control_panels_all(
549550
page_size: Optional[int] = None,
550551
) -> List[ControlPanel]:
551552
"""
552-
List all control panels type.
553-
List the control panels type: cpanel or plesk.
553+
"List the control panels type: cpanel or plesk.".
554554
:param region: Region to target. If none is passed will use default region from the config.
555555
:param page: Page number to return, from the paginated results (must be a positive integer).
556556
:param page_size: Number of control panels to return (must be a positive integer lower or equal to 100).
@@ -606,3 +606,36 @@ async def create_session(
606606

607607
self._throw_on_error(res)
608608
return unmarshal_Session(res.json())
609+
610+
async def reset_hosting_password(
611+
self,
612+
*,
613+
hosting_id: str,
614+
region: Optional[Region] = None,
615+
) -> ResetHostingPasswordResponse:
616+
"""
617+
:param hosting_id: UUID of the hosting.
618+
:param region: Region to target. If none is passed will use default region from the config.
619+
:return: :class:`ResetHostingPasswordResponse <ResetHostingPasswordResponse>`
620+
621+
Usage:
622+
::
623+
624+
result = await api.reset_hosting_password(
625+
hosting_id="example",
626+
)
627+
"""
628+
629+
param_region = validate_path_param(
630+
"region", region or self.client.default_region
631+
)
632+
param_hosting_id = validate_path_param("hosting_id", hosting_id)
633+
634+
res = self._request(
635+
"POST",
636+
f"/webhosting/v1alpha1/regions/{param_region}/hostings/{param_hosting_id}/reset-password",
637+
body={},
638+
)
639+
640+
self._throw_on_error(res)
641+
return unmarshal_ResetHostingPasswordResponse(res.json())

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
OfferProduct,
2323
Offer,
2424
ListOffersResponse,
25+
ResetHostingPasswordResponse,
2526
Session,
2627
CreateHostingRequestDomainConfiguration,
2728
CreateHostingRequest,
@@ -453,6 +454,21 @@ def unmarshal_ListOffersResponse(data: Any) -> ListOffersResponse:
453454
return ListOffersResponse(**args)
454455

455456

457+
def unmarshal_ResetHostingPasswordResponse(data: Any) -> ResetHostingPasswordResponse:
458+
if not isinstance(data, dict):
459+
raise TypeError(
460+
"Unmarshalling the type 'ResetHostingPasswordResponse' failed as data isn't a dictionary."
461+
)
462+
463+
args: Dict[str, Any] = {}
464+
465+
field = data.get("password", None)
466+
if field is not None:
467+
args["password"] = field
468+
469+
return ResetHostingPasswordResponse(**args)
470+
471+
456472
def unmarshal_Session(data: Any) -> Session:
457473
if not isinstance(data, dict):
458474
raise TypeError(

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,27 @@ class ListOffersResponse:
682682
"""
683683

684684

685+
@dataclass
686+
class ResetHostingPasswordRequest:
687+
hosting_id: str
688+
"""
689+
UUID of the hosting.
690+
"""
691+
692+
region: Optional[Region]
693+
"""
694+
Region to target. If none is passed will use default region from the config.
695+
"""
696+
697+
698+
@dataclass
699+
class ResetHostingPasswordResponse:
700+
password: str
701+
"""
702+
New password.
703+
"""
704+
705+
685706
@dataclass
686707
class RestoreHostingRequest:
687708
hosting_id: str

scaleway/scaleway/webhosting/v1alpha1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
from .types import ListHostingsResponse
3232
from .types import ListOffersRequest
3333
from .types import ListOffersResponse
34+
from .types import ResetHostingPasswordRequest
35+
from .types import ResetHostingPasswordResponse
3436
from .types import RestoreHostingRequest
3537
from .types import Session
3638
from .types import UpdateHostingRequest
@@ -68,6 +70,8 @@
6870
"ListHostingsResponse",
6971
"ListOffersRequest",
7072
"ListOffersResponse",
73+
"ResetHostingPasswordRequest",
74+
"ResetHostingPasswordResponse",
7175
"RestoreHostingRequest",
7276
"Session",
7377
"UpdateHostingRequest",

scaleway/scaleway/webhosting/v1alpha1/api.py

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
ListControlPanelsResponse,
2626
ListHostingsResponse,
2727
ListOffersResponse,
28+
ResetHostingPasswordResponse,
2829
Session,
2930
UpdateHostingRequest,
3031
)
@@ -37,6 +38,7 @@
3738
unmarshal_ListControlPanelsResponse,
3839
unmarshal_ListHostingsResponse,
3940
unmarshal_ListOffersResponse,
41+
unmarshal_ResetHostingPasswordResponse,
4042
unmarshal_Session,
4143
marshal_CreateHostingRequest,
4244
marshal_UpdateHostingRequest,
@@ -512,8 +514,7 @@ def list_control_panels(
512514
page_size: Optional[int] = None,
513515
) -> ListControlPanelsResponse:
514516
"""
515-
List all control panels type.
516-
List the control panels type: cpanel or plesk.
517+
"List the control panels type: cpanel or plesk.".
517518
:param region: Region to target. If none is passed will use default region from the config.
518519
:param page: Page number to return, from the paginated results (must be a positive integer).
519520
:param page_size: Number of control panels to return (must be a positive integer lower or equal to 100).
@@ -549,8 +550,7 @@ def list_control_panels_all(
549550
page_size: Optional[int] = None,
550551
) -> List[ControlPanel]:
551552
"""
552-
List all control panels type.
553-
List the control panels type: cpanel or plesk.
553+
"List the control panels type: cpanel or plesk.".
554554
:param region: Region to target. If none is passed will use default region from the config.
555555
:param page: Page number to return, from the paginated results (must be a positive integer).
556556
:param page_size: Number of control panels to return (must be a positive integer lower or equal to 100).
@@ -606,3 +606,36 @@ def create_session(
606606

607607
self._throw_on_error(res)
608608
return unmarshal_Session(res.json())
609+
610+
def reset_hosting_password(
611+
self,
612+
*,
613+
hosting_id: str,
614+
region: Optional[Region] = None,
615+
) -> ResetHostingPasswordResponse:
616+
"""
617+
:param hosting_id: UUID of the hosting.
618+
:param region: Region to target. If none is passed will use default region from the config.
619+
:return: :class:`ResetHostingPasswordResponse <ResetHostingPasswordResponse>`
620+
621+
Usage:
622+
::
623+
624+
result = api.reset_hosting_password(
625+
hosting_id="example",
626+
)
627+
"""
628+
629+
param_region = validate_path_param(
630+
"region", region or self.client.default_region
631+
)
632+
param_hosting_id = validate_path_param("hosting_id", hosting_id)
633+
634+
res = self._request(
635+
"POST",
636+
f"/webhosting/v1alpha1/regions/{param_region}/hostings/{param_hosting_id}/reset-password",
637+
body={},
638+
)
639+
640+
self._throw_on_error(res)
641+
return unmarshal_ResetHostingPasswordResponse(res.json())

scaleway/scaleway/webhosting/v1alpha1/marshalling.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
OfferProduct,
2323
Offer,
2424
ListOffersResponse,
25+
ResetHostingPasswordResponse,
2526
Session,
2627
CreateHostingRequestDomainConfiguration,
2728
CreateHostingRequest,
@@ -453,6 +454,21 @@ def unmarshal_ListOffersResponse(data: Any) -> ListOffersResponse:
453454
return ListOffersResponse(**args)
454455

455456

457+
def unmarshal_ResetHostingPasswordResponse(data: Any) -> ResetHostingPasswordResponse:
458+
if not isinstance(data, dict):
459+
raise TypeError(
460+
"Unmarshalling the type 'ResetHostingPasswordResponse' failed as data isn't a dictionary."
461+
)
462+
463+
args: Dict[str, Any] = {}
464+
465+
field = data.get("password", None)
466+
if field is not None:
467+
args["password"] = field
468+
469+
return ResetHostingPasswordResponse(**args)
470+
471+
456472
def unmarshal_Session(data: Any) -> Session:
457473
if not isinstance(data, dict):
458474
raise TypeError(

scaleway/scaleway/webhosting/v1alpha1/types.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,27 @@ class ListOffersResponse:
682682
"""
683683

684684

685+
@dataclass
686+
class ResetHostingPasswordRequest:
687+
hosting_id: str
688+
"""
689+
UUID of the hosting.
690+
"""
691+
692+
region: Optional[Region]
693+
"""
694+
Region to target. If none is passed will use default region from the config.
695+
"""
696+
697+
698+
@dataclass
699+
class ResetHostingPasswordResponse:
700+
password: str
701+
"""
702+
New password.
703+
"""
704+
705+
685706
@dataclass
686707
class RestoreHostingRequest:
687708
hosting_id: str

0 commit comments

Comments
 (0)