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/k8s/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
from .types import ListPoolsResponse
from .types import ListVersionsRequest
from .types import ListVersionsResponse
from .types import MigratePoolsToNewImagesRequest
from .types import NodeMetadata
from .types import RebootNodeRequest
from .types import ReplaceNodeRequest
Expand Down Expand Up @@ -164,6 +165,7 @@
"ListPoolsResponse",
"ListVersionsRequest",
"ListVersionsResponse",
"MigratePoolsToNewImagesRequest",
"NodeMetadata",
"RebootNodeRequest",
"ReplaceNodeRequest",
Expand Down
44 changes: 44 additions & 0 deletions scaleway-async/scaleway_async/k8s/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
ListNodesResponse,
ListPoolsResponse,
ListVersionsResponse,
MigratePoolsToNewImagesRequest,
Node,
NodeMetadata,
Pool,
Expand Down Expand Up @@ -92,6 +93,7 @@
marshal_AddClusterACLRulesRequest,
marshal_CreateClusterRequest,
marshal_CreatePoolRequest,
marshal_MigratePoolsToNewImagesRequest,
marshal_SetClusterACLRulesRequest,
marshal_SetClusterTypeRequest,
marshal_UpdateClusterRequest,
Expand Down Expand Up @@ -1334,6 +1336,48 @@ async def delete_pool(
self._throw_on_error(res)
return unmarshal_Pool(res.json())

async def migrate_pools_to_new_images(
self,
*,
cluster_id: str,
region: Optional[ScwRegion] = None,
pool_ids: Optional[List[str]] = None,
) -> None:
"""
Migrate specific pools or all pools of a cluster to new images.
If no pool is specified, all pools of the cluster will be migrated to new images.
:param cluster_id:
:param region: Region to target. If none is passed will use default region from the config.
:param pool_ids:

Usage:
::

result = await api.migrate_pools_to_new_images(
cluster_id="example",
)
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)
param_cluster_id = validate_path_param("cluster_id", cluster_id)

res = self._request(
"POST",
f"/k8s/v1/regions/{param_region}/clusters/{param_cluster_id}/migrate-pools-to-new-images",
body=marshal_MigratePoolsToNewImagesRequest(
MigratePoolsToNewImagesRequest(
cluster_id=cluster_id,
region=region,
pool_ids=pool_ids,
),
self.client,
),
)

self._throw_on_error(res)

async def get_node_metadata(
self,
*,
Expand Down
41 changes: 33 additions & 8 deletions scaleway-async/scaleway_async/k8s/v1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
CreateClusterRequest,
CreatePoolRequestUpgradePolicy,
CreatePoolRequest,
MigratePoolsToNewImagesRequest,
SetClusterACLRulesRequest,
SetClusterTypeRequest,
UpdateClusterRequestAutoUpgrade,
Expand Down Expand Up @@ -120,6 +121,14 @@ def unmarshal_Pool(data: Any) -> Pool:
if field is not None:
args["size"] = field

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

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

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

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

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

field = data.get("container_runtime", None)
if field is not None:
args["container_runtime"] = field
Expand Down Expand Up @@ -190,6 +191,12 @@ def unmarshal_Pool(data: Any) -> Pool:
else:
args["root_volume_size"] = None

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

return Pool(**args)


Expand Down Expand Up @@ -498,6 +505,12 @@ def unmarshal_Cluster(data: Any) -> Cluster:
else:
args["acl_available"] = None

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

return Cluster(**args)


Expand Down Expand Up @@ -1424,6 +1437,18 @@ def marshal_CreatePoolRequest(
return output


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

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

return output


def marshal_SetClusterACLRulesRequest(
request: SetClusterACLRulesRequest,
defaults: ProfileDefaults,
Expand Down
38 changes: 30 additions & 8 deletions scaleway-async/scaleway_async/k8s/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,24 +375,24 @@ class Pool:
Size (number of nodes) of the pool.
"""

created_at: Optional[datetime]
min_size: int
"""
Date on which the pool was created.
Defines the minimum size of the pool. Note that this field is only used when autoscaling is enabled on the pool.
"""

updated_at: Optional[datetime]
max_size: int
"""
Date on which the pool was last updated.
Defines the maximum size of the pool. Note that this field is only used when autoscaling is enabled on the pool.
"""

min_size: int
created_at: Optional[datetime]
"""
Defines the minimum size of the pool. Note that this field is only used when autoscaling is enabled on the pool.
Date on which the pool was created.
"""

max_size: int
updated_at: Optional[datetime]
"""
Defines the maximum size of the pool. Note that this field is only used when autoscaling is enabled on the pool.
Date on which the pool was last updated.
"""

container_runtime: Runtime
Expand Down Expand Up @@ -453,6 +453,11 @@ class Pool:
System volume disk size.
"""

new_images_enabled: Optional[bool]
"""
Defines whether the pool is migrated to new images.
"""


@dataclass
class ACLRuleRequest:
Expand Down Expand Up @@ -917,6 +922,11 @@ class Cluster:
Defines whether ACL is available on the cluster.
"""

new_images_enabled: Optional[bool]
"""
Defines whether all pools are migrated to new images.
"""


@dataclass
class Node:
Expand Down Expand Up @@ -1819,6 +1829,18 @@ class ListVersionsResponse:
"""


@dataclass
class MigratePoolsToNewImagesRequest:
cluster_id: str

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

pool_ids: Optional[List[str]]


@dataclass
class NodeMetadata:
id: str
Expand Down
2 changes: 2 additions & 0 deletions scaleway/scaleway/k8s/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
from .types import ListPoolsResponse
from .types import ListVersionsRequest
from .types import ListVersionsResponse
from .types import MigratePoolsToNewImagesRequest
from .types import NodeMetadata
from .types import RebootNodeRequest
from .types import ReplaceNodeRequest
Expand Down Expand Up @@ -164,6 +165,7 @@
"ListPoolsResponse",
"ListVersionsRequest",
"ListVersionsResponse",
"MigratePoolsToNewImagesRequest",
"NodeMetadata",
"RebootNodeRequest",
"ReplaceNodeRequest",
Expand Down
44 changes: 44 additions & 0 deletions scaleway/scaleway/k8s/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
ListNodesResponse,
ListPoolsResponse,
ListVersionsResponse,
MigratePoolsToNewImagesRequest,
Node,
NodeMetadata,
Pool,
Expand Down Expand Up @@ -92,6 +93,7 @@
marshal_AddClusterACLRulesRequest,
marshal_CreateClusterRequest,
marshal_CreatePoolRequest,
marshal_MigratePoolsToNewImagesRequest,
marshal_SetClusterACLRulesRequest,
marshal_SetClusterTypeRequest,
marshal_UpdateClusterRequest,
Expand Down Expand Up @@ -1334,6 +1336,48 @@ def delete_pool(
self._throw_on_error(res)
return unmarshal_Pool(res.json())

def migrate_pools_to_new_images(
self,
*,
cluster_id: str,
region: Optional[ScwRegion] = None,
pool_ids: Optional[List[str]] = None,
) -> None:
"""
Migrate specific pools or all pools of a cluster to new images.
If no pool is specified, all pools of the cluster will be migrated to new images.
:param cluster_id:
:param region: Region to target. If none is passed will use default region from the config.
:param pool_ids:

Usage:
::

result = api.migrate_pools_to_new_images(
cluster_id="example",
)
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)
param_cluster_id = validate_path_param("cluster_id", cluster_id)

res = self._request(
"POST",
f"/k8s/v1/regions/{param_region}/clusters/{param_cluster_id}/migrate-pools-to-new-images",
body=marshal_MigratePoolsToNewImagesRequest(
MigratePoolsToNewImagesRequest(
cluster_id=cluster_id,
region=region,
pool_ids=pool_ids,
),
self.client,
),
)

self._throw_on_error(res)

def get_node_metadata(
self,
*,
Expand Down
Loading