# coding: utf-8

"""
    Rapidata Asset API

    The API for the Rapidata Asset service

    The version of the OpenAPI document: v1
    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 pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class GetJobByIdEndpointOutput(BaseModel):
    """
    The result when a job has been retrieved.
    """ # noqa: E501
    job_id: StrictStr = Field(description="The job id.", alias="jobId")
    name: StrictStr = Field(description="The job name.")
    definition_id: StrictStr = Field(description="The job definition id.", alias="definitionId")
    audience_id: StrictStr = Field(description="The audience id.", alias="audienceId")
    revision_number: StrictInt = Field(description="The revision number.", alias="revisionNumber")
    pipeline_id: StrictStr = Field(description="The pipeline id.", alias="pipelineId")
    status: StrictStr = Field(description="The job status.")
    completed_at: Optional[datetime] = Field(default=None, description="The timestamp when the job was completed.", alias="completedAt")
    result_file_name: Optional[StrictStr] = Field(default=None, description="The file name of the result.", alias="resultFileName")
    failed_at: Optional[datetime] = Field(default=None, description="The timestamp when the job failed.", alias="failedAt")
    failure_message: Optional[StrictStr] = Field(default=None, description="The failure message.", alias="failureMessage")
    created_at: datetime = Field(description="The creation timestamp.", alias="createdAt")
    __properties: ClassVar[List[str]] = ["jobId", "name", "definitionId", "audienceId", "revisionNumber", "pipelineId", "status", "completedAt", "resultFileName", "failedAt", "failureMessage", "createdAt"]

    model_config = ConfigDict(
        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) -> Optional[Self]:
        """Create an instance of GetJobByIdEndpointOutput 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.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # set to None if completed_at (nullable) is None
        # and model_fields_set contains the field
        if self.completed_at is None and "completed_at" in self.model_fields_set:
            _dict['completedAt'] = None

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

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of GetJobByIdEndpointOutput from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "jobId": obj.get("jobId"),
            "name": obj.get("name"),
            "definitionId": obj.get("definitionId"),
            "audienceId": obj.get("audienceId"),
            "revisionNumber": obj.get("revisionNumber"),
            "pipelineId": obj.get("pipelineId"),
            "status": obj.get("status"),
            "completedAt": obj.get("completedAt"),
            "resultFileName": obj.get("resultFileName"),
            "failedAt": obj.get("failedAt"),
            "failureMessage": obj.get("failureMessage"),
            "createdAt": obj.get("createdAt")
        })
        return _obj


