-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathacs_entrances.py
More file actions
126 lines (102 loc) · 4.35 KB
/
acs_entrances.py
File metadata and controls
126 lines (102 loc) · 4.35 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
124
125
126
from typing import Optional, Any, List, Dict, Union
from ..client import SeamHttpClient
from .models import AbstractAcsEntrances, AcsEntrance, AcsCredential, ActionAttempt
from ..modules.action_attempts import resolve_action_attempt
class AcsEntrances(AbstractAcsEntrances):
def __init__(self, client: SeamHttpClient, defaults: Dict[str, Any]):
self.client = client
self.defaults = defaults
def get(self, *, acs_entrance_id: str) -> AcsEntrance:
json_payload = {}
if acs_entrance_id is not None:
json_payload["acs_entrance_id"] = acs_entrance_id
res = self.client.post("/acs/entrances/get", json=json_payload)
return AcsEntrance.from_dict(res["acs_entrance"])
def grant_access(
self,
*,
acs_entrance_id: str,
acs_user_id: Optional[str] = None,
user_identity_id: Optional[str] = None
) -> None:
json_payload = {}
if acs_entrance_id is not None:
json_payload["acs_entrance_id"] = acs_entrance_id
if acs_user_id is not None:
json_payload["acs_user_id"] = acs_user_id
if user_identity_id is not None:
json_payload["user_identity_id"] = user_identity_id
self.client.post("/acs/entrances/grant_access", json=json_payload)
return None
def list(
self,
*,
acs_credential_id: Optional[str] = None,
acs_entrance_ids: Optional[List[str]] = None,
acs_system_id: Optional[str] = None,
connected_account_id: Optional[str] = None,
customer_key: Optional[str] = None,
limit: Optional[int] = None,
location_id: Optional[str] = None,
page_cursor: Optional[str] = None,
search: Optional[str] = None,
space_id: Optional[str] = None
) -> List[AcsEntrance]:
json_payload = {}
if acs_credential_id is not None:
json_payload["acs_credential_id"] = acs_credential_id
if acs_entrance_ids is not None:
json_payload["acs_entrance_ids"] = acs_entrance_ids
if acs_system_id is not None:
json_payload["acs_system_id"] = acs_system_id
if connected_account_id is not None:
json_payload["connected_account_id"] = connected_account_id
if customer_key is not None:
json_payload["customer_key"] = customer_key
if limit is not None:
json_payload["limit"] = limit
if location_id is not None:
json_payload["location_id"] = location_id
if page_cursor is not None:
json_payload["page_cursor"] = page_cursor
if search is not None:
json_payload["search"] = search
if space_id is not None:
json_payload["space_id"] = space_id
res = self.client.post("/acs/entrances/list", json=json_payload)
return [AcsEntrance.from_dict(item) for item in res["acs_entrances"]]
def list_credentials_with_access(
self, *, acs_entrance_id: str, include_if: Optional[List[str]] = None
) -> List[AcsCredential]:
json_payload = {}
if acs_entrance_id is not None:
json_payload["acs_entrance_id"] = acs_entrance_id
if include_if is not None:
json_payload["include_if"] = include_if
res = self.client.post(
"/acs/entrances/list_credentials_with_access", json=json_payload
)
return [AcsCredential.from_dict(item) for item in res["acs_credentials"]]
def unlock(
self,
*,
acs_credential_id: str,
acs_entrance_id: str,
wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = None
) -> ActionAttempt:
json_payload = {}
if acs_credential_id is not None:
json_payload["acs_credential_id"] = acs_credential_id
if acs_entrance_id is not None:
json_payload["acs_entrance_id"] = acs_entrance_id
res = self.client.post("/acs/entrances/unlock", 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,
)