GithubHelp home page GithubHelp logo

alexeiser / python-litmos-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from charliequinn/python-litmos-api

0.0 0.0 0.0 141 KB

A python client for the Litmos REST api

License: BSD 2-Clause "Simplified" License

Python 100.00%

python-litmos-api's Introduction

Litmos API

Documentation Status

Travis-CI Build Status

Coverage Status

Code Quality Status

PyPI Package latest release

PyPI Package monthly downloads

PyPI Wheel

Supported versions

Supported implementations

Litmos REST API client for python 3.5 and above

  • Free software: BSD license

Installation

pip install litmos-api

Getting started

from litmos import Litmos


API_KEY = 'AXXXXXXXXXX'
LITMOS_APP_NAME = 'jins.litmos.com'
LITMOS_SERVER_URL = 'https://api.litmos.com/v1.svc'  # https://support.litmos.com/hc/en-us/articles/227734667-Overview-Developer-API
litmos = Litmos(API_KEY, LITMOS_APP_NAME, LITMOS_SERVER_URL)


# --- User ---
# retrieve users
all_users = litmos.User.all()

# retrieve all users (with all information populated - default /users/all API endpoint only returns a subset of user fields)
# much longer than .all() as individual requests to /find/{user-id} for every user are made
all_users_with_full_details = litmos.User.all(True)

#find user by Id
user = litmos.User.find('rnjx2WaQOa11')

# search for user by username
user = litmos.User.search('[email protected]')

# update JobTitle & City fields
user.JobTitle = 'Pie eater'
user.City = 'Pieland'

# save user
user.save()

# deactivate user
user.deactivate()

# create user
user = litmos.User.create({
        'UserName': '[email protected]',
        'FirstName': 'Jo',
        'LastName': 'Baba72',
        'Email': '[email protected]'
    })

# remove all teams from user
user.remove_teams()

# delete user
# with Id
litmos.User.delete('YmrD112qlm41')

# instance
user.destroy()

# --- Team ---
# get all teams
all_teams = litmos.Team.all()

# find team by Id
team = litmos.Team.find('rnjx2WaQOa11')

# get team members
users = team.users()

# get team leaders
leaders = team.leaders()

# create team (at root level)
team = litmos.Team.create({'Name': 'A-Team','Description': 'I pity the fool!'})

# add sub-team
sub_team = litmos.Team()
sub_team.Name = 'B-Team'
sub_team.Description = 'Woohoo'

sub_team_id = team.add_sub_team(sub_team)

# assign courses to team
course1 = litmos.Course.find('d2cJSDvIU0c1')
course2 = litmos.Course.find('d2cJSDvIU0c2')
team.assign_courses([course1, course2])

# unassign courses to team
course1 = litmos.Course.find('d2cJSDvIU0c1')
course2 = litmos.Course.find('d2cJSDvIU0c2')
team.unassign_courses([course1, course2])

# --- Team members ---

# add users to team
user1 = litmos.User.find('rnjx2WaQOa11')
user2 = litmos.User.find('rnjx2WaQOa12')
team.add_users([user1, user2])

# remove users from team
team.remove_user(user2)

# --- Team leaders ---
# promote user
team.promote_team_leader(user1)

# demote user
team.demote_team_leader(user1)

Documentation

https://python-litmos-api.readthedocs.io/

Development

To run the all tests run:

nosetests

python-litmos-api's People

Contributors

charliequinn-skyscanner avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.