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