# coding: utf-8

"""
    Slurm Rest API

    API to access and control Slurm.

    The version of the OpenAPI document: 0.0.38
    Contact: sales@schedmd.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 typing import Any, ClassVar, Dict, List, Optional
from pydantic import BaseModel, StrictInt, StrictStr
from pydantic import Field
try:
    from typing import Self
except ImportError:
    from typing_extensions import Self

class V0038Partition(BaseModel):
    """
    V0038Partition
    """ # noqa: E501
    flags: Optional[List[StrictStr]] = Field(default=None, description="partition options")
    preemption_mode: Optional[List[StrictStr]] = Field(default=None, description="preemption type")
    allowed_allocation_nodes: Optional[StrictStr] = Field(default=None, description="list names of allowed allocating nodes")
    allowed_accounts: Optional[StrictStr] = Field(default=None, description="comma delimited list of accounts")
    allowed_groups: Optional[StrictStr] = Field(default=None, description="comma delimited list of groups")
    allowed_qos: Optional[StrictStr] = Field(default=None, description="comma delimited list of qos")
    alternative: Optional[StrictStr] = Field(default=None, description="name of alternate partition")
    billing_weights: Optional[StrictStr] = Field(default=None, description="TRES billing weights")
    default_memory_per_cpu: Optional[StrictInt] = Field(default=None, description="default MB memory per allocated CPU")
    default_time_limit: Optional[StrictInt] = Field(default=None, description="default time limit (minutes)")
    denied_accounts: Optional[StrictStr] = Field(default=None, description="comma delimited list of denied accounts")
    denied_qos: Optional[StrictStr] = Field(default=None, description="comma delimited list of denied qos")
    preemption_grace_time: Optional[StrictInt] = Field(default=None, description="preemption grace time (seconds)")
    maximum_cpus_per_node: Optional[StrictInt] = Field(default=None, description="maximum allocated CPUs per node")
    maximum_memory_per_node: Optional[StrictInt] = Field(default=None, description="maximum memory per allocated node (MiB)")
    maximum_nodes_per_job: Optional[StrictInt] = Field(default=None, description="Max nodes per job")
    max_time_limit: Optional[StrictInt] = Field(default=None, description="Max time limit per job")
    min_nodes_per_job: Optional[StrictInt] = Field(default=None, description="Min number of nodes per job")
    name: Optional[StrictStr] = Field(default=None, description="Partition name")
    nodes: Optional[StrictStr] = Field(default=None, description="list names of nodes in partition")
    over_time_limit: Optional[StrictInt] = Field(default=None, description="job's time limit can be exceeded by this number of minutes before cancellation")
    priority_job_factor: Optional[StrictInt] = Field(default=None, description="job priority weight factor")
    priority_tier: Optional[StrictInt] = Field(default=None, description="tier for scheduling and preemption")
    qos: Optional[StrictStr] = Field(default=None, description="partition QOS name")
    state: Optional[StrictStr] = Field(default=None, description="Partition state")
    total_cpus: Optional[StrictInt] = Field(default=None, description="Total cpus in partition")
    total_nodes: Optional[StrictInt] = Field(default=None, description="Total number of nodes in partition")
    tres: Optional[StrictStr] = Field(default=None, description="configured TRES in partition")
    maximum_memory_per_cpu: Optional[StrictInt] = Field(default=None, description="maximum memory per allocated CPU (MiB)")
    default_memory_per_node: Optional[StrictInt] = Field(default=None, description="default MB memory per allocated node")
    __properties: ClassVar[List[str]] = ["flags", "preemption_mode", "allowed_allocation_nodes", "allowed_accounts", "allowed_groups", "allowed_qos", "alternative", "billing_weights", "default_memory_per_cpu", "default_time_limit", "denied_accounts", "denied_qos", "preemption_grace_time", "maximum_cpus_per_node", "maximum_memory_per_node", "maximum_nodes_per_job", "max_time_limit", "min_nodes_per_job", "name", "nodes", "over_time_limit", "priority_job_factor", "priority_tier", "qos", "state", "total_cpus", "total_nodes", "tres", "maximum_memory_per_cpu", "default_memory_per_node"]

    model_config = {
        "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) -> Self:
        """Create an instance of V0038Partition 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,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "flags": obj.get("flags"),
            "preemption_mode": obj.get("preemption_mode"),
            "allowed_allocation_nodes": obj.get("allowed_allocation_nodes"),
            "allowed_accounts": obj.get("allowed_accounts"),
            "allowed_groups": obj.get("allowed_groups"),
            "allowed_qos": obj.get("allowed_qos"),
            "alternative": obj.get("alternative"),
            "billing_weights": obj.get("billing_weights"),
            "default_memory_per_cpu": obj.get("default_memory_per_cpu"),
            "default_time_limit": obj.get("default_time_limit"),
            "denied_accounts": obj.get("denied_accounts"),
            "denied_qos": obj.get("denied_qos"),
            "preemption_grace_time": obj.get("preemption_grace_time"),
            "maximum_cpus_per_node": obj.get("maximum_cpus_per_node"),
            "maximum_memory_per_node": obj.get("maximum_memory_per_node"),
            "maximum_nodes_per_job": obj.get("maximum_nodes_per_job"),
            "max_time_limit": obj.get("max_time_limit"),
            "min_nodes_per_job": obj.get("min_nodes_per_job"),
            "name": obj.get("name"),
            "nodes": obj.get("nodes"),
            "over_time_limit": obj.get("over_time_limit"),
            "priority_job_factor": obj.get("priority_job_factor"),
            "priority_tier": obj.get("priority_tier"),
            "qos": obj.get("qos"),
            "state": obj.get("state"),
            "total_cpus": obj.get("total_cpus"),
            "total_nodes": obj.get("total_nodes"),
            "tres": obj.get("tres"),
            "maximum_memory_per_cpu": obj.get("maximum_memory_per_cpu"),
            "default_memory_per_node": obj.get("default_memory_per_node")
        })
        return _obj


