Welcome to pluralsight client for Python’s documentation!¶
pluralsight¶
Pluralsight client library for API management
- Free software: Apache-2 license
- Documentation: https://pluralsight.readthedocs.org.
Features¶
- Invitation management using the license API
- User management using the license API
- Team information
Usage¶
from pluralsight.licensing import LicensingAPIClient
client = LicensingAPIClient(plan, api_key)
invites = client.invites.get_all_invites()
Contents:
Installation¶
At the command line:
$ easy_install pluralsight
Or, if you have virtualenvwrapper installed:
$ mkvirtualenv pluralsight
$ pip install pluralsight
Usage¶
Licensing¶
To use pluralsight in a project
1 2 3 4 5 6 7 8 9 10 11 12 | from pluralsight.licensing import LicensingAPIClient
client = LicensingAPIClient(plan, api_key)
# invites
invites = client.invites.get_all_invites()
# users
users = client.users.get_all_users()
# teams
teams = client.teams.get_all_teams()
|
Invites¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # This script will find an invitation for a user and show you the invite link
from pluralsight.licensing import LicensingAPIClient
import sys
invite_email = sys.argv[1]
plan = sys.argv[2]
api_key = sys.argv[3]
client = LicensingAPIClient(plan, api_key)
invites = client.invites.get_invites(email=invite_email)
print("Found {0} invites".format(len(invites)))
for invite in invites:
print("Link - " + invite.generate_url(plan))
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | # This script will get all the outstanding invitations and send them an email
# via your Exchange Web Access API.
# pip install exchangelib
# Tested on Python 3.5
from pluralsight.licensing import LicensingAPIClient
from exchangelib import DELEGATE, Account, Credentials, Message, Mailbox
from exchangelib.folders import HTMLBody
plan = 'your-plan-name'
api_key = 'your-license-api-key'
email = 'youremail.com'
me = "Your name <{0}>".format(email)
EXCHANGE_PASSWORD = 'password 123'
# Username in WINDOMAIN\username format. Office365 wants usernames in PrimarySMTPAddress
# ('myusername@example.com') format. UPN format is also supported.
#
# By default, fault-tolerant error handling is used. This means that calls may block for a long time
# if the server is unavailable. If you need immediate failures, add 'is_service_account=False' to
# Credentials.
credentials = Credentials(username=email, password=EXCHANGE_PASSWORD)
account = Account(primary_smtp_address=email, credentials=credentials,
autodiscover=True)
def generate_email(invite):
# Create message container - the correct MIME type is multipart/alternative.
subject = "Please register for your DevOps, Developer and Automation training portal access"
# Customize this to your own message.
html = """\
<html>
<body>
<p>Hi,<br><br>
Happy New Year. You should have received emails from me regarding access to pluralsight.com, invitations are limited
to a small group of individuals, of which you are one. Invitations will expire/be reallocated for any users that
have not accepted their invitations by the deadline. <br><br>
This is your unique registration link - <a href="{0}">{0}</a>.
<br><br>
Please register this week, <u>do not forward this email</u>. Registration links are unique.<br><br>
Regards,<br>
</p>
</body>
</html>
""".format(invite.generate_url(plan))
return Message(
account=account,
folder=account.sent,
subject=subject,
body=HTMLBody(html),
to_recipients=[Mailbox(email_address=invite.email)]
)
client = LicensingAPIClient(plan, api_key)
invites = client.invites.get_all_invites()
print("Fetched {0} invites".format(len(invites)))
for invite in invites:
msg = generate_email(invite)
try:
msg.send_and_save()
print("Sent invite reminder to {0}".format(invite.email))
except error:
print(error)
print("Failed to send invite reminder to {0}".format(invite.email))
|
pluralsight.licensing package¶
Submodules¶
pluralsight.licensing.client module¶
pluralsight.licensing.invites module¶
-
class
pluralsight.licensing.invites.
InvitesClient
(client)[source]¶ Bases:
object
Invites API
-
cancel_invite
(id)[source]¶ Cancel an invitation
Parameters: id ( str
) – The identifierReturn type: None
-
get_invite
(id)[source]¶ Fetch an invitation by ID
Parameters: id ( str
) – The identifierReturns: An instance Invite
Return type: Invite
-
get_invites
(email=None, note=None, team_id=None)[source]¶ Get invitations matching certain filters
Parameters: - email (
str
) – The users’ email address - team_id (
str
) – The team identifier - note (
str
) – Additional notes on the user
Returns: A list of
Invite
Return type: list
ofInvite
- email (
-
pluralsight.licensing.teams module¶
pluralsight.licensing.users module¶
-
class
pluralsight.licensing.users.
UsersClient
(client)[source]¶ Bases:
object
Users API
-
delete_user
(id)[source]¶ Delete an existing user
Parameters: id ( str
) – The identifierReturn type: None
-
get_all_users
(first_name=None, last_name=None, email=None, note=None, team_id=None)[source]¶ Get all users
Parameters: - first_name (
str
) – Filter by first name - last_name (
str
) – Filter by last name - email (
str
) – Filter by email - note (
str
) – Filter by note - team_id (
str
) – Filter by team ID
Returns: A list of
User
Return type: list
ofUser
- first_name (
-
Module contents¶
pluralsight.reports package¶
Submodules¶
pluralsight.reports.client module¶
-
class
pluralsight.reports.client.
ReportsAPIClient
(plan, api_key)[source]¶ Bases:
object
Reports API client
-
download_course_completion_report
(plan, path, start_date=None, end_date=None)[source]¶ Download the course completion report and store in a file
Parameters: - plan (
str
) – The plan name - path (
str
) – Path to the downloaded CSV - start_date (
str
) – (optional) Start date in format YYYY-MM-DD - end_date (
str
) – (optional) End date in format YYYY-MM-DD
- plan (
-
download_course_usage_report
(plan, path, start_date=None, end_date=None)[source]¶ Download the course usage report and store in a file
Parameters: - plan (
str
) – The plan name - path (
str
) – Path to the downloaded CSV - start_date (
str
) – (optional) Start date in format YYYY-MM-DD - end_date (
str
) – (optional) End date in format YYYY-MM-DD
- plan (
-
Module contents¶
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at https://github.com/tonybaloney/pluralsight/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “feature” is open to whoever wants to implement it.
Write Documentation¶
pluralsight could always use more documentation, whether as part of the official pluralsight docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at https://github.com/tonybaloney/pluralsight/issues.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up pluralsight for local development.
Fork the pluralsight repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/pluralsight.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv pluralsight $ cd pluralsight/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 pluralsight tests $ python setup.py test $ tox
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
- The pull request should work for Python 2.6, 2.7, 3.3, 3.4 and 3.5, and for PyPy. Check https://travis-ci.org/tonybaloney/pluralsight/pull_requests and make sure that the tests pass for all supported Python versions.
Credits¶
Development Lead¶
- Anthony Shaw <anthonyshaw@apache.org>
Contributors¶
None yet. Why not be the first?
History¶
0.16.0 (20th Jan 2017)¶
- Added string representations for the core models
0.15.0 (19th Jan 2017)¶
- Add support for filtering invitations
0.14.0 (17th Jan 2017)¶
- Add support for generating the invite URL from an invite object using
Invite
.`generate_url()`
0.13.0 (21st Dec 2016)¶
- Add support for cancelling invitations
0.12.0 (20th Dec 2016)¶
- Fix bug in initialization of invite objects
0.11.0 (20th Dec 2016)¶
- Provide the error message from the Pluralsight API on non-20x responses
0.10.0 (2016-12-12)¶
- First stable release on PyPI.
- Support for models, invites, users and reports