# coding: utf-8

"""
    Artifact Keeper API

    Enterprise artifact registry supporting 45+ package formats.

    The version of the OpenAPI document: 1.0.0-rc.3
    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, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing import Optional, Set
from typing_extensions import Self

class MigrationJobResponse(BaseModel):
    """
    MigrationJobResponse
    """ # noqa: E501
    completed_items: StrictInt
    config: Dict[str, Any]
    created_at: datetime
    error_summary: Optional[StrictStr] = None
    estimated_time_remaining: Optional[StrictInt] = None
    failed_items: StrictInt
    finished_at: Optional[datetime] = None
    id: StrictStr
    job_type: StrictStr
    progress_percent: Union[StrictFloat, StrictInt]
    skipped_items: StrictInt
    source_connection_id: StrictStr
    started_at: Optional[datetime] = None
    status: StrictStr
    total_bytes: StrictInt
    total_items: StrictInt
    transferred_bytes: StrictInt
    __properties: ClassVar[List[str]] = ["completed_items", "config", "created_at", "error_summary", "estimated_time_remaining", "failed_items", "finished_at", "id", "job_type", "progress_percent", "skipped_items", "source_connection_id", "started_at", "status", "total_bytes", "total_items", "transferred_bytes"]

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "completed_items": obj.get("completed_items"),
            "config": obj.get("config"),
            "created_at": obj.get("created_at"),
            "error_summary": obj.get("error_summary"),
            "estimated_time_remaining": obj.get("estimated_time_remaining"),
            "failed_items": obj.get("failed_items"),
            "finished_at": obj.get("finished_at"),
            "id": obj.get("id"),
            "job_type": obj.get("job_type"),
            "progress_percent": obj.get("progress_percent"),
            "skipped_items": obj.get("skipped_items"),
            "source_connection_id": obj.get("source_connection_id"),
            "started_at": obj.get("started_at"),
            "status": obj.get("status"),
            "total_bytes": obj.get("total_bytes"),
            "total_items": obj.get("total_items"),
            "transferred_bytes": obj.get("transferred_bytes")
        })
        return _obj


