@@ -41,31 +41,69 @@ def __init__(self, json):
4141
4242 @property
4343 def id (self ):
44- return self ._json ['id' ]
44+ """The person's unique ID."""
45+ return self ._json .get ('id' )
4546
4647 @property
4748 def emails (self ):
49+ """Email address(es) of the person.
50+
51+ CURRENT LIMITATION: Spark (today) only allows you to provide a single
52+ email address for a person. The list data type was selected to enable
53+ future support for providing multiple email address.
54+
55+ """
4856 return self ._json ['emails' ]
4957
5058 @property
5159 def displayName (self ):
52- return self ._json ['displayName' ]
60+ """Full name of the person."""
61+ return self ._json .get ('displayName' )
62+
63+ @property
64+ def firstName (self ):
65+ """First name of the person."""
66+ return self ._json .get ('firstName' )
67+
68+ @property
69+ def lastName (self ):
70+ """Last name of the person."""
71+ return self ._json .get ('lastName' )
5372
5473 @property
5574 def avatar (self ):
56- return self ._json ['avatar' ]
75+ """URL to the person's avatar in PNG format."""
76+ return self ._json .get ('avatar' )
5777
5878 @property
59- def created (self ):
60- return self ._json ['created' ]
79+ def orgId (self ):
80+ """ID of the organization to which this person belongs."""
81+ return self ._json .get ('orgId' )
6182
6283 @property
63- def lastActivity (self ):
64- return self ._json ['lastActivity' ]
84+ def roles (self ):
85+ """Roles of the person."""
86+ return self ._json .get ('roles' )
87+
88+ @property
89+ def licenses (self ):
90+ """Licenses allocated to the person."""
91+ return self ._json .get ('licenses' )
92+
93+ @property
94+ def created (self ):
95+ """The date and time the person was created."""
96+ return self ._json .get ('created' )
6597
6698 @property
6799 def status (self ):
68- return self ._json ['status' ]
100+ """The person's current status."""
101+ return self ._json .get ('status' )
102+
103+ @property
104+ def lastActivity (self ):
105+ """The date and time of the person's last activity."""
106+ return self ._json .get ('lastActivity' )
69107
70108
71109class PeopleAPI (object ):
@@ -146,6 +184,103 @@ def list(self, email=None, displayName=None, max=None):
146184 for item in items :
147185 yield Person (item )
148186
187+ def create (self , emails , ** person_attributes ):
188+ """Create a new user account for a given organization
189+
190+ Only an admin can create a new user account.
191+
192+ You must specify displayName and/or firstName and lastName.
193+
194+ Args:
195+ emails(list): Email address(es) of the person. (list of strings)
196+ CURRENT LIMITATION: Spark (today) only allows you to provide a
197+ single email address for a person. The list data type was
198+ selected to enable future support for providing multiple email
199+ address.
200+ **person_attributes:
201+ displayName(string_types): Full name of the person
202+ firstName(string_types): First name of the person
203+ lastName(string_types): Last name of the person
204+ avatar(string_types): URL to the person's avatar in PNG format
205+ orgId(string_types): ID of the organization to which this
206+ person belongs
207+ roles(list): Roles of the person (list of strings containing
208+ the role IDs to be assigned to the person)
209+ licenses(list): Licenses allocated to the person (list of
210+ strings containing the license IDs to be allocated to the
211+ person)
212+
213+ Returns:
214+ Person: With the details of the created person.
215+
216+ Raises:
217+ AssertionError: If the parameter types are incorrect.
218+ ciscosparkapiException: If required parameters have been omitted.
219+ SparkApiError: If the Cisco Spark cloud returns an error.
220+
221+ """
222+ # Process args
223+ assert isinstance (emails , string_types ) and len (emails ) == 1
224+ post_data = {}
225+ post_data ['emails' ] = emails
226+ post_data .update (person_attributes )
227+
228+ # API request
229+ json_obj = self ._session .post ('people' , json = post_data )
230+
231+ # Return a Room object created from the returned JSON object
232+ return Person (json_obj )
233+
234+ def update (self , personId , ** person_attributes ):
235+ """Update details for a person, by ID.
236+
237+ Only an admin can update a person details.
238+
239+ Args:
240+ personId(string_types): The ID of the person to be updated.
241+ **person_attributes:
242+ emails(list): Email address(es) of the person. (list of
243+ strings) CURRENT LIMITATION: Spark (today) only allows you
244+ to provide a single email address for a person. The list
245+ data type was selected to enable future support for
246+ providing multiple email address.
247+ displayName(string_types): Full name of the person
248+ firstName(string_types): First name of the person
249+ lastName(string_types): Last name of the person
250+ avatar(string_types): URL to the person's avatar in PNG format
251+ orgId(string_types): ID of the organization to which this
252+ person belongs
253+ roles(list): Roles of the person (list of strings containing
254+ the role IDs to be assigned to the person)
255+ licenses(list): Licenses allocated to the person (list of
256+ strings containing the license IDs to be allocated to the
257+ person)
258+
259+ Returns:
260+ Person: With the updated person details.
261+
262+ Raises:
263+ AssertionError: If the parameter types are incorrect.
264+ ciscosparkapiException: If an update attribute is not provided.
265+ SparkApiError: If the Cisco Spark cloud returns an error.
266+
267+ """
268+ # Process args
269+ assert isinstance (personId , string_types )
270+
271+ # Process update_attributes keyword arguments
272+ if not person_attributes :
273+ error_message = "At least one **update_attributes keyword " \
274+ "argument must be specified."
275+ raise ciscosparkapiException (error_message )
276+
277+ # API request
278+ json_obj = self ._session .put ('people/' + personId ,
279+ json = person_attributes )
280+
281+ # Return a Person object created from the returned JSON object
282+ return Person (json_obj )
283+
149284 def get (self , personId ):
150285 """Get person details, by personId.
151286
0 commit comments