-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathspaces.py
More file actions
187 lines (145 loc) · 5.75 KB
/
spaces.py
File metadata and controls
187 lines (145 loc) · 5.75 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
from typing import Optional, Any, List, Dict, Union
from ..client import SeamHttpClient
from .models import AbstractSpaces, Space, Batch
class Spaces(AbstractSpaces):
def __init__(self, client: SeamHttpClient, defaults: Dict[str, Any]):
self.client = client
self.defaults = defaults
def add_acs_entrances(self, *, acs_entrance_ids: List[str], space_id: str) -> None:
json_payload = {}
if acs_entrance_ids is not None:
json_payload["acs_entrance_ids"] = acs_entrance_ids
if space_id is not None:
json_payload["space_id"] = space_id
self.client.post("/spaces/add_acs_entrances", json=json_payload)
return None
def add_devices(self, *, device_ids: List[str], space_id: str) -> None:
json_payload = {}
if device_ids is not None:
json_payload["device_ids"] = device_ids
if space_id is not None:
json_payload["space_id"] = space_id
self.client.post("/spaces/add_devices", json=json_payload)
return None
def create(
self,
*,
name: str,
acs_entrance_ids: Optional[List[str]] = None,
customer_key: Optional[str] = None,
device_ids: Optional[List[str]] = None,
space_key: Optional[str] = None
) -> Space:
json_payload = {}
if name is not None:
json_payload["name"] = name
if acs_entrance_ids is not None:
json_payload["acs_entrance_ids"] = acs_entrance_ids
if customer_key is not None:
json_payload["customer_key"] = customer_key
if device_ids is not None:
json_payload["device_ids"] = device_ids
if space_key is not None:
json_payload["space_key"] = space_key
res = self.client.post("/spaces/create", json=json_payload)
return Space.from_dict(res["space"])
def delete(self, *, space_id: str) -> None:
json_payload = {}
if space_id is not None:
json_payload["space_id"] = space_id
self.client.post("/spaces/delete", json=json_payload)
return None
def get(
self, *, space_id: Optional[str] = None, space_key: Optional[str] = None
) -> Space:
json_payload = {}
if space_id is not None:
json_payload["space_id"] = space_id
if space_key is not None:
json_payload["space_key"] = space_key
res = self.client.post("/spaces/get", json=json_payload)
return Space.from_dict(res["space"])
def get_related(
self,
*,
exclude: Optional[List[str]] = None,
include: Optional[List[str]] = None,
space_ids: Optional[List[str]] = None,
space_keys: Optional[List[str]] = None
) -> Batch:
json_payload = {}
if exclude is not None:
json_payload["exclude"] = exclude
if include is not None:
json_payload["include"] = include
if space_ids is not None:
json_payload["space_ids"] = space_ids
if space_keys is not None:
json_payload["space_keys"] = space_keys
res = self.client.post("/spaces/get_related", json=json_payload)
return Batch.from_dict(res["batch"])
def list(
self,
*,
customer_key: Optional[str] = None,
limit: Optional[float] = None,
page_cursor: Optional[str] = None,
search: Optional[str] = None,
space_key: Optional[str] = None
) -> List[Space]:
json_payload = {}
if customer_key is not None:
json_payload["customer_key"] = customer_key
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
if space_key is not None:
json_payload["space_key"] = space_key
res = self.client.post("/spaces/list", json=json_payload)
return [Space.from_dict(item) for item in res["spaces"]]
def remove_acs_entrances(
self, *, acs_entrance_ids: List[str], space_id: str
) -> None:
json_payload = {}
if acs_entrance_ids is not None:
json_payload["acs_entrance_ids"] = acs_entrance_ids
if space_id is not None:
json_payload["space_id"] = space_id
self.client.post("/spaces/remove_acs_entrances", json=json_payload)
return None
def remove_devices(self, *, device_ids: List[str], space_id: str) -> None:
json_payload = {}
if device_ids is not None:
json_payload["device_ids"] = device_ids
if space_id is not None:
json_payload["space_id"] = space_id
self.client.post("/spaces/remove_devices", json=json_payload)
return None
def update(
self,
*,
acs_entrance_ids: Optional[List[str]] = None,
customer_key: Optional[str] = None,
device_ids: Optional[List[str]] = None,
name: Optional[str] = None,
space_id: Optional[str] = None,
space_key: Optional[str] = None
) -> Space:
json_payload = {}
if acs_entrance_ids is not None:
json_payload["acs_entrance_ids"] = acs_entrance_ids
if customer_key is not None:
json_payload["customer_key"] = customer_key
if device_ids is not None:
json_payload["device_ids"] = device_ids
if name is not None:
json_payload["name"] = name
if space_id is not None:
json_payload["space_id"] = space_id
if space_key is not None:
json_payload["space_key"] = space_key
res = self.client.post("/spaces/update", json=json_payload)
return Space.from_dict(res["space"])