Skip to content
Closed
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
6 changes: 6 additions & 0 deletions scaleway-async/scaleway_async/k8s/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from .types import Cluster
from .types import Node
from .types import Pool
from .types import UserDataSummary
from .types import NodeMetadataCoreV1Taint
from .types import UpdateClusterRequestAutoUpgrade
from .types import UpdateClusterRequestAutoscalerConfig
Expand Down Expand Up @@ -74,6 +75,8 @@
from .types import ListNodesResponse
from .types import ListPoolsRequest
from .types import ListPoolsResponse
from .types import ListUserDataRequest
from .types import ListUserDataResponse
from .types import ListVersionsRequest
from .types import ListVersionsResponse
from .types import NodeMetadata
Expand Down Expand Up @@ -131,6 +134,7 @@
"Cluster",
"Node",
"Pool",
"UserDataSummary",
"NodeMetadataCoreV1Taint",
"UpdateClusterRequestAutoUpgrade",
"UpdateClusterRequestAutoscalerConfig",
Expand Down Expand Up @@ -167,6 +171,8 @@
"ListNodesResponse",
"ListPoolsRequest",
"ListPoolsResponse",
"ListUserDataRequest",
"ListUserDataResponse",
"ListVersionsRequest",
"ListVersionsResponse",
"NodeMetadata",
Expand Down
44 changes: 43 additions & 1 deletion scaleway-async/scaleway_async/k8s/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
ListClustersResponse,
ListNodesResponse,
ListPoolsResponse,
ListUserDataResponse,
ListVersionsResponse,
Node,
NodeMetadata,
Expand Down Expand Up @@ -88,6 +89,7 @@
unmarshal_ListClustersResponse,
unmarshal_ListNodesResponse,
unmarshal_ListPoolsResponse,
unmarshal_ListUserDataResponse,
unmarshal_ListVersionsResponse,
unmarshal_NodeMetadata,
unmarshal_SetClusterACLRulesResponse,
Expand Down Expand Up @@ -1068,6 +1070,7 @@ async def create_pool(
startup_taints: Optional[list[CoreV1Taint]] = None,
private_network_id: Optional[str] = None,
user_data: Optional[dict[str, str]] = None,
max_termination_grace_period: Optional[str] = None,
) -> Pool:
"""
Create a new Pool in a Cluster.
Expand Down Expand Up @@ -1099,6 +1102,7 @@ async def create_pool(
:param startup_taints: Kubernetes taints applied at node creation but not reconciled afterwards.
:param private_network_id: Private network where the nodes are attached. Should be member of the same VPC as the API Server.
:param user_data: User data applied and reconciled with the pool.
:param max_termination_grace_period: Maximum amount of time before the API forces the drain and deletion of a `deleting` node. It overrides pods `PodDisruptionBudget` and `terminationGracePeriodSeconds`. Defaults to 15 minutes, up to 1 hour.
:return: :class:`Pool <Pool>`

Usage:
Expand Down Expand Up @@ -1148,6 +1152,7 @@ async def create_pool(
startup_taints=startup_taints,
private_network_id=private_network_id,
user_data=user_data,
max_termination_grace_period=max_termination_grace_period,
),
self.client,
),
Expand Down Expand Up @@ -1287,6 +1292,7 @@ async def update_pool(
kubelet_args: Optional[dict[str, str]] = None,
upgrade_policy: Optional[UpdatePoolRequestUpgradePolicy] = None,
security_group_id: Optional[str] = None,
max_termination_grace_period: Optional[str] = None,
) -> Pool:
"""
Update a Pool in a Cluster.
Expand All @@ -1302,6 +1308,7 @@ async def update_pool(
:param kubelet_args: New Kubelet arguments to be used by this pool. Note that this feature is experimental.
:param upgrade_policy: New upgrade policy for the pool.
:param security_group_id: Security group ID in which all the nodes of the pool will be moved.
:param max_termination_grace_period: New maximum amount of time before the API forces the drain and deletion of a `deleting` node.
:return: :class:`Pool <Pool>`

Usage:
Expand Down Expand Up @@ -1333,6 +1340,7 @@ async def update_pool(
kubelet_args=kubelet_args,
upgrade_policy=upgrade_policy,
security_group_id=security_group_id,
max_termination_grace_period=max_termination_grace_period,
),
self.client,
),
Expand Down Expand Up @@ -1518,7 +1526,7 @@ async def get_user_data(
Get a pool related user data.
Retrieve specific user data content for a given pool.
Tip: add `?dl=1` at the end of the URL to directly retrieve the base64 decoded content of your user data.
:param pool_id: Pool the user data will be attached to.
:param pool_id: Pool the user data are associated to.
:param key: User data key to retrieved.
:param region: Region to target. If none is passed will use default region from the config.
:return: :class:`ScwFile <ScwFile>`
Expand Down Expand Up @@ -1546,6 +1554,40 @@ async def get_user_data(
self._throw_on_error(res)
return unmarshal_ScwFile(res.json())

async def list_user_data(
self,
*,
pool_id: str,
region: Optional[ScwRegion] = None,
) -> ListUserDataResponse:
"""
List all user data related to a given pool.
This list only the user data key and not the content.
:param pool_id: Pool the user data are associated to.
:param region: Region to target. If none is passed will use default region from the config.
:return: :class:`ListUserDataResponse <ListUserDataResponse>`

Usage:
::

result = await api.list_user_data(
pool_id="example",
)
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)
param_pool_id = validate_path_param("pool_id", pool_id)

res = self._request(
"GET",
f"/k8s/v1/regions/{param_region}/pools/{param_pool_id}/user-data",
)

self._throw_on_error(res)
return unmarshal_ListUserDataResponse(res.json())

async def get_node_metadata(
self,
*,
Expand Down
53 changes: 53 additions & 0 deletions scaleway-async/scaleway_async/k8s/v1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
ListClustersResponse,
ListNodesResponse,
ListPoolsResponse,
UserDataSummary,
ListUserDataResponse,
ListVersionsResponse,
NodeMetadataCoreV1Taint,
NodeMetadata,
Expand Down Expand Up @@ -882,6 +884,12 @@ def unmarshal_Pool(data: Any) -> Pool:
else:
args["error_message"] = None

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

return Pool(**args)


Expand Down Expand Up @@ -1218,6 +1226,42 @@ def unmarshal_ListPoolsResponse(data: Any) -> ListPoolsResponse:
return ListPoolsResponse(**args)


def unmarshal_UserDataSummary(data: Any) -> UserDataSummary:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'UserDataSummary' failed as data isn't a dictionary."
)

args: dict[str, Any] = {}

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

return UserDataSummary(**args)


def unmarshal_ListUserDataResponse(data: Any) -> ListUserDataResponse:
if not isinstance(data, dict):
raise TypeError(
"Unmarshalling the type 'ListUserDataResponse' failed as data isn't a dictionary."
)

args: dict[str, Any] = {}

field = data.get("user_data", None)
if field is not None:
args["user_data"] = (
[unmarshal_UserDataSummary(v) for v in field] if field is not None else None
)
else:
args["user_data"] = []

return ListUserDataResponse(**args)


def unmarshal_ListVersionsResponse(data: Any) -> ListVersionsResponse:
if not isinstance(data, dict):
raise TypeError(
Expand Down Expand Up @@ -1675,6 +1719,9 @@ def marshal_CreateClusterRequestPoolConfig(
if request.private_network_id is not None:
output["private_network_id"] = request.private_network_id

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

return output


Expand Down Expand Up @@ -1864,6 +1911,9 @@ def marshal_CreatePoolRequest(
if request.user_data is not None:
output["user_data"] = {key: value for key, value in request.user_data.items()}

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

return output


Expand Down Expand Up @@ -2123,6 +2173,9 @@ def marshal_UpdatePoolRequest(
if request.security_group_id is not None:
output["security_group_id"] = request.security_group_id

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

return output


Expand Down
51 changes: 50 additions & 1 deletion scaleway-async/scaleway_async/k8s/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,11 @@ class CreateClusterRequestPoolConfig:
Private network where the nodes are attached. Should be member of the same VPC as the API Server.
"""

max_termination_grace_period: Optional[str] = None
"""
Maximum amount of time before the API forces the drain and deletion of a `deleting` node. It overrides pods `PodDisruptionBudget` and `terminationGracePeriodSeconds`. Defaults to 15 minutes, up to 1 hour.
"""


@dataclass
class CreatePoolRequestUpgradePolicy:
Expand Down Expand Up @@ -1141,6 +1146,19 @@ class Pool:
Details of the error, if any occurred when managing the pool.
"""

max_termination_grace_period: Optional[str] = None
"""
Maximum amount of time before the API forces the drain and deletion of a `deleting` node. It overrides pods `PodDisruptionBudget` and `terminationGracePeriodSeconds`. Defaults to 15 minutes, up to 1 hour.
"""


@dataclass
class UserDataSummary:
key: str
"""
Key name of a given user data.
"""


@dataclass
class NodeMetadataCoreV1Taint:
Expand Down Expand Up @@ -1537,6 +1555,11 @@ class CreatePoolRequest:
User data applied and reconciled with the pool.
"""

max_termination_grace_period: Optional[str] = None
"""
Maximum amount of time before the API forces the drain and deletion of a `deleting` node. It overrides pods `PodDisruptionBudget` and `terminationGracePeriodSeconds`. Defaults to 15 minutes, up to 1 hour.
"""


@dataclass
class DeleteACLRuleRequest:
Expand Down Expand Up @@ -1675,7 +1698,7 @@ class GetPoolRequest:
class GetUserDataRequest:
pool_id: str
"""
Pool the user data will be attached to.
Pool the user data are associated to.
"""

key: str
Expand Down Expand Up @@ -1996,6 +2019,27 @@ class ListPoolsResponse:
"""


@dataclass
class ListUserDataRequest:
pool_id: str
"""
Pool the user data are associated to.
"""

region: Optional[ScwRegion] = None
"""
Region to target. If none is passed will use default region from the config.
"""


@dataclass
class ListUserDataResponse:
user_data: list[UserDataSummary]
"""
User data information.
"""


@dataclass
class ListVersionsRequest:
region: Optional[ScwRegion] = None
Expand Down Expand Up @@ -2280,6 +2324,11 @@ class UpdatePoolRequest:
Security group ID in which all the nodes of the pool will be moved.
"""

max_termination_grace_period: Optional[str] = None
"""
New maximum amount of time before the API forces the drain and deletion of a `deleting` node.
"""


@dataclass
class UpgradeClusterRequest:
Expand Down
2 changes: 1 addition & 1 deletion scaleway-async/scaleway_async/mongodb/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,7 @@ async def apply_maintenance(
) -> Maintenance:
"""
Apply a maintenance of a MongoDB® Database Instance.
:param maintenance_id:
:param maintenance_id: ID of the maintenance.
:param region: Region to target. If none is passed will use default region from the config.
:return: :class:`Maintenance <Maintenance>`

Expand Down
4 changes: 4 additions & 0 deletions scaleway-async/scaleway_async/mongodb/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,10 @@ class Version:
@dataclass
class ApplyMaintenanceRequest:
maintenance_id: str
"""
ID of the maintenance.
"""

region: Optional[ScwRegion] = None
"""
Region to target. If none is passed will use default region from the config.
Expand Down
6 changes: 6 additions & 0 deletions scaleway/scaleway/k8s/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from .types import Cluster
from .types import Node
from .types import Pool
from .types import UserDataSummary
from .types import NodeMetadataCoreV1Taint
from .types import UpdateClusterRequestAutoUpgrade
from .types import UpdateClusterRequestAutoscalerConfig
Expand Down Expand Up @@ -74,6 +75,8 @@
from .types import ListNodesResponse
from .types import ListPoolsRequest
from .types import ListPoolsResponse
from .types import ListUserDataRequest
from .types import ListUserDataResponse
from .types import ListVersionsRequest
from .types import ListVersionsResponse
from .types import NodeMetadata
Expand Down Expand Up @@ -131,6 +134,7 @@
"Cluster",
"Node",
"Pool",
"UserDataSummary",
"NodeMetadataCoreV1Taint",
"UpdateClusterRequestAutoUpgrade",
"UpdateClusterRequestAutoscalerConfig",
Expand Down Expand Up @@ -167,6 +171,8 @@
"ListNodesResponse",
"ListPoolsRequest",
"ListPoolsResponse",
"ListUserDataRequest",
"ListUserDataResponse",
"ListVersionsRequest",
"ListVersionsResponse",
"NodeMetadata",
Expand Down
Loading
Loading