Skip to content

Commit 250183f

Browse files
committed
Update docstrings
1 parent 93c5dc1 commit 250183f

File tree

2 files changed

+68
-20
lines changed

2 files changed

+68
-20
lines changed

ciscosparkapi/api/rooms.py

Lines changed: 63 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
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+
"""
29

310

411
from ciscosparkapi.exceptions import ciscosparkapiException
@@ -8,9 +15,18 @@
815

916

1017
class Room(SparkData):
11-
"""Spark room-object wrapper class."""
18+
"""Model a Spark 'room' JSON object as a native Python object."""
1219

1320
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+
"""
1430
super(Room, self).__init__(json)
1531

1632
@property
@@ -50,9 +66,28 @@ def teamId(self):
5066

5167

5268
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+
"""
5479

5580
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+
"""
5691
assert isinstance(session, RestSession)
5792
super(RoomsAPI, self).__init__()
5893
self.session = session
@@ -64,25 +99,27 @@ def list(self, max=None, **query_params):
6499
65100
This method supports Cisco Spark's implmentation of RFC5988 Web Linking
66101
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.
70105
71106
Args:
72107
max(int): Limits the maximum number of rooms returned from the
73108
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.
74115
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.
83118
84119
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+
86123
"""
87124
# Process args
88125
assert max is None or isinstance(max, int)
@@ -109,7 +146,8 @@ def create(self, title, teamId=None):
109146
teamId(string): The team ID with which this room is associated.
110147
111148
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.
113151
"""
114152
# Process args
115153
assert isinstance(title, basestring)
@@ -129,7 +167,9 @@ def get(self, roomId):
129167
roomId(string): The roomId of the room.
130168
131169
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+
133173
"""
134174
# Process args
135175
assert isinstance(roomId, basestring)
@@ -151,8 +191,10 @@ def update(self, roomId, **update_attributes):
151191
A Room object with the updated Spark room details.
152192
153193
Raises:
194+
AssertionError: If the parameter types are incorrect.
154195
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+
156198
"""
157199
# Process args
158200
assert isinstance(roomId, basestring)
@@ -177,7 +219,9 @@ def delete(self, roomId):
177219
roomId(string): The roomId of the room to be deleted.
178220
179221
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+
181225
"""
182226
# Process args
183227
assert isinstance(roomId, basestring)

ciscosparkapi/sparkdata.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
u'Chris Lunsford (chrlunsf)'
2020
>>> python_obj.created
2121
u'2012-06-15T20:36:48.914Z'
22+
2223
"""
2324

2425

@@ -36,6 +37,7 @@ def _json_dict(json):
3637
3738
Raises:
3839
TypeError: If the input object is not a dictionary or string.
40+
3941
"""
4042
if isinstance(json, dict):
4143
return json
@@ -51,13 +53,14 @@ class SparkData(object):
5153
"""Model Spark JSON objects as native Python objects."""
5254

5355
def __init__(self, json):
54-
"""Create a new SparkData object from a JSON dictionary or string.
56+
"""Inits a new SparkData object from a JSON dictionary or string.
5557
5658
Args:
5759
json(dict, unicode, str): Input JSON object.
5860
5961
Raises:
6062
TypeError: If the input object is not a dictionary or string.
63+
6164
"""
6265
super(SparkData, self).__init__()
6366
self._json = _json_dict(json)
@@ -80,6 +83,7 @@ def __getattr__(self, item):
8083
Raises:
8184
AttributeError: If the JSON object does not contain the attribute
8285
requested.
86+
8387
"""
8488
if item in self._json.keys():
8589
item_data = self._json[item]

0 commit comments

Comments
 (0)