github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/clients/python/lakefs_sdk/models/commit.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 Dict, List, Optional 23 try: 24 from pydantic.v1 import BaseModel, Field, StrictInt, StrictStr, conint, conlist 25 except ImportError: 26 from pydantic import BaseModel, Field, StrictInt, StrictStr, conint, conlist 27 28 class Commit(BaseModel): 29 """ 30 Commit 31 """ 32 id: StrictStr = Field(...) 33 parents: conlist(StrictStr) = Field(...) 34 committer: StrictStr = Field(...) 35 message: StrictStr = Field(...) 36 creation_date: StrictInt = Field(..., description="Unix Epoch in seconds") 37 meta_range_id: StrictStr = Field(...) 38 metadata: Optional[Dict[str, StrictStr]] = None 39 generation: Optional[StrictInt] = None 40 version: Optional[conint(strict=True, le=1, ge=0)] = None 41 __properties = ["id", "parents", "committer", "message", "creation_date", "meta_range_id", "metadata", "generation", "version"] 42 43 class Config: 44 """Pydantic configuration""" 45 allow_population_by_field_name = True 46 validate_assignment = True 47 48 def to_str(self) -> str: 49 """Returns the string representation of the model using alias""" 50 return pprint.pformat(self.dict(by_alias=True)) 51 52 def to_json(self) -> str: 53 """Returns the JSON representation of the model using alias""" 54 return json.dumps(self.to_dict()) 55 56 @classmethod 57 def from_json(cls, json_str: str) -> Commit: 58 """Create an instance of Commit from a JSON string""" 59 return cls.from_dict(json.loads(json_str)) 60 61 def to_dict(self): 62 """Returns the dictionary representation of the model using alias""" 63 _dict = self.dict(by_alias=True, 64 exclude={ 65 }, 66 exclude_none=True) 67 return _dict 68 69 @classmethod 70 def from_dict(cls, obj: dict) -> Commit: 71 """Create an instance of Commit from a dict""" 72 if obj is None: 73 return None 74 75 if not isinstance(obj, dict): 76 return Commit.parse_obj(obj) 77 78 _obj = Commit.parse_obj({ 79 "id": obj.get("id"), 80 "parents": obj.get("parents"), 81 "committer": obj.get("committer"), 82 "message": obj.get("message"), 83 "creation_date": obj.get("creation_date"), 84 "meta_range_id": obj.get("meta_range_id"), 85 "metadata": obj.get("metadata"), 86 "generation": obj.get("generation"), 87 "version": obj.get("version") 88 }) 89 return _obj 90 91