Skip to content

Commit d890f35

Browse files
Generate git
1 parent 0c94c46 commit d890f35

File tree

6 files changed

+157
-33
lines changed

6 files changed

+157
-33
lines changed

services/git/src/stackit/git/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@
3333
"Flavor",
3434
"GenericErrorResponse",
3535
"Instance",
36+
"InstanceFlavor",
3637
"InternalServerErrorResponse",
3738
"ListFlavors",
3839
"ListInstances",
3940
"ListRunnerLabels",
41+
"PatchInstancePayload",
4042
"PatchOperation",
4143
"RunnerLabel",
4244
"UnauthorizedResponse",
@@ -65,12 +67,16 @@
6567
GenericErrorResponse as GenericErrorResponse,
6668
)
6769
from stackit.git.models.instance import Instance as Instance
70+
from stackit.git.models.instance_flavor import InstanceFlavor as InstanceFlavor
6871
from stackit.git.models.internal_server_error_response import (
6972
InternalServerErrorResponse as InternalServerErrorResponse,
7073
)
7174
from stackit.git.models.list_flavors import ListFlavors as ListFlavors
7275
from stackit.git.models.list_instances import ListInstances as ListInstances
7376
from stackit.git.models.list_runner_labels import ListRunnerLabels as ListRunnerLabels
77+
from stackit.git.models.patch_instance_payload import (
78+
PatchInstancePayload as PatchInstancePayload,
79+
)
7480
from stackit.git.models.patch_operation import PatchOperation as PatchOperation
7581
from stackit.git.models.runner_label import RunnerLabel as RunnerLabel
7682
from stackit.git.models.unauthorized_response import (

services/git/src/stackit/git/api/default_api.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from stackit.git.models.list_flavors import ListFlavors
3232
from stackit.git.models.list_instances import ListInstances
3333
from stackit.git.models.list_runner_labels import ListRunnerLabels
34-
from stackit.git.models.patch_operation import PatchOperation
34+
from stackit.git.models.patch_instance_payload import PatchInstancePayload
3535
from stackit.git.rest import RESTResponseType
3636

3737

@@ -1548,7 +1548,7 @@ def patch_instance(
15481548
instance_id: Annotated[
15491549
str, Field(min_length=36, strict=True, max_length=36, description="Instance identifier.")
15501550
],
1551-
patch_operation: List[PatchOperation],
1551+
patch_instance_payload: PatchInstancePayload,
15521552
_request_timeout: Union[
15531553
None,
15541554
Annotated[StrictFloat, Field(gt=0)],
@@ -1567,8 +1567,8 @@ def patch_instance(
15671567
:type project_id: str
15681568
:param instance_id: Instance identifier. (required)
15691569
:type instance_id: str
1570-
:param patch_operation: (required)
1571-
:type patch_operation: List[PatchOperation]
1570+
:param patch_instance_payload: (required)
1571+
:type patch_instance_payload: PatchInstancePayload
15721572
:param _request_timeout: timeout setting for this request. If one
15731573
number provided, it will be total request
15741574
timeout. It can also be a pair (tuple) of
@@ -1594,7 +1594,7 @@ def patch_instance(
15941594
_param = self._patch_instance_serialize(
15951595
project_id=project_id,
15961596
instance_id=instance_id,
1597-
patch_operation=patch_operation,
1597+
patch_instance_payload=patch_instance_payload,
15981598
_request_auth=_request_auth,
15991599
_content_type=_content_type,
16001600
_headers=_headers,
@@ -1624,7 +1624,7 @@ def patch_instance_with_http_info(
16241624
instance_id: Annotated[
16251625
str, Field(min_length=36, strict=True, max_length=36, description="Instance identifier.")
16261626
],
1627-
patch_operation: List[PatchOperation],
1627+
patch_instance_payload: PatchInstancePayload,
16281628
_request_timeout: Union[
16291629
None,
16301630
Annotated[StrictFloat, Field(gt=0)],
@@ -1643,8 +1643,8 @@ def patch_instance_with_http_info(
16431643
:type project_id: str
16441644
:param instance_id: Instance identifier. (required)
16451645
:type instance_id: str
1646-
:param patch_operation: (required)
1647-
:type patch_operation: List[PatchOperation]
1646+
:param patch_instance_payload: (required)
1647+
:type patch_instance_payload: PatchInstancePayload
16481648
:param _request_timeout: timeout setting for this request. If one
16491649
number provided, it will be total request
16501650
timeout. It can also be a pair (tuple) of
@@ -1670,7 +1670,7 @@ def patch_instance_with_http_info(
16701670
_param = self._patch_instance_serialize(
16711671
project_id=project_id,
16721672
instance_id=instance_id,
1673-
patch_operation=patch_operation,
1673+
patch_instance_payload=patch_instance_payload,
16741674
_request_auth=_request_auth,
16751675
_content_type=_content_type,
16761676
_headers=_headers,
@@ -1700,7 +1700,7 @@ def patch_instance_without_preload_content(
17001700
instance_id: Annotated[
17011701
str, Field(min_length=36, strict=True, max_length=36, description="Instance identifier.")
17021702
],
1703-
patch_operation: List[PatchOperation],
1703+
patch_instance_payload: PatchInstancePayload,
17041704
_request_timeout: Union[
17051705
None,
17061706
Annotated[StrictFloat, Field(gt=0)],
@@ -1719,8 +1719,8 @@ def patch_instance_without_preload_content(
17191719
:type project_id: str
17201720
:param instance_id: Instance identifier. (required)
17211721
:type instance_id: str
1722-
:param patch_operation: (required)
1723-
:type patch_operation: List[PatchOperation]
1722+
:param patch_instance_payload: (required)
1723+
:type patch_instance_payload: PatchInstancePayload
17241724
:param _request_timeout: timeout setting for this request. If one
17251725
number provided, it will be total request
17261726
timeout. It can also be a pair (tuple) of
@@ -1746,7 +1746,7 @@ def patch_instance_without_preload_content(
17461746
_param = self._patch_instance_serialize(
17471747
project_id=project_id,
17481748
instance_id=instance_id,
1749-
patch_operation=patch_operation,
1749+
patch_instance_payload=patch_instance_payload,
17501750
_request_auth=_request_auth,
17511751
_content_type=_content_type,
17521752
_headers=_headers,
@@ -1769,7 +1769,7 @@ def _patch_instance_serialize(
17691769
self,
17701770
project_id,
17711771
instance_id,
1772-
patch_operation,
1772+
patch_instance_payload,
17731773
_request_auth,
17741774
_content_type,
17751775
_headers,
@@ -1778,9 +1778,7 @@ def _patch_instance_serialize(
17781778

17791779
_host = None
17801780

1781-
_collection_formats: Dict[str, str] = {
1782-
"PatchOperation": "",
1783-
}
1781+
_collection_formats: Dict[str, str] = {}
17841782

17851783
_path_params: Dict[str, str] = {}
17861784
_query_params: List[Tuple[str, str]] = []
@@ -1798,8 +1796,8 @@ def _patch_instance_serialize(
17981796
# process the header parameters
17991797
# process the form parameters
18001798
# process the body parameter
1801-
if patch_operation is not None:
1802-
_body_params = patch_operation
1799+
if patch_instance_payload is not None:
1800+
_body_params = patch_instance_payload
18031801

18041802
# set the HTTP header `Accept`
18051803
if "Accept" not in _header_params:
@@ -1809,7 +1807,9 @@ def _patch_instance_serialize(
18091807
if _content_type:
18101808
_header_params["Content-Type"] = _content_type
18111809
else:
1812-
_default_content_type = self.api_client.select_header_content_type(["application/json-patch+json"])
1810+
_default_content_type = self.api_client.select_header_content_type(
1811+
["application/json", "application/json-patch+json"]
1812+
)
18131813
if _default_content_type is not None:
18141814
_header_params["Content-Type"] = _default_content_type
18151815

services/git/src/stackit/git/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919
from stackit.git.models.flavor import Flavor
2020
from stackit.git.models.generic_error_response import GenericErrorResponse
2121
from stackit.git.models.instance import Instance
22+
from stackit.git.models.instance_flavor import InstanceFlavor
2223
from stackit.git.models.internal_server_error_response import (
2324
InternalServerErrorResponse,
2425
)
2526
from stackit.git.models.list_flavors import ListFlavors
2627
from stackit.git.models.list_instances import ListInstances
2728
from stackit.git.models.list_runner_labels import ListRunnerLabels
29+
from stackit.git.models.patch_instance_payload import PatchInstancePayload
2830
from stackit.git.models.patch_operation import PatchOperation
2931
from stackit.git.models.runner_label import RunnerLabel
3032
from stackit.git.models.unauthorized_response import UnauthorizedResponse

services/git/src/stackit/git/models/create_instance_payload.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
2323
from typing_extensions import Annotated, Self
2424

25+
from stackit.git.models.instance_flavor import InstanceFlavor
26+
2527

2628
class CreateInstancePayload(BaseModel):
2729
"""
@@ -31,24 +33,12 @@ class CreateInstancePayload(BaseModel):
3133
acl: Optional[Annotated[List[StrictStr], Field(max_length=50)]] = Field(
3234
default=None, description="A list of CIDR network addresses that are allowed to access the instance."
3335
)
34-
flavor: Optional[Annotated[str, Field(strict=True, max_length=255)]] = Field(
35-
default=None, description="Desired instance flavor. Must be one of the defined enum values"
36-
)
36+
flavor: Optional[InstanceFlavor] = None
3737
name: Annotated[str, Field(min_length=5, strict=True, max_length=32)] = Field(
3838
description="A user chosen name to distinguish multiple STACKIT Git instances."
3939
)
4040
__properties: ClassVar[List[str]] = ["acl", "flavor", "name"]
4141

42-
@field_validator("flavor")
43-
def flavor_validate_enum(cls, value):
44-
"""Validates the enum"""
45-
if value is None:
46-
return value
47-
48-
if value not in set(["git-10", "git-100"]):
49-
raise ValueError("must be one of enum values ('git-10', 'git-100')")
50-
return value
51-
5242
@field_validator("name")
5343
def name_validate_regular_expression(cls, value):
5444
"""Validates the regular expression"""
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# coding: utf-8
2+
3+
"""
4+
STACKIT Git API
5+
6+
STACKIT Git management API.
7+
8+
The version of the OpenAPI document: 1beta.0.4
9+
Contact: git@stackit.cloud
10+
Generated by OpenAPI Generator (https://openapi-generator.tech)
11+
12+
Do not edit the class manually.
13+
""" # noqa: E501
14+
15+
from __future__ import annotations
16+
17+
import json
18+
from enum import Enum
19+
20+
from typing_extensions import Self
21+
22+
23+
class InstanceFlavor(str, Enum):
24+
"""
25+
Desired instance flavor. Must be one of the defined enum values.
26+
"""
27+
28+
"""
29+
allowed enum values
30+
"""
31+
GIT_MINUS_10 = "git-10"
32+
GIT_MINUS_100 = "git-100"
33+
34+
@classmethod
35+
def from_json(cls, json_str: str) -> Self:
36+
"""Create an instance of InstanceFlavor from a JSON string"""
37+
return cls(json.loads(json_str))
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# coding: utf-8
2+
3+
"""
4+
STACKIT Git API
5+
6+
STACKIT Git management API.
7+
8+
The version of the OpenAPI document: 1beta.0.4
9+
Contact: git@stackit.cloud
10+
Generated by OpenAPI Generator (https://openapi-generator.tech)
11+
12+
Do not edit the class manually.
13+
""" # noqa: E501
14+
15+
from __future__ import annotations
16+
17+
import json
18+
import pprint
19+
from typing import Any, ClassVar, Dict, List, Optional, Set
20+
21+
from pydantic import BaseModel, ConfigDict, Field, StrictStr
22+
from typing_extensions import Annotated, Self
23+
24+
25+
class PatchInstancePayload(BaseModel):
26+
"""
27+
Properties to patch on an instance. All fields are optional.
28+
""" # noqa: E501
29+
30+
acl: Optional[Annotated[List[StrictStr], Field(max_length=50)]] = Field(
31+
default=None, description="A list of CIDR network addresses that are allowed to access the instance."
32+
)
33+
__properties: ClassVar[List[str]] = ["acl"]
34+
35+
model_config = ConfigDict(
36+
populate_by_name=True,
37+
validate_assignment=True,
38+
protected_namespaces=(),
39+
)
40+
41+
def to_str(self) -> str:
42+
"""Returns the string representation of the model using alias"""
43+
return pprint.pformat(self.model_dump(by_alias=True))
44+
45+
def to_json(self) -> str:
46+
"""Returns the JSON representation of the model using alias"""
47+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48+
return json.dumps(self.to_dict())
49+
50+
@classmethod
51+
def from_json(cls, json_str: str) -> Optional[Self]:
52+
"""Create an instance of PatchInstancePayload from a JSON string"""
53+
return cls.from_dict(json.loads(json_str))
54+
55+
def to_dict(self) -> Dict[str, Any]:
56+
"""Return the dictionary representation of the model using alias.
57+
58+
This has the following differences from calling pydantic's
59+
`self.model_dump(by_alias=True)`:
60+
61+
* `None` is only added to the output dict for nullable fields that
62+
were set at model initialization. Other fields with value `None`
63+
are ignored.
64+
"""
65+
excluded_fields: Set[str] = set([])
66+
67+
_dict = self.model_dump(
68+
by_alias=True,
69+
exclude=excluded_fields,
70+
exclude_none=True,
71+
)
72+
# set to None if acl (nullable) is None
73+
# and model_fields_set contains the field
74+
if self.acl is None and "acl" in self.model_fields_set:
75+
_dict["acl"] = None
76+
77+
return _dict
78+
79+
@classmethod
80+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
81+
"""Create an instance of PatchInstancePayload from a dict"""
82+
if obj is None:
83+
return None
84+
85+
if not isinstance(obj, dict):
86+
return cls.model_validate(obj)
87+
88+
_obj = cls.model_validate({"acl": obj.get("acl")})
89+
return _obj

0 commit comments

Comments
 (0)