# coding: utf-8

"""
    HPE Machine Learning Inference Software (MLIS/Aioli)

    HPE MLIS is *Aioli* -- The AI On-line Inference Platform that enables easy deployment, tracking, and serving of your packaged models regardless of your preferred AI framework.

    The version of the OpenAPI document: 1.3.0-dev21
    Contact: community@determined-ai
    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 typing import Any, ClassVar, Dict, List, Optional
from pydantic import BaseModel, StrictStr
from pydantic import Field
from aiolirest.models.resource_profile import ResourceProfile
try:
    from typing import Self
except ImportError:
    from typing_extensions import Self

class ConfigurationResources(BaseModel):
    """
    ConfigurationResources models a configuration's resource requirements.
    """ # noqa: E501
    gpu_type: Optional[StrictStr] = Field(default=None, description="An optional GPU type required by this service (e.g. nvidia-tesla-a100). If unspecified, any GPU available will be used. Your cluster administrator should provide the list of GPU types that can be specified on your cluster. Unless otherwise configured by the administrator, the default resource name for GPU allocation is nvidia.com/gpu. You can override this default resource name for GPUs by specifying an alternate resource name here (it will include a / character). Your administrator may provide other resource names for GPUs available on your cluster (e.g. amd.com/gpu, intel.com/gpu, or a MIG format such as nvidia.com/mig-1g.5gb).", alias="gpuType")
    limits: Optional[ResourceProfile] = None
    requests: Optional[ResourceProfile] = None
    __properties: ClassVar[List[str]] = ["gpuType", "limits", "requests"]

    model_config = {
        "populate_by_name": True,
        "validate_assignment": True
    }


    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) -> Self:
        """Create an instance of ConfigurationResources 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.
        """
        _dict = self.model_dump(
            by_alias=True,
            exclude={
            },
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of limits
        if self.limits:
            _dict['limits'] = self.limits.to_dict()
        # override the default output from pydantic by calling `to_dict()` of requests
        if self.requests:
            _dict['requests'] = self.requests.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Dict) -> Self:
        """Create an instance of ConfigurationResources from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "gpuType": obj.get("gpuType"),
            "limits": ResourceProfile.from_dict(obj.get("limits")) if obj.get("limits") is not None else None,
            "requests": ResourceProfile.from_dict(obj.get("requests")) if obj.get("requests") is not None else None
        })
        return _obj


