diff --git a/scaleway-async/scaleway_async/webhosting/v1alpha1/__init__.py b/scaleway-async/scaleway_async/webhosting/v1alpha1/__init__.py index 09a3260ea..4e73adf86 100644 --- a/scaleway-async/scaleway_async/webhosting/v1alpha1/__init__.py +++ b/scaleway-async/scaleway_async/webhosting/v1alpha1/__init__.py @@ -20,6 +20,7 @@ from .types import Hosting from .types import Offer from .types import CreateHostingRequest +from .types import CreateSessionRequest from .types import DeleteHostingRequest from .types import DnsRecords from .types import GetDomainDnsRecordsRequest @@ -31,6 +32,7 @@ from .types import ListOffersRequest from .types import ListOffersResponse from .types import RestoreHostingRequest +from .types import Session from .types import UpdateHostingRequest from .api import WebhostingV1Alpha1API @@ -55,6 +57,7 @@ "Hosting", "Offer", "CreateHostingRequest", + "CreateSessionRequest", "DeleteHostingRequest", "DnsRecords", "GetDomainDnsRecordsRequest", @@ -66,6 +69,7 @@ "ListOffersRequest", "ListOffersResponse", "RestoreHostingRequest", + "Session", "UpdateHostingRequest", "WebhostingV1Alpha1API", ] diff --git a/scaleway-async/scaleway_async/webhosting/v1alpha1/api.py b/scaleway-async/scaleway_async/webhosting/v1alpha1/api.py index 0874850ba..ffc3be078 100644 --- a/scaleway-async/scaleway_async/webhosting/v1alpha1/api.py +++ b/scaleway-async/scaleway_async/webhosting/v1alpha1/api.py @@ -25,6 +25,7 @@ ListControlPanelsResponse, ListHostingsResponse, ListOffersResponse, + Session, UpdateHostingRequest, ) from .content import ( @@ -36,6 +37,7 @@ unmarshal_ListControlPanelsResponse, unmarshal_ListHostingsResponse, unmarshal_ListOffersResponse, + unmarshal_Session, marshal_CreateHostingRequest, marshal_UpdateHostingRequest, ) @@ -570,3 +572,37 @@ async def list_control_panels_all( "page_size": page_size, }, ) + + async def create_session( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + ) -> Session: + """ + Create a user session. + :param hosting_id: Hosting ID. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Session ` + + Usage: + :: + + result = await api.create_session( + hosting_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_hosting_id = validate_path_param("hosting_id", hosting_id) + + res = self._request( + "POST", + f"/webhosting/v1alpha1/regions/{param_region}/hostings/{param_hosting_id}/sessions", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_Session(res.json()) diff --git a/scaleway-async/scaleway_async/webhosting/v1alpha1/marshalling.py b/scaleway-async/scaleway_async/webhosting/v1alpha1/marshalling.py index 7329b7b2e..8657b549a 100644 --- a/scaleway-async/scaleway_async/webhosting/v1alpha1/marshalling.py +++ b/scaleway-async/scaleway_async/webhosting/v1alpha1/marshalling.py @@ -22,6 +22,7 @@ OfferProduct, Offer, ListOffersResponse, + Session, CreateHostingRequestDomainConfiguration, CreateHostingRequest, UpdateHostingRequest, @@ -452,6 +453,21 @@ def unmarshal_ListOffersResponse(data: Any) -> ListOffersResponse: return ListOffersResponse(**args) +def unmarshal_Session(data: Any) -> Session: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Session' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("url", None) + if field is not None: + args["url"] = field + + return Session(**args) + + def marshal_CreateHostingRequestDomainConfiguration( request: CreateHostingRequestDomainConfiguration, defaults: ProfileDefaults, diff --git a/scaleway-async/scaleway_async/webhosting/v1alpha1/types.py b/scaleway-async/scaleway_async/webhosting/v1alpha1/types.py index 5ad502b05..9bdb3e484 100644 --- a/scaleway-async/scaleway_async/webhosting/v1alpha1/types.py +++ b/scaleway-async/scaleway_async/webhosting/v1alpha1/types.py @@ -474,6 +474,19 @@ class CreateHostingRequest: """ +@dataclass +class CreateSessionRequest: + hosting_id: str + """ + Hosting ID. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + @dataclass class DeleteHostingRequest: hosting_id: str @@ -682,6 +695,14 @@ class RestoreHostingRequest: """ +@dataclass +class Session: + url: str + """ + Logged user's session URL. + """ + + @dataclass class UpdateHostingRequest: hosting_id: str diff --git a/scaleway/scaleway/webhosting/v1alpha1/__init__.py b/scaleway/scaleway/webhosting/v1alpha1/__init__.py index 09a3260ea..4e73adf86 100644 --- a/scaleway/scaleway/webhosting/v1alpha1/__init__.py +++ b/scaleway/scaleway/webhosting/v1alpha1/__init__.py @@ -20,6 +20,7 @@ from .types import Hosting from .types import Offer from .types import CreateHostingRequest +from .types import CreateSessionRequest from .types import DeleteHostingRequest from .types import DnsRecords from .types import GetDomainDnsRecordsRequest @@ -31,6 +32,7 @@ from .types import ListOffersRequest from .types import ListOffersResponse from .types import RestoreHostingRequest +from .types import Session from .types import UpdateHostingRequest from .api import WebhostingV1Alpha1API @@ -55,6 +57,7 @@ "Hosting", "Offer", "CreateHostingRequest", + "CreateSessionRequest", "DeleteHostingRequest", "DnsRecords", "GetDomainDnsRecordsRequest", @@ -66,6 +69,7 @@ "ListOffersRequest", "ListOffersResponse", "RestoreHostingRequest", + "Session", "UpdateHostingRequest", "WebhostingV1Alpha1API", ] diff --git a/scaleway/scaleway/webhosting/v1alpha1/api.py b/scaleway/scaleway/webhosting/v1alpha1/api.py index 0c5915c27..5812ad922 100644 --- a/scaleway/scaleway/webhosting/v1alpha1/api.py +++ b/scaleway/scaleway/webhosting/v1alpha1/api.py @@ -25,6 +25,7 @@ ListControlPanelsResponse, ListHostingsResponse, ListOffersResponse, + Session, UpdateHostingRequest, ) from .content import ( @@ -36,6 +37,7 @@ unmarshal_ListControlPanelsResponse, unmarshal_ListHostingsResponse, unmarshal_ListOffersResponse, + unmarshal_Session, marshal_CreateHostingRequest, marshal_UpdateHostingRequest, ) @@ -570,3 +572,37 @@ def list_control_panels_all( "page_size": page_size, }, ) + + def create_session( + self, + *, + hosting_id: str, + region: Optional[Region] = None, + ) -> Session: + """ + Create a user session. + :param hosting_id: Hosting ID. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Session ` + + Usage: + :: + + result = api.create_session( + hosting_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_hosting_id = validate_path_param("hosting_id", hosting_id) + + res = self._request( + "POST", + f"/webhosting/v1alpha1/regions/{param_region}/hostings/{param_hosting_id}/sessions", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_Session(res.json()) diff --git a/scaleway/scaleway/webhosting/v1alpha1/marshalling.py b/scaleway/scaleway/webhosting/v1alpha1/marshalling.py index 7329b7b2e..8657b549a 100644 --- a/scaleway/scaleway/webhosting/v1alpha1/marshalling.py +++ b/scaleway/scaleway/webhosting/v1alpha1/marshalling.py @@ -22,6 +22,7 @@ OfferProduct, Offer, ListOffersResponse, + Session, CreateHostingRequestDomainConfiguration, CreateHostingRequest, UpdateHostingRequest, @@ -452,6 +453,21 @@ def unmarshal_ListOffersResponse(data: Any) -> ListOffersResponse: return ListOffersResponse(**args) +def unmarshal_Session(data: Any) -> Session: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Session' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("url", None) + if field is not None: + args["url"] = field + + return Session(**args) + + def marshal_CreateHostingRequestDomainConfiguration( request: CreateHostingRequestDomainConfiguration, defaults: ProfileDefaults, diff --git a/scaleway/scaleway/webhosting/v1alpha1/types.py b/scaleway/scaleway/webhosting/v1alpha1/types.py index 5ad502b05..9bdb3e484 100644 --- a/scaleway/scaleway/webhosting/v1alpha1/types.py +++ b/scaleway/scaleway/webhosting/v1alpha1/types.py @@ -474,6 +474,19 @@ class CreateHostingRequest: """ +@dataclass +class CreateSessionRequest: + hosting_id: str + """ + Hosting ID. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + @dataclass class DeleteHostingRequest: hosting_id: str @@ -682,6 +695,14 @@ class RestoreHostingRequest: """ +@dataclass +class Session: + url: str + """ + Logged user's session URL. + """ + + @dataclass class UpdateHostingRequest: hosting_id: str