github.com/treeverse/lakefs@v1.24.1-0.20240520134607-95648127bfb0/clients/python/lakefs_sdk/models/statement.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, StrictStr, conlist, validator
    25  except ImportError:
    26      from pydantic import BaseModel, Field, StrictStr, conlist, validator
    27  
    28  class Statement(BaseModel):
    29      """
    30      Statement
    31      """
    32      effect: StrictStr = Field(...)
    33      resource: StrictStr = Field(...)
    34      action: conlist(StrictStr, min_items=1) = Field(...)
    35      __properties = ["effect", "resource", "action"]
    36  
    37      @validator('effect')
    38      def effect_validate_enum(cls, value):
    39          """Validates the enum"""
    40          if value not in ('allow', 'deny'):
    41              raise ValueError("must be one of enum values ('allow', 'deny')")
    42          return value
    43  
    44      class Config:
    45          """Pydantic configuration"""
    46          allow_population_by_field_name = True
    47          validate_assignment = True
    48  
    49      def to_str(self) -> str:
    50          """Returns the string representation of the model using alias"""
    51          return pprint.pformat(self.dict(by_alias=True))
    52  
    53      def to_json(self) -> str:
    54          """Returns the JSON representation of the model using alias"""
    55          return json.dumps(self.to_dict())
    56  
    57      @classmethod
    58      def from_json(cls, json_str: str) -> Statement:
    59          """Create an instance of Statement from a JSON string"""
    60          return cls.from_dict(json.loads(json_str))
    61  
    62      def to_dict(self):
    63          """Returns the dictionary representation of the model using alias"""
    64          _dict = self.dict(by_alias=True,
    65                            exclude={
    66                            },
    67                            exclude_none=True)
    68          return _dict
    69  
    70      @classmethod
    71      def from_dict(cls, obj: dict) -> Statement:
    72          """Create an instance of Statement from a dict"""
    73          if obj is None:
    74              return None
    75  
    76          if not isinstance(obj, dict):
    77              return Statement.parse_obj(obj)
    78  
    79          _obj = Statement.parse_obj({
    80              "effect": obj.get("effect"),
    81              "resource": obj.get("resource"),
    82              "action": obj.get("action")
    83          })
    84          return _obj
    85  
    86