|
| 1 | +# coding: utf-8 |
| 2 | + |
| 3 | +""" |
| 4 | + STACKIT Marketplace API |
| 5 | +
|
| 6 | + API to manage STACKIT Marketplace. |
| 7 | +
|
| 8 | + The version of the OpenAPI document: 1 |
| 9 | + Contact: marketplace@stackit.cloud |
| 10 | + Generated by OpenAPI Generator (https://openapi-generator.tech) |
| 11 | +
|
| 12 | + Do not edit the class manually. |
| 13 | +""" # noqa: E501 docstring might be too long |
| 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, field_validator |
| 22 | +from typing_extensions import Self |
| 23 | + |
| 24 | +from stackit.stackitmarketplace.models.become_vendor_become_vendor import ( |
| 25 | + BecomeVendorBecomeVendor, |
| 26 | +) |
| 27 | + |
| 28 | + |
| 29 | +class BecomeVendor(BaseModel): |
| 30 | + """ |
| 31 | + Become a vendor. |
| 32 | + """ |
| 33 | + |
| 34 | + become_vendor: BecomeVendorBecomeVendor = Field(alias="becomeVendor") |
| 35 | + type: StrictStr = Field(description="The form type.") |
| 36 | + __properties: ClassVar[List[str]] = ["becomeVendor", "type"] |
| 37 | + |
| 38 | + @field_validator("type") |
| 39 | + def type_validate_enum(cls, value): |
| 40 | + """Validates the enum""" |
| 41 | + if value not in set(["become_vendor"]): |
| 42 | + raise ValueError("must be one of enum values ('become_vendor')") |
| 43 | + return value |
| 44 | + |
| 45 | + model_config = ConfigDict( |
| 46 | + populate_by_name=True, |
| 47 | + validate_assignment=True, |
| 48 | + protected_namespaces=(), |
| 49 | + ) |
| 50 | + |
| 51 | + def to_str(self) -> str: |
| 52 | + """Returns the string representation of the model using alias""" |
| 53 | + return pprint.pformat(self.model_dump(by_alias=True)) |
| 54 | + |
| 55 | + def to_json(self) -> str: |
| 56 | + """Returns the JSON representation of the model using alias""" |
| 57 | + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead |
| 58 | + return json.dumps(self.to_dict()) |
| 59 | + |
| 60 | + @classmethod |
| 61 | + def from_json(cls, json_str: str) -> Optional[Self]: |
| 62 | + """Create an instance of BecomeVendor from a JSON string""" |
| 63 | + return cls.from_dict(json.loads(json_str)) |
| 64 | + |
| 65 | + def to_dict(self) -> Dict[str, Any]: |
| 66 | + """Return the dictionary representation of the model using alias. |
| 67 | +
|
| 68 | + This has the following differences from calling pydantic's |
| 69 | + `self.model_dump(by_alias=True)`: |
| 70 | +
|
| 71 | + * `None` is only added to the output dict for nullable fields that |
| 72 | + were set at model initialization. Other fields with value `None` |
| 73 | + are ignored. |
| 74 | + """ |
| 75 | + excluded_fields: Set[str] = set([]) |
| 76 | + |
| 77 | + _dict = self.model_dump( |
| 78 | + by_alias=True, |
| 79 | + exclude=excluded_fields, |
| 80 | + exclude_none=True, |
| 81 | + ) |
| 82 | + # override the default output from pydantic by calling `to_dict()` of become_vendor |
| 83 | + if self.become_vendor: |
| 84 | + _dict["becomeVendor"] = self.become_vendor.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 BecomeVendor 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 | + "becomeVendor": ( |
| 99 | + BecomeVendorBecomeVendor.from_dict(obj["becomeVendor"]) |
| 100 | + if obj.get("becomeVendor") is not None |
| 101 | + else None |
| 102 | + ), |
| 103 | + "type": obj.get("type"), |
| 104 | + } |
| 105 | + ) |
| 106 | + return _obj |
0 commit comments