1
- """Cisco Spark rooms API wrapper classes.
1
+ """Cisco Spark Rooms- API wrapper classes.
2
2
3
3
Classes:
4
4
Room: Models a Spark 'room' JSON object as a native Python object.
@@ -18,7 +18,7 @@ class Room(SparkData):
18
18
"""Model a Spark 'room' JSON object as a native Python object."""
19
19
20
20
def __init__ (self , json ):
21
- """Initialize a new Room data object from a JSON dictionary or string.
21
+ """Init a new Person data object from a JSON dictionary or string.
22
22
23
23
Args:
24
24
json(dict, unicode, str): Input JSON object.
@@ -78,7 +78,7 @@ class RoomsAPI(object):
78
78
"""
79
79
80
80
def __init__ (self , session ):
81
- """Inits a new RoomAPI object with the provided RestSession.
81
+ """Init a new RoomAPI object with the provided RestSession.
82
82
83
83
Args:
84
84
session(RestSession): The RESTful session object to be used for
@@ -111,14 +111,14 @@ def list(self, max=None, **query_params):
111
111
max(int): Limits the maximum number of rooms returned from the
112
112
Spark service per request.
113
113
**query_params:
114
- teamId(string ): Limit the rooms to those associated with a
115
- team.
116
- type(string ):
114
+ teamId(unicode, str ): Limit the rooms to those associated with
115
+ a team.
116
+ type(unicode, str ):
117
117
'direct': returns all 1-to-1 rooms.
118
118
'group': returns all group rooms.
119
119
120
120
Yields:
121
- Room : The the next room from the Cisco Spark query.
121
+ Person : The the next room from the Cisco Spark query.
122
122
123
123
Raises:
124
124
AssertionError: If the parameter types are incorrect.
@@ -136,22 +136,24 @@ def list(self, max=None, **query_params):
136
136
params [utf8 (param )] = value
137
137
# API request - get items
138
138
items = self .session .get_items ('rooms' , params = params )
139
- # Yield Room objects created from the returned items JSON objects
139
+ # Yield Person objects created from the returned items JSON objects
140
140
for item in items :
141
141
yield Room (item )
142
142
143
143
def create (self , title , teamId = None ):
144
- """Creates a room.
144
+ """Create a room.
145
145
146
146
The authenticated user is automatically added as a member of the room.
147
147
148
148
Args:
149
- title(string): A user-friendly name for the room.
150
- teamId(string): The team ID with which this room is associated.
149
+ title(unicode, str): A user-friendly name for the room.
150
+ teamId(unicode, str): The team ID with which this room is
151
+ associated.
151
152
152
153
Raises:
153
154
AssertionError: If the parameter types are incorrect.
154
155
SparkApiError: If the Cisco Spark cloud returns an error.
156
+
155
157
"""
156
158
# Process args
157
159
assert isinstance (title , basestring )
@@ -160,15 +162,15 @@ def create(self, title, teamId=None):
160
162
post_data [u'title' ] = utf8 (title )
161
163
if teamId : post_data [u'teamId' ] = utf8 (teamId )
162
164
# API request
163
- json_room_obj = self .session .post ('rooms' , json = post_data )
164
- # Return a Room object created from the response JSON data
165
- return Room (json_room_obj )
165
+ json_obj = self .session .post ('rooms' , json = post_data )
166
+ # Return a Person object created from the response JSON data
167
+ return Room (json_obj )
166
168
167
169
def get (self , roomId ):
168
- """Gets the details of a room.
170
+ """Get the details of a room, by ID .
169
171
170
172
Args:
171
- roomId(string ): The roomId of the room.
173
+ roomId(unicode, str ): The roomId of the room.
172
174
173
175
Raises:
174
176
AssertionError: If the parameter types are incorrect.
@@ -178,21 +180,21 @@ def get(self, roomId):
178
180
# Process args
179
181
assert isinstance (roomId , basestring )
180
182
# API request
181
- json_room_obj = self .session .get ('rooms/' + roomId )
182
- # Return a Room object created from the response JSON data
183
- return Room (json_room_obj )
183
+ json_obj = self .session .get ('rooms/' + roomId )
184
+ # Return a Person object created from the response JSON data
185
+ return Room (json_obj )
184
186
185
187
def update (self , roomId , ** update_attributes ):
186
- """Updates details for a room.
188
+ """Update details for a room.
187
189
188
190
Args:
189
- roomId(string ): The roomId of the room to be updated.
191
+ roomId(unicode, str ): The roomId of the room to be updated.
190
192
191
193
**update_attributes:
192
- title(string ): A user-friendly name for the room.
194
+ title(unicode, str ): A user-friendly name for the room.
193
195
194
196
Returns:
195
- A Room object with the updated Spark room details.
197
+ A Person object with the updated Spark room details.
196
198
197
199
Raises:
198
200
AssertionError: If the parameter types are incorrect.
@@ -204,23 +206,23 @@ def update(self, roomId, **update_attributes):
204
206
assert isinstance (roomId , basestring )
205
207
# Process update_attributes keyword arguments
206
208
if not update_attributes :
207
- error_message = "You must provide at least one " \
208
- "**update_attributes keyword argument; 0 provided ."
209
+ error_message = "At least one **update_attributes keyword " \
210
+ "argument must be specified ."
209
211
raise ciscosparkapiException (error_message )
210
212
put_data = {}
211
213
for param , value in update_attributes .items ():
212
214
if isinstance (value , basestring ): value = utf8 (value )
213
215
put_data [utf8 (param )] = value
214
216
# API request
215
- json_room_obj = self .session .post ('rooms' , json = put_data )
216
- # Return a Room object created from the response JSON data
217
- return Room (json_room_obj )
217
+ json_obj = self .session .post ('rooms' , json = put_data )
218
+ # Return a Person object created from the response JSON data
219
+ return Room (json_obj )
218
220
219
221
def delete (self , roomId ):
220
222
"""Delete a room.
221
223
222
224
Args:
223
- roomId(string ): The roomId of the room to be deleted.
225
+ roomId(unicode, str ): The roomId of the room to be deleted.
224
226
225
227
Raises:
226
228
AssertionError: If the parameter types are incorrect.
0 commit comments