# coding: utf-8

"""
    Kubernetes

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: release-1.29
    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, Field, StrictInt
from .v1_node_selector_term import V1NodeSelectorTerm

class V1PreferredSchedulingTerm(BaseModel):
    """
    An empty preferred scheduling term matches all objects with implicit weight 0 (i.e. it's a no-op). A null preferred scheduling term matches no objects (i.e. is also a no-op).  # noqa: E501
    """
    preference: V1NodeSelectorTerm = Field(...)
    weight: StrictInt = Field(..., description="Weight associated with matching the corresponding nodeSelectorTerm, in the range 1-100.")
    __properties = ["preference", "weight"]

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_name = True
        validate_assignment = True

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.dict(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> V1PreferredSchedulingTerm:
        """Create an instance of V1PreferredSchedulingTerm from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of preference
        if self.preference:
            _dict['preference'] = self.preference.to_dict()
        return _dict

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

        if not isinstance(obj, dict):
            return V1PreferredSchedulingTerm.parse_obj(obj)

        _obj = V1PreferredSchedulingTerm.parse_obj({
            "preference": V1NodeSelectorTerm.from_dict(obj.get("preference")) if obj.get("preference") is not None else None,
            "weight": obj.get("weight")
        })
        return _obj


