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