Skip to content
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
2 changes: 1 addition & 1 deletion services/ske/oas_commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d2755fb2bda0e2105f920af64d7176d184b2bcb7
dbce7f0e7162ca95fd0427e4f3981dbed2e1b9e3
27 changes: 21 additions & 6 deletions services/ske/src/stackit/ske/api/default_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down
21 changes: 19 additions & 2 deletions services/ske/src/stackit/ske/models/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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,
Expand Down
Loading