devices¶
The following methods allow for interaction with the ZCC Devices API endpoints.
Methods are accessible via zcc.devices
Copyright (c) 2023, Zscaler Inc.
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- class DevicesAPI¶
Bases:
APIClient- download_devices(query_params=None, filename=None)¶
Downloads the list of devices as a CSV file from the ZCC portal.
- Parameters:
query_params (dict, optional) –
A dictionary containing supported filters.
[query_params.os_types]{str}: Filter by OS type. Valid values:ios, android, windows, macos, linux.
[query_params.registration_types]{str}: Filter by registration type. Valid values:all, registered, unregistered, removal_pending, removed, quarantined.
filename (str, optional) – Custom filename for the CSV file. Defaults to timestamped name.
- Returns:
Path to the downloaded CSV file.
- Return type:
Examples
Download list of devices as a CSV:
>>> try: ... filename = client.zcc.devices.download_devices( ... query_params={ ... "os_types": ["windows"], ... "registration_types": ["unregistered"] ... }, ... filename="unregistered_devices.csv" ... ) ... print(f"Devices downloaded successfully: {filename}") ... except Exception as e: ... print(f"Error during download: {e}")
- download_disable_reasons(query_params=None, filename=None)¶
Downloads or exports a report as a CSV file showing the disable reasons of devices.
- Parameters:
query_params (dict, optional) –
A dictionary containing supported filters.
[query_params.os_types]{list}: Filter by OS type. Valid values:ios, android, windows, macos, linux.
[query_params.start_date]{str}: Start date for the report. Accepts various formats:YYYY-MM-DD, YYYY-MM-DD HH:MM:SS, YYYY-MM-DDTHH:MM:SS, etc. Will be converted to ZCC API format.
[query_params.end_date]{str}: End date for the report. Accepts various formats:YYYY-MM-DD, YYYY-MM-DD HH:MM:SS, YYYY-MM-DDTHH:MM:SS, etc. Will be converted to ZCC API format.
[query_params.time_zone]{str}: IANA time zone for date interpretation.Examples: ‘America/New_York’, ‘UTC’, ‘Europe/London’.
filename (str, optional) – Custom filename for the CSV file. Defaults to timestamped name.
- Returns:
Path to the downloaded CSV file.
- Return type:
Examples
Download disable reasons report for Windows devices:
>>> try: ... filename = client.zcc.devices.download_disable_reasons( ... query_params={ ... "os_types": ["windows"], ... "start_date": "2024-01-01", ... "end_date": "2024-01-31", ... "time_zone": "America/New_York" ... }, ... filename="disable_reasons_jan2024.csv" ... ) ... print(f"Disable reasons report downloaded successfully: {filename}") ... except Exception as e: ... print(f"Error during download: {e}")
Download disable reasons for all devices with specific date range:
>>> try: ... filename = client.zcc.devices.download_disable_reasons( ... query_params={ ... "start_date": "2024-01-01 00:00:00", ... "end_date": "2024-01-31 23:59:59", ... "time_zone": "UTC" ... } ... ) ... print(f"Report downloaded: {filename}") ... except Exception as e: ... print(f"Error: {e}")
- download_service_status(query_params=None, filename=None)¶
Downloads service status for all devices from the ZCC portal.
- Parameters:
query_params (dict, optional) –
A dictionary containing supported filters.
[query_params.os_types]{str}: Filter by OS type. Valid values:ios, android, windows, macos, linux.
[query_params.registration_types]{str}: Filter by registration type. Valid values:all, registered, unregistered, removal_pending, removed, quarantined.
filename (str, optional): Custom filename for the CSV file. Defaults to timestamped name.
- Returns:
Path to the downloaded CSV file.
- Return type:
Examples
Download list of devices as a CSV:
>>> try: ... filename = client.zcc.devices.download_service_status( ... query_params={ ... "os_types": ["windows"], ... "registration_types": ["unregistered"] ... }, ... filename="unregistered_devices.csv" ... ) ... print(f"Device Service Status downloaded successfully: {filename}") ... except Exception as e: ... print(f"Error during download: {e}")
- force_remove_devices(query_params=None, **kwargs)¶
Force remove of the devices from the Client Connector Portal.
- Parameters:
{dict} (query_params) –
Map of query parameters for the request.
[query_params.page_size]{int}: Specifies the page size.If not provided, the default page size is 30. The max page size is 5000.
client_connector_version (list[str]): List of the client connector agent versions os_type (int): Valid options are: ios, android, windows, macos, linux. udids (list[str]): The list of udids for the devices to be removed user_name (str): The username i.e jdoe@acme.com of the user to which the device is associated with.
- Returns:
Forces the removal of devices from the Client Connector Portal.
- Return type:
Examples
Removes devices in the Client Connector Portal to the console:
>>> remove_devices, _, error = client.zcc.devices.force_remove_devices( ... client_connector_version=['3.0.0.57'], ... os_type='windows', ... udids='VMware-42-02-38-a5-5f-9c-86-39-ff-5a-d0-60-5c-35-68-90:D630C3617830C5C0B2DDE986EA7D994324C4EC1D', ... user_name='jdoe@acme.com' ... ) >>> if error: ... print(f"Error removing device: {error}") ... return ... for device in remove_devices: ... print(f"Removed device: {device.as_dict()}")
- get_device_cleanup_info()¶
Returns device cleanup sync information from the Client Connector Portal.
- Parameters:
N/A
- Returns:
Returns device cleanup sync information in the Client Connector Portal.
- Return type:
Examples
Prints all devices in the Client Connector Portal to the console:
>>> devices, _, err = client.zcc.devices.get_device_cleanup_info() >>> if err: ... print(f"Error fetching device clean up: {err}") ... return ... print("Device clean up fetched successfully.") ... print(devices)
- get_device_details(query_params=None)¶
Lists device details of enrolled devices of your organization.
- Keyword Args:
[query_params.username]{str, optional}: Filter by enrolled user name for the device.[query_params.udid]{str, optional}: Filter by unique device identifier.- Returns:
DeviceDetails: Returns device detail information in the Client Connector Portal.- Examples:
Prints device details in the Client Connector Portal to the console:
>>> details, _, err = client.zcc.devices.get_device_details() >>> if err: ... print(f"Error listing device details: {err}") ... return ... print(details.as_dict())
Prints device details in the Client Connector Portal to the console:
>>> details, _, err = client.zcc.devices.get_device_details( ... query_params:{'username': 'jdoe'}) >>> if err: ... print(f"Error listing device details: {err}") ... return ... print(details.as_dict())
- list_devices(query_params=None)¶
Returns the list of devices enrolled in the Client Connector Portal.
- Parameters:
query_params (dict, optional) –
A dictionary containing supported filters.
[query_params.os_type]{str}: Filter by device operating system type. Valid options are:ios, android, windows, macos, linux.
[query_params.username]{str}: Filter by enrolled username for the device.[query_params.page]{str}: Specifies the page number.[query_params.page_size]{str}: Specifies the page size.The default page size is 50. The max page size is 5000.
- Returns:
A list containing devices using ZCC enrolled in the Client Connector Portal.
- Return type:
Examples
Prints all devices in the Client Connector Portal to the console:
>>> device_list, _, err = client.zcc.devices.list_devices( ... query_params = {'username': 'jdoe@acme.com', "os_type": "3", 'page': 1, 'page_size': 1}) >>> if err: ... print(f"Error listing devices: {err}") ... return ... print(f"Total devices found: {len(device_list)}") ... for device in device_list: ... print(device.as_dict())
- remove_devices(query_params=None, **kwargs)¶
Remove of the devices from the Client Connector Portal.
- Parameters:
{dict} (query_params) –
Map of query parameters for the request.
[query_params.page_size]{int}: Specifies the page size.If not provided, the default page size is 30. The max page size is 5000.
client_connector_version (list[str]): List of the client connector agent versions os_type (int): Valid options are: ios, android, windows, macos, linux. udids (list[str]): The list of udids for the devices to be removed user_name (str): The username i.e jdoe@acme.com of the user to which the device is associated with.
- Returns:
Remove devices from the Client Connector Portal.
- Return type:
Examples
Removes devices in the Client Connector Portal to the console:
>>> remove_devices, _, error = client.zcc.devices.remove_devices( ... client_connector_version=['3.0.0.57'], ... os_type='3', ... udids='VMware-42-02-38-a5-5f-9c-86-39-ff-5a-d0-60-5c-35-68-90:D630C3617830C5C0B2DDE986EA7D994324C4EC1D', ... username='jdoe@acme.com' ... ) >>> if error: ... print(f"Error removing device: {error}") ... return ... for device in remove_devices: ... print(f"Removed device: {device.as_dict()}")
- remove_machine_tunnel(query_params=None, **kwargs)¶
Remove machine tunnel devices from the Client Connector Portal.
- Parameters:
{dict} (query_params) – Map of query parameters for the request.
[query_params.hostname]{int}: Comma-separated list of hostnames for the device.[query_params.machine_token]{int}: Comma-separated list of hostnames for the device.- Keyword Arguments:
- Returns:
Remove machine tunnel devices from the Client Connector Portal.
- Return type:
Examples
Removes machine tunnels in the Client Connector Portal to the console:
>>> remove_tunnels, _, error = client.zcc.devices.remove_machine_tunnel( ... host_names=['FXJ14JLFQW'], ... ) >>> if error: ... print(f"Error removing machine tunnel: {error}") ... return ... print("Removed machine tunnel:", remove_tunnels)
- update_device_cleanup_info(**kwargs)¶
Set Device Cleaup Information
- Parameters:
N/A
- Returns:
A tuple containing the updated Device Cleaup Information, response, and error.
- Return type:
Examples
Updated Device Cleaup Information:
>>> device, _, err = client.zcc.devices.update_device_cleanup_info( ... active=1, ... force_remove_type=1, ... device_exceed_limit=16 ... ) >>> if err: ... print(f"Error fetching device cleanup info: {err}") ... return ... print("Current device cleanup info fetched successfully.") ... print(device)