# coding: utf-8

"""
    authentik

    Making authentication simple.

    The version of the OpenAPI document: 2024.2.2
    Contact: hello@goauthentik.io
    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, Union
from pydantic import BaseModel, Field, StrictFloat, StrictInt, StrictStr, conlist
from authentik_client.models.system_task_status_enum import SystemTaskStatusEnum

class SystemTask(BaseModel):
    """
    Serialize TaskInfo and TaskResult  # noqa: E501
    """
    uuid: StrictStr = Field(...)
    name: StrictStr = Field(...)
    full_name: StrictStr = Field(..., description="Get full name with UID")
    uid: Optional[StrictStr] = None
    description: StrictStr = Field(...)
    start_timestamp: datetime = Field(...)
    finish_timestamp: datetime = Field(...)
    duration: Union[StrictFloat, StrictInt] = Field(...)
    status: SystemTaskStatusEnum = Field(...)
    messages: conlist(StrictStr) = Field(...)
    __properties = ["uuid", "name", "full_name", "uid", "description", "start_timestamp", "finish_timestamp", "duration", "status", "messages"]

    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) -> SystemTask:
        """Create an instance of SystemTask 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={
                            "uuid",
                            "full_name",
                            "start_timestamp",
                            "finish_timestamp",
                            "duration",
                          },
                          exclude_none=True)
        return _dict

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

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

        _obj = SystemTask.parse_obj({
            "uuid": obj.get("uuid"),
            "name": obj.get("name"),
            "full_name": obj.get("full_name"),
            "uid": obj.get("uid"),
            "description": obj.get("description"),
            "start_timestamp": obj.get("start_timestamp"),
            "finish_timestamp": obj.get("finish_timestamp"),
            "duration": obj.get("duration"),
            "status": obj.get("status"),
            "messages": obj.get("messages")
        })
        return _obj


