github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/clients/python/lakefs_sdk/models/ref_list.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 List
    23  try:
    24      from pydantic.v1 import BaseModel, Field, conlist
    25  except ImportError:
    26      from pydantic import BaseModel, Field, conlist
    27  from lakefs_sdk.models.pagination import Pagination
    28  from lakefs_sdk.models.ref import Ref
    29  
    30  class RefList(BaseModel):
    31      """
    32      RefList
    33      """
    34      pagination: Pagination = Field(...)
    35      results: conlist(Ref) = Field(...)
    36      __properties = ["pagination", "results"]
    37  
    38      class Config:
    39          """Pydantic configuration"""
    40          allow_population_by_field_name = True
    41          validate_assignment = True
    42  
    43      def to_str(self) -> str:
    44          """Returns the string representation of the model using alias"""
    45          return pprint.pformat(self.dict(by_alias=True))
    46  
    47      def to_json(self) -> str:
    48          """Returns the JSON representation of the model using alias"""
    49          return json.dumps(self.to_dict())
    50  
    51      @classmethod
    52      def from_json(cls, json_str: str) -> RefList:
    53          """Create an instance of RefList from a JSON string"""
    54          return cls.from_dict(json.loads(json_str))
    55  
    56      def to_dict(self):
    57          """Returns the dictionary representation of the model using alias"""
    58          _dict = self.dict(by_alias=True,
    59                            exclude={
    60                            },
    61                            exclude_none=True)
    62          # override the default output from pydantic by calling `to_dict()` of pagination
    63          if self.pagination:
    64              _dict['pagination'] = self.pagination.to_dict()
    65          # override the default output from pydantic by calling `to_dict()` of each item in results (list)
    66          _items = []
    67          if self.results:
    68              for _item in self.results:
    69                  if _item:
    70                      _items.append(_item.to_dict())
    71              _dict['results'] = _items
    72          return _dict
    73  
    74      @classmethod
    75      def from_dict(cls, obj: dict) -> RefList:
    76          """Create an instance of RefList from a dict"""
    77          if obj is None:
    78              return None
    79  
    80          if not isinstance(obj, dict):
    81              return RefList.parse_obj(obj)
    82  
    83          _obj = RefList.parse_obj({
    84              "pagination": Pagination.from_dict(obj.get("pagination")) if obj.get("pagination") is not None else None,
    85              "results": [Ref.from_dict(_item) for _item in obj.get("results")] if obj.get("results") is not None else None
    86          })
    87          return _obj
    88  
    89