github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/clients/python/lakefs_sdk/models/diff.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  
    22  from typing import Optional
    23  try:
    24      from pydantic.v1 import BaseModel, Field, StrictInt, StrictStr, validator
    25  except ImportError:
    26      from pydantic import BaseModel, Field, StrictInt, StrictStr, validator
    27  
    28  class Diff(BaseModel):
    29      """
    30      Diff
    31      """
    32      type: StrictStr = Field(...)
    33      path: StrictStr = Field(...)
    34      path_type: StrictStr = Field(...)
    35      size_bytes: Optional[StrictInt] = Field(None, description="represents the size of the added/changed/deleted entry")
    36      __properties = ["type", "path", "path_type", "size_bytes"]
    37  
    38      @validator('type')
    39      def type_validate_enum(cls, value):
    40          """Validates the enum"""
    41          if value not in ('added', 'removed', 'changed', 'conflict', 'prefix_changed'):
    42              raise ValueError("must be one of enum values ('added', 'removed', 'changed', 'conflict', 'prefix_changed')")
    43          return value
    44  
    45      @validator('path_type')
    46      def path_type_validate_enum(cls, value):
    47          """Validates the enum"""
    48          if value not in ('common_prefix', 'object'):
    49              raise ValueError("must be one of enum values ('common_prefix', 'object')")
    50          return value
    51  
    52      class Config:
    53          """Pydantic configuration"""
    54          allow_population_by_field_name = True
    55          validate_assignment = True
    56  
    57      def to_str(self) -> str:
    58          """Returns the string representation of the model using alias"""
    59          return pprint.pformat(self.dict(by_alias=True))
    60  
    61      def to_json(self) -> str:
    62          """Returns the JSON representation of the model using alias"""
    63          return json.dumps(self.to_dict())
    64  
    65      @classmethod
    66      def from_json(cls, json_str: str) -> Diff:
    67          """Create an instance of Diff from a JSON string"""
    68          return cls.from_dict(json.loads(json_str))
    69  
    70      def to_dict(self):
    71          """Returns the dictionary representation of the model using alias"""
    72          _dict = self.dict(by_alias=True,
    73                            exclude={
    74                            },
    75                            exclude_none=True)
    76          return _dict
    77  
    78      @classmethod
    79      def from_dict(cls, obj: dict) -> Diff:
    80          """Create an instance of Diff from a dict"""
    81          if obj is None:
    82              return None
    83  
    84          if not isinstance(obj, dict):
    85              return Diff.parse_obj(obj)
    86  
    87          _obj = Diff.parse_obj({
    88              "type": obj.get("type"),
    89              "path": obj.get("path"),
    90              "path_type": obj.get("path_type"),
    91              "size_bytes": obj.get("size_bytes")
    92          })
    93          return _obj
    94  
    95