# coding: utf-8

"""
    InductivaWebAPI

    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 pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing import Optional, Set
from typing_extensions import Self


class TaskMetrics(BaseModel):
    """
    TaskMetrics
    """

  # noqa: E501
    total_seconds: Optional[Union[StrictFloat, StrictInt]] = None
    container_image_download_seconds: Optional[Union[StrictFloat,
                                                     StrictInt]] = None
    container_image_size_bytes: Optional[StrictInt] = None
    queue_time_seconds: Optional[Union[StrictFloat, StrictInt]] = None
    computation_seconds: Optional[Union[StrictFloat, StrictInt]] = None
    input_upload_seconds: Optional[Union[StrictFloat, StrictInt]] = None
    input_download_seconds: Optional[Union[StrictFloat, StrictInt]] = None
    input_decompression_seconds: Optional[Union[StrictFloat, StrictInt]] = None
    output_upload_seconds: Optional[Union[StrictFloat, StrictInt]] = None
    input_zipped_size_bytes: Optional[StrictInt] = None
    input_size_bytes: Optional[StrictInt] = None
    output_total_files: Optional[StrictInt] = None
    output_size_bytes: Optional[StrictInt] = None
    output_zipped_size_bytes: Optional[StrictInt] = None
    output_compression_seconds: Optional[Union[StrictFloat, StrictInt]] = None
    __properties: ClassVar[List[str]] = [
        "total_seconds", "container_image_download_seconds",
        "container_image_size_bytes", "queue_time_seconds",
        "computation_seconds", "input_upload_seconds", "input_download_seconds",
        "input_decompression_seconds", "output_upload_seconds",
        "input_zipped_size_bytes", "input_size_bytes", "output_total_files",
        "output_size_bytes", "output_zipped_size_bytes",
        "output_compression_seconds"
    ]

    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 TaskMetrics 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 total_seconds (nullable) is None
        # and model_fields_set contains the field
        if self.total_seconds is None and "total_seconds" in self.model_fields_set:
            _dict['total_seconds'] = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "total_seconds":
                obj.get("total_seconds"),
            "container_image_download_seconds":
                obj.get("container_image_download_seconds"),
            "container_image_size_bytes":
                obj.get("container_image_size_bytes"),
            "queue_time_seconds":
                obj.get("queue_time_seconds"),
            "computation_seconds":
                obj.get("computation_seconds"),
            "input_upload_seconds":
                obj.get("input_upload_seconds"),
            "input_download_seconds":
                obj.get("input_download_seconds"),
            "input_decompression_seconds":
                obj.get("input_decompression_seconds"),
            "output_upload_seconds":
                obj.get("output_upload_seconds"),
            "input_zipped_size_bytes":
                obj.get("input_zipped_size_bytes"),
            "input_size_bytes":
                obj.get("input_size_bytes"),
            "output_total_files":
                obj.get("output_total_files"),
            "output_size_bytes":
                obj.get("output_size_bytes"),
            "output_zipped_size_bytes":
                obj.get("output_zipped_size_bytes"),
            "output_compression_seconds":
                obj.get("output_compression_seconds")
        })
        return _obj
