User¶
-
class
alpine.user.
User
(base_url, session, token)¶ A class for interacting with user accounts.
-
class
AdminRole
¶ Convenience strings for administrator roles.
-
class
ApplicationRole
¶ Convenience strings for application roles.
-
create
(username, password, first_name, last_name, email, title=None, dept=None, notes=None, admin_role=None, app_role=None, email_notification=False)¶ Create a user account with the specified parameters.
Parameters: - username (str) – A unique name.
- password (str) – Password of the user.
- first_name (str) – First name of the user.
- last_name (str) – Last name of the user.
- email (str) – Email of the user.
- title (str) – Title of the user.
- dept (str) – Department of the user.
- notes (str) – Notes for the user.
- admin_role (str) – Administration role. Refer to User.AdminRole. By default, the user is not an Admin.
- app_role (str) – Application role. Refer to User.ApplicationRole. The default application role is User.ApplicationRole.BusinessUser.
- email_notification (bool) – Option to subscribe to email notifications.
Returns: Created user information or error message.
Return type: dict
Example:
>>> user_info = session.create(username = 'demo_user', password = 'temp_password', >>> first_name = 'Demo', last_name = 'User', >>> email = 'demouser@alpinenow.com', title = 'Data Scientist', >>> dept = 'Product')
-
delete
(user_id)¶ Attempts to delete the given user. Will fail if the user does not exist.
Parameters: user_id (int) – ID of user to be deleted. Returns: None. Return type: NoneType Raises: UserNotFoundException – The username does not exist. Example:
>>> session.user.delete(user_id = 51)
-
get
(user_id)¶ Get a user’s metadata.
Parameters: user_id (str) – A unique user ID. Returns: Selected user’s metadata. Return type: dict Raises: UserNotFoundException – The user does not exist. Example:
>>> session.user.get(user_id = 51)
-
get_id
(username)¶ Gets the ID of the user. Will throw an exception if the user does not exist.
Parameters: username (str) – Unique user name Returns: ID of the user. Return type: int Raises: UserNotFoundException – The username does not exist. Example
>>> user_id = session.user.get_id(username = 'demo_user') >>> print(user_id) 51
-
get_list
(per_page=100)¶ Get a list of all users’ metadata.
Parameters: per_page (int) – Maximum number to fetch with each API call. Returns: A list of all the users’ data. Return type: list of dict Example:
>>> all_users = session.user.get_list() >>> len(all_users) 99
-
update
(user_id, first_name=None, last_name=None, email=None, title=None, dept=None, notes=None, admin_role=None, app_role=None, email_notification=None)¶ Only included fields will be updated.
Parameters: - user_id (str) – ID of the user to update.
- first_name (str) – New first name of the user.
- last_name (str) – New last name of the user.
- email (str) – New email of the user.
- title (str) – New title of the user.
- dept (str) – New department of the user.
- notes (str) – New notes for the user.
- admin_role (str) – New Administration Role. Refer to User.AdminRole.
- app_role (str) – New Application Role. Refer to User.ApplicationRole.
- email_notification (bool) – Change option to subscribe to email notifications.
Returns: Updated user information.
Return type: dict
Raises: UserNotFoundException – The user does not exist.
Example:
>>> updated_info = session.user.update(user_id = 51, title = "Senior Data Scientist")
-
class