# coding: utf-8

"""
    Metal API

    The version of the OpenAPI document: 1.0.0
    Contact: support@equinixmetal.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

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


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from equinix.services.metalv1.models.spot_prices_per_baremetal import SpotPricesPerBaremetal
from typing import Optional, Set
from typing_extensions import Self

class SpotPricesPerFacility(BaseModel):
    """
    SpotPricesPerFacility
    """ # noqa: E501
    baremetal_0: Optional[SpotPricesPerBaremetal] = None
    baremetal_1: Optional[SpotPricesPerBaremetal] = None
    baremetal_2: Optional[SpotPricesPerBaremetal] = None
    baremetal_2a: Optional[SpotPricesPerBaremetal] = None
    baremetal_2a2: Optional[SpotPricesPerBaremetal] = None
    baremetal_3: Optional[SpotPricesPerBaremetal] = None
    baremetal_s: Optional[SpotPricesPerBaremetal] = None
    c2_medium_x86: Optional[SpotPricesPerBaremetal] = Field(default=None, alias="c2.medium.x86")
    href: Optional[StrictStr] = None
    m2_xlarge_x86: Optional[SpotPricesPerBaremetal] = Field(default=None, alias="m2.xlarge.x86")
    __properties: ClassVar[List[str]] = ["baremetal_0", "baremetal_1", "baremetal_2", "baremetal_2a", "baremetal_2a2", "baremetal_3", "baremetal_s", "c2.medium.x86", "href", "m2.xlarge.x86"]

    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 SpotPricesPerFacility 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 baremetal_0
        if self.baremetal_0:
            _dict['baremetal_0'] = self.baremetal_0.to_dict()
        # override the default output from pydantic by calling `to_dict()` of baremetal_1
        if self.baremetal_1:
            _dict['baremetal_1'] = self.baremetal_1.to_dict()
        # override the default output from pydantic by calling `to_dict()` of baremetal_2
        if self.baremetal_2:
            _dict['baremetal_2'] = self.baremetal_2.to_dict()
        # override the default output from pydantic by calling `to_dict()` of baremetal_2a
        if self.baremetal_2a:
            _dict['baremetal_2a'] = self.baremetal_2a.to_dict()
        # override the default output from pydantic by calling `to_dict()` of baremetal_2a2
        if self.baremetal_2a2:
            _dict['baremetal_2a2'] = self.baremetal_2a2.to_dict()
        # override the default output from pydantic by calling `to_dict()` of baremetal_3
        if self.baremetal_3:
            _dict['baremetal_3'] = self.baremetal_3.to_dict()
        # override the default output from pydantic by calling `to_dict()` of baremetal_s
        if self.baremetal_s:
            _dict['baremetal_s'] = self.baremetal_s.to_dict()
        # override the default output from pydantic by calling `to_dict()` of c2_medium_x86
        if self.c2_medium_x86:
            _dict['c2.medium.x86'] = self.c2_medium_x86.to_dict()
        # override the default output from pydantic by calling `to_dict()` of m2_xlarge_x86
        if self.m2_xlarge_x86:
            _dict['m2.xlarge.x86'] = self.m2_xlarge_x86.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "baremetal_0": SpotPricesPerBaremetal.from_dict(obj["baremetal_0"]) if obj.get("baremetal_0") is not None else None,
            "baremetal_1": SpotPricesPerBaremetal.from_dict(obj["baremetal_1"]) if obj.get("baremetal_1") is not None else None,
            "baremetal_2": SpotPricesPerBaremetal.from_dict(obj["baremetal_2"]) if obj.get("baremetal_2") is not None else None,
            "baremetal_2a": SpotPricesPerBaremetal.from_dict(obj["baremetal_2a"]) if obj.get("baremetal_2a") is not None else None,
            "baremetal_2a2": SpotPricesPerBaremetal.from_dict(obj["baremetal_2a2"]) if obj.get("baremetal_2a2") is not None else None,
            "baremetal_3": SpotPricesPerBaremetal.from_dict(obj["baremetal_3"]) if obj.get("baremetal_3") is not None else None,
            "baremetal_s": SpotPricesPerBaremetal.from_dict(obj["baremetal_s"]) if obj.get("baremetal_s") is not None else None,
            "c2.medium.x86": SpotPricesPerBaremetal.from_dict(obj["c2.medium.x86"]) if obj.get("c2.medium.x86") is not None else None,
            "href": obj.get("href"),
            "m2.xlarge.x86": SpotPricesPerBaremetal.from_dict(obj["m2.xlarge.x86"]) if obj.get("m2.xlarge.x86") is not None else None
        })
        return _obj


