antimatter.session_mixins.fact_mixin#

Module Contents#

Classes#

FactMixin

Session mixin defining CRUD functionality for facts and fact types.

class antimatter.session_mixins.fact_mixin.FactMixin(domain: str, client_func: Callable[[], antimatter.client.DefaultApi], **kwargs)#

Session mixin defining CRUD functionality for facts and fact types.

Parameters:
  • domain – The domain to use for the session.

  • client – The client to use for the session.

list_fact_types()#

Returns a list of fact types available for the current domain and auth

list_facts(fact_type: str)#

Returns a list of facts for the given fact type

add_fact_type(name: str, description: str, arguments: Dict[str, str]) None#

Upserts a fact type for the current domain and auth

Parameters:
  • name – The “type name” for this fact, like “has_role”

  • description – The human-readable description of the fact type

  • arguments – Name:description argument pairs for the fact type

add_fact(fact_type: str, *arguments: str) Dict[str, Any]#

Upserts a fact for the current domain and auth

Parameters:
  • fact_type – The name of the type of fact being added

  • arguments – The fact arguments to add

Returns:

The upserted fact

get_fact_type(fact_type: str) Dict[str, Any]#

Get the fact type details for the given fact type

Parameters:

fact_type – The “type name” for this fact, like “has_role”

Returns:

The fact type details

get_fact(fact_type: str, fact_id: str) Dict[str, Any]#

Returns the fact details for the given fact type and name

Parameters:
  • fact_type – The “type name” for this fact, like “has_role”

  • fact_id – The ID for the fact to be retrieved

Returns:

The fact details

delete_fact_type(fact_type: str) None#

Delete a fact type AND ALL FACTS INSIDE IT.

Parameters:

fact_type – The “type name” for this fact, like “has_role”

delete_fact(fact_type: str, fact_id: str | None = None, arguments: List[str] | None = None) None#

Delete a fact by ID or argument. One of ‘fact_id’ or ‘arguments’ must be provided. If ‘fact_id’ is provided, it will be used solely. If arguments are provided, each must fully match the name and/or arguments of the fact for it to be deleted.

Parameters:
  • fact_type – The “type name” for this fact, like “has_role”

  • fact_id – The ID for the fact to be deleted

  • arguments – The arguments for the fact to be deleted

delete_all_facts(fact_type: str) None#

Delete all the facts for the given fact type.

Parameters:

fact_type – The “type name” for this fact, like “has_role”