Module pyinventory.api.user
Functions
def activate_user(client: SymphonyClient, user: User) -> NoneType
-
Activate the user which would allow the user to login again to symphony
Args
user (
User
): user to activateRaises
FailedOperationException
- internal inventory error
Example
user = client.get_user(email="user@test.com") client.activate_user(user=user)
def add_user(client: SymphonyClient, email: str, password: str) -> User
-
Adds new user to inventory with its email and password
Args
email
:str
- the email address of the user
password
:str
- password the user would connect with
Returns
User
objectRaises
EntityNotFoundError
: the user was not created properlyFailedOperationException
- internal inventory error
AssertionError
- The user was not created for some known reason
HTTPError
- Error with connection
Example
user = client.add_user(email="user@test.com", password="P0ssW!rd0f43")
def deactivate_user(client: SymphonyClient, user: User) -> NoneType
-
Deactivate the user which would prevent the user from login in to symphony Users in symphony are never deleted. Only de-activated.
Args: user (
User
): user to deactivateRaises: FailedOperationException: internal inventory error
Example:
user = client.get_user(email="user@test.com") client.deactivate_user(user=user)
def edit_user(client: SymphonyClient, user: User, new_password: Union[str, NoneType] = None, new_role: Union[pyinventory.graphql.user_role_enum.UserRole, NoneType] = None) -> NoneType
-
Edit user password and role
Args
- user (
User
): user to edit new_password
:Optional[str]
- new password the user would connect with
new_role (
UserRole
): user new roleRaises
FailedOperationException
- internal inventory error
AssertionError
- The user was not edited for some known reason
HTTPError
- Error with connection
Example
user = client.add_user(email="user@test.com", password="P0ssW!rd0f43") client.edit_user(user=user, new_password="New_Password4Ever", new_role=UserRole.ADMIN)
- user (
def get_active_users(client: SymphonyClient) -> List[User]
-
Get the list of the active users in the system
Returns
List[
pyinventory.common.data_class.User
]Raises
FailedOperationException
- internal inventory error
Example
users = client.get_active_users() for user in users: print(user.email)
def get_user(client: SymphonyClient, email: str) -> User
-
Returns
User
object by its emailArgs
email
:str
- the email address the user registered with
Returns
User
objectRaises
EntityNotFoundError
: the user was not foundFailedOperationException
- internal inventory error
Example
user = client.get_user(email="user@test.com")
def get_users(client: SymphonyClient) -> List[User]
-
Get the list of users in the system (both active and deactivate)
Returns
List[
pyinventory.common.data_class.User
]Raises
FailedOperationException
- internal inventory error
Example
users = client.get_users() for user in users: print(user.email)