Welcome to python-syncope’s documentation!

Documentation Status

Overview

This is an python wrapper for the Syncope REST API. You’ll be able to get, create and update User, roles and a lot more via the API.

Installation

Installation can be done with:

pip install python-syncope

API doc

Overview of the python-syncope api function that can be used to do your stuff.

python-syncope is an python wrapper for the Syncope Rest API.

class syncope.Syncope(syncope_url='', username=None, password=None, timeout=10)

Syncope Rest Interface.

create_users(arguments)

Will create an user.

Parameters:arguments (JSON) – An JSON structure for creating the user. An example can be found in the ‘examples’ folder.
Returns:False when something went wrong, or json data with all information from the just created user.
Example:
>>> import syncope
>>> syn = syncope.Syncope(syncope_url="http://192.168.10.13:9080", username="admin", password="password")
>>> create_user = '{"attributes": [{"schema": "aLong","values": [],"readonly": false},{"schema": "activationDate","values": [""],"readonly": false},{"schema": "cool","values": ["false"],"readonly": false},{"schema": "email","values": ["werner@dj-wasabi.nl"],"readonly": false},{"schema": "firstname","values": ["Werner"],"readonly": false},{"schema": "fullname","values": ["Werner Dijkerman"],"readonly": false},{"schema": "gender","values": ["M"],"readonly": false},{"schema": "loginDate","values": [""],"readonly": false},{"schema": "makeItDouble","values": [],"readonly": false},{"schema": "surname","values": ["Dijkerman"],"readonly": false},{"schema": "type","values": ["account"],"readonly": false},{"schema": "uselessReadonly","values": [""],"readonly": true},{"schema": "userId","values": ["werner@dj-wasabi.nl"],"readonly": false}],"id": 0,"derivedAttributes": [{"schema": "cn","values": [],"readonly": false}],"virtualAttributes": [],"password": "password1234","status": null,"token": null,"tokenExpireTime": null,"username": "wedijkerman","lastLoginDate": null,"creationDate": null,"changePwdDate": null,"failedLogins": null}'
>>> print syn.create_users(create_user)
{u'status': u'active', u'username': u'wedijkerman', u'creationDate': 1444152747171, <cut>}
delete_users_id(id=None)

Will delete an user.

Parameters:id (int) – The id of the user to delete.
Returns:True when user is deleted, False when user don’t exists or something failed.
edit_users_id_activate(id=None)

Will activate an user.

Parameters:id (int) – The id of the user to activate.
Returns:False when something went wrong, or json data with all information from this specific user.
Example:
>>> import syncope
>>> syn = syncope.Syncope(syncope_url="http://192.168.10.13:9080", username="admin", password="password")
>>> print syn.edit_users_id_activate(1)
{u'status': u'active', u'username': u'rossini', <cut>}
edit_users_id_reactivate(id=None)

Will reactivate an user.

Parameters:id (int) – The id of the user to reactivate.
Returns:False when something went wrong, or json data with all information from this specific user.
Example:
>>> import syncope
>>> syn = syncope.Syncope(syncope_url="http://192.168.10.13:9080", username="admin", password="password")
>>> print syn.edit_users_id_reactivate(1)
{u'status': u'active', u'username': u'rossini', <cut>}
edit_users_id_suspend(id=None)

Will suspend an user.

Parameters:id (int) – The id of the user to suspend.
Returns:False when something went wrong, or json data with all information from this specific user.
Example:
>>> import syncope
>>> syn = syncope.Syncope(syncope_url="http://192.168.10.13:9080", username="admin", password="password")
>>> print syn.edit_users_id_suspend(1)
{u'status': u'suspended', u'username': u'rossini', <cut>}
edit_users_username_activate(username=None)

Will activate an user.

Parameters:username (string) – The username of the user to activate.
Returns:False when something went wrong, or json data with all information from this specific user.
Example:
>>> import syncope
>>> syn = syncope.Syncope(syncope_url="http://192.168.10.13:9080", username="admin", password="password")
>>> print syn.edit_users_username_activate("rossini")
{u'status': u'active', u'username': u'rossini', <cut>}
edit_users_username_reactivate(username=None)

Will reactivate an user.

Parameters:username (string) – The username of the user to reactivate.
Returns:False when something went wrong, or json data with all information from this specific user.
Example:
>>> import syncope
>>> syn = syncope.Syncope(syncope_url="http://192.168.10.13:9080", username="admin", password="password")
>>> print syn.edit_users_username_reactivate("rossini")
{u'status': u'active', u'username': u'rossini', <cut>}
edit_users_username_suspend(username=None)

Will suspend an user.

Parameters:username (string) – The username of the user to suspend.
Returns:False when something went wrong, or json data with all information from this specific user.
Example:
>>> import syncope
>>> syn = syncope.Syncope(syncope_url="http://192.168.10.13:9080", username="admin", password="password")
>>> print syn.edit_users_username_suspend("rossini")
{u'status': u'suspended', u'username': u'rossini', <cut>}
get_users()

Get information from all users in JSON.

Returns:False when something went wrong, or json data with all information from all users.
get_users_count()

Will count all users found in Syncope and return an number.

Returns:False when something went wrong, or the amount of users.
Example:
>>> import syncope
>>> syn = syncope.Syncope(syncope_url="http://192.168.10.13:9080", username="admin", password="password")
>>> print syn.get_users_count()
5
get_users_id(id=None)

Will get all data from specific user, specified via id.

Parameters:id (int) – The id of the user to get information.
Returns:False when something went wrong, or json data with all information from this specific user.
Example:
>>> import syncope
>>> syn = syncope.Syncope(syncope_url="http://192.168.10.13:9080", username="admin", password="password")
>>> print syn.get_users_id(5)
{u'status': u'active', u'username': u'puccini', <cut>}

Will search an user. It will require an python dict to be used for the searching.

Parameters:arguments (JSON) – An JSON structure. See example for more information.
Returns:False when something went wrong, or json data with all information from the search request.
Example:
>>> import syncope
>>> syn = syncope.Syncope(syncope_url="http://192.168.10.13:9080", username="admin", password="password")
>>> search_req = '{"type":"LEAF","attributableCond":{"type":"EQ","schema":"username","expression":"vivaldi"}}'
>>> print syn.get_users_search(search_req)
{u'status': u'active', u'username': u'vivaldi', <cut>}
>>> search_req = '{"type":"LEAF","resourceCond":{"resourceName":"ws-target-resource-1"}}'
>>> print syn.get_users_search(search_req)
{u'status': u'active', u'username': u'vivaldi', <cut>}
get_users_search_count(arguments=None)

Will count the users matching the search request.

Parameters:arguments (JSON) – An JSON structure. See example for more information.
Returns:False when something went wrong, or the amount of users matching the request.
Example:
>>> import syncope
>>> syn = syncope.Syncope(syncope_url="http://192.168.10.13:9080", username="admin", password="password")
>>> search_req = '{"type":"LEAF","attributableCond":{"type":"EQ","schema":"username","expression":"vivaldi"}}'
>>> print syn.get_users_search_count(search_req)
5
>>> search_req = '{"type":"LEAF","resourceCond":{"resourceName":"ws-target-resource-1"}}'
>>> print syn.get_users_search_count(search_req)
1
get_users_search_page(arguments=None, page=None, size=None)

Will search an user and will return the data by pages.

Parameters:
  • arguments (JSON) – An JSON structure. See example for more information.
  • page (int) – The page it should return.
  • size (int) – The amount of results per page.
Returns:

False when something went wrong, or json data with all information from the search request.

Example:
>>> import syncope
>>> syn = syncope.Syncope(syncope_url="http://192.168.10.13:9080", username="admin", password="password")
>>> search_req = '{"type":"LEAF","attributableCond":{"type":"EQ","schema":"status","expression":"active"}}'
>>> print syn.get_users_search_page(search_user, 1, 1)
{u'status': u'active', u'username': u'rossini', <cut>}
>>> print syn.get_users_search_page(search_user, 3, 1)
{u'status': u'active', u'username': u'vivaldi', <cut>}
get_users_username(username=None)

Will get all data from specific user, specified via username.

Parameters:username (string) – The username of the user to get information.
Returns:False when something went wrong, or json data with all information from this specific user.
Example:
>>> import syncope
>>> syn = syncope.Syncope(syncope_url="http://192.168.10.13:9080", username="admin", password="password")
>>> print syn.get_users_username("puccini")
{u'status': u'active', u'username': u'puccini', <cut>}

Indices and tables