diff --git a/scaleway-async/scaleway_async/webhosting/v1/__init__.py b/scaleway-async/scaleway_async/webhosting/v1/__init__.py index 6da8dd39a..894681eeb 100644 --- a/scaleway-async/scaleway_async/webhosting/v1/__init__.py +++ b/scaleway-async/scaleway_async/webhosting/v1/__init__.py @@ -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 @@ -112,6 +113,7 @@ "PlatformControlPanelUrls", "OfferOption", "PlatformControlPanel", + "CreateDatabaseRequestUser", "CreateHostingRequestDomainConfiguration", "OfferOptionRequest", "DnsRecord", diff --git a/scaleway-async/scaleway_async/webhosting/v1/api.py b/scaleway-async/scaleway_async/webhosting/v1/api.py index c23c0bf75..3d1b374e2 100644 --- a/scaleway-async/scaleway_async/webhosting/v1/api.py +++ b/scaleway-async/scaleway_async/webhosting/v1/api.py @@ -24,6 +24,7 @@ ListWebsitesRequestOrderBy, CheckUserOwnsDomainResponse, ControlPanel, + CreateDatabaseRequestUser, CreateHostingRequestDomainConfiguration, Database, DatabaseApiAssignDatabaseUserRequest, @@ -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 ` Usage: @@ -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, ), diff --git a/scaleway-async/scaleway_async/webhosting/v1/marshalling.py b/scaleway-async/scaleway_async/webhosting/v1/marshalling.py index 1edf72fcc..0074ebae7 100644 --- a/scaleway-async/scaleway_async/webhosting/v1/marshalling.py +++ b/scaleway-async/scaleway_async/webhosting/v1/marshalling.py @@ -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, @@ -40,6 +44,7 @@ Session, DatabaseApiAssignDatabaseUserRequest, DatabaseApiChangeDatabaseUserPasswordRequest, + CreateDatabaseRequestUser, DatabaseApiCreateDatabaseRequest, DatabaseApiCreateDatabaseUserRequest, DatabaseApiUnassignDatabaseUserRequest, @@ -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 diff --git a/scaleway-async/scaleway_async/webhosting/v1/types.py b/scaleway-async/scaleway_async/webhosting/v1/types.py index 1521f5bdc..b15201cea 100644 --- a/scaleway-async/scaleway_async/webhosting/v1/types.py +++ b/scaleway-async/scaleway_async/webhosting/v1/types.py @@ -243,6 +243,13 @@ class PlatformControlPanel: """ +@dataclass +class CreateDatabaseRequestUser: + username: str + + password: str + + @dataclass class CreateHostingRequestDomainConfiguration: update_nameservers: bool @@ -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: diff --git a/scaleway/scaleway/webhosting/v1/__init__.py b/scaleway/scaleway/webhosting/v1/__init__.py index 6da8dd39a..894681eeb 100644 --- a/scaleway/scaleway/webhosting/v1/__init__.py +++ b/scaleway/scaleway/webhosting/v1/__init__.py @@ -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 @@ -112,6 +113,7 @@ "PlatformControlPanelUrls", "OfferOption", "PlatformControlPanel", + "CreateDatabaseRequestUser", "CreateHostingRequestDomainConfiguration", "OfferOptionRequest", "DnsRecord", diff --git a/scaleway/scaleway/webhosting/v1/api.py b/scaleway/scaleway/webhosting/v1/api.py index 42f4eddf0..2745e2302 100644 --- a/scaleway/scaleway/webhosting/v1/api.py +++ b/scaleway/scaleway/webhosting/v1/api.py @@ -24,6 +24,7 @@ ListWebsitesRequestOrderBy, CheckUserOwnsDomainResponse, ControlPanel, + CreateDatabaseRequestUser, CreateHostingRequestDomainConfiguration, Database, DatabaseApiAssignDatabaseUserRequest, @@ -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 ` Usage: @@ -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, ), diff --git a/scaleway/scaleway/webhosting/v1/marshalling.py b/scaleway/scaleway/webhosting/v1/marshalling.py index 1edf72fcc..0074ebae7 100644 --- a/scaleway/scaleway/webhosting/v1/marshalling.py +++ b/scaleway/scaleway/webhosting/v1/marshalling.py @@ -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, @@ -40,6 +44,7 @@ Session, DatabaseApiAssignDatabaseUserRequest, DatabaseApiChangeDatabaseUserPasswordRequest, + CreateDatabaseRequestUser, DatabaseApiCreateDatabaseRequest, DatabaseApiCreateDatabaseUserRequest, DatabaseApiUnassignDatabaseUserRequest, @@ -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 diff --git a/scaleway/scaleway/webhosting/v1/types.py b/scaleway/scaleway/webhosting/v1/types.py index 1521f5bdc..b15201cea 100644 --- a/scaleway/scaleway/webhosting/v1/types.py +++ b/scaleway/scaleway/webhosting/v1/types.py @@ -243,6 +243,13 @@ class PlatformControlPanel: """ +@dataclass +class CreateDatabaseRequestUser: + username: str + + password: str + + @dataclass class CreateHostingRequestDomainConfiguration: update_nameservers: bool @@ -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: