Skip to main content

enterprise_ai.privacy

Source: sdks/python/src/enterprise_ai/privacy/__init__.py. Back to the Python SDK reference index.

note

This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.

Class PrivacyClient​

/v1/privacy, /v1/retention, /v1/lineage.

Resource

PrivacyClient.classify​

classify(text: str | None = None, media_id: str | None = None) -> Any

Classify a text or a media. With text, detects the entities with the tenant rules and returns classification, findings and engine, without changing the text. With media_id, returns the classification, findings and DLP result already computed for that media (404 not_found for an unknown media). One of the two is required (400 invalid_request). Open to any member of the tenant.

Route: /v1/privacy/classify (POST).

NameTypeDefaultRequiredDescription
textstr | NoneNonenoText to classify.
media_idstr | NoneNonenoIdentifier of an uploaded media whose stored classification is returned.

Returns: Any. Decoded JSON answer of the operation "Classify a text or a media".

Raises: ValueError, the typed errors of the transport (Errors).

PrivacyClient.classify_local​

classify_local(text: str) -> dict[str, Any]

Local estimate with the regex pre-scan (no network).

NameTypeDefaultRequiredDescription
textstryesText to classify.

Returns: dict[str, Any]. Dict {classification, findings}: the level of classify_text and the masked findings of scan.

PrivacyClient.create_retention_policy​

create_retention_policy(resource_type: str, ttl_days: int, **extra: Any) -> Any

Create or update a retention policy. Sets the retention policy of one resource type, replacing the existing one. Needs tenant_admin, security_officer or data_steward. An unknown resource type or an action other than erase or archive answers 400 invalid_request. The policy takes effect at the next retention run. Writes the audit event retention.policy.upsert. Answers 201 with the policy.

Route: /v1/retention/policies (POST).

NameTypeDefaultRequiredDescription
resource_typestryesResource type: memory, sessions, media, usage_raw, telemetry, documents or realtime.
ttl_daysintyesLifetime in days, 0 to 36500. Items older than that are purged by the next run.
**extraAnynoExtra fields merged into the request body.

Returns: Any. Decoded JSON answer of the operation "Create or update a retention policy".

Raises: the typed errors of the transport (Errors).

PrivacyClient.detect​

detect(text: str, **extra: Any) -> Any

Inspect a text for sensitive data. Runs DLP on the text with the tenant rules, in mode detect unless mode says otherwise. The answer gives text, findings (type, position, score, classification, short preview, action, rule), action (strongest action applied), classification, mode, engine (builtin or presidio), blocked and count. An unknown mode answers 400. Open to any member of the tenant. Writes the audit event dlp.inspect (counts and types only).

Route: /v1/dlp/inspect (POST).

NameTypeDefaultRequiredDescription
textstryesText to inspect or redact.
**extraAnynoExtra fields merged into the request body.

Returns: Any. Decoded JSON answer of the operation "Inspect a text for sensitive data".

Raises: the typed errors of the transport (Errors).

PrivacyClient.detokenize​

detokenize(tokens: list[str], purpose: str, **extra: Any) -> Any

Detokenize values. Returns the original values of tokens given in tokens or found in text.

Route: /v1/tokenization/detokenize (POST).

NameTypeDefaultRequiredDescription
tokenslist[str]yesTokens to resolve, tok_<type>_<hex>.
purposestryesWhy the values are needed, passed to the policy as context.purpose and written to the audit trail.
**extraAnynoExtra fields merged into the request body.

Returns: Any. Decoded JSON answer of the operation "Detokenize values".

Raises: the typed errors of the transport (Errors).

PrivacyClient.encrypt​

encrypt(plaintext: bytes | str, key: str, aad: str | None = None, **extra: Any) -> Any

Encrypt data with a tenant key. Encrypts plaintext (UTF-8 text) or plaintext_base64 (bytes) with the current version of the key, bound to aad. Returns ciphertext (eaienc1:...), key_id and key_version. One of the two inputs is required, and base64 must be valid (400 invalid_request); an unknown key answers 404 key_not_found. Open to any member of the tenant. Writes the audit event encryption.encrypt (size only).

Route: /v1/encryption/encrypt (POST).

NameTypeDefaultRequiredDescription
plaintextbytes | stryesUTF-8 text to encrypt.
keystryesKey to use, by identifier (UUID) or name.
aadstr | NoneNonenoAssociated data bound to the ciphertext; the same value is required to decrypt (empty by default).
**extraAnynoExtra fields merged into the request body.

Returns: Any. Decoded JSON answer of the operation "Encrypt data with a tenant key".

Raises: the typed errors of the transport (Errors).

PrivacyClient.erase_subject​

erase_subject(subject_id: str, reason: str | None = None, dry_run: bool | None = None, include_documents: bool | None = None) -> Any

Erase a data subject. Deletes the data held on one subject, in one transaction. Needs tenant_admin, security_officer or data_steward.

Route: /v1/retention/erase (POST).

NameTypeDefaultRequiredDescription
subject_idstryesSubject to erase, as known by the platform (user subject), 1 to 200 characters.
reasonstr | NoneNonenoLegal basis of the erasure, written to the audit trail. Default gdpr_art_17.
dry_runbool | NoneNonenoWhen true, counts what would be erased without deleting anything (default false).
include_documentsbool | NoneNonenoWhen true, also deletes the knowledge base documents created by the subject and their vectors (default false).

Returns: Any. Decoded JSON answer of the operation "Erase a data subject".

Raises: the typed errors of the transport (Errors).

PrivacyClient.legal_hold​

legal_hold(resource_type: str, resource_id: str, active: bool = True, reason: str | None = None) -> Any

Place or release a legal hold. Without hold_id, places a new hold on a subject (subject_id) or on one resource (resource_type and resource_id); reason is required (400 invalid_request otherwise). With hold_id, activates or releases that hold with active (404 not_found for an unknown hold).

Route: /v1/retention/legal-hold (POST).

NameTypeDefaultRequiredDescription
resource_typestryesType of the held resource, for example memory, media, sessions or documents. Goes with resource_id.
resource_idstryesIdentifier of the held resource.
activeboolTruenotrue (default) to hold, false to release the hold given by hold_id.
reasonstr | NoneNonenoWhy the hold is placed, for example a case number. Required for a new hold.

Returns: Any. Decoded JSON answer of the operation "Place or release a legal hold".

Raises: the typed errors of the transport (Errors).

PrivacyClient.lineage_dataset​

lineage_dataset(dataset_id: str) -> Any

Get the lineage of a dataset. Returns the dataset node, the jobs that produce it (produced_by), the jobs that consume it (consumed_by) and its upstream and downstream graphs up to depth hops. Open to any member of the tenant. Answers 404 not_found for an unknown dataset.

Route: /v1/lineage/datasets/{dataset_id} (GET).

NameTypeDefaultRequiredDescription
dataset_idstryesDataset key, dataset:<namespace>:<name> or <namespace>:<name> (the prefix is added), URL encoded.

Returns: Any. Decoded JSON answer of the operation "Get the lineage of a dataset".

Raises: the typed errors of the transport (Errors).

PrivacyClient.lineage_event​

lineage_event(event: dict[str, Any]) -> Any

Send OpenLineage events. Accepts one OpenLineage RunEvent or {"events": [RunEvent, ...]}, in one transaction. Each event needs run.runId and job.namespace and job.name; eventType is one of START, RUNNING, COMPLETE, ABORT, FAIL or OTHER (default; any other answers 400); eventTime defaults to the reception time.

Route: /v1/lineage/events (POST).

NameTypeDefaultRequiredDescription
eventdict[str, Any]yesOpenLineage run event, sent as the request body.

Returns: Any. Decoded JSON answer of the operation "Send OpenLineage events".

Raises: the typed errors of the transport (Errors).

PrivacyClient.lineage_graph​

lineage_graph(**filters: Any) -> Any

Get the lineage graph. Returns nodes and edges. With node, the graph is walked from that node in direction up to depth hops (404 not_found for an unknown node). Without node, returns up to limit job and dataset nodes ordered by key, and the edges between them. A direction other than both, upstream or downstream answers 400 invalid_request. Open to any member of the tenant.

Route: /v1/lineage/graph (GET).

NameTypeDefaultRequiredDescription
**filtersAnynoQuery parameters of the lineage graph, sent as is.

Returns: Any. Decoded JSON answer of the operation "Get the lineage graph".

Raises: the typed errors of the transport (Errors).

PrivacyClient.list_retention_policies​

list_retention_policies() -> Any

List the retention policies. Returns the retention policies of the tenant ordered by resource type in items, and the active legal holds in legal_holds. Open to any member of the tenant. next_cursor is always null.

Route: /v1/retention/policies (GET).

This element takes no parameter.

Returns: Any. Decoded JSON answer of the operation "List the retention policies".

Raises: the typed errors of the transport (Errors).

PrivacyClient.mask​

mask(text: str, **extra: Any) -> Any

Redact sensitive data from a text. Same as inspect, in mode mask by default: each finding is replaced by [TYPE] (for example [EMAIL]), or tokenized or blocked when a tenant rule or mode says so; a blocked text comes back empty with blocked: true. Open to any member of the tenant. Writes the audit event dlp.redact.

Route: /v1/dlp/redact (POST).

NameTypeDefaultRequiredDescription
textstryesText to inspect or redact.
**extraAnynoExtra fields merged into the request body.

Returns: Any. Decoded JSON answer of the operation "Redact sensitive data from a text".

Raises: the typed errors of the transport (Errors).

PrivacyClient.run_retention​

run_retention(dry_run: bool = False) -> Any

Run the retention policies. Applies the enabled policies now, to every resource type or to resource_types. Memory items and media past their own expiry are purged even without a policy; realtime transcripts and recordings follow the retention period of the participant consent. Items under legal hold are skipped.

Route: /v1/retention/run (POST).

NameTypeDefaultRequiredDescription
dry_runboolFalsenoWhen true, the request is checked and its result returned, but nothing is changed.

Returns: Any. Decoded JSON answer of the operation "Run the retention policies".

Raises: the typed errors of the transport (Errors).

PrivacyClient.tokenize​

tokenize(values: list[dict[str, str]] | None = None, text: str | None = None, **extra: Any) -> Any

Tokenize values. Replaces sensitive values by deterministic tokens tok_<type>_<hex> of the tenant (the same value always gives the same token), the values being stored encrypted in the vault. With values, returns tokens; with text, detects the entities and returns the tokenized text, findings and classification. One of the two is required (400 invalid_request). Open to any member of the tenant. Writes the audit event tokenization.tokenize (count only).

Route: /v1/tokenization/tokenize (POST).

NameTypeDefaultRequiredDescription
valueslist[dict[str, str]] | NoneNonenoValues to tokenize, each with its type.
textstr | NoneNonenoText whose detected entities are replaced by tokens.
**extraAnynoExtra fields merged into the request body.

Returns: Any. Decoded JSON answer of the operation "Tokenize values".

Raises: the typed errors of the transport (Errors).