# 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
from openapi_client.models.v0038_reservation_purge_completed import V0038ReservationPurgeCompleted
try:
    from typing import Self
except ImportError:
    from typing_extensions import Self

class V0038Reservation(BaseModel):
    """
    V0038Reservation
    """ # noqa: E501
    accounts: Optional[StrictStr] = Field(default=None, description="Allowed accounts")
    burst_buffer: Optional[StrictStr] = Field(default=None, description="Reserved burst buffer")
    core_count: Optional[StrictInt] = Field(default=None, description="Number of reserved cores")
    core_spec_cnt: Optional[StrictInt] = Field(default=None, description="Number of reserved specialized cores")
    end_time: Optional[StrictInt] = Field(default=None, description="End time of the reservation")
    features: Optional[StrictStr] = Field(default=None, description="List of features")
    flags: Optional[List[StrictStr]] = Field(default=None, description="Reservation options")
    groups: Optional[StrictStr] = Field(default=None, description="List of groups permitted to use the reserved nodes")
    licenses: Optional[StrictStr] = Field(default=None, description="List of licenses")
    max_start_delay: Optional[StrictInt] = Field(default=None, description="Maximum delay in which jobs outside of the reservation will be permitted to overlap once any jobs are queued for the reservation")
    name: Optional[StrictStr] = Field(default=None, description="Reservationn name")
    node_count: Optional[StrictInt] = Field(default=None, description="Count of nodes reserved")
    node_list: Optional[StrictStr] = Field(default=None, description="List of reserved nodes")
    partition: Optional[StrictStr] = Field(default=None, description="Partition")
    purge_completed: Optional[V0038ReservationPurgeCompleted] = None
    start_time: Optional[StrictInt] = Field(default=None, description="Start time of reservation")
    watts: Optional[StrictInt] = Field(default=None, description="amount of power to reserve in watts")
    tres: Optional[StrictStr] = Field(default=None, description="List of TRES")
    users: Optional[StrictStr] = Field(default=None, description="List of users")
    __properties: ClassVar[List[str]] = ["accounts", "burst_buffer", "core_count", "core_spec_cnt", "end_time", "features", "flags", "groups", "licenses", "max_start_delay", "name", "node_count", "node_list", "partition", "purge_completed", "start_time", "watts", "tres", "users"]

    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 V0038Reservation 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 purge_completed
        if self.purge_completed:
            _dict['purge_completed'] = self.purge_completed.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "accounts": obj.get("accounts"),
            "burst_buffer": obj.get("burst_buffer"),
            "core_count": obj.get("core_count"),
            "core_spec_cnt": obj.get("core_spec_cnt"),
            "end_time": obj.get("end_time"),
            "features": obj.get("features"),
            "flags": obj.get("flags"),
            "groups": obj.get("groups"),
            "licenses": obj.get("licenses"),
            "max_start_delay": obj.get("max_start_delay"),
            "name": obj.get("name"),
            "node_count": obj.get("node_count"),
            "node_list": obj.get("node_list"),
            "partition": obj.get("partition"),
            "purge_completed": V0038ReservationPurgeCompleted.from_dict(obj.get("purge_completed")) if obj.get("purge_completed") is not None else None,
            "start_time": obj.get("start_time"),
            "watts": obj.get("watts"),
            "tres": obj.get("tres"),
            "users": obj.get("users")
        })
        return _obj


