Skip to content

feat(baremetal): add protected flag on servers #1075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
9 changes: 8 additions & 1 deletion scaleway-async/scaleway_async/baremetal/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ async def create_server(
offer_id: str,
name: str,
description: str,
protected: bool,
zone: Optional[ScwZone] = None,
organization_id: Optional[str] = None,
project_id: Optional[str] = None,
Expand All @@ -294,6 +295,7 @@ async def create_server(
:param offer_id: Offer ID of the new server.
:param name: Name of the server (≠hostname).
:param description: Description associated with the server, max 255 characters.
:param protected: If enabled, the server can not be deleted.
:param zone: Zone to target. If none is passed will use default zone from the config.
:param organization_id: Organization ID with which the server will be created.
One-Of ('project_identifier'): at most one of 'project_id', 'organization_id' could be set.
Expand All @@ -311,6 +313,7 @@ async def create_server(
offer_id="example",
name="example",
description="example",
protected=False,
)
"""

Expand All @@ -324,6 +327,7 @@ async def create_server(
offer_id=offer_id,
name=name,
description=description,
protected=protected,
zone=zone,
tags=tags,
install=install,
Expand All @@ -346,15 +350,17 @@ async def update_server(
name: Optional[str] = None,
description: Optional[str] = None,
tags: Optional[List[str]] = None,
protected: Optional[bool] = None,
) -> Server:
"""
Update an Elastic Metal server.
Update the server associated with the ID. You can update parameters such as the server's name, tags and description. Any parameters left null in the request body are not updated.
Update the server associated with the ID. You can update parameters such as the server's name, tags, description and protection flag. Any parameters left null in the request body are not updated.
:param server_id: ID of the server to update.
:param zone: Zone to target. If none is passed will use default zone from the config.
:param name: Name of the server (≠hostname), not updated if null.
:param description: Description associated with the server, max 255 characters, not updated if null.
:param tags: Tags associated with the server, not updated if null.
:param protected: If enabled, the server can not be deleted.
:return: :class:`Server <Server>`

Usage:
Expand All @@ -378,6 +384,7 @@ async def update_server(
name=name,
description=description,
tags=tags,
protected=protected,
),
self.client,
),
Expand Down
26 changes: 18 additions & 8 deletions scaleway-async/scaleway_async/baremetal/v1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,14 @@ def unmarshal_Server(data: Any) -> Server:
if field is not None:
args["status"] = field

field = data.get("offer_id", None)
if field is not None:
args["offer_id"] = field

field = data.get("offer_name", None)
if field is not None:
args["offer_name"] = field

field = data.get("updated_at", None)
if field is not None:
args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field
Expand All @@ -1067,14 +1075,6 @@ def unmarshal_Server(data: Any) -> Server:
else:
args["created_at"] = None

field = data.get("offer_id", None)
if field is not None:
args["offer_id"] = field

field = data.get("offer_name", None)
if field is not None:
args["offer_name"] = field

field = data.get("tags", None)
if field is not None:
args["tags"] = field
Expand Down Expand Up @@ -1105,6 +1105,10 @@ def unmarshal_Server(data: Any) -> Server:
[unmarshal_ServerOption(v) for v in field] if field is not None else None
)

field = data.get("protected", None)
if field is not None:
args["protected"] = field

field = data.get("install", None)
if field is not None:
args["install"] = unmarshal_ServerInstall(field)
Expand Down Expand Up @@ -1603,6 +1607,9 @@ def marshal_CreateServerRequest(
if request.description is not None:
output["description"] = request.description

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

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

Expand Down Expand Up @@ -1739,6 +1746,9 @@ def marshal_UpdateServerRequest(
if request.tags is not None:
output["tags"] = request.tags

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

return output


Expand Down
31 changes: 23 additions & 8 deletions scaleway-async/scaleway_async/baremetal/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,24 +959,24 @@ class Server:
Status of the server.
"""

updated_at: Optional[datetime]
offer_id: str
"""
Last modification date of the server.
Offer ID of the server.
"""

created_at: Optional[datetime]
offer_name: str
"""
Creation date of the server.
Offer name of the server.
"""

offer_id: str
updated_at: Optional[datetime]
"""
Offer ID of the server.
Last modification date of the server.
"""

offer_name: str
created_at: Optional[datetime]
"""
Offer name of the server.
Creation date of the server.
"""

tags: List[str]
Expand Down Expand Up @@ -1014,6 +1014,11 @@ class Server:
Options enabled on the server.
"""

protected: bool
"""
If enabled, the server can not be deleted.
"""

install: Optional[ServerInstall]
"""
Configuration of the installation.
Expand Down Expand Up @@ -1111,6 +1116,11 @@ class CreateServerRequest:
Description associated with the server, max 255 characters.
"""

protected: bool
"""
If enabled, the server can not be deleted.
"""

zone: Optional[ScwZone]
"""
Zone to target. If none is passed will use default zone from the config.
Expand Down Expand Up @@ -1842,6 +1852,11 @@ class UpdateServerRequest:
Tags associated with the server, not updated if null.
"""

protected: Optional[bool]
"""
If enabled, the server can not be deleted.
"""


@dataclass
class UpdateSettingRequest:
Expand Down
9 changes: 8 additions & 1 deletion scaleway/scaleway/baremetal/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ def create_server(
offer_id: str,
name: str,
description: str,
protected: bool,
zone: Optional[ScwZone] = None,
organization_id: Optional[str] = None,
project_id: Optional[str] = None,
Expand All @@ -294,6 +295,7 @@ def create_server(
:param offer_id: Offer ID of the new server.
:param name: Name of the server (≠hostname).
:param description: Description associated with the server, max 255 characters.
:param protected: If enabled, the server can not be deleted.
:param zone: Zone to target. If none is passed will use default zone from the config.
:param organization_id: Organization ID with which the server will be created.
One-Of ('project_identifier'): at most one of 'project_id', 'organization_id' could be set.
Expand All @@ -311,6 +313,7 @@ def create_server(
offer_id="example",
name="example",
description="example",
protected=False,
)
"""

Expand All @@ -324,6 +327,7 @@ def create_server(
offer_id=offer_id,
name=name,
description=description,
protected=protected,
zone=zone,
tags=tags,
install=install,
Expand All @@ -346,15 +350,17 @@ def update_server(
name: Optional[str] = None,
description: Optional[str] = None,
tags: Optional[List[str]] = None,
protected: Optional[bool] = None,
) -> Server:
"""
Update an Elastic Metal server.
Update the server associated with the ID. You can update parameters such as the server's name, tags and description. Any parameters left null in the request body are not updated.
Update the server associated with the ID. You can update parameters such as the server's name, tags, description and protection flag. Any parameters left null in the request body are not updated.
:param server_id: ID of the server to update.
:param zone: Zone to target. If none is passed will use default zone from the config.
:param name: Name of the server (≠hostname), not updated if null.
:param description: Description associated with the server, max 255 characters, not updated if null.
:param tags: Tags associated with the server, not updated if null.
:param protected: If enabled, the server can not be deleted.
:return: :class:`Server <Server>`

Usage:
Expand All @@ -378,6 +384,7 @@ def update_server(
name=name,
description=description,
tags=tags,
protected=protected,
),
self.client,
),
Expand Down
26 changes: 18 additions & 8 deletions scaleway/scaleway/baremetal/v1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,14 @@ def unmarshal_Server(data: Any) -> Server:
if field is not None:
args["status"] = field

field = data.get("offer_id", None)
if field is not None:
args["offer_id"] = field

field = data.get("offer_name", None)
if field is not None:
args["offer_name"] = field

field = data.get("updated_at", None)
if field is not None:
args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field
Expand All @@ -1067,14 +1075,6 @@ def unmarshal_Server(data: Any) -> Server:
else:
args["created_at"] = None

field = data.get("offer_id", None)
if field is not None:
args["offer_id"] = field

field = data.get("offer_name", None)
if field is not None:
args["offer_name"] = field

field = data.get("tags", None)
if field is not None:
args["tags"] = field
Expand Down Expand Up @@ -1105,6 +1105,10 @@ def unmarshal_Server(data: Any) -> Server:
[unmarshal_ServerOption(v) for v in field] if field is not None else None
)

field = data.get("protected", None)
if field is not None:
args["protected"] = field

field = data.get("install", None)
if field is not None:
args["install"] = unmarshal_ServerInstall(field)
Expand Down Expand Up @@ -1603,6 +1607,9 @@ def marshal_CreateServerRequest(
if request.description is not None:
output["description"] = request.description

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

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

Expand Down Expand Up @@ -1739,6 +1746,9 @@ def marshal_UpdateServerRequest(
if request.tags is not None:
output["tags"] = request.tags

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

return output


Expand Down
31 changes: 23 additions & 8 deletions scaleway/scaleway/baremetal/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,24 +959,24 @@ class Server:
Status of the server.
"""

updated_at: Optional[datetime]
offer_id: str
"""
Last modification date of the server.
Offer ID of the server.
"""

created_at: Optional[datetime]
offer_name: str
"""
Creation date of the server.
Offer name of the server.
"""

offer_id: str
updated_at: Optional[datetime]
"""
Offer ID of the server.
Last modification date of the server.
"""

offer_name: str
created_at: Optional[datetime]
"""
Offer name of the server.
Creation date of the server.
"""

tags: List[str]
Expand Down Expand Up @@ -1014,6 +1014,11 @@ class Server:
Options enabled on the server.
"""

protected: bool
"""
If enabled, the server can not be deleted.
"""

install: Optional[ServerInstall]
"""
Configuration of the installation.
Expand Down Expand Up @@ -1111,6 +1116,11 @@ class CreateServerRequest:
Description associated with the server, max 255 characters.
"""

protected: bool
"""
If enabled, the server can not be deleted.
"""

zone: Optional[ScwZone]
"""
Zone to target. If none is passed will use default zone from the config.
Expand Down Expand Up @@ -1842,6 +1852,11 @@ class UpdateServerRequest:
Tags associated with the server, not updated if null.
"""

protected: Optional[bool]
"""
If enabled, the server can not be deleted.
"""


@dataclass
class UpdateSettingRequest:
Expand Down
Loading