github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/clients/python/lakefs_sdk/models/import_status.py (about)

     1  # coding: utf-8
     2  
     3  """
     4      lakeFS API
     5  
     6      lakeFS HTTP API
     7  
     8      The version of the OpenAPI document: 1.0.0
     9      Contact: services@treeverse.io
    10      Generated by OpenAPI Generator (https://openapi-generator.tech)
    11  
    12      Do not edit the class manually.
    13  """  # noqa: E501
    14  
    15  
    16  from __future__ import annotations
    17  import pprint
    18  import re  # noqa: F401
    19  import json
    20  
    21  from datetime import datetime
    22  from typing import Optional
    23  try:
    24      from pydantic.v1 import BaseModel, Field, StrictBool, StrictInt, StrictStr
    25  except ImportError:
    26      from pydantic import BaseModel, Field, StrictBool, StrictInt, StrictStr
    27  from lakefs_sdk.models.commit import Commit
    28  from lakefs_sdk.models.error import Error
    29  
    30  class ImportStatus(BaseModel):
    31      """
    32      ImportStatus
    33      """
    34      completed: StrictBool = Field(...)
    35      update_time: datetime = Field(...)
    36      ingested_objects: Optional[StrictInt] = Field(None, description="Number of objects processed so far")
    37      metarange_id: Optional[StrictStr] = None
    38      commit: Optional[Commit] = None
    39      error: Optional[Error] = None
    40      __properties = ["completed", "update_time", "ingested_objects", "metarange_id", "commit", "error"]
    41  
    42      class Config:
    43          """Pydantic configuration"""
    44          allow_population_by_field_name = True
    45          validate_assignment = True
    46  
    47      def to_str(self) -> str:
    48          """Returns the string representation of the model using alias"""
    49          return pprint.pformat(self.dict(by_alias=True))
    50  
    51      def to_json(self) -> str:
    52          """Returns the JSON representation of the model using alias"""
    53          return json.dumps(self.to_dict())
    54  
    55      @classmethod
    56      def from_json(cls, json_str: str) -> ImportStatus:
    57          """Create an instance of ImportStatus from a JSON string"""
    58          return cls.from_dict(json.loads(json_str))
    59  
    60      def to_dict(self):
    61          """Returns the dictionary representation of the model using alias"""
    62          _dict = self.dict(by_alias=True,
    63                            exclude={
    64                            },
    65                            exclude_none=True)
    66          # override the default output from pydantic by calling `to_dict()` of commit
    67          if self.commit:
    68              _dict['commit'] = self.commit.to_dict()
    69          # override the default output from pydantic by calling `to_dict()` of error
    70          if self.error:
    71              _dict['error'] = self.error.to_dict()
    72          return _dict
    73  
    74      @classmethod
    75      def from_dict(cls, obj: dict) -> ImportStatus:
    76          """Create an instance of ImportStatus from a dict"""
    77          if obj is None:
    78              return None
    79  
    80          if not isinstance(obj, dict):
    81              return ImportStatus.parse_obj(obj)
    82  
    83          _obj = ImportStatus.parse_obj({
    84              "completed": obj.get("completed"),
    85              "update_time": obj.get("update_time"),
    86              "ingested_objects": obj.get("ingested_objects"),
    87              "metarange_id": obj.get("metarange_id"),
    88              "commit": Commit.from_dict(obj.get("commit")) if obj.get("commit") is not None else None,
    89              "error": Error.from_dict(obj.get("error")) if obj.get("error") is not None else None
    90          })
    91          return _obj
    92  
    93