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(authz: antimatter.authz.Authorization, **kwargs)#

Bases: antimatter.session_mixins.base.BaseMixin

Session mixin defining CRUD functionality for facts and fact types.

list_fact_types() List[antimatter_api.FactTypeDefinition]#

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

list_facts(fact_type: str) List[antimatter_api.Fact]#

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) antimatter_api.Fact#

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) antimatter_api.FactTypeDefinition#

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) antimatter_api.Fact#

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, *arguments: str, fact_id: 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”