github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/clients/python/lakefs_sdk/models/setup_state.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, validator
    25  except ImportError:
    26      from pydantic import BaseModel, Field, StrictBool, StrictStr, validator
    27  from lakefs_sdk.models.login_config import LoginConfig
    28  
    29  class SetupState(BaseModel):
    30      """
    31      SetupState
    32      """
    33      state: Optional[StrictStr] = None
    34      comm_prefs_missing: Optional[StrictBool] = Field(None, description="true if the comm prefs are missing.")
    35      login_config: Optional[LoginConfig] = None
    36      __properties = ["state", "comm_prefs_missing", "login_config"]
    37  
    38      @validator('state')
    39      def state_validate_enum(cls, value):
    40          """Validates the enum"""
    41          if value is None:
    42              return value
    43  
    44          if value not in ('initialized', 'not_initialized'):
    45              raise ValueError("must be one of enum values ('initialized', 'not_initialized')")
    46          return value
    47  
    48      class Config:
    49          """Pydantic configuration"""
    50          allow_population_by_field_name = True
    51          validate_assignment = True
    52  
    53      def to_str(self) -> str:
    54          """Returns the string representation of the model using alias"""
    55          return pprint.pformat(self.dict(by_alias=True))
    56  
    57      def to_json(self) -> str:
    58          """Returns the JSON representation of the model using alias"""
    59          return json.dumps(self.to_dict())
    60  
    61      @classmethod
    62      def from_json(cls, json_str: str) -> SetupState:
    63          """Create an instance of SetupState from a JSON string"""
    64          return cls.from_dict(json.loads(json_str))
    65  
    66      def to_dict(self):
    67          """Returns the dictionary representation of the model using alias"""
    68          _dict = self.dict(by_alias=True,
    69                            exclude={
    70                            },
    71                            exclude_none=True)
    72          # override the default output from pydantic by calling `to_dict()` of login_config
    73          if self.login_config:
    74              _dict['login_config'] = self.login_config.to_dict()
    75          return _dict
    76  
    77      @classmethod
    78      def from_dict(cls, obj: dict) -> SetupState:
    79          """Create an instance of SetupState from a dict"""
    80          if obj is None:
    81              return None
    82  
    83          if not isinstance(obj, dict):
    84              return SetupState.parse_obj(obj)
    85  
    86          _obj = SetupState.parse_obj({
    87              "state": obj.get("state"),
    88              "comm_prefs_missing": obj.get("comm_prefs_missing"),
    89              "login_config": LoginConfig.from_dict(obj.get("login_config")) if obj.get("login_config") is not None else None
    90          })
    91          return _obj
    92  
    93