Method Documentation

The main SDK object by which all other methods are accessed is created by calling py42.sdk.from_local_account or py42.sdk.from_jwt_provider. For example:

import py42.sdk

sdk = py42.sdk.from_local_account("console.us.code42.com", "john.doe@example.com", "my_pw")
# access properties on 'sdk' to explore all the available methods

Important

py42 only supports token-based authentication.

Explore the complete public documentation for py42 below.

py42.sdk.from_jwt_provider(host_address, jwt_provider)

Creates a SDKClient object for accessing the Code42 REST APIs using a custom auth mechanism. User can use any authentication mechanism like that returns a JSON Web token on authentication which would then be used for all subsequent requests.

Parameters:
  • host_address (str) – The domain name of the Code42 instance being authenticated to, e.g. console.us.code42.com
  • jwt_provider (function) – A function that accepts no parameters and on execution returns a JSON web token string.
Returns:

py42.sdk.SDKClient

py42.sdk.from_local_account(host_address, username, password, totp=None)

Creates a SDKClient object for accessing the Code42 REST APIs using the supplied credentials. This method supports only accounts created within the Code42 console or using the APIs (including py42). Username/passwords that are based on Active Directory, Okta, or other Identity providers cannot be used with this method.

Parameters:
  • host_address (str) – The domain name of the Code42 instance being authenticated to, e.g. console.us.code42.com
  • username (str) – The username of the authenticating account.
  • password (str) – The password of the authenticating account.
  • totp (callable or str, optional) – The time-based one-time password of the authenticating account. Include only if the account uses Code42’s two-factor authentication. Defaults to None.
Returns:

py42.sdk.SDKClient

class py42.sdk.SDKClient(main_connection, auth)

Bases: object

alerts

A collection of methods related to retrieving and updating alerts rules.

Returns:py42.clients.alertrules.AlertRulesClient
archive

A collection of methods for accessing Code42 storage archives. Useful for doing web-restores or finding a file on an archive.

Returns:py42.clients.archive.ArchiveClient
auditlogs

A collection of methods for retrieving audit logs.

Returns:py42.clients.auditlogs.AuditLogsService
cases

A collection of methods and properties for managing cases and file events associated with the case.

Returns:py42.clients.cases.CaseClient
detectionlists

A collection of properties each containing methods for managing specific detection lists, such as departing employees.

Returns:py42.clients.detectionlists.DetectionListsClient
devices

A collection of methods for retrieving or updating data about devices in the Code42 environment.

Returns:py42.services.devices.DeviceService
classmethod from_jwt_provider(host_address, jwt_provider)
Creates a SDKClient object for accessing the Code42 REST APIs using a custom
auth mechanism. User can use any authentication mechanism like that returns a JSON Web token on authentication which would then be used for all subsequent requests.
Parameters:
  • host_address (str) – The domain name of the Code42 instance being authenticated to, e.g. console.us.code42.com
  • jwt_provider (function) – A function that accepts no parameters and on execution returns a
  • web token string. (JSON) –
Returns:

py42.sdk.SDKClient

classmethod from_local_account(host_address, username, password, totp=None)

Creates a SDKClient object for accessing the Code42 REST APIs using the supplied credentials. This method supports only accounts created within the Code42 console or using the APIs (including py42). Username/passwords that are based on Active Directory, Okta, or other Identity providers should use the from_jwt_provider method.

Parameters:
  • host_address (str) – The domain name of the Code42 instance being authenticated to, e.g. console.us.code42.com
  • username (str) – The username of the authenticating account.
  • password (str) – The password of the authenticating account.
  • totp (callable or str, optional) – The time-based one-time password of the authenticating account. Include only if the account uses Code42’s two-factor authentication. Defaults to None.
Returns:

py42.sdk.SDKClient

legalhold

A collection of methods for retrieving and updating legal-hold matters, policies, and custodians.

Returns:py42.services.legalhold.LegalHoldService
loginconfig

A collection of methods related to getting information about the login configuration of user accounts.

Returns:py42.clients.loginconfig.LoginConfigurationClient.
orgs

A collection of methods for retrieving or updating data about organizations in the Code42 environment.

Returns:py42.services.orgs.OrgService
securitydata
  • File events
    • Security plan information
Returns:py42.clients.securitydata.SecurityDataClient
Type:A collection of methods and properties for getting security data such as
serveradmin

A collection of methods for getting server information for on-premise environments and tenant information for cloud environments.

Returns:py42.services.administration.AdministrationService
usercontext

A collection of methods related to getting information about the currently logged in user, such as the tenant ID.

Returns:py42.usercontext.UserContext
users

A collection of methods for retrieving or updating data about users in the Code42 environment.

Returns:py42.services.users.UserService