prov2bigchaindb.core package¶
Submodules¶
prov2bigchaindb.core.accounts module¶
-
class
prov2bigchaindb.core.accounts.
BaseAccount
(account_id: str, store: prov2bigchaindb.core.local_stores.SqliteStore)[source]¶ Bases:
object
BigchainDB Base Account
-
class
prov2bigchaindb.core.accounts.
DocumentConceptAccount
(account_id: str, store: prov2bigchaindb.core.local_stores.SqliteStore)[source]¶ Bases:
prov2bigchaindb.core.accounts.BaseAccount
BigchainDB Document Concept Account
-
class
prov2bigchaindb.core.accounts.
GraphConceptAccount
(prov_element: prov.model.ProvElement, prov_relations: dict, id_mapping: dict, namespaces: list, store: prov2bigchaindb.core.local_stores.SqliteStore = <prov2bigchaindb.core.local_stores.SqliteStore object>)[source]¶ Bases:
prov2bigchaindb.core.accounts.BaseAccount
BigchainDB Graph Concept Account
-
get_tx_id
() → str[source]¶ Get the tx_id that describes the account in BigchainDB
Returns: Transaction id of account Return type: str
-
has_relations_with_id
() → bool[source]¶ Indicates whether an account has relation with ids or not :return: True if one or more relation does have ids :rtype: bool
-
has_relations_without_id
() → bool[source]¶ Indicates whether an account has relation without ids or not :return: True if one or more relation does have ids :rtype: bool
-
save_relations_with_ids
(bdb_connection: bigchaindb_driver.driver.BigchainDB) → list[source]¶ Writes all assets with relations (having ids) to BigchainDB
Parameters: bdb_connection (BigchainDB) – Connection object for BigchainDB Returns: Transactions ids of all relations Return type: list
-
-
class
prov2bigchaindb.core.accounts.
RoleConceptAccount
(agent: prov.model.ProvAgent, relations: list, elements: dict, id_mapping: dict, namespaces: list, store: prov2bigchaindb.core.local_stores.SqliteStore = <prov2bigchaindb.core.local_stores.SqliteStore object>)[source]¶ Bases:
prov2bigchaindb.core.accounts.BaseAccount
BigchainDB Graph Concept Account
-
get_tx_id
() → str[source]¶ Get the tx_id that describes the account in BigchainDB
Returns: Transaction id of account Return type: str
-
prov2bigchaindb.core.clients module¶
-
class
prov2bigchaindb.core.clients.
BaseClient
(host: str = '0.0.0.0', port: int = 9984, num_connections: int = 5, local_store: prov2bigchaindb.core.local_stores.SqliteStore = <prov2bigchaindb.core.local_stores.SqliteStore object>)[source]¶ Bases:
object
BigchainDB Base Client
-
test_transaction
(tx: dict) → bool[source]¶ Validate a transaction against BigchainDB
Parameters: tx (dict) – Transaction to test Returns: True or Exception Return type: bool
-
-
class
prov2bigchaindb.core.clients.
DocumentConceptClient
(account_id: str = None, host: str = '0.0.0.0', port: int = 9984, num_connections: int = 1, local_store: prov2bigchaindb.core.local_stores.SqliteStore = <prov2bigchaindb.core.local_stores.SqliteStore object>)[source]¶
-
class
prov2bigchaindb.core.clients.
GraphConceptClient
(host: str = '0.0.0.0', port: int = 9984, num_connections: int = 5, local_store: prov2bigchaindb.core.local_stores.SqliteStore = <prov2bigchaindb.core.local_stores.SqliteStore object>)[source]¶ Bases:
prov2bigchaindb.core.clients.BaseClient
-
static
calculate_account_data
(prov_document: prov.model.ProvDocument) → list[source]¶ Transforms a ProvDocument into a tuple with ProvElement, list of ProvRelation and list of Namespaces
Parameters: prov_document – Document to transform Returns: List of tuples(element, relations, namespace) Return type: list
-
static
-
class
prov2bigchaindb.core.clients.
RoleConceptClient
(host: str = '0.0.0.0', port: int = 9984, num_connections: int = 5, local_store: prov2bigchaindb.core.local_stores.SqliteStore = <prov2bigchaindb.core.local_stores.SqliteStore object>)[source]¶ Bases:
prov2bigchaindb.core.clients.BaseClient
-
static
calculate_account_data
(prov_document: prov.model.ProvDocument) → list[source]¶ Transforms a ProvDocument into a list of tuples including: ProvAgent, list of ProvRelations from agent, list of ProvElements associated to ProvAgent, list of Namespaces
Parameters: prov_document – Document to transform Returns: List of tuples(ProvAgent, list(), list(), list()) Return type: list
-
static
prov2bigchaindb.core.exceptions module¶
-
exception
prov2bigchaindb.core.exceptions.
CreateRecordException
[source]¶ Bases:
prov2bigchaindb.core.exceptions.Prov2BigchainDBException
-
exception
prov2bigchaindb.core.exceptions.
ParseException
[source]¶ Bases:
prov2bigchaindb.core.exceptions.Prov2BigchainDBException
-
exception
prov2bigchaindb.core.exceptions.
NoAccountFoundException
[source]¶ Bases:
prov2bigchaindb.core.exceptions.Prov2BigchainDBException
-
exception
prov2bigchaindb.core.exceptions.
AccountNotCreatedException
[source]¶ Bases:
prov2bigchaindb.core.exceptions.Prov2BigchainDBException
-
exception
prov2bigchaindb.core.exceptions.
NoRelationFoundException
[source]¶ Bases:
prov2bigchaindb.core.exceptions.Prov2BigchainDBException
-
exception
prov2bigchaindb.core.exceptions.
TransactionIdNotFound
[source]¶ Bases:
prov2bigchaindb.core.exceptions.Prov2BigchainDBException
-
exception
prov2bigchaindb.core.exceptions.
BlockIdNotFound
[source]¶ Bases:
prov2bigchaindb.core.exceptions.Prov2BigchainDBException
prov2bigchaindb.core.local_stores module¶
-
class
prov2bigchaindb.core.local_stores.
BaseStore
(db_name: str = None)[source]¶ Bases:
object
-
write_account
(account_id: str, public_key: str, private_key: str, tx_id: str = None)[source]¶ Writes a new account entry in to the table accounts
Parameters:
-
-
class
prov2bigchaindb.core.local_stores.
SqliteStore
(db_name: str = ':memory:')[source]¶ Bases:
prov2bigchaindb.core.local_stores.BaseStore
-
write_account
(account_id: str, public_key: str, private_key: str, tx_id: str = None)[source]¶ Writes a new account entry in to the table accounts
Parameters:
-
prov2bigchaindb.core.utils module¶
-
prov2bigchaindb.core.utils.
to_prov_document
(content: str) → prov.model.ProvDocument[source]¶ Takes a string, bytes or ProvDocument as argument and return a ProvDocument The strings or bytes can contain JSON or XML representations of PROV
Parameters: content – String or BufferedReader or ProvDocument Returns: ProvDocument Return type: ProvDocument
-
prov2bigchaindb.core.utils.
wait_until_valid
(tx_id: str, bdb_connection: bigchaindb_driver.driver.BigchainDB)[source]¶ Waits until a transaction is valid in BigchainDB
Parameters: - tx_id (str) – Id of transaction to wait on
- bdb_connection (BigchainDB) – Connection object for BigchainDB
-
prov2bigchaindb.core.utils.
is_valid_tx
(tx_id: str, bdb_connection: bigchaindb_driver.driver.BigchainDB) → bool[source]¶ Checks once if a transaction is valid
Parameters: - tx_id (str) – Id of transaction to check
- bdb_connection (BigchainDB) – Connection object for BigchainDB
Returns: True if valid
Return type:
-
prov2bigchaindb.core.utils.
is_block_to_tx_valid
(tx_id: str, bdb_connection: bigchaindb_driver.driver.BigchainDB) → bool[source]¶ Checks if block with transaction is valid
Parameters: - tx_id (str) – Id of transaction which should be included in the
- bdb_connection (BigchainDB) – Connection object for BigchainDB
Returns: True if transactions is in block and block is valid
Return type: