github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/clients/python/lakefs_sdk/models/repository_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 Optional 23 try: 24 from pydantic.v1 import BaseModel, Field, StrictBool, StrictStr, constr, validator 25 except ImportError: 26 from pydantic import BaseModel, Field, StrictBool, StrictStr, constr, validator 27 28 class RepositoryCreation(BaseModel): 29 """ 30 RepositoryCreation 31 """ 32 name: constr(strict=True) = Field(...) 33 storage_namespace: constr(strict=True) = Field(..., description="Filesystem URI to store the underlying data in (e.g. \"s3://my-bucket/some/path/\")") 34 default_branch: Optional[StrictStr] = None 35 sample_data: Optional[StrictBool] = False 36 read_only: Optional[StrictBool] = False 37 __properties = ["name", "storage_namespace", "default_branch", "sample_data", "read_only"] 38 39 @validator('name') 40 def name_validate_regular_expression(cls, value): 41 """Validates the regular expression""" 42 if not re.match(r"^[a-z0-9][a-z0-9-]{2,62}$", value): 43 raise ValueError(r"must validate the regular expression /^[a-z0-9][a-z0-9-]{2,62}$/") 44 return value 45 46 @validator('storage_namespace') 47 def storage_namespace_validate_regular_expression(cls, value): 48 """Validates the regular expression""" 49 if not re.match(r"^(s3|gs|https?|mem|local|transient):\/\/.*$", value): 50 raise ValueError(r"must validate the regular expression /^(s3|gs|https?|mem|local|transient):\/\/.*$/") 51 return value 52 53 class Config: 54 """Pydantic configuration""" 55 allow_population_by_field_name = True 56 validate_assignment = True 57 58 def to_str(self) -> str: 59 """Returns the string representation of the model using alias""" 60 return pprint.pformat(self.dict(by_alias=True)) 61 62 def to_json(self) -> str: 63 """Returns the JSON representation of the model using alias""" 64 return json.dumps(self.to_dict()) 65 66 @classmethod 67 def from_json(cls, json_str: str) -> RepositoryCreation: 68 """Create an instance of RepositoryCreation from a JSON string""" 69 return cls.from_dict(json.loads(json_str)) 70 71 def to_dict(self): 72 """Returns the dictionary representation of the model using alias""" 73 _dict = self.dict(by_alias=True, 74 exclude={ 75 }, 76 exclude_none=True) 77 return _dict 78 79 @classmethod 80 def from_dict(cls, obj: dict) -> RepositoryCreation: 81 """Create an instance of RepositoryCreation from a dict""" 82 if obj is None: 83 return None 84 85 if not isinstance(obj, dict): 86 return RepositoryCreation.parse_obj(obj) 87 88 _obj = RepositoryCreation.parse_obj({ 89 "name": obj.get("name"), 90 "storage_namespace": obj.get("storage_namespace"), 91 "default_branch": obj.get("default_branch"), 92 "sample_data": obj.get("sample_data") if obj.get("sample_data") is not None else False, 93 "read_only": obj.get("read_only") if obj.get("read_only") is not None else False 94 }) 95 return _obj 96 97