Users (risksense_api.__subject.__users.__users
)¶
User module defined for different user related api endpoints.
- class risksense_api.__subject.__users.__users.Users(profile)[source]¶
Bases:
Subject
Class for user function definitions.
- Parameters:
profile (
object
) – Profile Object
To utlise user function:
- Usage:
self.{risksenseobjectname}.users.{function}
Examples
To create an user using
create()
function>>> self.{risksenseobjectname}.users.create(args)
- __init__(profile)[source]¶
Initialization of Users object.
- Parameters:
profile (
object
) – Profile Object
- downloadfilterinexport(filename, filters, client_id=None)[source]¶
Download user data based on search filters.
- Parameters:
filename (
str
) – Name of the filefilters (
list
) – A list of dictionaries containing filter parametersclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
Note
IGNORE - Internal funtion for csv dump
- remove_users(useruuid, client_id=None, csvdump=False)[source]¶
Delete a user
- Parameters:
useruuid (
str
) – User UUIDclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.csvdump (
bool
) – Toggle to dump data in csv
- Return type:
int
- Returns:
Job Id
Examples
>>> apiobj = self.{risksenseobject}.users.remove_users('123-456')
Note
You can also dump the data of the group search in a csv file. Just make csvdump as True:
>>> self.{risksenseobject}.users.remove_users('123-456',csvdump=True)
- get_user_iaminfo(useruuid, client_id=None, csvdump=False)[source]¶
Get IAM info of a user.
- Parameters:
useruuid (
str
) – User UUIDclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.csvdump (
bool
) – Toggle to dump data in csv
- Return type:
dict
- Returns:
Json response
Examples
>>> apiobj = self.{risksenseobject}.users.get_user_iaminfo('123-456')
Note
You can also dump the data of the group search in a csv file. Just make csvdump as True:
>>> self.{risksenseobject}.users.get_user_iaminfo('123-456',csvdump=True)
- assign_group(filter, targetgroupids, client_id=None, csvdump=False)[source]¶
Assign users to groups.
- Parameters:
filter (
list
) – Search Filtertargetgroupids (
list
) – Target group idsclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.csvdump (
bool
) – Toggle to dump data in csv
- Return type:
dict
- Returns:
Json response
Examples
>>> apiobj = self.{risksenseobject}.users.assign_group([{"field":"id","exclusive":False,"operator":"EXACT","value":"6506","implicitFilters":[]}],[1234])
Note
You can also dump the data of the group search in a csv file. Just make csvdump as True:
>>> self.{risksenseobject}.users.assign_group([{"field":"id","exclusive":False,"operator":"EXACT","value":"6506","implicitFilters":[]}],[1234],csvdump=True)
- unassign_group(filter, targetgroupids, client_id=None, csvdump=False)[source]¶
Unassign users to groups.
- Parameters:
filter (
list
) – Search Filtertargetgroupids (
list
) – Target group idsclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.csvdump (
bool
) – Toggle to dump data in csv
- Return type:
dict
- Returns:
Json response
Examples
>>> apiobj = self.{risksenseobject}.users.unassign_group([{"field":"id","exclusive":False,"operator":"EXACT","value":"6506","implicitFilters":[]}],[1234])
Note
You can also dump the data of the group search in a csv file. Just make csvdump as True:
>>> self.{risksenseobject}.users.unassign_group([{"field":"id","exclusive":False,"operator":"EXACT","value":"6506","implicitFilters":[]}],[1234],csvdump=True)
- get_my_profile(csvdump=False)[source]¶
Get the profile for the user that owns the API key being used.
- Parameters:
csvdump (
bool
) – Toggle to dump data in csv- Return type:
dict
- Returns:
A dictionary containing the user’s profile.
Examples
>>> apiobj = self.{risksenseobject}.users.get_my_profile()
Note
You can also dump the data of the user profile in a csv file. Just make csvdump as True:
>>> self.{risksenseobject}.users.get_my_profile(csvdump=True)
- disallow_tokens(client_ids, user_id)[source]¶
Disallow use of tokens for a user.
- Parameters:
client_ids (
list
) – List of client Idsuser_id (
int
) – The ID of the user to be disallowed from token use.
- Return type:
bool
- Returns:
True/False indicating success or failure of submission of the operation.
Examples
>>> apiobj = self.{risksenseobject}.users.disallow_tokens([123,456],1234)
- allow_tokens(client_ids, user_id)[source]¶
Allow use of tokens for a user.
- Parameters:
client_ids (
list
) – List of client Idsuser_id (
int
) – The ID of the user to be disallowed from token use.
- Return type:
bool
- Returns:
True/False indicating success or failure of submission of the operation.
Examples
>>> apiobj = self.{risksenseobject}.users.allow_tokens([123,456],1234)
- getexporttemplate(client_id=None)[source]¶
Gets configurable export template for application findings.
- Parameters:
client_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.- Return type:
list
- Returns:
The Exportable fields
Examples
>>> apiobj = self.{risksenseobject}.users.getexporttemplate()
- export(search_filters, file_name, row_count='All', file_type='CSV', client_id=None)[source]¶
Initiates an export job on the platform for user based on the provided filter(s).
- Parameters:
search_filters (
list
) – A list of dictionaries containing filter parameters.file_name (
str
) – The name to be used for the exported file.row_count (
str
) – No of rows to be exported. Possible options : ExportRowNumbers.ROW_5000, ExportRowNumbers.ROW_10000, ExportRowNumbers.ROW_25000, ExportRowNumbers.ROW_50000, ExportRowNumbers.ROW_100000, ExportRowNumbers.ROW_ALLfile_type (
str
) – File type to export. ExportFileType.CSV, ExportFileType.XML, or ExportFileType.XLSXclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Return type:
int
- Returns:
The job ID in the platform from is returned.
Examples
>>> apiobj = self.{risksenseobject}.users.export([{"field":"id","exclusive":False,"operator":"EXACT","value":"6506","implicitFilters":[]}])
- get_single_search_page(search_filters, page_num=0, page_size=150, sort_field='id', sort_dir='ASC', client_id=None)[source]¶
Searches for and returns users based on the provided filter(s) and other parameters.
- Parameters:
search_filters (
list
) – A list of dictionaries containing filter parameters.page_num (
int
) – Page number of results to be returned.page_size (
int
) – Number of results to be returned per page.sort_field (
str
) – Name of field to sort results on.sort_dir (
str
) – Direction to sort. SortDirection.ASC or SortDirection.DESCclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Return type:
dict
- Returns:
Paginated JSON response from the platform.
Examples
>>> apiobj = self.{risksenseobject}.users.get_single_search_page([{"field":"id","exclusive":False,"operator":"EXACT","value":"6506","implicitFilters":[]}])
- search(search_filters, page_size=150, sort_field='id', sort_dir='ASC', csvdump=False, client_id=None)[source]¶
Searches for and returns users based on the provided filter(s) and other parameters. Rather than returning paginated results, this function cycles through all pages of results and returns them all in a single list.
- Parameters:
search_filters (
list
) – A list of dictionaries containing filter parameters.page_size (
int
) – The number of results per page to be returned.sort_field (
str
) – Name of field to sort results on.sort_dir (
str
) – Direction to sort. SortDirection.ASC or SortDirection.DESCcsvdump (
bool
) – Toggle to dump data in csvclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Return type:
list
- Returns:
A list containing all hosts returned by the search using the filter provided.
Examples
>>> apiobj = self.{risksenseobject}.users.search([{"field":"id","exclusive":False,"operator":"EXACT","value":"6506","implicitFilters":[]}])
Note
You can also dump the data of the users in a csv file. Just make csvdump as True:
>>> self.{risksenseobject}.users.search([{"field":"id","exclusive":False,"operator":"EXACT","value":"6506","implicitFilters":[]}],csvdump=True)
- list_user_filter_fields(client_id=None)[source]¶
List filter endpoints.
- Parameters:
filter_subject – Supported Subjects are:
client_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Return type:
dict
- Returns:
The JSON output from the platform is returned, listing the available filters.
Examples
>>> apiobj = self.{risksenseobject}.users.list_user_filter_fields()
- get_user_info(user_id=None, client_id=None, csvdump=False)[source]¶
Get info for a specific user. If user_id is not specified, the info for the requesting user is returned.
- Parameters:
user_id (
typing.Optional
[int
]) – User IDclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.csvdump (
bool
) – Toggle to dump data in csv
- Return type:
dict
- Returns:
User information.
Examples
>>> apiobj = self.{risksenseobject}.users.get_user_info(1234)
Note
You can also dump the data of the user information in a csv file. Just make csvdump as True:
>>> self.{risksenseobject}.users.get_user_info(1234,csvdump=True)
- create(username, first_name, last_name, email_address, group_ids=[], client_id=None, read_only=False, csvdump=False, **kwargs)[source]¶
Create a new user.
- Parameters:
username (
str
) – Usernamefirst_name (
str
) – First Namelast_name (
str
) – Last Nameemail_address (
str
) – E-mail addressgroup_ids (
list
) – Group IDs to assign user toclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.read_only (
bool
) – Read onlycsvdump – Toggle to dump data in csv
- Keyword Arguments:
use_saml (
bool
) – Is a SAML user?saml_attr_1 (
str
) – SAML Attribute 1saml_attr_2 (
str
) – SAML Attribute 2exp_date (
str
) – Expiration Date YYYY-MM-DD
- Return type:
int
- Returns:
Job ID
Examples
>>> apiobj = self.{risksenseobject}.users.create('test', 'test', 'test', 'abc@xyz.com')
Note
You can also dump the data of the user job id in a csv file. Just make csvdump as True:
>>> self.{risksenseobject}.users.create('test', 'test', 'test', 'abc@xyz.com',csvdump=True)
- update_user_role(newrole, newexpiration, user_uuid, client_id=None, csvdump=False)[source]¶
Update user role.
- Parameters:
newrole (
str
) – New User role idnewexpiration (
datetime.datetime
) – Expiration date. Allowed format : “YYYY-MM-DDTHH:MM:SSZ”(eg: 2020-12-31T00:00:00.000Z)user_uuid (
str
) – User UUIDclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.csvdump (
bool
) – Toggle to dump data in csv
- Return type:
dict
- Returns:
Roles JSON
Examples
>>> apiobj = self.{risksenseobject}.users.update_user_role('test','2020-12-31T00:00:00.000Z','123-456')
Note
You can also dump the data of the user profile in a csv file. Just make csvdump as True:
>>> self.{risksenseobject}.users.update_user_role('test','2020-12-31T00:00:00.000Z','123-456',csvdump=True)
- update_user(user_uuid, client_id=None, csvdump=False, **kwargs)[source]¶
Update a user.
- Parameters:
user_uuid (
str
) – User UUIDclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.csvdump (
bool
) – Toggle to dump data in csv
- Keyword Arguments:
username (
str
) – Usernamefirst_name (
str
) – First Namelast_name (
str
) – Last Nameemail (
str
) – Emailphone (
str
) – Phone Num.group_ids (
list
) – Group IDsread_only (
bool
) – Read-Onlyuse_saml (
bool
) – Use SAML?saml_attr_1 (
str
) – SAML Attribute 1saml_attr_2 (
str
) – SAML Attribute 2exp_date (
str
) – Expiration Date YYYY-MM-DD
- Return type:
int
- Returns:
Job ID
Examples
>>> apiobj = self.{risksenseobject}.users.update_user('123-456',username='test',first_name='test')
Note
You can also dump the data of the user in a csv file. Just make csvdump as True:
>>> self.{risksenseobject}.users.update_user('123-456',username='test',first_name='test',csvdump=True)
- send_welcome_email(search_filter, client_id=None)[source]¶
Send welcome e-mail to users identified by the search filter(s) provided.
- Parameters:
search_filter (
list
) – A list of dictionaries containing filter parameters.client_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Return type:
int
- Returns:
Job ID
Examples
>>> apiobj = self.{risksenseobject}.users.send_welcome_email([{"field":"id","exclusive":False,"operator":"EXACT","value":"6506","implicitFilters":[]}])
- get_roles(client_id=None)[source]¶
Get roles
- Parameters:
search_filter – A list of dictionaries containing filter parameters.
client_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Return type:
dict
- Returns:
Job ID
Examples
>>> apiobj = self.{risksenseobject}.users.get_roles()
- assign_clients(searchfilter, expirationdate, replacexistingroles=False, assignallgroups=False, client_id=None, client_idtouse=None)[source]¶
Assign user to clients
- Parameters:
searchfilter (
list
) – A list of dictionaries containing filter parameters.expirationdate (
str
) – Expiration date. YYYY-mm-ddreplacexistingroles (
bool
) – Replace existing rolesassignallgroups (
bool
) – Assign all groupsclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.client_idtouse (
typing.Optional
[int
]) – Client Id to use
- Return type:
int
- Returns:
Job ID
Examples
>>> apiobj = self.{risksenseobject}.users.assign_clients([{"field":"id","exclusive":False,"operator":"EXACT","value":"6506","implicitFilters":[]}],'2022-01-01',client_idtouse=111)
- assign_roles(userid, expirationdate=None, replacexistingroles=False, assignallgroups=False, client_id=None, client_idtouse=None)[source]¶
Assign roles to user
- Parameters:
userid (
int
) – User Idexpirationdate (
typing.Optional
[str
]) – Expiration date. YYYY-mm-ddreplacexistingroles (
bool
) – Replace existing rolesassignallgroups (
bool
) – Assign all groupsclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.client_idtouse (
typing.Optional
[int
]) – Client Id to use
- Return type:
dict
- Returns:
Job ID
Examples
>>> apiobj = self.{risksenseobject}.users.assign_roles(123,'2022-01-01',client_idtouse=111)
- remove_roles(userid, client_idtouse=None, client_id=None)[source]¶
Remove roles to user
- Parameters:
userid (
int
) – User Idclient_idtouse (
typing.Optional
[int
]) – Client Id to useclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Return type:
dict
- Returns:
Job ID
Examples
>>> apiobj = self.{risksenseobject}.users.remove_roles(123,client_idtouse=111)
- clientrolefiltering(client_ids=None, rolelabels=None, client_id=None)[source]¶
Client role filtering
- Parameters:
client_ids (
typing.Optional
[list
]) – Client Idsrolelabels (
typing.Optional
[list
]) – Role Labelsclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Return type:
dict
- Returns:
Job ID
Examples
>>> apiobj = self.{risksenseobject}.users.clientrolefiltering(client_ids=[123,12],rolelabels=['abc'])
- get_model(client_id=None)[source]¶
Get available projections and models for Users.
- Parameters:
client_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.- Return type:
dict
- Returns:
Users projections and models are returned.
Examples
>>> apiobj = self.{risksenseobject}.users.get_model()
- suggest(search_filter, suggest_filter, client_id=None)[source]¶
Suggest values for filter fields.
- Parameters:
search_filter (
list
) – Search Filtersuggest_filter (
dict
) – Suggest Filterclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Return type:
dict
- Returns:
Value suggestions
Examples
>>> apiobj = self.{risksenseobject}.users.suggest([],{"field":"id","exclusive":False,"operator":"WILDCARD","value":"65*","implicitFilters":[]})
- import_users_csv(file_name, absolute_path_file, client_id=None)[source]¶
Add a file to an upload.
- Parameters:
file_name (
str
) – The name to be used for the uploaded file.absolute_path_file (
str
) – Absolute path of the file to be uploadedclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Return type:
dict
- Returns:
The file ID is returned.
Examples
>>> apiobj = self.{risksenseobject}.users.import_users_csv('test','C:\test.csv')
- systemuser_get_single_search_page(search_filters, page_num=0, page_size=150, sort_field='username', sort_dir='DESC', client_id=None)[source]¶
Searches for and returns users based on the provided filter(s) and other parameters.
- Parameters:
search_filters (
list
) – A list of dictionaries containing filter parameters.page_num (
int
) – Page number of results to be returned.page_size (
int
) – Number of results to be returned per page.sort_field (
str
) – Name of field to sort results on.sort_dir (
str
) – Direction to sort. SortDirection.ASC or SortDirection.DESCclient_id (
typing.Optional
[int
]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.
- Return type:
dict
- Returns:
Paginated JSON response from the platform.
Examples
>>> apiobj = self.{risksenseobject}.users.systemuser_get_single_search_page([{"field":"id","exclusive":False,"operator":"EXACT","value":"6506","implicitFilters":[]}])