admin

class google.apis.admin.ReportsAPI(http=None, impersonated_user_email=None, start=None, end=None, timezone=None)[source]

Class to interact with G Suite Admin Reports APIs.

Documentation for the Python API: - https://developers.google.com/resources/api-libraries/documentation/admin/reports_v1/python/latest/

See also: https://developers.google.com/admin-sdk/reports/v1/quickstart/python

Parameters:
  • http (httplib2.Http) – An Http object for sending the requests. In general, this should be left as None, which will allow for auto-adjustment of the kind of Http object to create based on whether a user’s email address is to be impersonated.
  • impersonated_user_email (str) – The email address of a user to impersonate. This requires domain-wide delegation to be activated. See https://developers.google.com/admin-sdk/reports/v1/guides/delegation for instructions.
  • start (str) – The earliest data to collect. Can be any kind of date string, as long as it is unambiguous (e.g. “2017”). It can even be slang, such as “a year ago”. Be aware, however, that only the day of the date will be used, meaning time information will be discarded.
  • end (str) – The latest data to collect. Same format rules apply for this as for the start parameter.
  • timezone (str) – The timezone to convert all timestamps to before compiling. This should be a standard timezone name. For reference, the list that the timezone will be compared against is available at https://github.com/newvem/pytz/blob/master/pytz/__init__.py. If omitted, the local timezone of the computer will be used.
activity(user_key='all', app_name=None, **kwargs)[source]

Return the last 180 days of activities.

https://developers.google.com/admin-sdk/reports/v1/reference/activities/list

The application_name parameter specifies which events are to be retrieved. The possible values include:

  • admin – The Admin console application’s activity reports return account information about different types of administrator activity events.
  • calendar – The G Suite Calendar application’s activity reports return information about various Calendar activity events.
  • drive – The Google Drive application’s activity reports return information about various Google Drive activity events. The Drive activity report is only available for G Suite Business customers.
  • groups – The Google Groups application’s activity reports return information about various Groups activity events.
  • gplus – The Google+ application’s activity reports return information about various Google+ activity events.
  • login – The G Suite Login application’s activity reports return account information about different types of Login activity events.
  • mobile – The G Suite Mobile Audit activity report return information about different types of Mobile Audit activity events.
  • rules – The G Suite Rules activity report return information about different types of Rules activity events,.
  • token – The G Suite Token application’s activity reports return account information about different types of Token activity events.
Parameters:
  • user_key (str) – The value can be 'all', which returns all administrator information, or a userKey, which represents a user’s unique G Suite profile ID or the primary email address of a person or entity.
  • app_name (str) – Name of application from the list above. If set to None, data will be retrieved from all the applications listed above.
Returns:

JSON

get_customer_usage_reports(date, customer_id=False)[source]

Get customer usage reports.

https://developers.google.com/admin-sdk/reports/v1/reference/customerUsageReports/get

Parameters:
  • date
  • customer_id
Returns:

JSON

get_user_usage_report(date, user_key='all')[source]

Get user usage report.

https://developers.google.com/admin-sdk/reports/v1/reference/userUsageReport/get

Parameters:
  • date
  • user_key
Returns:

JSON

class google.apis.admin.DirectoryAPI(**kwargs)[source]

Class to interact with G Suite Admin Directory APIs.

Documentation for the Python API: - https://developers.google.com/resources/api-libraries/documentation/admin/directory_v1/python/latest/

See also: https://developers.google.com/admin-sdk/directory/v1/quickstart/python

list_chromeos_devices(fields='*')[source]

List up to 100 Chrome OS devices in the organization.

API: https://developers.google.com/resources/api-libraries/documentation/admin/directory_v1/python/latest/admin_directory_v1.chromeosdevices.html

Reference: https://developers.google.com/admin-sdk/directory/v1/reference/chromeosdevices/list

Parameters:fields (str) – Comma-separated list of metadata fields to request.
Returns:The list of Chrome OS devices. See one of the documentation links above for the format of the return value.
Return type:list
get_user(user_email)[source]

Get information for a single user specified by their email.

https://developers.google.com/admin-sdk/directory/v1/reference/users/get

Parameters:user_email (str) – user’s email
Returns:JSON
get_all_users(domain_name)[source]

Return all users in the domain.

https://developers.google.com/admin-sdk/directory/v1/reference/users/list

Parameters:domain_name (str) – the name of the domain
Returns:JSON
get_chrome_os_devices_properties(device_id)[source]

Get data pertaining to a single ChromeOS device.

https://developers.google.com/admin-sdk/directory/v1/reference/chromeosdevices/get

Parameters:device_id (str) – unique ID for the device.
Returns:JSON
list_customers_mobile_devices_properties()[source]

Get a list of mobile devices.

https://developers.google.com/admin-sdk/directory/v1/reference/mobiledevices/list

Returns:JSON
get_mobile_devices_properties(resource_id)[source]

Get data pertaining to a single mobile device.

https://developers.google.com/admin-sdk/directory/v1/reference/mobiledevices/get

Parameters:resource_id (str) – The unique ID the API service uses to identify the mobile device.
Returns:JSON
suspend_user_account(user_email)[source]

Suspend an user’s account.

https://developers.google.com/admin-sdk/directory/v1/reference/users/update https://developers.google.com/admin-sdk/directory/v1/guides/manage-users

Parameters:user_email (str) – Email for the user to be suspended.
Returns:JSON
unsuspend_user_account(user_email)[source]

Un-suspend a user’s account.

https://developers.google.com/admin-sdk/directory/v1/reference/users/update https://developers.google.com/admin-sdk/directory/v1/guides/manage-users

Parameters:user_email (str) – Email for the user to be un-suspended.
Returns:JSON