Detection Lists

class py42.clients.detectionlists.DetectionListsClient(user_profile_service, departing_employee_service, high_risk_employee_service)

Bases: object

Rest documentation

add_user_cloud_alias(user_id, alias)

Add a cloud alias to a user. Rest Documentation

Parameters:
  • user_id (str or int) – The userUid of the user whose alias you want to update.
  • alias (str) – The alias to be added.
Returns:

py42.response.Py42Response

add_user_risk_tags(user_id, tags)

Add one or more risk factor tags. Rest Documentation

Parameters:
  • user_id (str or int) – The userUid of the user whose risk factor tag(s) you want to update.
  • tags (str or list of str) – A single tag or multiple tags in a list to be added. For example: "tag1" or ["tag1", "tag2"].
Returns:

py42.response.Py42Response

create_user(username)

Deprecated. Used to create a detection list profile for a user, but now that happens automatically. Thus, this method instead returns the response from an API call that gets the user’s profile.

Parameters:username (str) – The Code42 username of the user.
Returns:py42.response.Py42Response
get_user(username)

Get user details by username. Rest Documentation

Parameters:username (str) – The Code42 username of the user.
Returns:py42.response.Py42Response
get_user_by_id(user_id)

Get user details by user_id. Rest Documentation

Parameters:user_id (str or int) – The Code42 userId of the user.
Returns:py42.response.Py42Response
refresh_user_scim_attributes(user_id)

Refresh SCIM attributes of a user. Rest Documentation

Parameters:user_id (str or int) – The userUid of the user whose attributes you wish to refresh.
Returns:py42.response.Py42Response
remove_user_cloud_alias(user_id, alias)

Remove a cloud alias from a user. Rest Documentation

Parameters:
  • user_id (str or int) – The userUid of the user whose alias needs to be removed.
  • alias (str) – The alias to be removed.
Returns:

py42.response.Py42Response

remove_user_risk_tags(user_id, tags)

Remove one or more risk factor tags. Rest Documentation

Parameters:
  • user_id (str or int) – The userUid of the user whose risk factor tag(s) needs you want to remove.
  • tags (str or list of str) – A single tag or multiple tags in a list to be removed. For example: "tag1" or ["tag1", "tag2"].
Returns:

py42.response.Py42Response

update_user_notes(user_id, notes)

Add or update notes related to the user. Rest Documentation

Parameters:
  • user_id (str or int) – The userUid of the user whose notes you want to update.
  • notes (str) – User profile notes.
Returns:

py42.response.Py42Response

Departing Employees

class py42.services.detectionlists.departing_employee.DepartingEmployeeFilters

Bases: py42.services.detectionlists._DetectionListFilters, py42.choices.Choices

Constants available for filtering Departing Employee search results.

class py42.services.detectionlists.departing_employee.DepartingEmployeeService(session, user_context, user_profile_service)

Bases: py42.services.BaseService

A service for interacting with Code42 Departing Employee APIs.

add(user_id, departure_date=None)

Adds a user to the Departing Employees list. REST Documentation

Raises a Py42UserAlreadyAddedError when a user already exists in the Departing Employee detection list.

Parameters:
  • user_id (str or int) – The Code42 userUid of the user you want to add to the departing employees list.
  • departure_date (str or datetime, optional) – Date in yyyy-MM-dd format or instance of datetime. Date is treated as UTC. Defaults to None.
Returns:

py42.response.Py42Response

get(user_id)

Gets departing employee data of a user. REST Documentation

Parameters:user_id (str or int) – The Code42 userUid of the user.
Returns:py42.response.Py42Response
get_all(filter_type='OPEN', sort_key='CREATED_AT', sort_direction='DESC', page_size=100)

Gets all Departing Employees.

Parameters:
  • filter_type (str, optional) – EXFILTRATION_30_DAYS, EXFILTRATION_24_HOURS, OPEN, or LEAVING_TODAY. Constants are available at py42.services.detectionlists.departing_employee.DepartingEmployeeFilters. Defaults to “OPEN”.
  • sort_key (str, optional) – Sort results based by field. Defaults to “CREATED_AT”.
  • sort_direction (str, optional) – ASC or DESC. Defaults to “DESC”.
  • page_size (int, optional) – The number of departing employees to return per page. Defaults to 100.
Returns:

An object that iterates over py42.response.Py42Response objects that each contain a page of departing employees.

Return type:

generator

get_page(page_num, filter_type='OPEN', sort_key='CREATED_AT', sort_direction='DESC', page_size=100)

Gets a single page of Departing Employees.

Parameters:
  • page_num (int) – The page number to request.
  • filter_type (str, optional) – EXFILTRATION_30_DAYS, EXFILTRATION_24_HOURS, OPEN, or LEAVING_TODAY. Constants are available at py42.services.detectionlists.departing_employee.DepartingEmployeeFilters. Defaults to “OPEN”.
  • sort_key (str, optional) – Sort results based by field. Defaults to “CREATED_AT”.
  • sort_direction (str. optional) – ASC or DESC. Defaults to “DESC”.
  • page_size (int, optional) – The number of departing employees to return per page. Defaults to 100.
Returns:

py42.response.Py42Response

remove(user_id)

Removes a user from the Departing Employees list. REST Documentation

Parameters:user_id (str or int) – The Code42 userUid of the user.
Returns:py42.response.Py42Response
set_alerts_enabled(alerts_enabled=True)

Enable or disable email alerting on Departing Employee exposure events. REST Documentation

Parameters:alerts_enabled (bool) – Set alerting to on (True) or off (False). Defaults to True.
Returns:py42.response.Py42Response
update_departure_date(user_id, departure_date)

Add or modify details of an existing Departing Employee case. REST Documentation

Parameters:
  • user_id (str) – The Code42 userUid of the user.
  • departure_date (str or datetime) – Date in yyyy-MM-dd format or instance of datetime. Date is treated as UTC.
Returns:

py42.response.Py42Response

High Risk Employee

class py42.services.detectionlists.high_risk_employee.HighRiskEmployeeFilters

Bases: py42.services.detectionlists._DetectionListFilters, py42.choices.Choices

Constants available for filtering High Risk Employee search results.

class py42.services.detectionlists.high_risk_employee.HighRiskEmployeeService(connection, user_context, user_profile_service)

Bases: py42.services.BaseService

A service for interacting with High Risk Employee APIs.

add(user_id)

Adds a user to the High Risk Employee detection list.

Raises a Py42UserAlreadyAddedError when a user already exists in the High Risk Employee detection list. REST Documentation

Parameters:user_id (str or int) – The Code42 userUid of the user you want to add to the High Risk Employee detection list.
Returns:py42.response.Py42Response
get(user_id)

Gets user information. Rest Documentation

Parameters:user_id (str or int) – The Code42 userUid of the user has been added to the High Risk Employee detection list.
Returns:py42.response.Py42Response
get_all(filter_type='OPEN', sort_key=None, sort_direction=None, page_size=100)

Searches High Risk Employee list. Filter results by filter_type. Rest Documentation

Parameters:
  • filter_type (str, optional) – EXFILTRATION_30_DAYS, EXFILTRATION_24_HOURS, or OPEN. Constants are available at py42.services.detectionlists.high_risk_employee.HighRiskEmployeeFilters. Defaults to “OPEN”.
  • sort_key (str, optional) – Sort results based by field. Defaults to None.
  • sort_direction (str, optional) – ASC or DESC. Constants available at py42.constants.SortDirection. Defaults to None.
  • page_size (int, optional) – The number of high risk employees to return per page. Defaults to 100.
Returns:

An object that iterates over py42.response.Py42Response objects that each contain a page of users.

Return type:

generator

get_page(page_num, filter_type='OPEN', sort_key=None, sort_direction=None, page_size=100)

Gets a single page of High Risk Employees.

Parameters:
  • page_num (int) – The page number to request.
  • filter_type (str, optional) – EXFILTRATION_30_DAYS, EXFILTRATION_24_HOURS, or OPEN. Constants are available at py42.services.detectionlists.high_risk_employee.HighRiskEmployeeFilters. Defaults to “OPEN”.
  • sort_key (str, optional) – Sort results based by field. Defaults to None.
  • sort_direction (str. optional) – ASC or DESC. Constants available at py42.constants.SortDirection. Defaults to None.
  • page_size (int, optional) – The number of high risk employees to return per page. Defaults to 100.
Returns:

py42.response.Py42Response

remove(user_id)

Removes a user from the High Risk Employee detection list. Rest Documentation

Parameters:user_id (str or int) – The Code42 userUid of the user you want to add to the High Risk Employee detection list.
Returns:py42.response.Py42Response
set_alerts_enabled(enabled=True)

Enables alerts. Rest Documentation

Parameters:enabled (bool) – Whether to enable alerts for all users.
Returns:py42.response.Py42Response