aries_cloudagent.storage package

Submodules

aries_cloudagent.storage.base module

Abstract base classes for non-secrets storage.

class aries_cloudagent.storage.base.BaseStorage[source]

Bases: abc.ABC

Abstract stored records interface.

add_record(record: aries_cloudagent.storage.record.StorageRecord)[source]

Add a new record to the store.

Parameters:recordStorageRecord to be stored
delete_all_records(type_filter: str, tag_query: Mapping[KT, VT_co] = None)[source]

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

delete_record(record: aries_cloudagent.storage.record.StorageRecord)[source]

Delete an existing record.

Parameters:recordStorageRecord to delete
find_all_records(type_filter: str, tag_query: Mapping[KT, VT_co] = None, options: Mapping[KT, VT_co] = None)[source]

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

find_record(type_filter: str, tag_query: Mapping[KT, VT_co] = None, options: Mapping[KT, VT_co] = None) → aries_cloudagent.storage.record.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
get_record(record_type: str, record_id: str, options: Mapping[KT, VT_co] = None) → aries_cloudagent.storage.record.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

update_record(record: aries_cloudagent.storage.record.StorageRecord, value: str, tags: Mapping[KT, VT_co])[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.ABC

Abstract stored records search interface.

search_records(type_filter: str, tag_query: Mapping[KT, VT_co] = None, page_size: int = None, options: Mapping[KT, VT_co] = None) → aries_cloudagent.storage.base.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.ABC

Abstract stored records search session interface.

close()[source]

Dispose of the search query.

fetch(max_count: int = None) → Sequence[aries_cloudagent.storage.record.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: aries_cloudagent.storage.base.BaseStorageSearchSession, page_size: int = None)[source]

Bases: object

A generic record search async iterator.

aries_cloudagent.storage.base.validate_record(record: aries_cloudagent.storage.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: str = None, **kwargs)[source]

Bases: aries_cloudagent.storage.error.StorageError

Duplicate record found in storage.

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

Bases: aries_cloudagent.core.error.BaseError

Base class for Storage errors.

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

Bases: aries_cloudagent.storage.error.StorageError

Record not found in storage.

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

Bases: aries_cloudagent.storage.error.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: aries_cloudagent.core.in_memory.InMemoryProfile)[source]

Bases: aries_cloudagent.storage.base.BaseStorage, aries_cloudagent.storage.base.BaseStorageSearch

Basic in-memory storage class.

add_record(record: aries_cloudagent.storage.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
delete_all_records(type_filter: str, tag_query: Mapping[KT, VT_co] = None)[source]

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

delete_record(record: aries_cloudagent.storage.record.StorageRecord)[source]

Delete a record.

Parameters:recordStorageRecord to delete
Raises:StorageNotFoundError – If record not found
find_all_records(type_filter: str, tag_query: Mapping[KT, VT_co] = None, options: Mapping[KT, VT_co] = None)[source]

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

get_record(record_type: str, record_id: str, options: Mapping[KT, VT_co] = None) → aries_cloudagent.storage.record.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: Mapping[KT, VT_co] = None, page_size: int = None, options: Mapping[KT, VT_co] = None) → aries_cloudagent.storage.in_memory.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

update_record(record: aries_cloudagent.storage.record.StorageRecord, value: str, tags: Mapping[KT, VT_co])[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: aries_cloudagent.core.in_memory.InMemoryProfile, type_filter: str, tag_query: Mapping[KT, VT_co], page_size: int = None, options: Mapping[KT, VT_co] = None)[source]

Bases: aries_cloudagent.storage.base.BaseStorageSearchSession

Represent an active stored records search.

close()[source]

Dispose of the search query.

fetch(max_count: int = None) → Sequence[aries_cloudagent.storage.record.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: aries_cloudagent.indy.sdk.wallet_setup.IndyOpenWallet)[source]

Bases: aries_cloudagent.storage.base.BaseStorage, aries_cloudagent.storage.base.BaseStorageSearch

Indy Non-Secrets interface.

add_record(record: aries_cloudagent.storage.record.StorageRecord)[source]

Add a new record to the store.

Parameters:recordStorageRecord to be stored
delete_all_records(type_filter: str, tag_query: Mapping[KT, VT_co] = None)[source]

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

delete_record(record: aries_cloudagent.storage.record.StorageRecord)[source]

Delete a record.

Parameters:

recordStorageRecord to delete

Raises:
  • StorageNotFoundError – If record not found
  • StorageError – If a libindy error occurs
find_all_records(type_filter: str, tag_query: Mapping[KT, VT_co] = None, options: Mapping[KT, VT_co] = None)[source]

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

get_record(record_type: str, record_id: str, options: Mapping[KT, VT_co] = None) → aries_cloudagent.storage.record.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: Mapping[KT, VT_co] = None, page_size: int = None, options: Mapping[KT, VT_co] = None) → aries_cloudagent.storage.indy.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

update_record(record: aries_cloudagent.storage.record.StorageRecord, value: str, tags: Mapping[KT, VT_co])[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
wallet

Accessor for IndyOpenWallet instance.

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

Bases: aries_cloudagent.storage.base.BaseStorageSearchSession

Represent an active stored records search.

close()[source]

Dispose of the search query.

fetch(max_count: int = None) → Sequence[aries_cloudagent.storage.record.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[source]

Bases: aries_cloudagent.storage.record.StorageRecord

Storage record class.