aries_cloudagent.storage package

Subpackages

Submodules

aries_cloudagent.storage.askar module

aries_cloudagent.storage.base module

Abstract base classes for non-secrets storage.

class aries_cloudagent.storage.base.BaseStorage[source]

Bases: ABC

Abstract stored records interface.

abstract async add_record(record: StorageRecord)[source]

Add a new record to the store.

Parameters

recordStorageRecord to be stored

abstract async delete_all_records(type_filter: str, tag_query: Optional[Mapping] = None)[source]

Remove all records matching a particular type filter and tag query.

abstract async delete_record(record: StorageRecord)[source]

Delete an existing record.

Parameters

recordStorageRecord to delete

abstract async find_all_records(type_filter: str, tag_query: Optional[Mapping] = None, options: Optional[Mapping] = None)[source]

Retrieve all records matching a particular type filter and tag query.

async find_record(type_filter: str, tag_query: Optional[Mapping] = None, options: Optional[Mapping] = None) StorageRecord[source]

Find a record using a unique tag filter.

Parameters
  • type_filter – Filter string

  • tag_query – Tags to query

  • options – Dictionary of backend-specific options

abstract async get_record(record_type: str, record_id: str, options: Optional[Mapping] = None) StorageRecord[source]

Fetch a record from the store by type and ID.

Parameters
  • record_type – The record type

  • record_id – The record id

  • options – A dictionary of backend-specific options

Returns

A StorageRecord instance

abstract async update_record(record: StorageRecord, value: str, tags: Mapping)[source]

Update an existing stored record’s value and tags.

Parameters
  • recordStorageRecord to update

  • value – The new value

  • tags – The new tags

class aries_cloudagent.storage.base.BaseStorageSearch[source]

Bases: ABC

Abstract stored records search interface.

abstract search_records(type_filter: str, tag_query: Optional[Mapping] = None, page_size: Optional[int] = None, options: Optional[Mapping] = None) BaseStorageSearchSession[source]

Create a new record query.

Parameters
  • type_filter – Filter string

  • tag_query – Tags to query

  • page_size – Page size

  • options – Dictionary of backend-specific options

Returns

An instance of BaseStorageSearchSession

class aries_cloudagent.storage.base.BaseStorageSearchSession[source]

Bases: ABC

Abstract stored records search session interface.

async close()[source]

Dispose of the search query.

abstract async fetch(max_count: Optional[int] = None) Sequence[StorageRecord][source]

Fetch the next list of results from the store.

Parameters

max_count – Max number of records to return. If not provided, defaults to the backend’s preferred page size

Returns

A list of StorageRecord instances

class aries_cloudagent.storage.base.IterSearch(search: BaseStorageSearchSession, page_size: Optional[int] = None)[source]

Bases: object

A generic record search async iterator.

aries_cloudagent.storage.base.validate_record(record: StorageRecord, *, delete=False)[source]

Ensure that a record is ready to be saved/updated/deleted.

aries_cloudagent.storage.error module

Storage-related exceptions.

exception aries_cloudagent.storage.error.StorageDuplicateError(*args, error_code: Optional[str] = None, **kwargs)[source]

Bases: StorageError

Duplicate record found in storage.

exception aries_cloudagent.storage.error.StorageError(*args, error_code: Optional[str] = None, **kwargs)[source]

Bases: BaseError

Base class for Storage errors.

exception aries_cloudagent.storage.error.StorageNotFoundError(*args, error_code: Optional[str] = None, **kwargs)[source]

Bases: StorageError

Record not found in storage.

exception aries_cloudagent.storage.error.StorageSearchError(*args, error_code: Optional[str] = None, **kwargs)[source]

Bases: StorageError

General exception during record search.

aries_cloudagent.storage.in_memory module

Basic in-memory storage implementation (non-wallet).

class aries_cloudagent.storage.in_memory.InMemoryStorage(profile: InMemoryProfile)[source]

Bases: BaseStorage, BaseStorageSearch

Basic in-memory storage class.

async add_record(record: StorageRecord)[source]

Add a new record to the store.

Parameters

recordStorageRecord to be stored

Raises
  • StorageError – If no record is provided

  • StorageError – If the record has no ID

async delete_all_records(type_filter: str, tag_query: Optional[Mapping] = None)[source]

Remove all records matching a particular type filter and tag query.

async delete_record(record: StorageRecord)[source]

Delete a record.

Parameters

recordStorageRecord to delete

Raises

StorageNotFoundError – If record not found

async find_all_records(type_filter: str, tag_query: Optional[Mapping] = None, options: Optional[Mapping] = None)[source]

Retrieve all records matching a particular type filter and tag query.

async get_record(record_type: str, record_id: str, options: Optional[Mapping] = None) StorageRecord[source]

Fetch a record from the store by type and ID.

Parameters
  • record_type – The record type

  • record_id – The record id

  • options – A dictionary of backend-specific options

Returns

A StorageRecord instance

Raises

StorageNotFoundError – If the record is not found

search_records(type_filter: str, tag_query: Optional[Mapping] = None, page_size: Optional[int] = None, options: Optional[Mapping] = None) InMemoryStorageSearch[source]

Search stored records.

Parameters
  • type_filter – Filter string

  • tag_query – Tags to query

  • page_size – Page size

  • options – Dictionary of backend-specific options

Returns

An instance of InMemoryStorageSearch

async update_record(record: StorageRecord, value: str, tags: Mapping)[source]

Update an existing stored record’s value.

Parameters
  • recordStorageRecord to update

  • value – The new value

  • tags – The new tags

Raises

StorageNotFoundError – If record not found

class aries_cloudagent.storage.in_memory.InMemoryStorageSearch(profile: InMemoryProfile, type_filter: str, tag_query: Mapping, page_size: Optional[int] = None, options: Optional[Mapping] = None)[source]

Bases: BaseStorageSearchSession

Represent an active stored records search.

async close()[source]

Dispose of the search query.

async fetch(max_count: Optional[int] = None) Sequence[StorageRecord][source]

Fetch the next list of results from the store.

Parameters

max_count – Max number of records to return. If not provided, defaults to the backend’s preferred page size

Returns

A list of StorageRecord instances

Raises

StorageSearchError – If the search query has not been opened

aries_cloudagent.storage.in_memory.tag_query_match(tags: dict, tag_query: dict) bool[source]

Match simple tag filters (string values).

aries_cloudagent.storage.in_memory.tag_value_match(value: str, match: dict) bool[source]

Match a single tag against a tag subquery.

TODO: What type coercion is needed? (support int or float values?)

aries_cloudagent.storage.indy module

Indy implementation of BaseStorage interface.

class aries_cloudagent.storage.indy.IndySdkStorage(wallet: IndyOpenWallet)[source]

Bases: BaseStorage, BaseStorageSearch

Indy Non-Secrets interface.

async add_record(record: StorageRecord)[source]

Add a new record to the store.

Parameters

recordStorageRecord to be stored

async delete_all_records(type_filter: str, tag_query: Optional[Mapping] = None)[source]

Remove all records matching a particular type filter and tag query.

async delete_record(record: StorageRecord)[source]

Delete a record.

Parameters

recordStorageRecord to delete

Raises
  • StorageNotFoundError – If record not found

  • StorageError – If a libindy error occurs

async find_all_records(type_filter: str, tag_query: Optional[Mapping] = None, options: Optional[Mapping] = None)[source]

Retrieve all records matching a particular type filter and tag query.

async get_record(record_type: str, record_id: str, options: Optional[Mapping] = None) StorageRecord[source]

Fetch a record from the store by type and ID.

Parameters
  • record_type – The record type

  • record_id – The record id

  • options – A dictionary of backend-specific options

Returns

A StorageRecord instance

Raises
  • StorageError – If the record is not provided

  • StorageError – If the record ID not provided

  • StorageNotFoundError – If the record is not found

  • StorageError – If record not found

search_records(type_filter: str, tag_query: Optional[Mapping] = None, page_size: Optional[int] = None, options: Optional[Mapping] = None) IndySdkStorageSearch[source]

Search stored records.

Parameters
  • type_filter – Filter string

  • tag_query – Tags to query

  • page_size – Page size

  • options – Dictionary of backend-specific options

Returns

An instance of IndySdkStorageSearch

async update_record(record: StorageRecord, value: str, tags: Mapping)[source]

Update an existing stored record’s value and tags.

Parameters
  • recordStorageRecord to update

  • value – The new value

  • tags – The new tags

Raises
  • StorageNotFoundError – If record not found

  • StorageError – If a libindy error occurs

property wallet: IndyOpenWallet

Accessor for IndyOpenWallet instance.

class aries_cloudagent.storage.indy.IndySdkStorageSearch(store: IndySdkStorage, type_filter: str, tag_query: Mapping, page_size: Optional[int] = None, options: Optional[Mapping] = None)[source]

Bases: BaseStorageSearchSession

Represent an active stored records search.

async close()[source]

Dispose of the search query.

async fetch(max_count: Optional[int] = None) Sequence[StorageRecord][source]

Fetch the next list of results from the store.

Parameters

max_count – Max number of records to return. If not provided, defaults to the backend’s preferred page size

Returns

A list of StorageRecord instances

Raises

StorageSearchError – If the search query has not been opened

aries_cloudagent.storage.record module

Record instance stored and searchable by BaseStorage implementation.

class aries_cloudagent.storage.record.StorageRecord(type, value, tags: Optional[dict] = None, id: Optional[str] = None)[source]

Bases: StorageRecord

Storage record class.

aries_cloudagent.storage.type module

Library version information.