diff --git a/services/scf/src/stackit/scf/__init__.py b/services/scf/src/stackit/scf/__init__.py index 060b977e..17da32a0 100644 --- a/services/scf/src/stackit/scf/__init__.py +++ b/services/scf/src/stackit/scf/__init__.py @@ -35,6 +35,8 @@ "CreateSpacePayload", "CreateSpaceRolePayload", "ErrorResponse", + "IsolationSegment", + "IsolationSegmentsList", "OrgManager", "OrgManagerDeleteResponse", "OrgManagerResponse", @@ -101,6 +103,10 @@ CreateSpaceRolePayload as CreateSpaceRolePayload, ) from stackit.scf.models.error_response import ErrorResponse as ErrorResponse +from stackit.scf.models.isolation_segment import IsolationSegment as IsolationSegment +from stackit.scf.models.isolation_segments_list import ( + IsolationSegmentsList as IsolationSegmentsList, +) from stackit.scf.models.org_manager import OrgManager as OrgManager from stackit.scf.models.org_manager_delete_response import ( OrgManagerDeleteResponse as OrgManagerDeleteResponse, diff --git a/services/scf/src/stackit/scf/models/__init__.py b/services/scf/src/stackit/scf/models/__init__.py index 4da3f792..70babd0f 100644 --- a/services/scf/src/stackit/scf/models/__init__.py +++ b/services/scf/src/stackit/scf/models/__init__.py @@ -23,6 +23,8 @@ from stackit.scf.models.create_space_payload import CreateSpacePayload from stackit.scf.models.create_space_role_payload import CreateSpaceRolePayload from stackit.scf.models.error_response import ErrorResponse +from stackit.scf.models.isolation_segment import IsolationSegment +from stackit.scf.models.isolation_segments_list import IsolationSegmentsList from stackit.scf.models.org_manager import OrgManager from stackit.scf.models.org_manager_delete_response import OrgManagerDeleteResponse from stackit.scf.models.org_manager_response import OrgManagerResponse diff --git a/services/scf/src/stackit/scf/models/isolation_segment.py b/services/scf/src/stackit/scf/models/isolation_segment.py new file mode 100644 index 00000000..401c2851 --- /dev/null +++ b/services/scf/src/stackit/scf/models/isolation_segment.py @@ -0,0 +1,137 @@ +# coding: utf-8 + +""" + STACKIT Cloud Foundry API + + API endpoints for managing STACKIT Cloud Foundry + + The version of the OpenAPI document: 1.0.0 + Contact: support@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 +import re # noqa: F401 +from datetime import datetime +from typing import Any, ClassVar, Dict, List, Optional, Set + +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing_extensions import Self + + +class IsolationSegment(BaseModel): + """ + IsolationSegment + """ # noqa: E501 + + created_at: datetime = Field(alias="createdAt") + guid: StrictStr + name: StrictStr + org_id: StrictStr = Field(alias="orgId") + platform_id: StrictStr = Field(alias="platformId") + project_id: StrictStr = Field(alias="projectId") + region: StrictStr + updated_at: datetime = Field(alias="updatedAt") + __properties: ClassVar[List[str]] = [ + "createdAt", + "guid", + "name", + "orgId", + "platformId", + "projectId", + "region", + "updatedAt", + ] + + @field_validator("created_at", mode="before") + def created_at_change_year_zero_to_one(cls, value): + """Workaround which prevents year 0 issue""" + if isinstance(value, str): + # Check for year "0000" at the beginning of the string + # This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ + if value.startswith("0000-01-01T") and re.match( + r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value + ): + # Workaround: Replace "0000" with "0001" + return "0001" + value[4:] # Take "0001" and append the rest of the string + return value + + @field_validator("updated_at", mode="before") + def updated_at_change_year_zero_to_one(cls, value): + """Workaround which prevents year 0 issue""" + if isinstance(value, str): + # Check for year "0000" at the beginning of the string + # This assumes common date formats like YYYY-MM-DDTHH:MM:SS+00:00 or YYYY-MM-DDTHH:MM:SSZ + if value.startswith("0000-01-01T") and re.match( + r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d{2}:\d{2}|Z)$", value + ): + # Workaround: Replace "0000" with "0001" + return "0001" + value[4:] # Take "0001" and append the rest of the string + return value + + 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 IsolationSegment 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, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of IsolationSegment from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "createdAt": obj.get("createdAt"), + "guid": obj.get("guid"), + "name": obj.get("name"), + "orgId": obj.get("orgId"), + "platformId": obj.get("platformId"), + "projectId": obj.get("projectId"), + "region": obj.get("region"), + "updatedAt": obj.get("updatedAt"), + } + ) + return _obj diff --git a/services/scf/src/stackit/scf/models/isolation_segments_list.py b/services/scf/src/stackit/scf/models/isolation_segments_list.py new file mode 100644 index 00000000..797d0fc6 --- /dev/null +++ b/services/scf/src/stackit/scf/models/isolation_segments_list.py @@ -0,0 +1,105 @@ +# coding: utf-8 + +""" + STACKIT Cloud Foundry API + + API endpoints for managing STACKIT Cloud Foundry + + The version of the OpenAPI document: 1.0.0 + Contact: support@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 +from typing_extensions import Self + +from stackit.scf.models.isolation_segment import IsolationSegment +from stackit.scf.models.pagination import Pagination + + +class IsolationSegmentsList(BaseModel): + """ + IsolationSegmentsList + """ # noqa: E501 + + pagination: Pagination + resources: List[IsolationSegment] + __properties: ClassVar[List[str]] = ["pagination", "resources"] + + 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 IsolationSegmentsList 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, + ) + # override the default output from pydantic by calling `to_dict()` of pagination + if self.pagination: + _dict["pagination"] = self.pagination.to_dict() + # override the default output from pydantic by calling `to_dict()` of each item in resources (list) + _items = [] + if self.resources: + for _item in self.resources: + if _item: + _items.append(_item.to_dict()) + _dict["resources"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of IsolationSegmentsList from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "pagination": Pagination.from_dict(obj["pagination"]) if obj.get("pagination") is not None else None, + "resources": ( + [IsolationSegment.from_dict(_item) for _item in obj["resources"]] + if obj.get("resources") is not None + else None + ), + } + ) + return _obj