Skip to content

Commit 08e4386

Browse files
Generate serviceaccount
1 parent 427b7e6 commit 08e4386

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_payload.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from datetime import datetime
1919
from typing import Any, ClassVar, Dict, List, Optional, Set
2020

21-
from pydantic import BaseModel, ConfigDict, Field, StrictStr
21+
from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
2222
from typing_extensions import Self
2323

2424

@@ -27,6 +27,10 @@ class CreateServiceAccountKeyPayload(BaseModel):
2727
CreateServiceAccountKeyPayload
2828
""" # noqa: E501
2929

30+
algorithm: Optional[StrictStr] = Field(
31+
default=None,
32+
description="Optional, key algorithm of the generated key-pair. Used only if publicKey attribute is not specified, otherwise the algorithm is derived from the public key.",
33+
)
3034
public_key: Optional[StrictStr] = Field(
3135
default=None,
3236
description="Optional, public key part of the user generated RSA key-pair wrapped in a [X.509 v3 certificate](https://www.rfc-editor.org/rfc/rfc5280)",
@@ -37,7 +41,17 @@ class CreateServiceAccountKeyPayload(BaseModel):
3741
description="Optional, date of key expiration. When omitted, key is valid until deleted",
3842
alias="validUntil",
3943
)
40-
__properties: ClassVar[List[str]] = ["publicKey", "validUntil"]
44+
__properties: ClassVar[List[str]] = ["algorithm", "publicKey", "validUntil"]
45+
46+
@field_validator("algorithm")
47+
def algorithm_validate_enum(cls, value):
48+
"""Validates the enum"""
49+
if value is None:
50+
return value
51+
52+
if value not in set(["RSA_2048", "RSA_4096"]):
53+
raise ValueError("must be one of enum values ('RSA_2048', 'RSA_4096')")
54+
return value
4155

4256
model_config = ConfigDict(
4357
populate_by_name=True,
@@ -87,5 +101,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
87101
if not isinstance(obj, dict):
88102
return cls.model_validate(obj)
89103

90-
_obj = cls.model_validate({"publicKey": obj.get("publicKey"), "validUntil": obj.get("validUntil")})
104+
_obj = cls.model_validate(
105+
{"algorithm": obj.get("algorithm"), "publicKey": obj.get("publicKey"), "validUntil": obj.get("validUntil")}
106+
)
91107
return _obj

services/serviceaccount/src/stackit/serviceaccount/models/create_service_account_key_response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ class CreateServiceAccountKeyResponse(BaseModel):
6666
@field_validator("key_algorithm")
6767
def key_algorithm_validate_enum(cls, value):
6868
"""Validates the enum"""
69-
if value not in set(["RSA_2048"]):
70-
raise ValueError("must be one of enum values ('RSA_2048')")
69+
if value not in set(["RSA_2048", "RSA_4096"]):
70+
raise ValueError("must be one of enum values ('RSA_2048', 'RSA_4096')")
7171
return value
7272

7373
@field_validator("key_origin")

services/serviceaccount/src/stackit/serviceaccount/models/get_service_account_key_response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ class GetServiceAccountKeyResponse(BaseModel):
6666
@field_validator("key_algorithm")
6767
def key_algorithm_validate_enum(cls, value):
6868
"""Validates the enum"""
69-
if value not in set(["RSA_2048"]):
70-
raise ValueError("must be one of enum values ('RSA_2048')")
69+
if value not in set(["RSA_2048", "RSA_4096"]):
70+
raise ValueError("must be one of enum values ('RSA_2048', 'RSA_4096')")
7171
return value
7272

7373
@field_validator("key_origin")

services/serviceaccount/src/stackit/serviceaccount/models/partial_update_service_account_key_response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ class PartialUpdateServiceAccountKeyResponse(BaseModel):
5656
@field_validator("key_algorithm")
5757
def key_algorithm_validate_enum(cls, value):
5858
"""Validates the enum"""
59-
if value not in set(["RSA_2048"]):
60-
raise ValueError("must be one of enum values ('RSA_2048')")
59+
if value not in set(["RSA_2048", "RSA_4096"]):
60+
raise ValueError("must be one of enum values ('RSA_2048', 'RSA_4096')")
6161
return value
6262

6363
@field_validator("key_origin")

services/serviceaccount/src/stackit/serviceaccount/models/service_account_key_list_response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ class ServiceAccountKeyListResponse(BaseModel):
5656
@field_validator("key_algorithm")
5757
def key_algorithm_validate_enum(cls, value):
5858
"""Validates the enum"""
59-
if value not in set(["RSA_2048"]):
60-
raise ValueError("must be one of enum values ('RSA_2048')")
59+
if value not in set(["RSA_2048", "RSA_4096"]):
60+
raise ValueError("must be one of enum values ('RSA_2048', 'RSA_4096')")
6161
return value
6262

6363
@field_validator("key_origin")

0 commit comments

Comments
 (0)