dlp_templates

The following methods allow for interaction with the ZIA DLP Notification Templates API endpoints.

Methods are accessible via zia.dlp_templates

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 DLPTemplatesAPI

Bases: APIClient

A Client object for the DLP Templates resource.

add_dlp_template(**kwargs)

Adds a new DLP notification template to ZIA.

Parameters:
  • name (str) – The name of the DLP notification template.

  • subject (str) – The subject line displayed within the DLP notification email.

Keyword Arguments:
  • attach_content (bool) – If true, the content in violation is attached to the DLP notification email.

  • plain_text_message (str) – Template for the plain text UTF-8 message body displayed in the DLP notification email.

  • html_message (str) – Template for the HTML message body displayed in the DLP notification email.

  • tls_enabled (bool) – If true, enables TLS for the notification template.

Returns:

The newly created DLP Notification Template resource record.

Return type:

Tuple

Examples

Create a new DLP Notification Template:

>>> zia.dlp.add_dlp_template(name="New DLP Template",
...                         subject="Alert: DLP Violation Detected",
...                         attach_content=True,
...                         plain_text_message="Text message content",
...                         html_message="<html><body>HTML message content</body></html>")
delete_dlp_template(template_id)

Deletes the DLP Notification Template that matches the specified Template id.

Parameters:

template_id (str) – The unique id for the DLP Notification Template.

Returns:

The status code for the operation.

Return type:

int

Examples

>>> _, response, error = client.zia.dlp_templates.delete_dlp_template('63578')
... if error:
...     print(f"Error deleting Template: {error}")
...     return
...print(f"Template with ID {'63578'} deleted successfully.")
get_dlp_templates(template_id)

Returns the dlp notification template details for a given DLP template.

Parameters:

template_id (int) – The unique identifer for the DLP notification template.

Returns:

The DLP template resource record.

Return type:

Tuple

Examples

>>> fetched_template, response, error = client.zia.dlp_templates.get_dlp_templates('63578')
... if error:
...     print(f"Error fetching Template by ID: {error}")
...     return
... print(f"Fetched Template by ID: {fetched_template.as_dict()}")
list_dlp_templates(query_params=None)

Lists DLP Notification Templates. in your organization. If the search parameter is provided, the function filters the rules client-side.

Parameters:

{dict} (query_params) –

Map of query parameters for the request.

[query_params.search] {str}: Search string for filtering results.

Returns:

A tuple containing (list of DLPTemplates instances, Response, error)

Return type:

tuple

Examples

Print all dlp templates

>>> template_list, response, error = client.zia.dlp_templates.list_dlp_templates()
... if error:
...     print(f"Error listing templates: {error}")
...     return
... print(f"Total templates found: {len(template_list)}")
... for template in template_list:
...     print(template.as_dict())

Print templates that match the name ‘Standard_Template’

>>> template_list, response, error = client.zia.dlp_templates.list_dlp_templates(
    query_params={"search": 'Standard_Template'})
... if error:
...     print(f"Error listing templates: {error}")
...     return
... print(f"Total templates found: {len(template_list)}")
... for template in template_list:
...     print(template.as_dict())
update_dlp_template(template_id, **kwargs)

Updates the specified DLP Notification Template.

Parameters:

template_id (str) – The unique identifier for the DLP notification template.

Keyword Arguments:
  • name (str) – The new name of the DLP notification template.

  • subject (str) – The new subject line for the DLP notification email.

  • attach_content (bool) – If true, updates the setting for attaching content in violation.

  • plain_text_message (str) – New template for the plain text UTF-8 message body.

  • html_message (str) – New template for the HTML message body.

  • tls_enabled (bool) – If true, enables TLS for the notification template.

Returns:

A tuple containing the updated DLP Notification Template resource record, response, and error if any.

Return type:

tuple

Examples

Create a new DLP Notification Template:

>>> zia.dlp.add_dlp_template('63578'
...                         name="New DLP Template",
...                         subject="Alert: DLP Violation Detected",
...                         attach_content=True,
...                         plain_text_message="Text message content",
...                         html_message="<html><body>HTML message content</body></html>")