|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | + STACKIT Cloud Foundry API |
| 5 | +
|
| 6 | + API endpoints for managing STACKIT Cloud Foundry |
| 7 | +
|
| 8 | + The version of the OpenAPI document: 1.0.0 |
| 9 | + |
| 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 |
| 22 | +from typing_extensions import Self |
| 23 | + |
| 24 | +from stackit.scf.models.org_role_response import OrgRoleResponse |
| 25 | +from stackit.scf.models.space import Space |
| 26 | +from stackit.scf.models.space_role_create_response import SpaceRoleCreateResponse |
| 27 | + |
| 28 | + |
| 29 | +class SpaceCreatedBffResponse(BaseModel): |
| 30 | + """ |
| 31 | + SpaceCreatedBffResponse |
| 32 | + """ # noqa: E501 |
| 33 | + |
| 34 | + org_role: Optional[OrgRoleResponse] = Field(default=None, alias="orgRole") |
| 35 | + space: Space |
| 36 | + space_role: SpaceRoleCreateResponse = Field(alias="spaceRole") |
| 37 | + __properties: ClassVar[List[str]] = ["orgRole", "space", "spaceRole"] |
| 38 | + |
| 39 | + model_config = ConfigDict( |
| 40 | + populate_by_name=True, |
| 41 | + validate_assignment=True, |
| 42 | + protected_namespaces=(), |
| 43 | + ) |
| 44 | + |
| 45 | + def to_str(self) -> str: |
| 46 | + """Returns the string representation of the model using alias""" |
| 47 | + return pprint.pformat(self.model_dump(by_alias=True)) |
| 48 | + |
| 49 | + def to_json(self) -> str: |
| 50 | + """Returns the JSON representation of the model using alias""" |
| 51 | + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead |
| 52 | + return json.dumps(self.to_dict()) |
| 53 | + |
| 54 | + @classmethod |
| 55 | + def from_json(cls, json_str: str) -> Optional[Self]: |
| 56 | + """Create an instance of SpaceCreatedBffResponse from a JSON string""" |
| 57 | + return cls.from_dict(json.loads(json_str)) |
| 58 | + |
| 59 | + def to_dict(self) -> Dict[str, Any]: |
| 60 | + """Return the dictionary representation of the model using alias. |
| 61 | +
|
| 62 | + This has the following differences from calling pydantic's |
| 63 | + `self.model_dump(by_alias=True)`: |
| 64 | +
|
| 65 | + * `None` is only added to the output dict for nullable fields that |
| 66 | + were set at model initialization. Other fields with value `None` |
| 67 | + are ignored. |
| 68 | + """ |
| 69 | + excluded_fields: Set[str] = set([]) |
| 70 | + |
| 71 | + _dict = self.model_dump( |
| 72 | + by_alias=True, |
| 73 | + exclude=excluded_fields, |
| 74 | + exclude_none=True, |
| 75 | + ) |
| 76 | + # override the default output from pydantic by calling `to_dict()` of org_role |
| 77 | + if self.org_role: |
| 78 | + _dict["orgRole"] = self.org_role.to_dict() |
| 79 | + # override the default output from pydantic by calling `to_dict()` of space |
| 80 | + if self.space: |
| 81 | + _dict["space"] = self.space.to_dict() |
| 82 | + # override the default output from pydantic by calling `to_dict()` of space_role |
| 83 | + if self.space_role: |
| 84 | + _dict["spaceRole"] = self.space_role.to_dict() |
| 85 | + return _dict |
| 86 | + |
| 87 | + @classmethod |
| 88 | + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: |
| 89 | + """Create an instance of SpaceCreatedBffResponse from a dict""" |
| 90 | + if obj is None: |
| 91 | + return None |
| 92 | + |
| 93 | + if not isinstance(obj, dict): |
| 94 | + return cls.model_validate(obj) |
| 95 | + |
| 96 | + _obj = cls.model_validate( |
| 97 | + { |
| 98 | + "orgRole": OrgRoleResponse.from_dict(obj["orgRole"]) if obj.get("orgRole") is not None else None, |
| 99 | + "space": Space.from_dict(obj["space"]) if obj.get("space") is not None else None, |
| 100 | + "spaceRole": ( |
| 101 | + SpaceRoleCreateResponse.from_dict(obj["spaceRole"]) if obj.get("spaceRole") is not None else None |
| 102 | + ), |
| 103 | + } |
| 104 | + ) |
| 105 | + return _obj |
0 commit comments