General¶
-
tnglib.get_sp_path()¶ Get the configured SP url.
Returns: the SP url.
-
tnglib.set_sp_path(new_base_path)¶ Set the path were the SP can be reached.
Parameters: new_base_path – SP url
-
tnglib.sp_health_check()¶ Check if SP is reachable.
Returns: bool.
-
tnglib.set_timeout(timeout_in)¶ Set the timeout.
Parameters: timeout_in – new request timeout
-
tnglib.update_token(username, password, store_token=False)¶ Obtain a new authentication token
Parameters: - username – A string.
- password – A string.
- store_token – A bool. Store the token in local file system.
Returns: A string containing the token.
-
tnglib.get_token()¶ Obtain the token from storage
Returns: A string containing the token.
-
tnglib.is_token_valid()¶ Check whether the stored token is still valid.
Returns: A bool.
-
tnglib.add_token_to_header(token)¶ Set the header for all requests with the token.
Parameters: token – the token
-
tnglib.get_return_header()¶ Return the header of the last curl response.
Returns: dictionary containg header of last curl response.
-
tnglib.register(username, password, name='', email='', role='')¶ Register a new user.
Parameters: - username – A string containing the username
- password – A string containing the password
- name – Optional. A string containing a name
- email – Optional. A string containing an email adres
- role – Optional. A string containing a role
Returns: A bool.
-
tnglib.delete_users()¶ Clean the DB deleting all users .
Returns: A tuple. [0] is a bool with the result
-
tnglib.delete_user(username)¶ Deleting a specific user
Parameters: username – username of the user Returns: A tuple. [0] is a bool with the result
-
tnglib.logout_user(token)¶ Log out the session user.
Parameters: token – Token that authorizes the session user Returns: A tuple. [0] is a bool with the result
-
tnglib.user_info(username)¶ Log out the session user.
Parameters: username – Logged in username Returns: A tuple. [0] is a bool with the result [1] is a json with the user information