1
- """Cisco Spark rooms API wrapper classes."""
1
+ """Cisco Spark rooms API wrapper classes.
2
+
3
+ Classes:
4
+ Room: Models a Spark 'room' JSON object as a native Python object.
5
+ RoomsAPI: Wrappers the Cisco Spark Rooms-API and exposes the API calls as
6
+ Python method calls that return native Python objects.
7
+
8
+ """
2
9
3
10
4
11
from ciscosparkapi .exceptions import ciscosparkapiException
8
15
9
16
10
17
class Room (SparkData ):
11
- """Spark room- object wrapper class ."""
18
+ """Model a Spark ' room' JSON object as a native Python object ."""
12
19
13
20
def __init__ (self , json ):
21
+ """Initialize a new Room data object from a JSON dictionary or string.
22
+
23
+ Args:
24
+ json(dict, unicode, str): Input JSON object.
25
+
26
+ Raises:
27
+ TypeError: If the input object is not a dictionary or string.
28
+
29
+ """
14
30
super (Room , self ).__init__ (json )
15
31
16
32
@property
@@ -50,9 +66,28 @@ def teamId(self):
50
66
51
67
52
68
class RoomsAPI (object ):
53
- """Cisco Spark rooms API request wrapper class."""
69
+ """Cisco Spark Rooms-API wrapper class.
70
+
71
+ Wrappers the Cisco Spark Rooms-API and exposes the API calls as Python
72
+ method calls that return native Python objects.
73
+
74
+ Attributes:
75
+ session(RestSession): The RESTful session object to be used for API
76
+ calls to the Cisco Spark service.
77
+
78
+ """
54
79
55
80
def __init__ (self , session ):
81
+ """Inits a new RoomAPI object with the provided RestSession.
82
+
83
+ Args:
84
+ session(RestSession): The RESTful session object to be used for
85
+ API calls to the Cisco Spark service.
86
+
87
+ Raises:
88
+ AssertionError: If the parameter types are incorrect.
89
+
90
+ """
56
91
assert isinstance (session , RestSession )
57
92
super (RoomsAPI , self ).__init__ ()
58
93
self .session = session
@@ -64,25 +99,27 @@ def list(self, max=None, **query_params):
64
99
65
100
This method supports Cisco Spark's implmentation of RFC5988 Web Linking
66
101
to provide pagination support. It returns an iterator that
67
- incrementally yields all rooms returned by the query. It will
68
- automatically and efficiently request the additional 'pages' of
69
- responses from Spark as needed until all responses have been exhausted .
102
+ incrementally yield all rooms returned by the query. It will
103
+ automatically request additional 'pages' of responses from Spark as
104
+ needed until all responses have been returned .
70
105
71
106
Args:
72
107
max(int): Limits the maximum number of rooms returned from the
73
108
Spark service per request.
109
+ **query_params:
110
+ teamId(string): Limit the rooms to those associated with a
111
+ team.
112
+ type(string):
113
+ 'direct': returns all 1-to-1 rooms.
114
+ 'group': returns all group rooms.
74
115
75
- **query_params:
76
- teamId(string): Limit the rooms to those associated with a team.
77
- type(string):
78
- 'direct': returns all 1-to-1 rooms.
79
- 'group': returns all group rooms.
80
-
81
- Returns:
82
- A Room iterator.
116
+ Yields:
117
+ Room: The the next room from the Cisco Spark query.
83
118
84
119
Raises:
85
- SparkApiError: If the list request fails.
120
+ AssertionError: If the parameter types are incorrect.
121
+ SparkApiError: If the Cisco Spark cloud returns an error.
122
+
86
123
"""
87
124
# Process args
88
125
assert max is None or isinstance (max , int )
@@ -109,7 +146,8 @@ def create(self, title, teamId=None):
109
146
teamId(string): The team ID with which this room is associated.
110
147
111
148
Raises:
112
- SparkApiError: If the create operation fails.
149
+ AssertionError: If the parameter types are incorrect.
150
+ SparkApiError: If the Cisco Spark cloud returns an error.
113
151
"""
114
152
# Process args
115
153
assert isinstance (title , basestring )
@@ -129,7 +167,9 @@ def get(self, roomId):
129
167
roomId(string): The roomId of the room.
130
168
131
169
Raises:
132
- SparkApiError: If the get operation fails.
170
+ AssertionError: If the parameter types are incorrect.
171
+ SparkApiError: If the Cisco Spark cloud returns an error.
172
+
133
173
"""
134
174
# Process args
135
175
assert isinstance (roomId , basestring )
@@ -151,8 +191,10 @@ def update(self, roomId, **update_attributes):
151
191
A Room object with the updated Spark room details.
152
192
153
193
Raises:
194
+ AssertionError: If the parameter types are incorrect.
154
195
ciscosparkapiException: If an update attribute is not provided.
155
- SparkApiError: If the update operation fails.
196
+ SparkApiError: If the Cisco Spark cloud returns an error.
197
+
156
198
"""
157
199
# Process args
158
200
assert isinstance (roomId , basestring )
@@ -177,7 +219,9 @@ def delete(self, roomId):
177
219
roomId(string): The roomId of the room to be deleted.
178
220
179
221
Raises:
180
- SparkApiError: If the delete operation fails.
222
+ AssertionError: If the parameter types are incorrect.
223
+ SparkApiError: If the Cisco Spark cloud returns an error.
224
+
181
225
"""
182
226
# Process args
183
227
assert isinstance (roomId , basestring )
0 commit comments