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
2 changes: 2 additions & 0 deletions scaleway-async/scaleway_async/webhosting/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from .types import PlatformControlPanelUrls
from .types import OfferOption
from .types import PlatformControlPanel
from .types import CreateDatabaseRequestUser
from .types import CreateHostingRequestDomainConfiguration
from .types import OfferOptionRequest
from .types import DnsRecord
Expand Down Expand Up @@ -112,6 +113,7 @@
"PlatformControlPanelUrls",
"OfferOption",
"PlatformControlPanel",
"CreateDatabaseRequestUser",
"CreateHostingRequestDomainConfiguration",
"OfferOptionRequest",
"DnsRecord",
Expand Down
9 changes: 9 additions & 0 deletions scaleway-async/scaleway_async/webhosting/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
ListWebsitesRequestOrderBy,
CheckUserOwnsDomainResponse,
ControlPanel,
CreateDatabaseRequestUser,
CreateHostingRequestDomainConfiguration,
Database,
DatabaseApiAssignDatabaseUserRequest,
Expand Down Expand Up @@ -185,12 +186,18 @@ async def create_database(
hosting_id: str,
database_name: str,
region: Optional[Region] = None,
new_user: Optional[CreateDatabaseRequestUser] = None,
existing_username: Optional[str] = None,
) -> Database:
"""
"Create a new database within your hosting plan".
:param hosting_id: UUID of the hosting plan where the database will be created.
:param database_name: Name of the database to be created.
:param region: Region to target. If none is passed will use default region from the config.
:param new_user: (Optional) Username and password to create a user and link to the database.
One-Of ('user'): at most one of 'new_user', 'existing_username' could be set.
:param existing_username: (Optional) Username to link an existing user to the database.
One-Of ('user'): at most one of 'new_user', 'existing_username' could be set.
:return: :class:`Database <Database>`

Usage:
Expand All @@ -215,6 +222,8 @@ async def create_database(
hosting_id=hosting_id,
database_name=database_name,
region=region,
new_user=new_user,
existing_username=existing_username,
),
self.client,
),
Expand Down
28 changes: 28 additions & 0 deletions scaleway-async/scaleway_async/webhosting/v1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
from scaleway_core.bridge import (
unmarshal_Money,
)
from scaleway_core.utils import (
OneOfPossibility,
resolve_one_of,
)
from .types import (
DatabaseUser,
Database,
Expand Down Expand Up @@ -40,6 +44,7 @@
Session,
DatabaseApiAssignDatabaseUserRequest,
DatabaseApiChangeDatabaseUserPasswordRequest,
CreateDatabaseRequestUser,
DatabaseApiCreateDatabaseRequest,
DatabaseApiCreateDatabaseUserRequest,
DatabaseApiUnassignDatabaseUserRequest,
Expand Down Expand Up @@ -852,11 +857,34 @@ def marshal_DatabaseApiChangeDatabaseUserPasswordRequest(
return output


def marshal_CreateDatabaseRequestUser(
request: CreateDatabaseRequestUser,
defaults: ProfileDefaults,
) -> Dict[str, Any]:
output: Dict[str, Any] = {}

if request.username is not None:
output["username"] = request.username

if request.password is not None:
output["password"] = request.password

return output


def marshal_DatabaseApiCreateDatabaseRequest(
request: DatabaseApiCreateDatabaseRequest,
defaults: ProfileDefaults,
) -> Dict[str, Any]:
output: Dict[str, Any] = {}
output.update(
resolve_one_of(
[
OneOfPossibility("new_user", request.new_user),
OneOfPossibility("existing_username", request.existing_username),
]
),
)

if request.database_name is not None:
output["database_name"] = request.database_name
Expand Down
11 changes: 11 additions & 0 deletions scaleway-async/scaleway_async/webhosting/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ class PlatformControlPanel:
"""


@dataclass
class CreateDatabaseRequestUser:
username: str

password: str


@dataclass
class CreateHostingRequestDomainConfiguration:
update_nameservers: bool
Expand Down Expand Up @@ -632,6 +639,10 @@ class DatabaseApiCreateDatabaseRequest:
Region to target. If none is passed will use default region from the config.
"""

new_user: Optional[CreateDatabaseRequestUser]

existing_username: Optional[str]


@dataclass
class DatabaseApiCreateDatabaseUserRequest:
Expand Down
2 changes: 2 additions & 0 deletions scaleway/scaleway/webhosting/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from .types import PlatformControlPanelUrls
from .types import OfferOption
from .types import PlatformControlPanel
from .types import CreateDatabaseRequestUser
from .types import CreateHostingRequestDomainConfiguration
from .types import OfferOptionRequest
from .types import DnsRecord
Expand Down Expand Up @@ -112,6 +113,7 @@
"PlatformControlPanelUrls",
"OfferOption",
"PlatformControlPanel",
"CreateDatabaseRequestUser",
"CreateHostingRequestDomainConfiguration",
"OfferOptionRequest",
"DnsRecord",
Expand Down
9 changes: 9 additions & 0 deletions scaleway/scaleway/webhosting/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
ListWebsitesRequestOrderBy,
CheckUserOwnsDomainResponse,
ControlPanel,
CreateDatabaseRequestUser,
CreateHostingRequestDomainConfiguration,
Database,
DatabaseApiAssignDatabaseUserRequest,
Expand Down Expand Up @@ -185,12 +186,18 @@ def create_database(
hosting_id: str,
database_name: str,
region: Optional[Region] = None,
new_user: Optional[CreateDatabaseRequestUser] = None,
existing_username: Optional[str] = None,
) -> Database:
"""
"Create a new database within your hosting plan".
:param hosting_id: UUID of the hosting plan where the database will be created.
:param database_name: Name of the database to be created.
:param region: Region to target. If none is passed will use default region from the config.
:param new_user: (Optional) Username and password to create a user and link to the database.
One-Of ('user'): at most one of 'new_user', 'existing_username' could be set.
:param existing_username: (Optional) Username to link an existing user to the database.
One-Of ('user'): at most one of 'new_user', 'existing_username' could be set.
:return: :class:`Database <Database>`

Usage:
Expand All @@ -215,6 +222,8 @@ def create_database(
hosting_id=hosting_id,
database_name=database_name,
region=region,
new_user=new_user,
existing_username=existing_username,
),
self.client,
),
Expand Down
28 changes: 28 additions & 0 deletions scaleway/scaleway/webhosting/v1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
from scaleway_core.bridge import (
unmarshal_Money,
)
from scaleway_core.utils import (
OneOfPossibility,
resolve_one_of,
)
from .types import (
DatabaseUser,
Database,
Expand Down Expand Up @@ -40,6 +44,7 @@
Session,
DatabaseApiAssignDatabaseUserRequest,
DatabaseApiChangeDatabaseUserPasswordRequest,
CreateDatabaseRequestUser,
DatabaseApiCreateDatabaseRequest,
DatabaseApiCreateDatabaseUserRequest,
DatabaseApiUnassignDatabaseUserRequest,
Expand Down Expand Up @@ -852,11 +857,34 @@ def marshal_DatabaseApiChangeDatabaseUserPasswordRequest(
return output


def marshal_CreateDatabaseRequestUser(
request: CreateDatabaseRequestUser,
defaults: ProfileDefaults,
) -> Dict[str, Any]:
output: Dict[str, Any] = {}

if request.username is not None:
output["username"] = request.username

if request.password is not None:
output["password"] = request.password

return output


def marshal_DatabaseApiCreateDatabaseRequest(
request: DatabaseApiCreateDatabaseRequest,
defaults: ProfileDefaults,
) -> Dict[str, Any]:
output: Dict[str, Any] = {}
output.update(
resolve_one_of(
[
OneOfPossibility("new_user", request.new_user),
OneOfPossibility("existing_username", request.existing_username),
]
),
)

if request.database_name is not None:
output["database_name"] = request.database_name
Expand Down
11 changes: 11 additions & 0 deletions scaleway/scaleway/webhosting/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ class PlatformControlPanel:
"""


@dataclass
class CreateDatabaseRequestUser:
username: str

password: str


@dataclass
class CreateHostingRequestDomainConfiguration:
update_nameservers: bool
Expand Down Expand Up @@ -632,6 +639,10 @@ class DatabaseApiCreateDatabaseRequest:
Region to target. If none is passed will use default region from the config.
"""

new_user: Optional[CreateDatabaseRequestUser]

existing_username: Optional[str]


@dataclass
class DatabaseApiCreateDatabaseUserRequest:
Expand Down
Loading