Policy Detection

The following methods allow for interaction with the Zscaler AI Guard Policy Detection API endpoints.

Methods are accessible via zaiguard.policy_detection .. _zaiguard-policy_detection:

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 PolicyDetectionAPI

Bases: APIClient

API client for AIGuard Policy Detection operations.

execute_policy(content, direction, policy_id=None, transaction_id=None)

Executes a policy detection with a specific policy ID.

Parameters:
  • content (str) – The content to scan

  • direction (str) – The direction of the content (‘IN’ or ‘OUT’)

  • policy_id (int, optional) – The policy ID to execute against

  • transaction_id (str, optional) – Optional transaction ID for tracking

Returns:

Tuple of (result, response, error)

Return type:

APIResult[ExecuteDetectionsPolicyResponse]

Examples

Minimal payload (content + direction):
>>> result, resp, err = client.zguard.policy_detection.execute_policy(
...     content="User prompt or AI response to scan",
...     direction="IN"
... )
With optional policy_id and transaction_id:
>>> result, resp, err = client.zguard.policy_detection.execute_policy(
...     content="Content to scan",
...     direction="OUT",
...     policy_id=12345,
...     transaction_id="txn-abc-123"
... )
resolve_and_execute_policy(content, direction, transaction_id=None)

Resolves and executes a policy detection (automatic policy selection).

Parameters:
  • content (str) – The content to scan

  • direction (str) – The direction of the content (‘IN’ or ‘OUT’)

  • transaction_id (str, optional) – Optional transaction ID for tracking

Returns:

Tuple of (result, response, error)

Return type:

APIResult[ResolveAndExecuteDetectionsPolicyResponse]

Examples

Minimal payload (content + direction):
>>> result, resp, err = client.zguard.policy_detection.resolve_and_execute_policy(
...     content="User prompt or AI response to scan",
...     direction="IN"
... )
With optional transaction_id:
>>> result, resp, err = client.zguard.policy_detection.resolve_and_execute_policy(
...     content="Content to scan",
...     direction="OUT",
...     transaction_id="txn-abc-123"
... )