class documentation

This abstract class defines the interface for database bindings.

Method addBatchNotification Add a batch notification to the database.
Method addOriginator Add an originator to the database.
Method backupDB Backup the database to a directory.
Method closeDB Close the database.
Method countBatchNotifications Return the number of batch notifications for a resource and notification URI.
Method countResources Return the number of resources in the database.
Method deleteIdentifier Delete an identifier from the identifiers DB.
Method deleteRequests Remnove all stored requests from the database.
Method deleteResource Delete a resource from the database.
Method discoverResourcesByFilter Search for resources by a filter function. This goes through all resources in the database and applies the filter function to each resource. If the filter function returns True, the resource is added to the result list.
Method getActionRep Get an action representation by resource ID.
Method getAllActionReprs Return all action representations.
Method getBatchNotifications Return the batch notifications for a resource and notification URI.
Method getOriginator Get an originator and its information from the database.
Method getRequests Get requests for a resource ID, or all requests.
Method getSchedule Get a schedule from the database.
Method getSchedules Get all schedules from the database.
Method hasResource Check if a resource exists in the database.
Method insertRequest Add a request to the requests database.
Method insertResource Insert a resource into the database.
Method purgeDB Purge the database. Remove all data
Method purgeStatistics Purge the statistics DB.
Method removeActionRepr Remove an action representation.
Method removeBatchNotifications Remove the batch notifications for a resource and notification URI.
Method removeChildResource Remove a child resource from the childResources DB.
Method removeOldRequests Remove old requests from the database.
Method removeOriginator Remove an originator from the database.
Method removeSchedule Remove a schedule from the database.
Method removeSubscriptionRepr Remove a subscription representation from the database.
Method searchActionsReprsForSubject Search for action representations by subject.
Method searchByFragment Search and return all resources that match the given dictionary/document.
Method searchChildResourceIDsByParentRIAndType Search for child resources by parent resource ID and optional type.
Method searchIdentifiers Search for an resource ID OR for a structured name in the identifiers DB.
Method searchResources Search for resources by structured resource name, resource ID, CSE-ID, parent resource ID, resource type, or application entity ID.
Method searchSchedulesForParent Search for schedules in the database.
Method searchStatistics Search for statistics.
Method searchSubscriptionReprs Search for subscription representations by resource ID or parent resource ID.
Method updateActionRepr Update an action representation.
Method updateResource Update a resource in the database. Only the fields that are not None will be updated.
Method upsertActionRepr Update or insert an action representation.
Method upsertChildResource Add a child resource to the childResources DB.
Method upsertIdentifier Insert or update an identifier into the identifiers DB and a structured resource name into the structuredResourceNames DB.
Method upsertResource Update or insert a resource into the database.
Method upsertSchedule Add or update a schedule in the database.
Method upsertStatistics Update or insert statistics.
Method upsertSubscriptionRepr Update or insert a subscription representation into the database.
@abstractmethod
def addBatchNotification(self, batchRecord: JSON) -> bool:

Add a batch notification to the database.

Parameters
batchRecord:JSONThe batch notification to add.
Returns
boolTrue if the batch notification was added, False otherwise.
@abstractmethod
def addOriginator(self, originatorStructure: JSON, originator: str) -> bool:

Add an originator to the database.

Parameters
originatorStructure:JSONThe originator structure to add.
originator:strThe originator to add.
Returns
boolBoolean value to indicate success or failure.
@abstractmethod
def backupDB(self, dir: str) -> bool:

Backup the database to a directory.

Parameters
dir:strThe directory to backup to.
Returns
boolBoolean value to indicate success or failure.
@abstractmethod
def countBatchNotifications(self, ri: str, nu: str) -> int:

Return the number of batch notifications for a resource and notification URI.

Parameters
ri:strThe resource ID of the resource.
nu:strThe notification URI.
Returns
intThe number of batch notifications for the resource and notification URI.
@abstractmethod
def countResources(self) -> int:

Return the number of resources in the database.

Returns
intThe number of resources in the database.
@abstractmethod
def deleteIdentifier(self, ri: str, srn: str):

Delete an identifier from the identifiers DB.

Parameters
ri:strThe resource ID of the resource.
srn:strThe structured resource name of the resource.
@abstractmethod
def deleteRequests(self, ri: str | None = None):

Remnove all stored requests from the database.

Parameters
ri:str | NoneOptional resouce ID. Only requests for this resource ID will be deleted.
@abstractmethod
def deleteResource(self, ri: str):

Delete a resource from the database.

Parameters
ri:strThe resource ID of the resource.
@abstractmethod
def discoverResourcesByFilter(self, func: Callable[[JSON], bool]) -> list[JSON]:

Search for resources by a filter function. This goes through all resources in the database and applies the filter function to each resource. If the filter function returns True, the resource is added to the result list.

Parameters
func:Callable[[JSON], bool]The filter function to use.
Returns
list[JSON]A list of found resource documents, or an empty list.
@abstractmethod
def getActionRep(self, ri: str) -> JSON | None:

Get an action representation by resource ID.

Parameters
ri:strThe resource ID of the action representation.
Returns
JSON | NoneThe action representation, or None if not found.
@abstractmethod
def getAllActionReprs(self) -> list[JSON]:

Return all action representations.

Returns
list[JSON]A list of action representations, or None if not found.
@abstractmethod
def getBatchNotifications(self, ri: str, nu: str) -> list[JSON]:

Return the batch notifications for a resource and notification URI.

Parameters
ri:strThe resource ID of the resource.
nu:strThe notification URI.
Returns
list[JSON]A list of batch notifications for the resource and notification URI.
@abstractmethod
def getOriginator(self, originator: str) -> tuple[str, OriginatorType] | None:

Get an originator and its information from the database.

Parameters
originator:strThe originator to search for.
Returns
tuple[str, OriginatorType] | NoneTuple containing the originator and its type, or None if not found.
@abstractmethod
def getRequests(self, ri: str | None = None) -> list[JSON]:

Get requests for a resource ID, or all requests.

Parameters
ri:str | NoneThe target resource's resource ID. If None or empty, then all requests are returned
Returns
list[JSON]List of Documents. May be empty.
@abstractmethod
def getSchedule(self, ri: str) -> JSON | None:

Get a schedule from the database.

Parameters
ri:strThe resource ID of the schedule.
Returns
JSON | NoneThe schedule, or None if not found.
@abstractmethod
def getSchedules(self) -> list[JSON]:

Get all schedules from the database.

Returns
list[JSON]List of Documents. May be empty.
@abstractmethod
def hasResource(self, ri: str | None = None, srn: str | None = None, ty: int | None = None) -> bool:

Check if a resource exists in the database.

Only one of the parameters may be used at a time. The order of precedence is: structured resource name, resource ID, resource type.

Parameters
ri:str | NoneA resource ID.
srn:str | NoneA structured resource name.
ty:int | NoneA resource type.
Returns
boolTrue if the resource exists, False otherwise.
@abstractmethod
def insertRequest(self, req: JSON, ts: float) -> bool:

Add a request to the requests database.

Parameters
req:JSONThe request to store.
ts:floatThe timestamp of the request.
Returns
boolBoolean value to indicate success or failure.
@abstractmethod
def insertResource(self, resource: JSON, ri: str):

Insert a resource into the database.

Parameters
resource:JSONThe resource to insert.
ri:strThe resource ID of the resource.
@abstractmethod
def purgeDB(self):
@abstractmethod
def purgeStatistics(self):
@abstractmethod
def removeActionRepr(self, ri: str) -> bool:

Remove an action representation.

Parameters
ri:strThe action's resource ID.
Returns
boolTrue if the action representation was removed, False otherwise.
@abstractmethod
def removeBatchNotifications(self, ri: str, nu: str) -> bool:

Remove the batch notifications for a resource and notification URI.

Parameters
ri:strThe resource ID of the resource.
nu:strThe notification URI.
Returns
boolTrue if the batch notifications were removed, False otherwise.
@abstractmethod
def removeChildResource(self, ri: str, pi: str):

Remove a child resource from the childResources DB.

Parameters
ri:strThe resource ID of the resource.
pi:strThe resource ID of the parent resource.
@abstractmethod
def removeOldRequests(self, maxRequests: int):

Remove old requests from the database.

Parameters
maxRequests:intThe maximum number of requests to keep.
@abstractmethod
def removeOriginator(self, originator: str) -> bool:

Remove an originator from the database.

Parameters
originator:strThe originator to remove.
Returns
boolBoolean value to indicate success or failure.
@abstractmethod
def removeSchedule(self, ri: str) -> bool:

Remove a schedule from the database.

Parameters
ri:strThe resource ID of the schedule to remove.
Returns
boolTrue if the schedule was removed, False otherwise.
@abstractmethod
def removeSubscriptionRepr(self, ri: str) -> bool:

Remove a subscription representation from the database.

Parameters
ri:strThe resource ID of the original SUB resource.
Returns
boolTrue if the subscription representation was removed, False otherwise.
@abstractmethod
def searchActionsReprsForSubject(self, subjectRi: str) -> Sequence[JSON]:

Search for action representations by subject.

Parameters
subjectRi:strThe resource ID of the action representation's subject.
Returns
Sequence[JSON]A list of action representations, or an empty list if not found.
@abstractmethod
def searchByFragment(self, dct: dict) -> list[JSON]:

Search and return all resources that match the given dictionary/document.

Parameters
dct:dictThe dictionary/document to search for.
Returns
list[JSON]A list of found resources, or an empty list.
@abstractmethod
def searchChildResourceIDsByParentRIAndType(self, pi: str, ty: ResourceTypes | list[ResourceTypes] | None = None) -> list[str]:

Search for child resources by parent resource ID and optional type.

Parameters
pi:strThe parent resource ID.
ty:ResourceTypes | list[ResourceTypes] | NoneThe resource type of the child resources to search for, or a list of resource types.
Returns
list[str]A list of child resource IDs, or an empty list if not found.
@abstractmethod
def searchIdentifiers(self, ri: str | None = None, srn: str | None = None) -> list[JSON]:

Search for an resource ID OR for a structured name in the identifiers DB.

Either ri or srn shall be given. If both are given then srn is taken.

Parameters
ri:str | NoneResource ID to search for.
srn:str | NoneStructured path to search for.
Returns
list[JSON]A list of found identifier documents (see upsertIdentifier), or an empty list if not found.
@abstractmethod
def searchResources(self, ri: str | None = None, csi: str | None = None, srn: str | None = None, pi: str | None = None, ty: int | None = None, aei: str | None = None) -> list[JSON]:

Search for resources by structured resource name, resource ID, CSE-ID, parent resource ID, resource type, or application entity ID.

Only one of the parameters may be used at a time. The order of precedence is: structured resource name, resource ID, CSE-ID, structured resource name, parent resource ID, resource type, application entity ID.

Parameters
ri:str | NoneA resource ID.
csi:str | NoneA CSE ID.
srn:str | NoneA structured resource name.
pi:str | NoneA parent resource ID.
ty:int | NoneA resource type.
aei:str | NoneAn application entity ID.
Returns
list[JSON]A list of found resource documents, or an empty list.
@abstractmethod
def searchSchedulesForParent(self, pi: str) -> list[JSON]:

Search for schedules in the database.

Parameters
pi:strThe resource ID of the parent resource.
Returns
list[JSON]List of Documents. May be empty.
@abstractmethod
def searchStatistics(self) -> JSON:

Search for statistics.

Returns
JSONThe statistics, or None if not found.
@abstractmethod
def searchSubscriptionReprs(self, ri: str | None = None, pi: str | None = None) -> list[JSON] | None:

Search for subscription representations by resource ID or parent resource ID.

Only one of the parameters may be used at a time. The order of precedence is: resource ID, parent resource ID.

Parameters
ri:str | NoneA resource ID.
pi:str | NoneA parent resource ID.
Returns
list[JSON] | NoneA list of found subscription representations, or None.
@abstractmethod
def updateActionRepr(self, actionRepr: JSON) -> bool:

Update an action representation.

Parameters
actionRepr:JSONThe action representation to update.
Returns
boolTrue if the action representation was updated, False otherwise.
@abstractmethod
def updateResource(self, resource: JSON, ri: str) -> JSON:

Update a resource in the database. Only the fields that are not None will be updated.

Parameters
resource:JSONThe resource to update.
ri:strThe resource ID of the resource.
Returns
JSONThe updated resource dirctionary.
@abstractmethod
def upsertActionRepr(self, actionRepr: JSON, ri: str) -> bool:

Update or insert an action representation.

Parameters
actionRepr:JSONThe action representation to update or insert.
ri:strThe resource ID of the action representation.
Returns
boolTrue if the action representation was updated or inserted, False otherwise.
@abstractmethod
def upsertChildResource(self, childResource: JSON, ri: str):

Add a child resource to the childResources DB.

Parameters
childResource:JSONThe resource to add as a child.
ri:strThe resource ID of the resource.
@abstractmethod
def upsertIdentifier(self, identifierMapping: JSON, structuredPathMapping: JSON, ri: str, srn: str):

Insert or update an identifier into the identifiers DB and a structured resource name into the structuredResourceNames DB.

Parameters
identifierMapping:JSONThe identifier mapping to insert.
structuredPathMapping:JSONThe structured path mapping to insert.
ri:strThe resource ID of the resource.
srn:strThe structured resource name of the resource.
@abstractmethod
def upsertResource(self, resource: JSON, ri: str):

Update or insert a resource into the database.

Parameters
resource:JSONThe resource to upate or insert.
ri:strThe resource ID of the resource.
@abstractmethod
def upsertSchedule(self, schedule: JSON, ri: str) -> bool:

Add or update a schedule in the database.

Parameters
schedule:JSONThe schedule to store.
ri:strThe resource ID of the schedule.
Returns
boolTrue if the schedule was added or updated, False otherwise.
@abstractmethod
def upsertStatistics(self, stats: JSON) -> bool:

Update or insert statistics.

Parameters
stats:JSONThe statistics to update or insert.
Returns
boolTrue if the statistics were updated or inserted, False otherwise.
@abstractmethod
def upsertSubscriptionRepr(self, subscription: JSON, ri: str) -> bool:

Update or insert a subscription representation into the database.

Parameters
subscription:JSONThe subscription representation to update or insert.
ri:strThe resource ID of the original SUB resource.
Returns
boolTrue if the subscription representation was updated or inserted, False otherwise.