-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaccess_methods.py
More file actions
123 lines (99 loc) · 4.13 KB
/
access_methods.py
File metadata and controls
123 lines (99 loc) · 4.13 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
from typing import Optional, Any, List, Dict, Union
from ..client import SeamHttpClient
from .models import AbstractAccessMethods, ActionAttempt, AccessMethod, Batch
from .access_methods_unmanaged import AccessMethodsUnmanaged
from ..modules.action_attempts import resolve_action_attempt
class AccessMethods(AbstractAccessMethods):
def __init__(self, client: SeamHttpClient, defaults: Dict[str, Any]):
self.client = client
self.defaults = defaults
self._unmanaged = AccessMethodsUnmanaged(client=client, defaults=defaults)
@property
def unmanaged(self) -> AccessMethodsUnmanaged:
return self._unmanaged
def delete(
self,
*,
access_method_id: Optional[str] = None,
access_grant_id: Optional[str] = None,
reservation_key: Optional[str] = None
) -> None:
json_payload = {}
if access_method_id is not None:
json_payload["access_method_id"] = access_method_id
if access_grant_id is not None:
json_payload["access_grant_id"] = access_grant_id
if reservation_key is not None:
json_payload["reservation_key"] = reservation_key
self.client.post("/access_methods/delete", json=json_payload)
return None
def encode(
self,
*,
access_method_id: str,
acs_encoder_id: str,
wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = None
) -> ActionAttempt:
json_payload = {}
if access_method_id is not None:
json_payload["access_method_id"] = access_method_id
if acs_encoder_id is not None:
json_payload["acs_encoder_id"] = acs_encoder_id
res = self.client.post("/access_methods/encode", json=json_payload)
wait_for_action_attempt = (
self.defaults.get("wait_for_action_attempt")
if wait_for_action_attempt is None
else wait_for_action_attempt
)
return resolve_action_attempt(
client=self.client,
action_attempt=ActionAttempt.from_dict(res["action_attempt"]),
wait_for_action_attempt=wait_for_action_attempt,
)
def get(self, *, access_method_id: str) -> AccessMethod:
json_payload = {}
if access_method_id is not None:
json_payload["access_method_id"] = access_method_id
res = self.client.post("/access_methods/get", json=json_payload)
return AccessMethod.from_dict(res["access_method"])
def get_related(
self,
*,
access_method_ids: List[str],
exclude: Optional[List[str]] = None,
include: Optional[List[str]] = None
) -> Batch:
json_payload = {}
if access_method_ids is not None:
json_payload["access_method_ids"] = access_method_ids
if exclude is not None:
json_payload["exclude"] = exclude
if include is not None:
json_payload["include"] = include
res = self.client.post("/access_methods/get_related", json=json_payload)
return Batch.from_dict(res["batch"])
def list(
self,
*,
access_code_id: Optional[str] = None,
access_grant_id: Optional[str] = None,
access_grant_key: Optional[str] = None,
acs_entrance_id: Optional[str] = None,
device_id: Optional[str] = None,
space_id: Optional[str] = None
) -> List[AccessMethod]:
json_payload = {}
if access_code_id is not None:
json_payload["access_code_id"] = access_code_id
if access_grant_id is not None:
json_payload["access_grant_id"] = access_grant_id
if access_grant_key is not None:
json_payload["access_grant_key"] = access_grant_key
if acs_entrance_id is not None:
json_payload["acs_entrance_id"] = acs_entrance_id
if device_id is not None:
json_payload["device_id"] = device_id
if space_id is not None:
json_payload["space_id"] = space_id
res = self.client.post("/access_methods/list", json=json_payload)
return [AccessMethod.from_dict(item) for item in res["access_methods"]]