-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaccess_grants.py
More file actions
207 lines (176 loc) · 7.51 KB
/
access_grants.py
File metadata and controls
207 lines (176 loc) · 7.51 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
from typing import Optional, Any, List, Dict, Union
from ..client import SeamHttpClient
from .models import AbstractAccessGrants, AccessGrant, Batch
from .access_grants_unmanaged import AccessGrantsUnmanaged
class AccessGrants(AbstractAccessGrants):
def __init__(self, client: SeamHttpClient, defaults: Dict[str, Any]):
self.client = client
self.defaults = defaults
self._unmanaged = AccessGrantsUnmanaged(client=client, defaults=defaults)
@property
def unmanaged(self) -> AccessGrantsUnmanaged:
return self._unmanaged
def create(
self,
*,
requested_access_methods: List[Dict[str, Any]],
user_identity_id: Optional[str] = None,
user_identity: Optional[Dict[str, Any]] = None,
access_grant_key: Optional[str] = None,
acs_entrance_ids: Optional[List[str]] = None,
customization_profile_id: Optional[str] = None,
device_ids: Optional[List[str]] = None,
ends_at: Optional[str] = None,
location: Optional[Dict[str, Any]] = None,
location_ids: Optional[List[str]] = None,
name: Optional[str] = None,
reservation_key: Optional[str] = None,
space_ids: Optional[List[str]] = None,
space_keys: Optional[List[str]] = None,
starts_at: Optional[str] = None
) -> AccessGrant:
json_payload = {}
if requested_access_methods is not None:
json_payload["requested_access_methods"] = requested_access_methods
if user_identity_id is not None:
json_payload["user_identity_id"] = user_identity_id
if user_identity is not None:
json_payload["user_identity"] = user_identity
if access_grant_key is not None:
json_payload["access_grant_key"] = access_grant_key
if acs_entrance_ids is not None:
json_payload["acs_entrance_ids"] = acs_entrance_ids
if customization_profile_id is not None:
json_payload["customization_profile_id"] = customization_profile_id
if device_ids is not None:
json_payload["device_ids"] = device_ids
if ends_at is not None:
json_payload["ends_at"] = ends_at
if location is not None:
json_payload["location"] = location
if location_ids is not None:
json_payload["location_ids"] = location_ids
if name is not None:
json_payload["name"] = name
if reservation_key is not None:
json_payload["reservation_key"] = reservation_key
if space_ids is not None:
json_payload["space_ids"] = space_ids
if space_keys is not None:
json_payload["space_keys"] = space_keys
if starts_at is not None:
json_payload["starts_at"] = starts_at
res = self.client.post("/access_grants/create", json=json_payload)
return AccessGrant.from_dict(res["access_grant"])
def delete(self, *, access_grant_id: str) -> None:
json_payload = {}
if access_grant_id is not None:
json_payload["access_grant_id"] = access_grant_id
self.client.post("/access_grants/delete", json=json_payload)
return None
def get(
self,
*,
access_grant_id: Optional[str] = None,
access_grant_key: Optional[str] = None
) -> AccessGrant:
json_payload = {}
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
res = self.client.post("/access_grants/get", json=json_payload)
return AccessGrant.from_dict(res["access_grant"])
def get_related(
self,
*,
access_grant_ids: Optional[List[str]] = None,
access_grant_keys: Optional[List[str]] = None,
exclude: Optional[List[str]] = None,
include: Optional[List[str]] = None
) -> Batch:
json_payload = {}
if access_grant_ids is not None:
json_payload["access_grant_ids"] = access_grant_ids
if access_grant_keys is not None:
json_payload["access_grant_keys"] = access_grant_keys
if exclude is not None:
json_payload["exclude"] = exclude
if include is not None:
json_payload["include"] = include
res = self.client.post("/access_grants/get_related", json=json_payload)
return Batch.from_dict(res["batch"])
def list(
self,
*,
access_code_id: Optional[str] = None,
access_grant_ids: Optional[List[str]] = None,
access_grant_key: Optional[str] = None,
acs_entrance_id: Optional[str] = None,
acs_system_id: Optional[str] = None,
customer_key: Optional[str] = None,
limit: Optional[float] = None,
location_id: Optional[str] = None,
page_cursor: Optional[str] = None,
reservation_key: Optional[str] = None,
space_id: Optional[str] = None,
user_identity_id: Optional[str] = None
) -> List[AccessGrant]:
json_payload = {}
if access_code_id is not None:
json_payload["access_code_id"] = access_code_id
if access_grant_ids is not None:
json_payload["access_grant_ids"] = access_grant_ids
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 acs_system_id is not None:
json_payload["acs_system_id"] = acs_system_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 reservation_key is not None:
json_payload["reservation_key"] = reservation_key
if space_id is not None:
json_payload["space_id"] = space_id
if user_identity_id is not None:
json_payload["user_identity_id"] = user_identity_id
res = self.client.post("/access_grants/list", json=json_payload)
return [AccessGrant.from_dict(item) for item in res["access_grants"]]
def request_access_methods(
self, *, access_grant_id: str, requested_access_methods: List[Dict[str, Any]]
) -> AccessGrant:
json_payload = {}
if access_grant_id is not None:
json_payload["access_grant_id"] = access_grant_id
if requested_access_methods is not None:
json_payload["requested_access_methods"] = requested_access_methods
res = self.client.post(
"/access_grants/request_access_methods", json=json_payload
)
return AccessGrant.from_dict(res["access_grant"])
def update(
self,
*,
access_grant_id: str,
ends_at: Optional[str] = None,
name: Optional[str] = None,
starts_at: Optional[str] = None
) -> None:
json_payload = {}
if access_grant_id is not None:
json_payload["access_grant_id"] = access_grant_id
if ends_at is not None:
json_payload["ends_at"] = ends_at
if name is not None:
json_payload["name"] = name
if starts_at is not None:
json_payload["starts_at"] = starts_at
self.client.post("/access_grants/update", json=json_payload)
return None