antimatter.session_mixins.write_context_mixin#

Module Contents#

Classes#

WriteContextMixin

Session mixin defining CRUD functionality for write contexts.

class antimatter.session_mixins.write_context_mixin.WriteContextMixin(authz: antimatter.authz.Authorization, **kwargs)#

Bases: antimatter.session_mixins.base.BaseMixin

Session mixin defining CRUD functionality for write contexts.

add_write_context(name: str, builder: antimatter.builders.WriteContextBuilder) None#

Upserts a write context for the current domain and auth

Parameters:
  • name – The name of the write context to add or update

  • builder – The builder containing write context configuration

list_write_context() List[antimatter_api.WriteContextDetails]#

Returns a list of write contexts available for the current domain and auth

describe_write_context(name: str) antimatter_api.WriteContextDetails#

Returns the write context with the given name for the current domain and auth

Parameters:

name – The name of the write context to describe

Returns:

The full details of the write context

upsert_write_context_configuration(name: str, builder: antimatter.builders.WriteContextConfigurationBuilder) None#

Update a write context configuration. The write context must already exist.

Parameters:
  • name – The name of the write context to update the configuration for

  • builder – The builder containing write context configuration

delete_write_context(name: str) None#

Delete a write context. All configuration associated with this write context will also be deleted. Domain policy rules referencing this write context will be left as-is.

Parameters:

name – The name of the write context to delete

list_write_context_classifier_rules(context_name: str) List[antimatter_api.ClassifierRule]#

List all regex rules for the write context.

Parameters:

context_name – The name of the write context

Returns:

The list of rules

insert_write_context_classifier_rule(context_name: str, comment: str | None = None, span_tags: List[str] = [], capsule_tags: List[str] = [], llm_model: str | None = None, llm_prompt: str | None = None, regex_pattern: str | None = None, regex_match_on_key: bool | None = None) str#

Insert a classifier rule for the context.

Parameters:
  • context_name – The name of the write context

  • comment – The comment for the classifier rule

  • span_tags – The span tags for the classifier rule

  • capsule_tags – The capsule tags for the classifier rule Span tags and capsule tags can be of the form: - A list of unary tags, like [‘tag.antimatter.io/pii/email’, ‘tag.antimatter.io/pii/name’] - A list of key-value pairs, like [“tag.antimatter.io/pii/date=24/12/2021”, “tag.antimatter.io/pii/credit_card=1234”] - A list of dictionaries, like [{“tag.antimatter.io/pii/email”: “”}, {“tag.antimatter.io/pii/date”: “24/12/2021”}] - A list of dictionaries as a name/value pair, like [{“name”: “tag.antimatter.io/pii/email”, “value”: “”}, {“name”: “tag.antimatter.io/pii/date”, “value”: “24/12/2021”}] - Any combination of the above

  • llm_model – The LLM model for the classifier rule. One of: ‘openai’, ‘bedrock’ One of the following must be provided: llm classifier rules or regex classifier rules

  • llm_prompt – The LLM prompt for the classifier rule

  • regex_pattern – A regex pattern for the classifier rule One of the following must be provided: llm classifier rules or regex classifier rules

  • regex_match_on_key – A regex match on key for the classifier rule

delete_write_context_classifier_rule(context_name: str, rule_id: str) None#

Delete a regex classifier rule for the context.

Parameters:
  • context_name – The name of the write context

  • rule_id – The ID of the rule to delete

delete_write_context_classifier_rules(context_name: str) None#

Delete the regex classifier rules for the context.

Parameters:

context_name – The name of the write context