Devices

class py42.services.devices.DeviceService(connection)

Bases: py42.services.BaseService

A class to interact with Code42 device/computer APIs.

block(device_id)

Blocks a device causing the user not to be able to log in to or restore from Code42 on that device. REST Documentation

Parameters:device_id (int) – The identification number of the device.
Returns:py42.response.Py42Response
deactivate(device_id)

Deactivates a device, causing backups to stop and archives to go to cold storage. REST Documentation

Parameters:device_id (int) – The identification number of the device.
Returns:py42.response.Py42Response
deauthorize(device_id)

Deauthorizes the device with the given ID. If used on a cloud connector device, it will remove the authorization token for that account. REST Documentation

Parameters:device_id (int) – The identification number of the device.
Returns:py42.response.Py42Response
get_agent_full_disk_access_state(guid)

Gets the full disk access status of a device. REST Documentation

Parameters:guid (str) – The globally unique identifier of the device.
Returns:A response containing settings information.
Return type:py42.response.Py42Response
get_agent_state(guid, property_name)

Gets the agent state of the device. REST Documentation

Parameters:
  • guid (str) – The globally unique identifier of the device.
  • property_name (str) – The name of the property to retrieve (e.g. fullDiskAccess).
Returns:

A response containing settings information.

Return type:

py42.response.Py42Response

get_all(active=None, blocked=None, org_uid=None, user_uid=None, destination_guid=None, include_backup_usage=None, include_counts=True, q=None, **kwargs)

Gets all device information.

When no arguments are passed, all records are returned. To filter results, specify respective arguments. For example, to retrieve all active and blocked devices, pass active=true and blocked=true. REST Documentation

Parameters:
  • active (bool, optional) – Filters results by device state. When set to True, gets all active devices. When set to False, gets all deactivated devices. When set to None or excluded, gets all devices regardless of state. Defaults to None.
  • blocked (bool, optional) – Filters results by blocked status: True or False. Defaults to None.
  • org_uid (int, optional) – The identification number of an Organization. Defaults to None.
  • user_uid (int, optional) – The identification number of a User. Defaults to None.
  • destination_guid (str or int, optional) – The globally unique identifier of the storage server that the device back up to. Defaults to None.
  • include_backup_usage (bool, optional) – A flag to denote whether to include the destination and its backup stats. Defaults to None.
  • include_counts (bool, optional) – A flag to denote whether to include total, warning, and critical counts. Defaults to True.
  • q (str, optional) – Searches results flexibly by incomplete GUID, hostname, computer name, etc. Defaults to None.
Returns:

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

The devices returned by get_all() are based on the role and permissions of the user authenticating the py42 SDK.

Return type:

generator

get_by_guid(guid, include_backup_usage=None, **kwargs)

Gets device information by GUID. REST Documentation

Parameters:
  • guid (str) – The globally unique identifier of the device.
  • include_backup_usage (bool, optional) – A flag to denote whether to include the destination and its backup stats. Defaults to None.
Returns:

A response containing device information.

Return type:

py42.response.Py42Response

get_by_id(device_id, include_backup_usage=None, **kwargs)

Gets device information by ID. REST Documentation

Parameters:
  • device_id (int) – The identification number of the device.
  • include_backup_usage (bool, optional) – A flag to denote whether to include the destination and its backup stats. Defaults to None.
Returns:

A response containing device information.

Return type:

py42.response.Py42Response

get_page(page_num, active=None, blocked=None, org_uid=None, user_uid=None, destination_guid=None, include_backup_usage=None, include_counts=True, page_size=None, q=None)

Gets a page of devices. REST Documentation

Parameters:
  • page_num (int) – The page number to request.
  • active (bool, optional) – Filters results by device state. When set to True, gets all active devices. When set to False, gets all deactivated devices. When set to None or excluded, gets all devices regardless of state. Defaults to None.
  • blocked (bool, optional) – Filters results by blocked status: True or False. Defaults to None.
  • org_uid (int, optional) – The identification number of an Organization. Defaults to None.
  • user_uid (int, optional) – The identification number of a User. Defaults to None.
  • destination_guid (str or int, optional) – The globally unique identifier of the storage server that the device back up to. Defaults to None.
  • include_backup_usage (bool, optional) – A flag to denote whether to include the destination and its backup stats. Defaults to None.
  • include_counts (bool, optional) – A flag to denote whether to include total, warning, and critical counts. Defaults to True.
  • page_size (int, optional) – The number of devices to return per page. Defaults to py42.settings.items_per_page.
  • q (str, optional) – Searches results flexibly by incomplete GUID, hostname, computer name, etc. Defaults to None.
Returns:

py42.response.Py42Response

get_settings(guid, keys=None)

Gets settings of the device. REST Documentation

Parameters:
  • guid (str) – The globally unique identifier of the device.
  • keys (str, optional) – A comma separated list of device keys. Defaults to None.
Returns:

A response containing settings information.

Return type:

py42.response.Py42Response

reactivate(device_id)

Activates a previously deactivated device. REST Documentation

Parameters:device_id (int) – The identification number of the device.
Returns:py42.response.Py42Response
unblock(device_id)

Unblocks a device, permitting a user to be able to login and restore again. REST Documentation

Parameters:device_id (int) – The identification number of the device.
Returns:py42.response.Py42Response