-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathacs_credentials.py
More file actions
192 lines (158 loc) · 6.77 KB
/
acs_credentials.py
File metadata and controls
192 lines (158 loc) · 6.77 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
from typing import Optional, Any, List, Dict, Union
from ..client import SeamHttpClient
from .models import AbstractAcsCredentials, AcsCredential, AcsEntrance
class AcsCredentials(AbstractAcsCredentials):
def __init__(self, client: SeamHttpClient, defaults: Dict[str, Any]):
self.client = client
self.defaults = defaults
def assign(
self,
*,
acs_credential_id: str,
acs_user_id: Optional[str] = None,
user_identity_id: Optional[str] = None
) -> None:
json_payload = {}
if acs_credential_id is not None:
json_payload["acs_credential_id"] = acs_credential_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/credentials/assign", json=json_payload)
return None
def create(
self,
*,
access_method: str,
acs_system_id: Optional[str] = None,
acs_user_id: Optional[str] = None,
allowed_acs_entrance_ids: Optional[List[str]] = None,
assa_abloy_vostio_metadata: Optional[Dict[str, Any]] = None,
code: Optional[str] = None,
credential_manager_acs_system_id: Optional[str] = None,
ends_at: Optional[str] = None,
is_multi_phone_sync_credential: Optional[bool] = None,
salto_space_metadata: Optional[Dict[str, Any]] = None,
starts_at: Optional[str] = None,
user_identity_id: Optional[str] = None,
visionline_metadata: Optional[Dict[str, Any]] = None
) -> AcsCredential:
json_payload = {}
if access_method is not None:
json_payload["access_method"] = access_method
if acs_system_id is not None:
json_payload["acs_system_id"] = acs_system_id
if acs_user_id is not None:
json_payload["acs_user_id"] = acs_user_id
if allowed_acs_entrance_ids is not None:
json_payload["allowed_acs_entrance_ids"] = allowed_acs_entrance_ids
if assa_abloy_vostio_metadata is not None:
json_payload["assa_abloy_vostio_metadata"] = assa_abloy_vostio_metadata
if code is not None:
json_payload["code"] = code
if credential_manager_acs_system_id is not None:
json_payload["credential_manager_acs_system_id"] = (
credential_manager_acs_system_id
)
if ends_at is not None:
json_payload["ends_at"] = ends_at
if is_multi_phone_sync_credential is not None:
json_payload["is_multi_phone_sync_credential"] = (
is_multi_phone_sync_credential
)
if salto_space_metadata is not None:
json_payload["salto_space_metadata"] = salto_space_metadata
if starts_at is not None:
json_payload["starts_at"] = starts_at
if user_identity_id is not None:
json_payload["user_identity_id"] = user_identity_id
if visionline_metadata is not None:
json_payload["visionline_metadata"] = visionline_metadata
res = self.client.post("/acs/credentials/create", json=json_payload)
return AcsCredential.from_dict(res["acs_credential"])
def delete(self, *, acs_credential_id: str) -> None:
json_payload = {}
if acs_credential_id is not None:
json_payload["acs_credential_id"] = acs_credential_id
self.client.post("/acs/credentials/delete", json=json_payload)
return None
def get(self, *, acs_credential_id: str) -> AcsCredential:
json_payload = {}
if acs_credential_id is not None:
json_payload["acs_credential_id"] = acs_credential_id
res = self.client.post("/acs/credentials/get", json=json_payload)
return AcsCredential.from_dict(res["acs_credential"])
def list(
self,
*,
acs_user_id: Optional[str] = None,
acs_system_id: Optional[str] = None,
user_identity_id: Optional[str] = None,
created_before: Optional[str] = None,
is_multi_phone_sync_credential: Optional[bool] = None,
limit: Optional[float] = None,
page_cursor: Optional[str] = None,
search: Optional[str] = None
) -> List[AcsCredential]:
json_payload = {}
if acs_user_id is not None:
json_payload["acs_user_id"] = acs_user_id
if acs_system_id is not None:
json_payload["acs_system_id"] = acs_system_id
if user_identity_id is not None:
json_payload["user_identity_id"] = user_identity_id
if created_before is not None:
json_payload["created_before"] = created_before
if is_multi_phone_sync_credential is not None:
json_payload["is_multi_phone_sync_credential"] = (
is_multi_phone_sync_credential
)
if limit is not None:
json_payload["limit"] = limit
if page_cursor is not None:
json_payload["page_cursor"] = page_cursor
if search is not None:
json_payload["search"] = search
res = self.client.post("/acs/credentials/list", json=json_payload)
return [AcsCredential.from_dict(item) for item in res["acs_credentials"]]
def list_accessible_entrances(self, *, acs_credential_id: str) -> List[AcsEntrance]:
json_payload = {}
if acs_credential_id is not None:
json_payload["acs_credential_id"] = acs_credential_id
res = self.client.post(
"/acs/credentials/list_accessible_entrances", json=json_payload
)
return [AcsEntrance.from_dict(item) for item in res["acs_entrances"]]
def unassign(
self,
*,
acs_credential_id: str,
acs_user_id: Optional[str] = None,
user_identity_id: Optional[str] = None
) -> None:
json_payload = {}
if acs_credential_id is not None:
json_payload["acs_credential_id"] = acs_credential_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/credentials/unassign", json=json_payload)
return None
def update(
self,
*,
acs_credential_id: str,
code: Optional[str] = None,
ends_at: Optional[str] = None
) -> None:
json_payload = {}
if acs_credential_id is not None:
json_payload["acs_credential_id"] = acs_credential_id
if code is not None:
json_payload["code"] = code
if ends_at is not None:
json_payload["ends_at"] = ends_at
self.client.post("/acs/credentials/update", json=json_payload)
return None