# coding: utf-8

"""
    AI Stats Gateway API

    A gateway API for accessing various AI models with OpenAI-compatible endpoints.

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

class BatchResponse(BaseModel):
    """
    BatchResponse
    """ # noqa: E501
    id: Optional[StrictStr] = None
    object: Optional[StrictStr] = None
    endpoint: Optional[StrictStr] = None
    errors: Optional[Dict[str, Any]] = None
    input_file_id: Optional[StrictStr] = None
    completion_window: Optional[StrictStr] = None
    status: Optional[StrictStr] = None
    output_file_id: Optional[StrictStr] = None
    error_file_id: Optional[StrictStr] = None
    created_at: Optional[StrictInt] = None
    in_progress_at: Optional[StrictInt] = None
    expires_at: Optional[StrictInt] = None
    finalizing_at: Optional[StrictInt] = None
    completed_at: Optional[StrictInt] = None
    failed_at: Optional[StrictInt] = None
    expired_at: Optional[StrictInt] = None
    cancelling_at: Optional[StrictInt] = None
    cancelled_at: Optional[StrictInt] = None
    request_counts: Optional[BatchRequestCounts] = None
    metadata: Optional[Dict[str, Any]] = None
    __properties: ClassVar[List[str]] = ["id", "object", "endpoint", "errors", "input_file_id", "completion_window", "status", "output_file_id", "error_file_id", "created_at", "in_progress_at", "expires_at", "finalizing_at", "completed_at", "failed_at", "expired_at", "cancelling_at", "cancelled_at", "request_counts", "metadata"]

    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 BatchResponse 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,
        )
        # override the default output from pydantic by calling `to_dict()` of request_counts
        if self.request_counts:
            _dict['request_counts'] = self.request_counts.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "object": obj.get("object"),
            "endpoint": obj.get("endpoint"),
            "errors": obj.get("errors"),
            "input_file_id": obj.get("input_file_id"),
            "completion_window": obj.get("completion_window"),
            "status": obj.get("status"),
            "output_file_id": obj.get("output_file_id"),
            "error_file_id": obj.get("error_file_id"),
            "created_at": obj.get("created_at"),
            "in_progress_at": obj.get("in_progress_at"),
            "expires_at": obj.get("expires_at"),
            "finalizing_at": obj.get("finalizing_at"),
            "completed_at": obj.get("completed_at"),
            "failed_at": obj.get("failed_at"),
            "expired_at": obj.get("expired_at"),
            "cancelling_at": obj.get("cancelling_at"),
            "cancelled_at": obj.get("cancelled_at"),
            "request_counts": BatchRequestCounts.from_dict(obj["request_counts"]) if obj.get("request_counts") is not None else None,
            "metadata": obj.get("metadata")
        })
        return _obj


