Python Driver API reference

Python Driver API reference consists of two sections:

Query section

Query section consists of the following methods:

TypeDB Driver methods

Instantiating a TypeDB Core client

Syntax
TypeDB.core_client(address, parallelisation)
Description

In order to communicate with TypeDB Core databases via sessions and transactions, we first need to instantiate a TypeDB Core client. The created object connects our application with the running TypeDB server.

Input parameters
Name Description Type Required Default Value

address

The address (host:port) on which the TypeDB server is running

String

True

parallelisation

The number of threads to use for server communication

int

False

2

Returns
  • [Client]

Instantiating a TypeDB cluster client

Syntax
TypeDB.cluster_client(addresses, credential, parallelisation)
Description

In order to communicate with TypeDB cluster databases via sessions and transactions, we first need to instantiate a TypeDB cluster client. The created object connects our application with the running TypeDB cluster.

Node.js and Python Drivers always have TLS enabled!

They can only connect to a server that is set up with TLS.

When instantiating a TypeDB cluster client, it is sufficient to supply the address of just one server, as the addresses of the other servers will be relayed back to the client. However, to avoid failure in the unlikely event that the single server whose address is provided fails before communicating the addresses of the others, it is best practice to supply addresses of all the servers.

Input parameters
Name Description Type Required Default Value

addresses

Addresses (host:port) on which TypeDB cluster nodes are running

list of String

True

credential

User credential and TLS encryption setting

TypeDBCredential

True

parallelisation

The number of threads to use for server communication

int

False

2

Returns
  • [Client]

Client methods

Create a session for a database

Syntax
client.session(database, session_type, options)
Description

Opens a communication tunnel (session) to the given database on the running TypeDB server.

For more information on the methods, available with sessions, see the Session methods section.

Input parameters
Name Description Type Required Default Value

database

The name of the database with which the session connects.

String

True

N/A

type

The type of session to be created (DATA or SCHEMA)

SessionType

True

N/A

options

Options for the session.

TypeDBOptions

False

N/A

Returns

Retrieve all databases

Syntax
client.databases().all()
Description

Retrieves all databases running on the TypeDB server.

Returns
  • list of Database

Check if a database exists

Syntax
client.databases().contains(database)
Description

Checks if a database with the given name exists

Input parameters
Name Description Type Required Default Value

database

The database name to be checked.

String

True

N/A

Create a database

Syntax
client.databases().create("database name")
Description

Create a database with the given name.

Input parameters
Name Description Type Required Default Value

database

The name of the database to be created.

String

True

N/A

Returns
  • None

Retrieve a database

Syntax
client.databases().get("database name");
Description

Retrieve a database with the given name.

Input parameters
Name Description Type Required Default Value

database

The name of the database to retrieve.

String

True

N/A

Returns
  • Database

Delete a database

Syntax
client.databases().get("database name").delete()
Description

Deletes a database with the given name.

Input parameters
Name Description Type Required Default Value

database

The name of the database to be deleted.

String

True

N/A

Returns
  • None

Retrieve all users

Syntax
client.users().all()
Description

Retrieves all users running on the TypeDB server.

Returns
  • list of User

Check if a user exists

Syntax
client.users().contains(user)
Description

Checks if a user with the given name exists

Input parameters
Name Description Type Required Default Value

user

The user name to be checked.

String

True

N/A

Create a user

Syntax
client.users().create("user name")
Description

Create a user with the given name.

Input parameters
Name Description Type Required Default Value

user

The name of the user to be created.

String

True

N/A

Returns
  • None

Retrieve a user

Syntax
client.users().get("user name");
Description

Retrieve a user with the given name.

Input parameters
Name Description Type Required Default Value

user

The name of the user to retrieve.

String

True

N/A

Returns
  • user

Delete a user

Syntax
client.users().delete("username")
Description

Deletes a user with the given name.

Input parameters
Name Description Type Required Default Value

user

The name of the user to be deleted.

String

True

N/A

Returns
  • None

Set a user’s password

Syntax
client.users().passwordSet("username", "password")
Description

Deletes a user with the given name.

Input parameters
Name Description Type Required Default Value

user

The name of the user to update the password of.

String

True

N/A

password

User’s new password.

String

True

N/A

Returns
  • None

Close a client

Syntax
client.close()
Description

Closes the client. Before instantiating a new client, the client that’s currently open should first be closed.

Returns
  • None

Session methods

Open a transaction

Syntax
session.transaction(transaction_type, options)
Description

Opens a transaction to perform read or write queries on the database connected to the session.

Input parameters
Name Description Type Required Default Value

transactionType

The type of transaction to be created (READ or WRITE).

Transaction.Type

True

options

Options for the session.

[TypeDBOptions]

False

N/A

Returns

Check if a session is open

Syntax
session.is_open()
Description

Checks whether a session is presently open.

Returns
  • boolean

Check the session’s type

Syntax
session.session_type()
Description

Checks the current session’s type (SCHEMA or DATA)

Returns
  • SessionType

Get the session’s database

Syntax
session.database()
Description

Returns the database of the session.

Returns
  • Database object

Retrieve name of the database in the session

Syntax
session.database().name()
Description

Returns the current database name as a string.

Returns
  • String

Retrieve schema of the database in the session

Syntax
session.database().schema()
Description

Returns a full schema text as a valid TypeQL define query string.

Returns
  • String

Delete a database of the session

Syntax
session.database().delete()
Description

Deletes the database of the current session.

Returns
  • void

Close a session

Syntax
session.close()
Description

Closes the session. Before opening a new session, the session currently open should first be closed.

Returns
  • None

Transaction methods

Check the transaction’s type

Syntax
transaction.transaction_type()
Description

Checks the transaction’s type (READ or WRITE)

Returns
  • TransactionType

Check if the transaction is open

Syntax
transaction.is_open()
Returns
  • boolean

Access Concept API methods

Syntax
transaction.concepts();
Description

Gets the [ConceptManager]  for this Transaction, providing access to all Concept API methods.

Returns
  • [ConceptManager]

Access Concept API - Logic methods

Syntax
transaction.logic();
Description

Gets the [LogicManager]  for this Transaction, providing access to all Concept API - Logic methods.

Returns
  • [LogicManager]

Access Query API methods

Syntax
transaction.query();
Description

Gets the [QueryManager]  for this Transaction, from which any TypeQL query can be executed.

Returns
  • [QueryManager]

Commit a write transaction

Syntax
transaction.commit()
Description

Commits the changes made via this transaction to the TypeDB database. Whether or not the transaction is commited successfully, it gets closed after the commit call.

Returns
  • None

Rollback a write transaction

Syntax
transaction.rollback()
Description

Rolls back the uncommitted changes made via this transaction.

Returns
  • None

Close a read transaction

Syntax
transaction.close()
Description

Closes the transaction.

Returns
  • None

QueryManager methods

Execute a TypeQL Match (Get) query

Syntax
transaction.query().match(query, options)
Description

Performs a TypeQL Match (Get) query in the transaction.

Input parameters
Name Description Type Required Default Value

query

The TypeQL Match (Get) query to be executed.

string

True

N/A

options

Specify query options

[TypeDBOptions]

False

default TypeDBOptions - uses server defaults

Returns
  • Iterator of [ConceptMap]

Execute a TypeQL Match Aggregate query

Syntax
transaction.query().match_aggregate(query, options)
Description

Performs a TypeQL Match Aggregate query in the transaction.

Input parameters
Name Description Type Required Default Value

query

The TypeQL Match Aggregate query to be executed.

string

True

N/A

options

Specify query options

[TypeDBOptions]

False

default TypeDBOptions - uses server defaults

Returns
  • [QueryFuture]  of [Numeric]

Execute a TypeQL Match Group query

Syntax
transaction.query().match_group(query, options)
Description

Performs a TypeQL Match Group query in the transaction.

Input parameters
Name Description Type Required Default Value

query

The TypeQL Match Group query to be executed.

string

True

N/A

options

Specify query options

[TypeDBOptions]

False

default TypeDBOptions - uses server defaults

Returns
  • Iterator of [ConceptMapGroup]

Execute a TypeQL Match Group Aggregate query

Syntax
transaction.query().match_group_aggregate(query, options)
Description

Performs a TypeQL Match Group Aggregate query in the transaction.

Input parameters
Name Description Type Required Default Value

query

The TypeQL Match Group Aggregate query to be executed.

string

True

N/A

options

Specify query options

[TypeDBOptions]

False

default TypeDBOptions - uses server defaults

Returns
  • Iterator of [NumericGroup]

Execute a TypeQL Insert query

Syntax
transaction.query().insert(query, options)
Description

Performs a TypeQL Insert query in the transaction.

Input parameters
Name Description Type Required Default Value

query

The TypeQL Insert query to be executed.

string

True

N/A

options

Specify query options

[TypeDBOptions]

False

default TypeDBOptions - uses server defaults

Returns
  • Iterator of [ConceptMap]

Execute a TypeQL Delete query

Syntax
transaction.query().delete(query, options)
Description

Performs a TypeQL Delete query in the transaction.

Input parameters
Name Description Type Required Default Value

query

The TypeQL Delete query to be executed.

string

True

N/A

options

Specify query options

[TypeDBOptions]

False

default TypeDBOptions - uses server defaults

Returns
  • [QueryFuture]

Execute a TypeQL Update query

Syntax
transaction.query().update(query, options)
Description

Performs a TypeQL Update query in the transaction.

Input parameters
Name Description Type Required Default Value

query

The TypeQL Update query to be executed.

string

True

N/A

options

Specify query options

[TypeDBOptions]

False

default TypeDBOptions - uses server defaults

Returns
  • Iterator of [ConceptMap]

Execute a TypeQL Explain query

Syntax
transaction.query().explain(explainable, options)
Description

Performs a TypeQL Explain query in the transaction.

Input parameters
Name Description Type Required Default Value

explainable

The Explainable to be explained.

[ConceptMap.Explainable]

True

options

Specify query options

[TypeDBOptions]

False

default TypeDBOptions - uses server defaults

Returns
  • Iterator of [Explanation]

Execute a TypeQL Define query

Syntax
transaction.query().define(query, options)
Description

Performs a TypeQL Define query in the transaction.

Input parameters
Name Description Type Required Default Value

query

The TypeQL Define query to be executed.

string

True

N/A

options

Specify query options

[TypeDBOptions]

False

default TypeDBOptions - uses server defaults

Returns
  • [QueryFuture]

Execute a TypeQL Undefine query

Syntax
transaction.query().undefine(query, options)
Description

Performs a TypeQL Undefine query in the transaction.

Input parameters
Name Description Type Required Default Value

query

The TypeQL Undefine query to be executed.

string

True

N/A

options

Specify query options

[TypeDBOptions]

False

default TypeDBOptions - uses server defaults

Returns
  • [QueryFuture]

Options

The transaction query options object TypeDBOptions can be used to override the default server behaviour query processing. Use TypeDBOptions.core() to create a new TypeDB Core options object, or TypeDBOptions.cluster() for cluster client for TypeDB Enterprise & TypeDB Cloud..

The options are:

  • infer: whether to enable inference for the provided query (only settable at transaction level and above, and only affects read transactions) (default: False)

  • explain: whether to enable explanations for the provided query (only affects read transactions) (default: False)

  • parallel: whether the server should use parallel or single-threaded execution (default: True)

  • prefetch_size: a guideline number of answers that the server should send before the client issues a fresh request (default: 50)

  • trace_inference: if enabled, outputs reasoning tracing graphs in the logging directory. Should be used with parallel = False. (default: False)

  • prefetch: if enabled, the first batch of answers is streamed to the client even without an explicit request for it (default: True if query type is match, otherwise False)

  • session_idle_timeout_millis: this timeout allows the server to close sessions if a client terminates or becomes unresponsive (default: 30_000)

  • transaction_timeout_millis: this timeout will automatically kill transactions, preventing memory leaks in unclosed transactions (default: 300_000)

  • schema_lock_acquire_timeout_millis: how long the client should wait if opening a session or transaction is blocked by a schema write lock (default: 10_000)

TypeDBClusterOptions has an additional option:

  • read_any_replica: enables reading data from any replica, potentially boosting read throughput (default: False)


Response section

Response section consists of the following methods:

Answer methods

Retrieve a mapping of variables to concepts

Syntax
concept_map.map()
Description

Produces a dictionary where keys are variable names and values are [concept] s.

Returns
  • Dictionary of String to [Concept]

Retrieve concepts

Syntax
concept_map.concepts()
Description

Return an iterable collection of all the [concept] s in this ConceptMap.

Returns
  • Iterable of Concept

Retrieve a concept corresponding to a specific variable

Syntax
conceptMap.get(var)
Description

Retrieve a concept for a given variable name

Input parameters
Name Description Type Required Default Value

var

The string representation of a variable

String

Returns
  • [Concept]

Retrieve explainable concepts

Syntax
concept_map.explainables()
Description

Gets the [Explainables]  object for this ConceptMap, exposing which of the Concepts in this ConceptMap are explainable

Returns
  • [ConceptMap.Explainables]

Retrieve numeric value of an aggregate answer as an integer

Syntax
numeric.as_int();
Returns
  • int

Retrieve numeric value of an aggregate answer as a float

Syntax
numeric.as_float();
Returns
  • float

Checks if the type of an aggregate answer is an integer

Syntax
numeric.is_int();
Returns
  • boolean

Checks if the type of an aggregate answer is a float

Syntax
numeric.is_float();
Returns
  • boolean

Checks if the type of an aggregate answer is not a number

Syntax
concept_map_group.is_NaN()
Returns
  • boolean

Retrieve the concept that is the group owner

Syntax
concept_map_group.owner()
Returns
  • [Concept]

Retrieve the ConceptMaps of the group

Syntax
concept_map_group.concept_maps();
Returns
  • List of [ConceptMap] s

Retrieve the concept that is the group owner

Syntax
numeric_group.owner()
Returns
  • [Concept]

Retrieve the Numeric answer of the group

Syntax
numeric_group.numeric()
Returns
  • [Numeric]

Retrieve explainable relation

Syntax
concept_map.explainables().relation(variable);
Description

Retrieves the explainable relation with the given variable name.

Input parameters
Name Description Type Required Default Value

variable

The string representation of a variable

String

Returns
  • [ConceptMap.Explainable]

Retrieve explainable attribute

Syntax
concept_map.explainables().attribute(variable);
Description

Retrieves the explainable attribute with the given variable name.

Input parameters
Name Description Type Required Default Value

variable

The string representation of a variable

String

Returns
  • [ConceptMap.Explainable]

Retrieve explainable ownership

Syntax
concept_map.explainables().ownership(owner_var, attribute_var);
Description

Retrieves the explainable attribute ownership with the pair of (owner, attribute) variable names.

Input parameters
Name Description Type Required Default Value

variable

The string representation of a variable

String

Returns
  • [ConceptMap.Explainable]

Retrieve explainable relations

Syntax
concept_map.explainables().relations();
Description

Retrieves all of this ConceptMap’s explainable relations.

Returns
  • Dictionary of String to [ConceptMap.Explainable]

Retrieve explainable attributes

Syntax
concept_map.explainables().attributes();
Description

Retrieves all of this ConceptMap’s explainable attributes.

Returns
  • Dictionary of String to [ConceptMap.Explainable]

Retrieve explainable ownerships

Syntax
concept_map.explainables().ownerships();
Description

Retrieves all of this ConceptMap’s explainable attribute ownerships.

Returns
  • Dictionary of (String, String) to [ConceptMap.Explainable]

Retrieve conjunction

Syntax
explainable.conjunction()
Description

Retrieves the subquery of the original query that is actually being explained.

Returns
  • String

Retrieve ID

Syntax
explainable.explainable_id()
Description

Retrieves the unique ID that identifies this Explainable.

Returns
  • int

Retrieve the rule

Syntax
explanation.rule()
Description

Retrieves the Rule for this Explanation.

Returns
  • Rule

Retrieve the conclusion

Syntax
explanation.conclusion()
Description

Retrieves the Conclusion for this Explanation.

Returns
  • ConceptMap

Retrieve the condition

Syntax
explanation.condition()
Description

Retrieves the Condition for this Explanation.

Returns
  • ConceptMap

Retrieve the variable mapping

Syntax
explanation.variable_mapping()
Description

Retrieves the mapping between rule variables and query variables for this Explanation.

Returns
  • Map<String, Set<String>>

Concept methods

Concept is inherited and extended by Value, Type and Data.

Get a Remote version of the concept.

Syntax
concept.as_remote(tx)
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

tx

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • RemoteConcept

Check if concept is a Type (Local)

Syntax
concept.is_type()
Returns
  • boolean

Check if concept is a Value (Local)

Syntax
concept.is_value()
Returns
  • boolean

Check if concept is a Thing (Local)

Syntax
concept.is_thing()
Returns
  • boolean

Check if concept is an EntityType (Local)

Syntax
concept.is_entity_type()
Returns
  • boolean

Check if concept is an AttributeType (Local)

Syntax
concept.is_attribute_type()
Returns
  • boolean

Check if concept is a RelationType (Local)

Syntax
concept.is_relation_type()
Returns
  • boolean

Check if concept is a RoleType (Local)

Syntax
concept.is_role_type()
Returns
  • boolean

Check if concept is an Entity (Local)

Syntax
concept.is_entity()
Returns
  • boolean

Check if concept is an Attribute (Local)

Syntax
concept.is_attribute()
Returns
  • boolean

Check if concept is a Relation (Local)

Syntax
concept.is_relation()
Returns
  • boolean

Cast the concept as Type (Local)

Syntax
concept.as_type()
Description

Casts the concept as Type so that we can call the Type methods on it.

Returns
  • [Type]

Cast the concept as Thing (Local)

Syntax
concept.as_thing()
Description

Casts the concept as Thing so that we can call the Thing methods on it.

Returns
  • [Thing]

Cast the concept as Value (Local)

Syntax
concept.as_value();
Description

Casts the concept object as Value so that we can use it as value.

Returns
  • string

  • int

  • float

  • boolean

  • Date

Cast the concept as EntityType (Local)

Syntax
concept.as_entity_type();
Description

Casts the concept as EntityType so that we can call the EntityType methods on it.

Returns
  • [EntityType]

Cast the concept as AttributeType (Local)

Syntax
concept.as_attribute_type();
Description

Casts the concept as AttributeType so that we can call the AttributeType methods on it.

Returns
  • [AttributeType]

Cast the concept as RelationType (Local)

Syntax
concept.as_relation_type();
Description

Casts the concept as RelationType so that we can call the RelationType methods on it.

Returns
  • [RelationType]

Cast the concept as RoleType (Local)

Syntax
concept.as_role_type();
Description

Casts the concept as RoleType so that we can call the RoleType methods on it.

Returns
  • [RoleType]

Cast the concept as Entity (Local)

Syntax
concept.as_entity();
Description

Casts the concept as Entity so that we can call the Entity methods on it.

Returns
  • [Entity]

Cast the concept as Attribute (Local)

Syntax
concept.as_attribute();
Description

Casts the concept as Attribute so that we can call the Attribute methods on it.

Returns
  • [Attribute]

Cast the concept as Relation (Local)

Syntax
concept.as_relation();
Description

Casts the concept as Relation so that we can call the Relation methods on it.

Returns
  • [Relation]

Delete concept

Syntax
concept.as_remote(tx).delete()
Returns
  • None

Check if the concept has been deleted

Syntax
concept.as_remote(tx).is_deleted()
Returns
  • boolean

Retrieve a concept as JSON

Syntax
concept.to_json()
Returns
  • JSON

ConceptManager methods

Retrieve the root ThingType

Syntax
transaction.concepts().get_root_thing_type()
Description

Retrieves the root ThingType, "thing".

Returns
  • [ThingType]

Retrieve the root EntityType

Syntax
transaction.concepts().get_root_entity_type()
Description

Retrieves the root EntityType, "entity".

Returns
  • [EntityType]

Retrieve the root RelationType

Syntax
transaction.concepts().get_root_relation_type()
Description

Retrieves the root RelationType, "relation".

Returns
  • [RelationType]

Retrieve the root AttributeType

Syntax
transaction.concepts().get_root_attribute_type()
Description

Retrieves the root AttributeType, "attribute".

Returns
  • [AttributeType]

Retrieve an EntityType

Syntax
transaction.concepts().get_entity_type(label)
Description

Retrieves an EntityType by its label.

Input parameters
Name Description Type Required Default Value

label

The label of the EntityType to retrieve.

string

True

N/A

Returns
  • [EntityType]

Create or retrieve an EntityType

Syntax
transaction.concepts().put_entity_type(label)
Description

Creates a new EntityType if none exists with the given label, otherwise retrieves the existing one.

Input parameters
Name Description Type Required Default Value

label

The label of the EntityType to create or retrive.

string

True

N/A

Returns
  • [EntityType]

Retrieve a RelationType

Syntax
transaction.concepts().get_relation_type(label)
Description

Retrieves a RelationType by its label.

Input parameters
Name Description Type Required Default Value

label

The label of the RelationType to retrieve.

string

True

N/A

Returns
  • [RelationType]

Create or retrieve a RelationType

Syntax
transaction.concepts().put_relation_type(label)
Description

Creates a new RelationType if none exists with the given label, otherwise retrieves the existing one.

Input parameters
Name Description Type Required Default Value

label

The label of the RelationType to create or retrive.

string

True

N/A

Returns
  • [RelationType]

Retrieve an AttributeType

Syntax
transaction.concepts().get_attribute_type(label)
Description

Retrieves an AttributeType by its label.

Input parameters
Name Description Type Required Default Value

label

The label of the AttributeType to retrieve.

string

True

N/A

Returns
  • [AttributeType]

Create or retrieve an AttributeType

Syntax
await transaction.concepts().put_attribute_type(label, value_type)
Description

Creates a new AttributeType if none exists with the given label, or retrieves the existing one.

Input parameters
Name Description Type Required Default Value

label

The label of the AttributeType to create or retrieve.

string

True

N/A

value_type

The value type of the AttributeType to create or retrieve.

ValueType (STRING | DATETIME | LONG | DOUBLE | BOOLEAN)

True

N/A

Returns
  • [AttributeType]

Retrieve a Thing

Syntax
transaction.concepts().get_thing(iid)
Description

Retrieves the Thing that has the given TypeDB internal ID.

Input parameters
Name Description Type Required Default Value

iid

The IID of the concept to retrieve.

string

True

N/A

Returns
  • [Thing]

Retrieve a ThingType

Syntax
transaction.concepts().get_thing_type(label)
Description

Retrieves a ThingType by its label.

Input parameters
Name Description Type Required Default Value

label

The label of the ThingType to retrieve.

string

True

N/A

Returns
  • [ThingType]

Future methods

Get the query result

Syntax
future.get()
Description

Waits for the query to finish execution, and returns its result, if present.

Returns
  • Returns according to type of query executed

Map the query result

Syntax
future.map(function)
Description

Transforms the QueryFuture into a new QueryFuture by running the supplied function on the query result when it is returned.

Returns
  • Return type of supplied function

Type methods

Type has all the Concept methods plus what follows.

Get a Remote version of the type.

Syntax
type.as_remote(tx)
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

tx

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • RemoteType

Retrieve label (Local)

Syntax
type.get_label().name()
Description

Retrieves the unique label of the type.

Returns
  • String

Check if type is abstract (Local)

Syntax
type.is_abstract()
Description

Checks if the type is prevented from having data instances (i.e., abstract).

Returns
  • boolean

Check if type is a root type (Local)

Syntax
type.is_root()
Description

Checks if the type is a root type.

Returns
  • boolean

Rename label

Syntax
type.as_remote(tx).set_label(label)
Description

Renames the label of the type. The new label must remain unique.

Input parameters
Name Description Type Required Default Value

label

The new label to be given to the type.

String

True

N/A

Returns
  • None

Retrieve direct supertype

Syntax
type.as_remote(tx).get_supertype()
Description

Retrieves the most immediate supertype of the type.

Returns
  • [Type]

  • None

Retrieve all supertypes

Syntax
type.as_remote(tx).get_supertypes()
Description

Retrieves all supertypes of the type.

Returns
  • Iterator of [Type]

Retrieve all subtypes

Syntax
type.as_remote(tx).get_subtypes()
Description

Retrieves all direct and indirect subtypes of the type.

Returns
  • Iterator of [Type]

ThingType methods

ThingType has all the Type methods plus what follows.

Get a Remote version of the ThingType.
Syntax
thing_type.as_remote(tx)
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

tx

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • RemoteThingType

Retrieve direct supertype
Syntax
thing_type.as_remote(tx).get_supertype()
Description

Retrieves the most immediate supertype of the ThingType.

Returns
  • [ThingType]

  • None

Retrieve all supertypes
Syntax
thing_type.as_remote(tx).get_supertypes()
Description

Retrieves all supertypes of the ThingType.

Returns
  • Iterator of [ThingType]

Retrieve all subtypes
Syntax
thing_type.as_remote(tx).get_subtypes()
Description

Retrieves all direct and indirect subtypes of the ThingType.

Returns
  • Iterator of [ThingType]

Retrieve instances
Syntax
thing_type.as_remote(tx).get_instances()
Returns
  • Iterator of [Thing]

Set abstract
Syntax
thing_type.as_remote(tx).set_abstract()
Description

Set a ThingType to be abstract, meaning it cannot have instances.

Returns
  • None

Unset abstract
Syntax
thing_type.as_remote(tx).unset_abstract()
Description

Set a ThingType to be non-abstract, meaning it can have instances.

Returns
  • None

Add new playable role
Syntax
thing_type.as_remote(tx).set_plays(role_type, overridden_type=None)
Description

Allows the instances of this type to play the given role.

Input parameters
Name Description Type Required Default Value

role_type

The role to be played by the instances of this type.

[RoleType]

True

N/A

overridden_type

The role type that this role overrides, if applicable.

[RoleType]

False

None

Returns
  • None

Add attribute ownership
Syntax
thing_type.as_remote(tx).set_owns(attribute_type, overridden_type=None, annotations=frozenset());
Description

Allows the instances of this type to own the given AttributeType.

Input parameters
Name Description Type Required Default Value

attributeType

The AttributeType to be owned by the instances of this type.

[AttributeType]

True

N/A

overriddenType

The AttributeType that this attribute ownership overrides, if applicable.

[AttributeType]

False

None

annotations

Adds annotations (KEY or UNIQUE) to the ownership.

set of Annotations

False

frozenset()

Returns
  • None

Retrieve playable roles
Syntax
thing_type.as_remote(tx).get_plays()
Description

Retrieves all direct and inherited roles that are allowed to be played by the instances of this type.

Returns
  • Iterator of [RoleType]

Retrieve playable roles
Syntax
thing_type.as_remote(tx).get_plays_explicit()
Description

Retrieves all direct roles that are allowed to be played by the instances of this type.

Returns
  • Iterator of [RoleType]

Retrieve attributes
Syntax
thing_type.as_remote(tx).get_owns(value_type=None, annotations=frozenset())
Description

Retrieves attribute types that the instances of this type are allowed to own directly or via inheritance.

Input parameters
Name Description Type Required Default Value

value_type

If specified, only attribute types of this ValueType will be retrieved.

ValueType

False

None

annotations

Only retrieve attribute types owned with annotations (KEY or UNIQUE).

set of Annotations

False

frozenset()

Returns
  • Iterator of [AttributeType]

Retrieve direct attributes
Syntax
thing_type.as_remote(tx).get_owns_explicit(value_type=None, annotations=frozenset())
Description

Retrieves attribute types that the instances of this type are allowed to own directly.

Input parameters
Name Description Type Required Default Value

value_type

If specified, only attribute types of this ValueType will be retrieved.

ValueType

False

None annotations

Returns
  • Iterator of [AttributeType]

Remove role
Syntax
thing_type.as_remote(tx).unset_plays(role)
Description

Disallows the instances of this type from playing the given role.

Input parameters
Name Description Type Required Default Value

role

The role to not be played by the instances of this type.

[RoleType]

True

N/A

Returns
  • None

Remove attribute
Syntax
thing_type.as_remote(tx).unset_owns(attribute_type)
Description

Disallows the instances of this type from owning the given AttributeType.

Input parameters
Name Description Type Required Default Value

attribute_type

The AttributeType to not be owned by the type.

[AttributeType]

True

N/A

Returns
  • None

EntityType methods

EntityType has all the ThingType methods plus what follows.

Create instance
Syntax
entity_type.as_remote(tx).create()
Description

Creates and returns a new instance of this EntityType.

Returns
  • [Entity]

Set supertype
Syntax
entity_type.as_remote(tx).set_supertype(entity_type)
Description

Sets the supplied EntityType as the supertype of the current EntityType

Input parameters
Name Description Type Required Default Value

entityType

The EntityType to set as the supertype of this EntityType

EntityType

True

N/A

Returns
  • None

Retrieve all subtypes
Syntax
type.as_remote(tx).get_subtypes()
Description

Retrieves all direct and indirect subtypes of the EntityType.

Returns
  • Iterator of [EntityType]

Retrieve all instances of this EntityType
Syntax
type.as_remote(tx).get_instances()
Description

Retrieves all direct and indirect Entity objects that are instances of this Type.

Returns
  • Iterator of [Entity]

Get a Remote version of the EntityType.
Syntax
entity_type.as_remote(tx)
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

transaction

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • RemoteEntityType

RelationType methods

RelationType has all the ThingType methods plus what follows.

Create instance
Syntax
relation_type.as_remote(tx).create()
Description

Creates and returns an instance of this RelationType.

Returns
  • [Relation]

Retrieve roles
Syntax
relation_type.as_remote(tx).get_relates()
Description

Retrieve roles that this RelationType relates to directly or via inheritance.

Returns
  • Iterator of [RoleType]

Retrieve direct roles
Syntax
relation_type.as_remote(tx).get_relates_explicit()
Description

Retrieve roles that this RelationType relates to directly.

Returns
  • Iterator of [RoleType]

Retrieve specific role
Syntax
relation_type.as_remote(tx).get_relates(label)
Description

Retrieve the role that this RelationType relates to, if it exists, with the specified label.

Input parameters
Name Description Type Required Default Value

label

Label of the role we wish to retrieve.

string

True

Returns
  • [RoleType]

Set new role
Syntax
relation_type.as_remote(tx).set_relates(label, overriddenRoleLabel)
Description

Sets the new role that this RelationType relates to. If we are setting an overriding type this way, we have to also pass the overridden type as a second argument.

Input parameters
Name Description Type Required Default Value

label

The new role for the RelationType to relate to.

string

True

N/A

overriddenRoleLabel

The label being overridden, if applicable

string

False

N/A

Returns
  • None

Remove role
Syntax
relation_type.as_remote(tx).unset_relates(role)
Description

Disallows this RelationType from relating to the given role.

Input parameters
Name Description Type Required Default Value

role

The role to not relate to the relation type.

RoleType

True

N/A

Returns
  • None

Set supertype
Syntax
relation_type.as_remote(tx).set_supertype(relation_type)
Description

Sets the supplied RelationType as the supertype of the current RelationType

Input parameters
Name Description Type Required Default Value

_type

The RelationType to set as the supertype of this RelationType

RelationType

True

N/A

Returns
  • None

Retrieve all subtypes
Syntax
type.as_remote(tx).get_subtypes()
Description

Retrieves all direct and indirect subtypes of the RelationType.

Returns
  • Iterator of [RelationType]

Retrieve all instances of this RelationType
Syntax
type.as_remote(tx).get_instances()
Description

Retrieves all direct and indirect Relations that are instances of this Type.

Returns
  • Iterator of [Relation]

Get a Remote version of the RelationType.
Syntax
relationType.as_remote(tx)
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

transaction

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • RemoteRelationType

RoleType methods

RoleType has all the Type methods plus what follows.

Get a Remote version of the role type.
Syntax
role_type.as_remote(tx)
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

tx

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • RemoteRoleType

Retrieve scope (Local)
Syntax
role_type.get_label().scope()
Description

Retrieves the scope (defined relation label) of the role type.

Returns
  • String

Retrieve scoped label (Local)
Syntax
role_type.get_label().scoped_name()
Description

Retrieves the scoped label (relation:role) of the role type.

Returns
  • String

Retrieve direct supertype
Syntax
type.as_remote(tx).get_supertype()
Description

Retrieves the most immediate supertype of the role type.

Returns
  • [RoleType]

  • None

Retrieve all supertypes
Syntax
type.as_remote(tx).get_supertypes()
Description

Retrieves all supertypes of the role type.

Returns
  • Iterator of [RoleType]

Retrieve all subtypes
Syntax
type.as_remote(tx).get_subtypes()
Description

Retrieves all direct and indirect subtypes of the type.

Returns
  • Iterator of [RoleType]

Retrieve relation
Syntax
role.as_remote(tx).get_relation_type()
Description

Retrieves the Relation instance that this role is directly related to.

Returns
  • [RelationType]

Retrieve relation types
Syntax
role.as_remote(tx).get_relation_types()
Description

Retrieves the RelationTypes that this role is related to.

Returns
  • Iterator of [RelationType]

Retrieve role players
Syntax
role.as_remote(tx).get_players()
Description

Retrieves the ThingTypes whose instances play this role.

Returns
  • Iterator of [ThingType](/docs/concept-api/type?tab=python)

AttributeType methods

AttributeType has all the ThingType methods plus what follows.

Retrieve valuetype (Local)
Syntax
attributeType.get_value_type()
Description

Retrieves the valuetype of this AttributeType.

Returns
  • AttributeType.ValueType (STRING | DATETIME | LONG | DOUBLE | BOOLEAN)

Set supertype
Syntax
attributeType.as_remote(tx).set_supertype(attribute_type)
Description

Sets the supplied AttributeType as the supertype of the current AttributeType

Input parameters
Name Description Type Required Default Value

attribute_type

The AttributeType to set as the supertype of this AttributeType

AttributeType

True

N/A

Returns
  • None

Retrieve all subtypes
Syntax
attributeType.as_remote(tx).get_subtypes()
Description

Retrieves all direct and indirect subtypes of the AttributeType.

Returns
  • Iterator of [AttributeType]

Retrieve all instances of this AttributeType
Syntax
attributeType.as_remote(tx).get_instances()
Description

Retrieves all direct and indirect Attributes that are instances of this Type.

Returns
  • Iterator of [Attribute]

Retrieve direct and inherited owners of this Type of Attribute
Syntax
attribute_type.as_remote(tx).get_owners(annotations=frozenset())
Description

Retrieve all Things that own an attribute of this type.
Optionally, filtered by annotations.

Input parameters
Name Description Type Required Default Value

annotations

Only retrieve things that have an attribute of this type with annotations (KEY or UNIQUE).

set of Annotations

False

frozenset()

Returns
  • Iterator of [Thing]

Retrieve direct owners of this Type of Attribute
Syntax
attribute_type.as_remote(tx).get_owners_explicit(annotations=frozenset())
Description

Retrieve all Things that directly own an attribute of this type. Optionally, filtered by annotations.

Input parameters
Name Description Type Required Default Value

annotations

Only retrieve things that directly have an attribute of this type with annotations (KEY or UNIQUE).

set of Annotations

False

frozenset()

Returns
  • Iterator of [Thing]

Get a Remote version of the AttributeType.
Syntax
attributeType.as_remote(tx)
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

transaction

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • RemoteAttributeType

Check if value is of type boolean
Syntax
attributeType.is_boolean()
Description

Returns true if the value for attributes of this type is of type boolean. Otherwise, returns false.

Check if value is of type long
Syntax
attributeType.is_long()
Description

Returns true if the value for attributes of this type is of type long. Otherwise, returns false.

Check if value is of type double
Syntax
attributeType.is_double()
Description

Returns true if the value for attributes of this type is of type double. Otherwise, returns false.

Check if value is of type string
Syntax
attributeType.is_string()
Description

Returns true if the value for attributes of this type is of type string. Otherwise, returns false.

Check if value is of type datetime
Syntax
attributeType.is_datetime()
Description

Returns true if the value for attributes of this type datetime. Otherwise, returns false.

BooleanAttributeType methods

BooleanAttributeType has all the AttributeType methods plus what follows.

Put instance
Syntax
booleanAttributeType.as_remote(tx).put(value)
Description

Puts and returns a new instance of this BooleanAttributeType with the specified value. If an attribute with this value does not yet exist, it will be created.

Input parameters
Name Description Type Required Default Value

value

The value of the instance to be put

boolean

True

N/A

Returns
  • BooleanAttribute object

Get instance
Syntax
booleanAttributeType.as_remote(tx).get(value)
Description

Returns the instance, if it exists, of this BooleanAttributeType with the specified value.

Input parameters
Name Description Type Required Default Value

value

The value of the instance to be retrieved

boolean

True

N/A

Returns
  • BooleanAttribute object

Set supertype
Syntax
booleanAttributeType.as_remote(tx).set_supertype(boolean_attribute_type)
Description

Sets the supplied BooleanAttributeType as the supertype of the current BooleanAttributeType

Input parameters
Name Description Type Required Default Value

_type

The AttributeType to set as the supertype of this BooleanAttributeType

BooleanAttributeType

True

N/A

Returns
  • None

Retrieve all subtypes
Syntax
booleanAttributeType.as_remote(tx).get_subtypes()
Description

Retrieves all direct and indirect subtypes of the BooleanAttributeType.

Returns
  • Iterator of [BooleanAttributeType]

Retrieve all instances of this BooleanAttributeType
Syntax
booleanAttributeType.as_remote(tx).get_instances()
Description

Retrieves all direct and indirect BooleanAttributes that are instances of this Type.

Returns
  • Iterator of [BooleanAttribute]

Get a Remote version of the BooleanAttributeType.
Syntax
booleanAttributeType.as_remote(tx)
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

transaction

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • RemoteBooleanAttributeType

LongAttributeType methods

LongAttributeType has all the AttributeType methods plus what follows.

Put instance
Syntax
longAttributeType.as_remote(tx).put(value)
Description

Puts and returns a new instance of this LongAttributeType with the specified value. If an attribute with this value does not yet exist, it will be created.

Input parameters
Name Description Type Required Default Value

value

The value of the instance to be put

int

True

N/A

Returns
  • LongAttribute

Get instance
Syntax
longAttributeType.as_remote(tx).get(value)
Description

Returns the instance, if it exists, of this LongAttributeType with the specified value.

Input parameters
Name Description Type Required Default Value

value

The value of the instance to be retrieved

int

True

N/A

Returns
  • LongAttribute

Set Supertype
Syntax
attributeType.as_remote(tx).set_supertype(longAttributeType)
Description

Sets the supplied LongAttributeType as the supertype of the current LongAttributeType

Input parameters
Name Description Type Required Default Value

_type

The AttributeType to set as the supertype of this LongAttributeType

LongAttributeType

True

N/A

Returns
  • None

Retrieve all subtypes
Syntax
type.as_remote(tx).get_subtypes()
Description

Retrieves all direct and indirect subtypes of the LongAttributeType.

Returns
  • Iterator of [LongAttributeType]

Retrieve all instances of this LongAttributeType
Syntax
type.as_remote(tx).get_instances()
Description

Retrieves all direct and indirect LongAttributes that are instances of this Type.

Returns
  • Iterator of [LongAttribute]

Get a Remote version of the LongAttributeType.
Syntax
longAttributeType.as_remote(tx)
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

transaction

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • RemoteLongAttributeType

DoubleAttributeType methods

DoubleAttributeType has all the AttributeType methods plus what follows.

Put instance
Syntax
doubleAttributeType.as_remote(tx).put(value)
Description

Puts and returns a new instance of this DoubleAttributeType with the specified value. If an attribute with this value does not yet exist, it will be created.

Input parameters
Name Description Type Required Default Value

value

The value of the instance to be put

float

True

N/A

Returns
  • DoubleAttribute

Get instance
Syntax
doubleAttributeType.as_remote(tx).get(value)
Description

Returns the instance, if it exists, of this DoubleAttributeType with the specified value.

Input parameters
Name Description Type Required Default Value

value

The value of the instance to be retrieved

float

True

N/A

Returns
  • DoubleAttribute

Set Supertype
Syntax
attributeType.as_remote(tx).set_supertype(doubleAttributeType)
Description

Sets the supplied DoubleAttributeType as the supertype of the current DoubleAttributeType

Input parameters
Name Description Type Required Default Value

_type

The AttributeType to set as the supertype of this DoubleAttributeType

DoubleAttributeType

True

N/A

Returns
  • None

Retrieve all subtypes
Syntax
type.as_remote(tx).get_subtypes()
Description

Retrieves all direct and indirect subtypes of the DoubleAttributeType.

Returns
  • Iterator of [DoubleAttributeType]

Retrieve all instances of this DoubleAttributeType
Syntax
type.as_remote(tx).get_instances()
Description

Retrieves all direct and indirect DoubleAttributes that are instances of this Type.

Returns
  • Iterator of [DoubleAttribute]

Get a Remote version of the DoubleAttributeType.
Syntax
doubleAttributeType.as_remote(tx)
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

transaction

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • RemoteDoubleAttributeType

StringAttributeType methods

StringAttributeType has all the AttributeType methods plus what follows.

Put instance
Syntax
string_attribute_type.as_remote(tx).put(value)
Description

Puts and returns a new instance of this StringAttributeType with the specified value. If an attribute with this value does not yet exist, it will be created.

Input parameters
Name Description Type Required Default Value

value

The value of the instance to be put

string

True

N/A

Returns
  • StringAttribute

Get instance
Syntax
stringAttributeType.as_remote(tx).get(value)
Description

Returns the instance, if it exists, of this StringAttributeType with the specified value.

Input parameters
Name Description Type Required Default Value

value

The value of the instance to be retrieved

string

True

N/A

Returns
  • StringAttribute

Retrieve regex
Syntax
string_attribute_type.as_remote(tx).get_regex()
Description

Retrieves the regex that all instances of this StringAttributeType must conform to.

Returns
  • string

  • null

Set regex
Syntax
string_attribute_type.as_remote(tx).set_regex(regex)
Description

Set the regex that all instances of this StringAttributeType must conform to.

Input parameters
Name Description Type Required Default Value

regex

The regex that all instances of this StringAttributeType must conform to.

string

True

N/A

Returns
  • void

Set Supertype
Syntax
attributeType.as_remote(tx).set_supertype(string_attribute_type)
Description

Sets the supplied StringAttributeType as the supertype of the current StringAttributeType

Input parameters
Name Description Type Required Default Value

_type

The AttributeType to set as the supertype of this StringAttributeType

StringAttributeType

True

N/A

Returns
  • None

Retrieve all subtypes
Syntax
type.as_remote(tx).get_subtypes()
Description

Retrieves all direct and indirect subtypes of the StringAttributeType.

Returns
  • Iterator of [StringAttributeType]

Retrieve all instances of this StringAttributeType
Syntax
type.as_remote(tx).get_instances()
Description

Retrieves all direct and indirect StringAttributes that are instances of this Type.

Returns
  • Iterator of [StringAttribute]

Get a Remote version of the StringAttributeType.
Syntax
stringAttributeType.as_remote(tx)
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

transaction

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • RemoteStringAttributeType

DateTimeAttributeType methods

DateTimeAttributeType has all the AttributeType methods plus what follows.

Put instance
Syntax
dateTimeAttributeType.as_remote(tx).put(value)
Description

Puts and returns a new instance of this DateTimeAttributeType with the specified value. If an attribute with this value does not yet exist, it will be created.

Input parameters
Name Description Type Required Default Value

value

The value of the instance to be put

datetime

True

N/A

Returns
  • DateTimeAttribute object

Get instance
Syntax
dateTimeAttributeType.as_remote(tx).get(value)
Description

Returns the instance, if it exists, of this DateTimeAttributeType with the specified value.

Input parameters
Name Description Type Required Default Value

value

The value of the instance to be retrieved

datetime

True

N/A

Returns
  • DateTimeAttribute object

Set Supertype
Syntax
attributeType.as_remote(tx).set_supertype(datetime_attribute_type)
Description

Sets the supplied DateTimeAttributeType as the supertype of the current DateTimeAttributeType

Input parameters
Name Description Type Required Default Value

_type

The AttributeType to set as the supertype of this DateTimeAttributeType

DateTimeAttributeType

True

N/A

Returns
  • None

Retrieve all subtypes
Syntax
type.as_remote(tx).get_subtypes()
Description

Retrieves all direct and indirect subtypes of the DateTimeAttributeType.

Returns
  • Iterator of [DateTimeAttributeType]

Retrieve all instances of this DateTimeAttributeType
Syntax
type.as_remote(tx).get_instances()
Description

Retrieves all direct and indirect DateTimeAttributes that are instances of this Type.

Returns
  • Iterator of [DateTimeAttribute]

Get a Remote version of the DateTimeAttributeType.
Syntax
dateTimeAttributeType.as_remote(tx)
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

transaction

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • RemoteDateTimeAttributeType

Rule methods

Retrieve label (Local)

Syntax
rule.get_label()
Description

Retrieves the unique label of the rule.

Returns
  • String

Get a Remote version of the rule.

Syntax
rule.as_remote(tx)
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

tx

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • RemoteRule

Retrieve the when body (Local)

Syntax
rule.get_when()
Description

Retrieves the statements that constructs the when body of the rule.

Returns
  • string

Retrieve the then body (Local)

Syntax
rule.get_then()
Description

Retrieves the single statement that constructs the then body of the rule.

Returns
  • string

Rename label

Syntax
rule.as_remote(tx).set_label(label)
Description

Renames the label of the rule. The new label must remain unique.

Input parameters
Name Description Type Required Default Value

label

The new label to be given to the rule.

String

True

N/A

Returns
  • None

Delete rule

Syntax
rule.as_remote(tx).delete();
Returns
  • None

Check if the rule has been deleted

Syntax
rule.as_remote(tx).is_deleted()
Returns
  • boolean

LogicManager

Retrieve a Rule
Syntax
transaction.logic().get_rule(label)
Description

Retrieves the Rule that has the given label.

Input parameters
Name Description Type Required Default Value

label

The label of the Rule to create or retrive.

String

True

N/A

Returns
  • [Rule]

Create or retrieve a Rule
Syntax
transaction.logic().put_rule(label, when, then)
Description

Creates a new Rule if none exists with the given label, or retrieves the existing one.

Input parameters
Name Description Type Required Default Value

label

The label of the Rule to create or retrive.

String

True

N/A

when

The when body of the rule to create.

String

True

N/A

then

The then body of the rule to create.

String

True

N/A

Returns
  • [Rule]


Data methods

Data has all the Concept methods plus what follows.

Retrieves internal ID (Local)

Syntax
thing.get_iid()
Description

Retrieves the unique id of the Thing.

Returns
  • string

Get a Remote version of the Thing.

Syntax
thing.as_remote(tx)
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

tx

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • RemoteThing

Retrieve type (Local)

Syntax
thing.get_type()
Description

Retrieves the type which this Thing belongs to.

Returns
  • [ThingType]

Check if inferred (Local)

Syntax
thing.is_inferred()
Description

Checks if this Thing is inferred by a [Reasoning Rule] .

Returns
  • boolean

Assign attribute

Syntax
thing.as_remote(tx).set_has(attribute)
Description

Assigns an Attribute to be owned by this Thing.

Input parameters
Name Description Type Required Default Value

attribute

The Attribute to be owned by this Thing.

[Attribute]

True

N/A

Returns
  • [Thing]

Unassign attribute

Syntax
thing.as_remote(tx).unset_has(attribute)
Description

Unassigns an Attribute from this Thing.

Input parameters
Name Description Type Required Default Value

attribute

The Attribute to be disowned from this Thing.

[Attribute]

True

N/A

Returns
  • [Thing]

Retrieve attributes

Syntax
thing.as_remote(tx).get_has(attribute_type=None, attribute_types=[], annotations=frozenset())
Description

Retrieves the Attributes that this Thing owns.
Optionally, filtered by one or more AttributeTypes.
Optionally, filtered by annotations.

Input parameters
Name Description Type Required Default Value

attribute_type

The AttributeType to filter the attributes by.

AttributeType

False

None

attribute_types

The AttributeTypes to filter the attributes by.

list of AttributeType

False

None

annotations

Only retrieve attributes with annotations (KEY or UNIQUE).

set of Annotations

False

frozenset()

Returns
  • Iterator of [Attribute]

Retrieve roles

Syntax
thing.as_remote(tx).get_playing()
Description

Retrieves the roles that this Thing is currently playing.

Returns
  • Iterator of [RoleType]

Retrieve relations

Syntax
thing.as_remote(tx).get_relations(role_types)
Description

Retrieves all the Relations which this Thing plays a role in, optionally filtered by one or more given roles.

Input parameters
Name Description Type Required Default Value

roleTypes

The list of roles to filter the relations by.

list of [RoleType]

False

N/A

Returns
  • Iterator of [Relation]

Retrieve a Thing as JSON.

Syntax
thing.to_json()
Returns
  • JSON

Entity methods

Entity has all the Data methods plus what follows.

Retrieve type (Local)
Syntax
entity.get_type()
Description

Retrieves the type which this Entity belongs to.

Returns
  • [EntityType]

Get a Remote version of the Entity.
Syntax
entity.as_remote(tx)
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

tx

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • RemoteEntity

Relation methods

Relation has all the Data methods plus what follows.

Retrieve type (Local)
Syntax
relation.get_type()
Description

Retrieves the type which this Relation belongs to.

Returns
  • [RelationType]

Retrieve role players per role
Syntax
relation.as_remote(tx).get_players_by_role_type()
Description

Retrieves a map of all instances involved in the Relation and the role each play.

Returns
  • Dictionary of [Role]  to List of [Thing]

Retrieve role types currently played
Syntax
relation.as_remote(tx).get_relating()
Description

Retrieves all role types currently played in this Relation.

Returns
  • Iterator of [RoleType]

Retrieve role players
Syntax
relation.as_remote(tx).get_players(role_types)
Description

Retrieves all roleplayers of this this Relation, optionally filtered by given role types.

Input parameters
Name Description Type Required Default Value

role

The roles to filter the role players by.

List of [RoleType]

False

N/A

Returns
  • Iterator of [Thing]

Add roleplayer
Syntax
relation.as_remote(tx).add_player(role, thing)
Description

Adds a new roleplayer to play the given role in this Relation.

Input parameters
Name Description Type Required Default Value

role

The role to be played by the thing

[RoleType]

True

N/A

thing

The thing to play the role

[Thing]

True

N/A

Returns
  • None

Remove a roleplayer
Syntax
relation.as_remote(tx).remove_player(role, thing)
Description

Removes the association of the given instance that plays the given role in this Relation.

Input parameters
Name Description Type Required Default Value

role

The role to no longer be played by the thing in this Relation.

[RoleType]

True

N/A

thing

The instance to no longer play the role in this Relation.

[Thing]

True

N/A

Returns
  • None

Get a Remote version of the Relation.
Syntax
relation.as_remote(tx)
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

transaction

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • RemoteRelation

Attribute methods

Attribute has all the Data methods plus what follows.

Retrieve type (Local)
Syntax
attribute.get_type()
Description

Retrieves the type which this Attribute belongs to.

Returns
  • [AttributeType]

Retrieve value (Local)
Syntax
attribute.get_value()
Description

Retrieves the value which the Attribute instance holds.

Returns
  • string

  • int

  • float

  • boolean

  • Date

Retrieve owners
Syntax
attribute.as_remote(tx).get_owners(ownerType)
Description

Retrieves the instances that own this Attribute.

Input parameters
Name Description Type Required Default Value

ownerType

If specified, filter results for only owners of the given type

Type

False

N/A

Returns
  • Iterator of [Thing]

Get a Remote version of the Attribute.
Syntax
concept.as_remote(tx)
Description

The remote version uses the given transaction to execute every method call.

Input parameters
Name Description Type Required Default Value

transaction

The transaction to be used to make method calls.

Transaction

True

N/A

Returns
  • RemoteAttribute

Check if value is of type boolean (Local)
Syntax
attribute.is_boolean()
Description

Returns true if the attribute value is of type boolean. Otherwise, returns false.

Returns
  • boolean

Check if value is of type long (Local)
Syntax
attribute.is_long()
Description

Returns true if the attribute value is of type long. Otherwise, returns false.

Returns
  • boolean

Check if value is of type double (Local)
Syntax
attribute.is_double()
Description

Returns true if the attribute value is of type double. Otherwise, returns false.

Returns
  • boolean

Check if value is of type string (Local)
Syntax
attribute.is_string()
Description

Returns true if the attribute value is of type string. Otherwise, returns false.

Returns
  • boolean

Check if value is of type datetime (Local)
Syntax
attribute.is_datetime()
Description

Returns true if the attribute value is of type datetime. Otherwise, returns false.

Returns
  • boolean

Retrieve an attribute as JSON.
Syntax
attribute.to_json()
Returns
  • JSON with fields type, value_type and value

Value methods

Value has all the concept methods plus what follows.

Retrieve value (Local)

Syntax
value.get_value()
Description

Retrieves the value which the value variable holds.

Returns
  • string

  • int

  • float

  • boolean

  • Date

Retrieve valuetype (Local)

Syntax
value.get_value_type()
Description

Retrieves the valuetype of the value in value variable.

Returns
  • AttributeType.ValueType (STRING | DATETIME | LONG | DOUBLE | BOOLEAN)