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