Skip to content

Commit 8a358e0

Browse files
Jose Bogarín Solanocmlccie
authored andcommitted
Include people example (#12)
* Include people API examples - Thank you Jose!
1 parent 710aea8 commit 8a358e0

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

examples/people.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
""" Script to demostrate the use of ciscosparkapi for the people API
4+
5+
The package natively retrieves your Spark access token from the
6+
SPARK_ACCESS_TOKEN environment variable. You must have this environment
7+
variable set to run this script.
8+
9+
"""
10+
11+
12+
from __future__ import print_function
13+
from ciscosparkapi import CiscoSparkAPI
14+
15+
16+
try:
17+
api = CiscoSparkAPI() # Create a CiscoSparkAPI connection object; uses your SPARK_ACCESS_TOKEN
18+
except Exception as e:
19+
print(e)
20+
21+
22+
# Get my user information
23+
print("Get my information ...")
24+
me = api.people.me()
25+
print(me)
26+
27+
# Get my user information using id
28+
print("Get my information but using id ...")
29+
me_by_id = api.people.get(me.id)
30+
print(me_by_id)
31+
32+
# Get my user information using id
33+
print("Get the list of people I know ...")
34+
people = api.people.list(displayName="Jose") # Creates a generator container (iterable) that lists the people I know
35+
for person in people:
36+
print(person.displayName) # Return the displayName of every person found

0 commit comments

Comments
 (0)