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
6 changes: 6 additions & 0 deletions services/git/src/stackit/git/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@
"Flavor",
"GenericErrorResponse",
"Instance",
"InstanceFlavor",
"InternalServerErrorResponse",
"ListFlavors",
"ListInstances",
"ListRunnerLabels",
"PatchInstancePayload",
"PatchOperation",
"RunnerLabel",
"UnauthorizedResponse",
Expand Down Expand Up @@ -65,12 +67,16 @@
GenericErrorResponse as GenericErrorResponse,
)
from stackit.git.models.instance import Instance as Instance
from stackit.git.models.instance_flavor import InstanceFlavor as InstanceFlavor
from stackit.git.models.internal_server_error_response import (
InternalServerErrorResponse as InternalServerErrorResponse,
)
from stackit.git.models.list_flavors import ListFlavors as ListFlavors
from stackit.git.models.list_instances import ListInstances as ListInstances
from stackit.git.models.list_runner_labels import ListRunnerLabels as ListRunnerLabels
from stackit.git.models.patch_instance_payload import (
PatchInstancePayload as PatchInstancePayload,
)
from stackit.git.models.patch_operation import PatchOperation as PatchOperation
from stackit.git.models.runner_label import RunnerLabel as RunnerLabel
from stackit.git.models.unauthorized_response import (
Expand Down
40 changes: 20 additions & 20 deletions services/git/src/stackit/git/api/default_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from stackit.git.models.list_flavors import ListFlavors
from stackit.git.models.list_instances import ListInstances
from stackit.git.models.list_runner_labels import ListRunnerLabels
from stackit.git.models.patch_operation import PatchOperation
from stackit.git.models.patch_instance_payload import PatchInstancePayload
from stackit.git.rest import RESTResponseType


Expand Down Expand Up @@ -1548,7 +1548,7 @@ def patch_instance(
instance_id: Annotated[
str, Field(min_length=36, strict=True, max_length=36, description="Instance identifier.")
],
patch_operation: List[PatchOperation],
patch_instance_payload: PatchInstancePayload,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Expand All @@ -1567,8 +1567,8 @@ def patch_instance(
:type project_id: str
:param instance_id: Instance identifier. (required)
:type instance_id: str
:param patch_operation: (required)
:type patch_operation: List[PatchOperation]
:param patch_instance_payload: (required)
:type patch_instance_payload: PatchInstancePayload
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
Expand All @@ -1594,7 +1594,7 @@ def patch_instance(
_param = self._patch_instance_serialize(
project_id=project_id,
instance_id=instance_id,
patch_operation=patch_operation,
patch_instance_payload=patch_instance_payload,
_request_auth=_request_auth,
_content_type=_content_type,
_headers=_headers,
Expand Down Expand Up @@ -1624,7 +1624,7 @@ def patch_instance_with_http_info(
instance_id: Annotated[
str, Field(min_length=36, strict=True, max_length=36, description="Instance identifier.")
],
patch_operation: List[PatchOperation],
patch_instance_payload: PatchInstancePayload,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Expand All @@ -1643,8 +1643,8 @@ def patch_instance_with_http_info(
:type project_id: str
:param instance_id: Instance identifier. (required)
:type instance_id: str
:param patch_operation: (required)
:type patch_operation: List[PatchOperation]
:param patch_instance_payload: (required)
:type patch_instance_payload: PatchInstancePayload
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
Expand All @@ -1670,7 +1670,7 @@ def patch_instance_with_http_info(
_param = self._patch_instance_serialize(
project_id=project_id,
instance_id=instance_id,
patch_operation=patch_operation,
patch_instance_payload=patch_instance_payload,
_request_auth=_request_auth,
_content_type=_content_type,
_headers=_headers,
Expand Down Expand Up @@ -1700,7 +1700,7 @@ def patch_instance_without_preload_content(
instance_id: Annotated[
str, Field(min_length=36, strict=True, max_length=36, description="Instance identifier.")
],
patch_operation: List[PatchOperation],
patch_instance_payload: PatchInstancePayload,
_request_timeout: Union[
None,
Annotated[StrictFloat, Field(gt=0)],
Expand All @@ -1719,8 +1719,8 @@ def patch_instance_without_preload_content(
:type project_id: str
:param instance_id: Instance identifier. (required)
:type instance_id: str
:param patch_operation: (required)
:type patch_operation: List[PatchOperation]
:param patch_instance_payload: (required)
:type patch_instance_payload: PatchInstancePayload
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
Expand All @@ -1746,7 +1746,7 @@ def patch_instance_without_preload_content(
_param = self._patch_instance_serialize(
project_id=project_id,
instance_id=instance_id,
patch_operation=patch_operation,
patch_instance_payload=patch_instance_payload,
_request_auth=_request_auth,
_content_type=_content_type,
_headers=_headers,
Expand All @@ -1769,7 +1769,7 @@ def _patch_instance_serialize(
self,
project_id,
instance_id,
patch_operation,
patch_instance_payload,
_request_auth,
_content_type,
_headers,
Expand All @@ -1778,9 +1778,7 @@ def _patch_instance_serialize(

_host = None

_collection_formats: Dict[str, str] = {
"PatchOperation": "",
}
_collection_formats: Dict[str, str] = {}

_path_params: Dict[str, str] = {}
_query_params: List[Tuple[str, str]] = []
Expand All @@ -1798,8 +1796,8 @@ def _patch_instance_serialize(
# process the header parameters
# process the form parameters
# process the body parameter
if patch_operation is not None:
_body_params = patch_operation
if patch_instance_payload is not None:
_body_params = patch_instance_payload

# set the HTTP header `Accept`
if "Accept" not in _header_params:
Expand All @@ -1809,7 +1807,9 @@ def _patch_instance_serialize(
if _content_type:
_header_params["Content-Type"] = _content_type
else:
_default_content_type = self.api_client.select_header_content_type(["application/json-patch+json"])
_default_content_type = self.api_client.select_header_content_type(
["application/json", "application/json-patch+json"]
)
if _default_content_type is not None:
_header_params["Content-Type"] = _default_content_type

Expand Down
2 changes: 2 additions & 0 deletions services/git/src/stackit/git/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
from stackit.git.models.flavor import Flavor
from stackit.git.models.generic_error_response import GenericErrorResponse
from stackit.git.models.instance import Instance
from stackit.git.models.instance_flavor import InstanceFlavor
from stackit.git.models.internal_server_error_response import (
InternalServerErrorResponse,
)
from stackit.git.models.list_flavors import ListFlavors
from stackit.git.models.list_instances import ListInstances
from stackit.git.models.list_runner_labels import ListRunnerLabels
from stackit.git.models.patch_instance_payload import PatchInstancePayload
from stackit.git.models.patch_operation import PatchOperation
from stackit.git.models.runner_label import RunnerLabel
from stackit.git.models.unauthorized_response import UnauthorizedResponse
16 changes: 3 additions & 13 deletions services/git/src/stackit/git/models/create_instance_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
from typing_extensions import Annotated, Self

from stackit.git.models.instance_flavor import InstanceFlavor


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

@field_validator("flavor")
def flavor_validate_enum(cls, value):
"""Validates the enum"""
if value is None:
return value

if value not in set(["git-10", "git-100"]):
raise ValueError("must be one of enum values ('git-10', 'git-100')")
return value

@field_validator("name")
def name_validate_regular_expression(cls, value):
"""Validates the regular expression"""
Expand Down
37 changes: 37 additions & 0 deletions services/git/src/stackit/git/models/instance_flavor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# coding: utf-8

"""
STACKIT Git API

STACKIT Git management API.

The version of the OpenAPI document: 1beta.0.4
Contact: git@stackit.cloud
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501

from __future__ import annotations

import json
from enum import Enum

from typing_extensions import Self


class InstanceFlavor(str, Enum):
"""
Desired instance flavor. Must be one of the defined enum values.
"""

"""
allowed enum values
"""
GIT_MINUS_10 = "git-10"
GIT_MINUS_100 = "git-100"

@classmethod
def from_json(cls, json_str: str) -> Self:
"""Create an instance of InstanceFlavor from a JSON string"""
return cls(json.loads(json_str))
89 changes: 89 additions & 0 deletions services/git/src/stackit/git/models/patch_instance_payload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# coding: utf-8

"""
STACKIT Git API

STACKIT Git management API.

The version of the OpenAPI document: 1beta.0.4
Contact: git@stackit.cloud
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501

from __future__ import annotations

import json
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set

from pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing_extensions import Annotated, Self


class PatchInstancePayload(BaseModel):
"""
Properties to patch on an instance. All fields are optional.
""" # noqa: E501

acl: Optional[Annotated[List[StrictStr], Field(max_length=50)]] = Field(
default=None, description="A list of CIDR network addresses that are allowed to access the instance."
)
__properties: ClassVar[List[str]] = ["acl"]

model_config = ConfigDict(
populate_by_name=True,
validate_assignment=True,
protected_namespaces=(),
)

def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.model_dump(by_alias=True))

def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())

@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of PatchInstancePayload from a JSON string"""
return cls.from_dict(json.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.

This has the following differences from calling pydantic's
`self.model_dump(by_alias=True)`:

* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
"""
excluded_fields: Set[str] = set([])

_dict = self.model_dump(
by_alias=True,
exclude=excluded_fields,
exclude_none=True,
)
# set to None if acl (nullable) is None
# and model_fields_set contains the field
if self.acl is None and "acl" in self.model_fields_set:
_dict["acl"] = None

return _dict

@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of PatchInstancePayload from a dict"""
if obj is None:
return None

if not isinstance(obj, dict):
return cls.model_validate(obj)

_obj = cls.model_validate({"acl": obj.get("acl")})
return _obj