diff --git a/services/ske/oas_commit b/services/ske/oas_commit index 6ba71f50d..aa9ae6bd9 100644 --- a/services/ske/oas_commit +++ b/services/ske/oas_commit @@ -1 +1 @@ -d2755fb2bda0e2105f920af64d7176d184b2bcb7 +c4beb10838a63f2e45612a1a762f13184034a638 diff --git a/services/ske/src/stackit/ske/api/default_api.py b/services/ske/src/stackit/ske/api/default_api.py index bc98e7451..a6ddd80f8 100644 --- a/services/ske/src/stackit/ske/api/default_api.py +++ b/services/ske/src/stackit/ske/api/default_api.py @@ -609,7 +609,12 @@ def create_or_update_cluster( self, project_id: StrictStr, region: StrictStr, - cluster_name: StrictStr, + cluster_name: Annotated[ + StrictStr, + Field( + description="Use lowercase alphanumeric characters or -, must start and end with an alphanumeric character, and be between 1 and 11 characters long." + ), + ], create_or_update_cluster_payload: CreateOrUpdateClusterPayload, _request_timeout: Union[ None, @@ -629,7 +634,7 @@ def create_or_update_cluster( :type project_id: str :param region: (required) :type region: str - :param cluster_name: (required) + :param cluster_name: Use lowercase alphanumeric characters or -, must start and end with an alphanumeric character, and be between 1 and 11 characters long. (required) :type cluster_name: str :param create_or_update_cluster_payload: (required) :type create_or_update_cluster_payload: CreateOrUpdateClusterPayload @@ -684,7 +689,12 @@ def create_or_update_cluster_with_http_info( self, project_id: StrictStr, region: StrictStr, - cluster_name: StrictStr, + cluster_name: Annotated[ + StrictStr, + Field( + description="Use lowercase alphanumeric characters or -, must start and end with an alphanumeric character, and be between 1 and 11 characters long." + ), + ], create_or_update_cluster_payload: CreateOrUpdateClusterPayload, _request_timeout: Union[ None, @@ -704,7 +714,7 @@ def create_or_update_cluster_with_http_info( :type project_id: str :param region: (required) :type region: str - :param cluster_name: (required) + :param cluster_name: Use lowercase alphanumeric characters or -, must start and end with an alphanumeric character, and be between 1 and 11 characters long. (required) :type cluster_name: str :param create_or_update_cluster_payload: (required) :type create_or_update_cluster_payload: CreateOrUpdateClusterPayload @@ -759,7 +769,12 @@ def create_or_update_cluster_without_preload_content( self, project_id: StrictStr, region: StrictStr, - cluster_name: StrictStr, + cluster_name: Annotated[ + StrictStr, + Field( + description="Use lowercase alphanumeric characters or -, must start and end with an alphanumeric character, and be between 1 and 11 characters long." + ), + ], create_or_update_cluster_payload: CreateOrUpdateClusterPayload, _request_timeout: Union[ None, @@ -779,7 +794,7 @@ def create_or_update_cluster_without_preload_content( :type project_id: str :param region: (required) :type region: str - :param cluster_name: (required) + :param cluster_name: Use lowercase alphanumeric characters or -, must start and end with an alphanumeric character, and be between 1 and 11 characters long. (required) :type cluster_name: str :param create_or_update_cluster_payload: (required) :type create_or_update_cluster_payload: CreateOrUpdateClusterPayload diff --git a/services/ske/src/stackit/ske/models/cluster.py b/services/ske/src/stackit/ske/models/cluster.py index 5bfbbd603..b6680d33e 100644 --- a/services/ske/src/stackit/ske/models/cluster.py +++ b/services/ske/src/stackit/ske/models/cluster.py @@ -15,9 +15,10 @@ import json import pprint +import re # noqa: F401 from typing import Any, ClassVar, Dict, List, Optional, Set -from pydantic import BaseModel, ConfigDict, Field, StrictStr +from pydantic import BaseModel, ConfigDict, Field, field_validator from pydantic_core import to_jsonable_python from typing_extensions import Annotated, Self @@ -41,7 +42,10 @@ class Cluster(BaseModel): hibernation: Optional[Hibernation] = None kubernetes: Kubernetes maintenance: Optional[Maintenance] = None - name: Optional[StrictStr] = None + name: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=11)]] = Field( + default=None, + description="Use lowercase alphanumeric characters or -, must start and end with an alphanumeric character, and be between 1 and 11 characters long.", + ) network: Optional[Network] = None nodepools: Annotated[List[Nodepool], Field(min_length=1, max_length=50)] status: Optional[ClusterStatus] = None @@ -57,6 +61,19 @@ class Cluster(BaseModel): "status", ] + @field_validator("name") + def name_validate_regular_expression(cls, value): + """Validates the regular expression""" + if value is None: + return value + + if not isinstance(value, str): + value = str(value) + + if not re.match(r"^[a-z0-9]([a-z0-9-]{0,9}[a-z0-9])?$", value): + raise ValueError(r"must validate the regular expression /^[a-z0-9]([a-z0-9-]{0,9}[a-z0-9])?$/") + return value + model_config = ConfigDict( validate_by_name=True, validate_by_alias=True,