forked from cyberark/ark-sdk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathark_model.py
More file actions
55 lines (39 loc) · 1.76 KB
/
Copy pathark_model.py
File metadata and controls
55 lines (39 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from typing import Any, Callable, Optional
from humps import camelize
from pydantic import BaseModel, Field, validator
from pydantic.generics import GenericModel
class ArkModel(BaseModel):
class Config:
allow_population_by_field_name = True
class ArkGenericModel(ArkModel, GenericModel):
pass
class ArkPresentableModel(ArkModel):
class Config:
use_enum_values = True
class ArkCamelizedModel(ArkPresentableModel):
class Config:
alias_generator = camelize
class ArkTitleizedModel(ArkPresentableModel):
class Config:
alias_generator = lambda s: s.replace("_", " ").title().replace(" ", "")
ArkPollCallback = Callable
class ArkPollableModel(ArkCamelizedModel):
poll: Optional[bool] = Field(description='Whether to poll for any async api action')
poll_timeout_seconds: Optional[int] = Field(description='For how long to poll in seconds', default=3600)
poll_progress_callback: Optional[Any] = Field(
description='Callback for poll progression, '
'sends the current async task, '
'seconds remaining whether the poll operation '
'finished or not and whether the operation was successful '
'or not, Note that its set to any due to pydantic internal prints'
)
poll_allow_refreshable_connection: Optional[bool] = Field(
description='Whether to allow authentication refreshing during poll operations '
'This is useful for when the poll operation is long and prolongs the actual token time'
)
# pylint: disable=no-self-use,no-self-argument
@validator('poll_progress_callback')
def poll_callback_must_be_callable(cls, v):
if v is not None and not isinstance(v, ArkPollCallback):
raise ValueError('Must be callable')
return v