proknow.Users
– Users¶
-
class
proknow.Users.
Users
(proknow, requestor)¶ This class should be used to interact with the users in a ProKnow organization. It is instantiated for you as an attribute of the
proknow.ProKnow.ProKnow
class.-
__init__
(proknow, requestor)¶ Initializes the Users class.
Parameters: - proknow (proknow.ProKnow.ProKnow) – The ProKnow instance that is instantiating the object.
- requestor (proknow.Requestor.Requestor) – An object used to make API requests.
-
create
(email, name, role_id, password=None)¶ Creates a new user.
Parameters: - email (str) – The email of the user.
- name (str) – The name of the user.
- role_id (str) – The id of the role for the user.
- password (str, optional) – The password of the user.
Returns: A representation of the created item.
Return type: Raises: AssertionError
– If the input parameters are invalid.
-
delete
(identifier)¶ Deletes a user.
Parameters: identifier (str) – The id of the user to delete. Raises: AssertionError
– If the input parameters are invalid.
-
find
(**kwargs)¶ Finds a user by id, email, or name.
Parameters: **kwargs – A dictionary of keyword arguments that may include identifier, email, and name. These arguments are considered—in that order—to find matching roles. Returns: A representation of the matching user. Return type: proknow.Users.UserItem
-
get
(identifier)¶ Gets a user.
Parameters: identifier (str) – The id of the user to get. Returns: an object representing a user in the organization Return type: proknow.Users.UserItem
-
query
()¶ Queries for users.
Returns: A list of proknow.Users.UserSummary
objects, each representing a summarized user in the organization.Return type: list
-
-
class
proknow.Users.
UserSummary
(users, user)¶ This class represents a summary view of a user. It’s instantiated by the
proknow.Users.Users.query()
method to represent each of the users returned in a query result.-
id
¶ str – The id of the user (readonly).
-
email
¶ str – The email of the user (readonly).
-
name
¶ str – The name of the user (readonly).
-
data
¶ dict – The summary representation of the user as returned from the API (readonly).
-
__init__
(users, user)¶ Initializes the UserSummary class.
Parameters: - users (proknow.Users.Users) – The User instance that is instantiating the object.
- user (dict) – A dictionary of user attributes.
-
get
()¶ Gets the complete representation of the user.
Returns: an object representing a user in the organization Return type: proknow.Users.UserItem
-
-
class
proknow.Users.
UserItem
(users, user)¶ This class represents a user. It’s instantiated by the
proknow.Users.Users
class as a complete representation of a user.-
id
¶ str – The id of the user (readonly).
-
data
¶ dict – The complete representation of the user as returned from the API (readonly).
-
name
¶ str – The name of the user.
-
email
¶ str – The email of the user.
-
active
¶ bool – Indicates whether the user is active.
-
role_id
¶ str – The id of the role for the user.
-
__init__
(users, user)¶ Initializes the UserItem class.
Parameters: - users (proknow.Users.Users) – The User instance that is instantiating the object.
- user (dict) – A dictionary of user attributes.
-
delete
()¶ Deletes the user.
-
save
()¶ Saves the changes made to a user.
Example
The following example illustrates how to find a user by its email, set it to inactive, and save it:
pk = ProKnow('https://example.proknow.com', credentials_file="./credentials.json") jsmith = pk.users.find(email='jsmith@example.com') jsmith.active = False jsmith.save()
-