# coding: utf-8

"""
    fine-tuning-api-server

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

    The version of the OpenAPI document: 0.1.0
    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 datetime import datetime
from typing import List, Optional
from pydantic.v1 import BaseModel, Field, StrictStr, conlist
from clients.fine_tuning.models.details1 import Details1
from clients.fine_tuning.models.tune_status import TuneStatus

class Tune(BaseModel):
    """
    A tune base class.  # noqa: E501
    """
    created_at: datetime = Field(..., description="The time this LoRA tune was created.")
    deleted_at: Optional[datetime] = Field(...)
    description: StrictStr = Field(..., description="The description of the tune.")
    details: Details1 = Field(...)
    id: StrictStr = Field(..., description="The ID of the LoRA tune.")
    name: StrictStr = Field(..., description="The name of the tune.")
    output_lora_ids: conlist(StrictStr) = Field(..., description="The output LoRA IDs, if the task was successful.")
    status: TuneStatus = Field(...)
    status_details: StrictStr = Field(..., description="The details of the status, only used when the associated task failed.")
    succeeded_at: Optional[datetime] = Field(...)
    tenant_id: StrictStr = Field(..., description="The tenant who requested the LoRA tune.")
    tune_type: StrictStr = Field(..., description="The type of tune requested.")
    updated_at: datetime = Field(..., description="The time this LoRA tune was updated.")
    __properties = ["created_at", "deleted_at", "description", "details", "id", "name", "output_lora_ids", "status", "status_details", "succeeded_at", "tenant_id", "tune_type", "updated_at"]

    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) -> Tune:
        """Create an instance of Tune 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 details
        if self.details:
            _dict['details'] = self.details.to_dict()
        # set to None if deleted_at (nullable) is None
        # and __fields_set__ contains the field
        if self.deleted_at is None and "deleted_at" in self.__fields_set__:
            _dict['deleted_at'] = None

        # set to None if succeeded_at (nullable) is None
        # and __fields_set__ contains the field
        if self.succeeded_at is None and "succeeded_at" in self.__fields_set__:
            _dict['succeeded_at'] = None

        return _dict

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

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

        _obj = Tune.parse_obj({
            "created_at": obj.get("created_at"),
            "deleted_at": obj.get("deleted_at"),
            "description": obj.get("description"),
            "details": Details1.from_dict(obj.get("details")) if obj.get("details") is not None else None,
            "id": obj.get("id"),
            "name": obj.get("name"),
            "output_lora_ids": obj.get("output_lora_ids"),
            "status": obj.get("status"),
            "status_details": obj.get("status_details"),
            "succeeded_at": obj.get("succeeded_at"),
            "tenant_id": obj.get("tenant_id"),
            "tune_type": obj.get("tune_type"),
            "updated_at": obj.get("updated_at")
        })
        return _obj


