4.6.9. System Users¶
Warning
This API is deprecated.
Axonius API v2 is now available, we recommend you move to API v2.
New features will no longer be added to this API. Axonius will only provide bug fixes.
API for working with system users.
- class axonius_api_client.api.system.system_users.SystemUsers(auth, log_level='debug', **kwargs)[source]¶
Bases:
ModelMixinsAPI for working with system users.
- get(generator=False)[source]¶
Get Axonius system users.
Examples
Create a
clientusingaxonius_api_client.connect.Connect>>> users = client.system_users.get() >>> [x['user_name'] for x in users] ['admin']
- Parameters:
generator (
bool) – return an iterator for objects that will yield rows as they are fetched- Return type:
typing.Union[typing.Generator[dict,None,None],typing.List[dict]]
- get_cached()[source]¶
Get Axonius system users using a cache mechanism.
- Return type:
typing.List[axonius_api_client.api.json_api.system_users.SystemUser]
- get_by_name(name)[source]¶
Get a user by name.
Examples
Create a
clientusingaxonius_api_client.connect.Connect>>> user = client.system_users.get_by_name(name="admin") >>> user["uuid"] '5f76721bebd8d8b5459b56c8'
- Parameters:
name (
str) – user name- Raises:
NotFoundError – if user not found
- Return type:
- get_by_uuid(uuid)[source]¶
Get a user by uuid.
Examples
Create a
clientusingaxonius_api_client.connect.Connect>>> user = client.system_users.get_by_uuid(uuid="5f76721bebd8d8b5459b56cc") >>> user["name"] 'administrator'
- Parameters:
uuid (
str) – uuid- Raises:
NotFoundError – if user not found
- Return type:
- add(name, password, role_name, first_name='', last_name='', email='', generate_password_link=False, email_password_link=False)[source]¶
Create a user.
Examples
Create a
clientusingaxonius_api_client.connect.ConnectCreate a user with the Admin role
>>> user = client.system_users.add( ... name="test1", ... password="test1", ... role_name="Admin", ... first="bad", ... last="wolf", ... email="badwolf@badwolf.com", ... ) >>> user['uuid'] '5f7ca7f1e4557d5cba415f12'
- Parameters:
name (
str) – usernamepassword (
str) – passwordrole_name (
str) – role namefirst_name (
str) – first namelast_name (
str) – last nameemail (
str) – email addressgenerate_password_link (
bool) – create a password reset linkemail_password_link (
bool) – email the password reset link to a users configured email address
- Raises:
ApiError – if user already exists matching name
- Return type:
- set_role(name, role_name)[source]¶
Change the role of a user.
Examples
Create a
clientusingaxonius_api_client.connect.Connect>>> user = client.system_users.set_role(name='test1', role_name='Viewer') >>> user['role_name'] 'Viewer'
- set_first_last(name, first, last)[source]¶
Change the first and last name of a user.
Examples
Create a
clientusingaxonius_api_client.connect.Connect>>> user = client.system_users.set_first_last(name='test1', first='Bad', last='Wolf') >>> user['first_name'] 'Bad' >>> user['last_name'] 'Wolf' >>> user['full_name'] 'Bad Wolf'
- set_password(name, password)[source]¶
Change the password for a user.
Examples
Create a
clientusingaxonius_api_client.connect.Connect>>> user = client.system_users.set_password(name='test1', password='super_secure')
- set_email(name, email)[source]¶
Change the email address for a user.
Examples
Create a
clientusingaxonius_api_client.connect.Connect>>> user = client.system_users.set_email(name='test1', email='bad@wolf.com') >>> user['email'] 'bad@wolf.com'
- set_ignore_role_assignment_rules(name, enabled)[source]¶
Set the ignore role assignment rules flag of an external user.
Examples
Create a
clientusingaxonius_api_client.connect.Connect>>> user = client.system_users.set_ignore_role_assignment_rules( ... name='test1', enabled=True ... )
- delete_by_name(name)[source]¶
Delete a user by name.
Examples
Create a
clientusingaxonius_api_client.connect.Connect>>> client.system_users.delete_by_name(name='test1')
- get_password_reset_link(name)[source]¶
Generate a password reset link for a user.
Examples
Create a
clientusingaxonius_api_client.connect.Connect>>> link = client.system_users.get_password_reset_link(name='test1') >>> link 'https://10.20.0.61/login?token=LUayznSkfLUjm3A2fIs_zAF-4CzcxRZc7DHOfhOkMRI'
Notes
This link can be provided to the user. They can browse to it, or they can use axonshell tools use-password-reset-token or use
axonius_api_client.api.system.signup.Signup.use_password_reset_token()
- email_password_reset_link(name, email=None, for_new_user=False, link='')[source]¶
Email a password reset link for a user.
Examples
Create a
clientusingaxonius_api_client.connect.ConnectUse the email address defined in the users account
>>> link, email_used = client.system_users.email_password_reset_link(name='test1') >>> link 'https://10.20.0.61/login?token=V-YW8DnCverKTgvsToMAJwGPqXtQQeeNuBFkN4dE4ew' >>> email_used 'jim@badwolf.com'
Use a custom email address
>>> link, email_used = client.system_users.email_password_reset_link( ... name='test1', email='james@badwolf.com' ... ) >>> link 'https://10.20.0.61/login?token=V-YW8DnCverKTgvsToMAJwGPqXtQQeeNuBFkN4dE4ew' >>> email_used 'james@badwolf.com'
Use the template for a new user instead of password reset
>>> link, email_used = client.system_users.email_password_reset_link( ... name='test1', email='james@badwolf.com', for_new_user=True ... )
Notes
This returns the password reset link like
get_password_reset_link()and the email address that was used to send the email.- Parameters:
name (
str) – usernameemail (
typing.Optional[str]) – use a custom email address to send the email instead of the users defined email address. required if the user has no defined email address.for_new_user (
bool) – use the new user email template instead of the password reset email templatelink (
str) – use the specified password reset link vs a newly generated one
- Return type:
- _get(limit=2000, offset=0, **kwargs)[source]¶
Direct API method to get all users.
- Parameters:
- Return type:
typing.List[axonius_api_client.api.json_api.system_users.SystemUser]
- _add(user_name, role_id, password=None, auto_generated_password=False, first_name='', last_name='', email='')[source]¶
Direct API method to add a user.
- Parameters:
- Return type:
axonius_api_client.api.json_api.system_users.SystemUser
- _delete(uuid)[source]¶
Direct API method to delete a user.
- Parameters:
uuid (
str) – user UUID- Return type:
axonius_api_client.api.json_api.system_users.SystemUser
- _update(uuid, user_name, role_id, password, first_name=None, last_name=None, email=None, last_updated=None, source=None, pic_name=None, ignore_role_assignment_rules=None, **kwargs)[source]¶
Direct API method to update a user.
- Parameters:
uuid (
str) – user UUIDuser – user metadata
user_name (
str) –role_id (
str) –password (
str) –first_name (
typing.Optional[str]) –last_name (
typing.Optional[str]) –email (
typing.Optional[str]) –last_updated (
typing.Optional[str]) –source (
typing.Optional[str]) –pic_name (
typing.Optional[str]) –ignore_role_assignment_rules (
typing.Optional[bool]) –
- Return type:
axonius_api_client.api.json_api.system_users.SystemUser
- _tokens_generate(uuid, user_name)[source]¶
Direct API method to generate a password reset link for a user.
- _tokens_notify(uuid, email, invite=False)[source]¶
Direct API method to send a password reset link to a user.
- _update_user_attr(name, must_be_internal, attr, value)[source]¶
Set an attribute on a user.
- Parameters:
- Raises:
ApiError –
if user is external but must be internal for the attribute to be set * if user is internal but must be external for the attribute to be set
- Return type:
-
LOG:
logging.Logger= None¶ Logger for this object.
- __init__(auth, log_level='debug', **kwargs)¶
Mixins for API Models.
- _init_auth(**kwargs)¶
Post init method for subclasses to use for overriding auth setup.
-
auth:
axonius_api_client.auth.model.AuthModel= None¶ Authentication model with bound Http object to use for requests.
-
http:
axonius_api_client.http.Http= None¶ Http object to use for requests.