-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Include people API examples - Thank you Jose!
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
""" Script to demostrate the use of ciscosparkapi for the people API | ||
The package natively retrieves your Spark access token from the | ||
SPARK_ACCESS_TOKEN environment variable. You must have this environment | ||
variable set to run this script. | ||
""" | ||
|
||
|
||
from __future__ import print_function | ||
from ciscosparkapi import CiscoSparkAPI | ||
|
||
|
||
try: | ||
api = CiscoSparkAPI() # Create a CiscoSparkAPI connection object; uses your SPARK_ACCESS_TOKEN | ||
except Exception as e: | ||
print(e) | ||
|
||
|
||
# Get my user information | ||
print("Get my information ...") | ||
me = api.people.me() | ||
print(me) | ||
|
||
# Get my user information using id | ||
print("Get my information but using id ...") | ||
me_by_id = api.people.get(me.id) | ||
print(me_by_id) | ||
|
||
# Get my user information using id | ||
print("Get the list of people I know ...") | ||
people = api.people.list(displayName="Jose") # Creates a generator container (iterable) that lists the people I know | ||
for person in people: | ||
print(person.displayName) # Return the displayName of every person found |