class TinyDBBinding(DBBinding):
This class implements the TinyDB binding to the database. It is used by the Storage class.
| Method | add |
Add a batch notification to the database. |
| Method | add |
Add an originator to the database. |
| Method | backup |
Backup the database to a directory. |
| Method | close |
Close the database. |
| Method | configure |
Callback method for the configuration phase of the plugin lifecycle. |
| Method | count |
Return the number of batch notifications for a resource and notification URI. |
| Method | count |
Return the number of resources in the database. |
| Method | delete |
Delete an identifier from the identifiers DB. |
| Method | delete |
Remnove all stored requests from the database. |
| Method | delete |
Delete a resource from the database. |
| Method | discover |
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 | get |
Get an action representation by resource ID. |
| Method | get |
Return all action representations. |
| Method | get |
Return the batch notifications for a resource and notification URI. |
| Method | get |
Get an originator and its information from the database. |
| Method | get |
Get requests for a resource ID, or all requests. |
| Method | get |
Get a schedule from the database. |
| Method | get |
Get all schedules from the database. |
| Method | has |
Check if a resource exists in the database. |
| Method | init |
Callback method for the initialization phase of the plugin lifecycle. |
| Method | insert |
Add a request to the requests database. |
| Method | insert |
Insert a resource into the database. |
| Method | purge |
Purge the database. Remove all data |
| Method | purge |
Purge the statistics DB. |
| Method | remove |
Remove an action representation. |
| Method | remove |
Remove the batch notifications for a resource and notification URI. |
| Method | remove |
Remove a child resource from the childResources DB. |
| Method | remove |
Remove old requests from the database. |
| Method | remove |
Remove an originator from the database. |
| Method | remove |
Remove a schedule from the database. |
| Method | remove |
Remove a subscription representation from the database. |
| Method | search |
Search for action representations by subject. |
| Method | search |
Search and return all resources that match the given dictionary/document. |
| Method | search |
Search for child resources by parent resource ID and optional type. |
| Method | search |
Search for an resource ID OR for a structured name in the identifiers DB. |
| Method | search |
Search for resources by structured resource name, resource ID, CSE-ID, parent resource ID, resource type, or application entity ID. |
| Method | search |
Search for schedules in the database. |
| Method | search |
Search for statistics. |
| Method | search |
Search for subscription representations by resource ID or parent resource ID. |
| Method | start |
Callback method for the start phase of the plugin lifecycle. |
| Method | update |
Update an action representation. |
| Method | update |
Update a resource in the database. Only the fields that are not None will be updated. |
| Method | upsert |
Update or insert an action representation. |
| Method | upsert |
Add a child resource to the childResources DB. |
| Method | upsert |
Insert or update an identifier into the identifiers DB and a structured resource name into the structuredResourceNames DB. |
| Method | upsert |
Update or insert a resource into the database. |
| Method | upsert |
Add or update a schedule in the database. |
| Method | upsert |
Update or insert statistics. |
| Method | upsert |
Update or insert a subscription representation into the database. |
| Method | validate |
Callback method for the validation phase of the plugin lifecycle. |
| Class Variable | __slots__ |
Define slots for instance variables. |
| Instance Variable | actions |
The TinyDB query object for the actions table. |
| Instance Variable | batch |
The TinyDB query object for the batchNotifications table. |
| Instance Variable | cache |
Size of the cache for the TinyDB tables. |
| Instance Variable | db |
The TinyDB database for the actions table. |
| Instance Variable | db |
The TinyDB database for the batchNotifications table. |
| Instance Variable | db |
The TinyDB database for the identifiers table. |
| Instance Variable | db |
The TinyDB database for the originators table. |
| Instance Variable | db |
The TinyDB database for the requests table. |
| Instance Variable | db |
The TinyDB database for the resources table. |
| Instance Variable | db |
The TinyDB database for the schedules table. |
| Instance Variable | db |
The TinyDB database for the statistics table. |
| Instance Variable | db |
The TinyDB database for the subscriptions table. |
| Instance Variable | file |
Filename for the actions table. |
| Instance Variable | file |
Filename for the batchNotifications table. |
| Instance Variable | file |
Filename for the identifiers table. |
| Instance Variable | file |
Filename for the originators table. |
| Instance Variable | file |
Filename for the requests table. |
| Instance Variable | file |
Filename for the resources table. |
| Instance Variable | file |
Filename for the schedules table. |
| Instance Variable | file |
Filename for the statistics table. |
| Instance Variable | file |
Filename for the subscriptions table. |
| Instance Variable | identifier |
The TinyDB query object for the identifiers table. |
| Instance Variable | lock |
Lock for the actions table. |
| Instance Variable | lock |
Lock for the batchNotifications table. |
| Instance Variable | lock |
Lock for the childResources table. |
| Instance Variable | lock |
Lock for the identifiers table. |
| Instance Variable | lock |
Lock for the originators. |
| Instance Variable | lock |
Lock for the requests table. |
| Instance Variable | lock |
Lock for the resources table. |
| Instance Variable | lock |
Lock for the schedules table. |
| Instance Variable | lock |
Lock for the statistics table. |
| Instance Variable | lock |
Lock for the structuredIDs table. |
| Instance Variable | lock |
Lock for the subscriptions table. |
| Instance Variable | originators |
The TinyDB query object for the originators table. |
| Instance Variable | path |
Path to the database directory. |
| Instance Variable | postfix |
Postfix for the database file names. |
| Instance Variable | requests |
The TinyDB query object for the requests table. |
| Instance Variable | resource |
The TinyDB query object for the resources table. |
| Instance Variable | schedules |
The TinyDB query object for the schedules table. |
| Instance Variable | subscription |
The TinyDB query object for the subscriptions table. |
| Instance Variable | tab |
The TinyDB table for the actions table. |
| Instance Variable | tab |
The TinyDB table for the batchNotifications table. |
| Instance Variable | tab |
The TinyDB table for the childResources table. |
| Instance Variable | tab |
The TinyDB table for the identifiers table. |
| Instance Variable | tab |
The TinyDB table for the originators table. |
| Instance Variable | tab |
The TinyDB table for the requests table. |
| Instance Variable | tab |
The TinyDB table for the resources table. |
| Instance Variable | tab |
The TinyDB table for the schedules table. |
| Instance Variable | tab |
The TinyDB table for the statistics table. |
| Instance Variable | tab |
The TinyDB table for the structuredIDs table. |
| Instance Variable | tab |
The TinyDB table for the subscriptions table. |
| Instance Variable | write |
Delay for writing to the database. |
Add a batch notification to the database.
| Parameters | |
batchJSON | The batch notification to add. |
| Returns | |
bool | True if the batch notification was added, False otherwise. |
Add an originator to the database.
| Parameters | |
originatorJSON | The originator structure to add. |
originator:str | The originator to add. |
| Returns | |
bool | Boolean value to indicate success or failure. |
Backup the database to a directory.
| Parameters | |
dir:str | The directory to backup to. |
| Returns | |
bool | Boolean value to indicate success or failure. |
Callback method for the configuration phase of the plugin lifecycle.
| Parameters | |
config:Configuration | The configuration object containing the configuration settings for the plugin. |
Return the number of batch notifications for a resource and notification URI.
| Parameters | |
ri:str | The resource ID of the resource. |
nu:str | The notification URI. |
| Returns | |
int | The number of batch notifications for the resource and notification URI. |
Delete an identifier from the identifiers DB.
| Parameters | |
ri:str | The resource ID of the resource. |
srn:str | The structured resource name of the resource. |
Remnove all stored requests from the database.
| Parameters | |
ri:str | None | Optional resouce ID. Only requests for this resource ID will be deleted. |
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[ | The filter function to use. |
| Returns | |
list[ | A list of found resource documents, or an empty list. |
Get an action representation by resource ID.
| Parameters | |
ri:str | The resource ID of the action representation. |
| Returns | |
JSON | None | The action representation, or None if not found. |
Return all action representations.
| Returns | |
list[ | A list of action representations, or None if not found. |
Return the batch notifications for a resource and notification URI.
| Parameters | |
ri:str | The resource ID of the resource. |
nu:str | The notification URI. |
| Returns | |
list[ | A list of batch notifications for the resource and notification URI. |
Get an originator and its information from the database.
| Parameters | |
originator:str | The originator to search for. |
| Returns | |
tuple[ | Tuple containing the originator and its type, or None if not found. |
Get requests for a resource ID, or all requests.
| Parameters | |
ri:str | None | The target resource's resource ID. If None or empty, then all requests are returned |
| Returns | |
list[ | List of Documents. May be empty. |
Get a schedule from the database.
| Parameters | |
ri:str | The resource ID of the schedule. |
| Returns | |
JSON | None | The schedule, or None if not found. |
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 | None | A resource ID. |
srn:str | None | A structured resource name. |
ty:int | None | A resource type. |
| Returns | |
bool | True if the resource exists, False otherwise. |
Add a request to the requests database.
| Parameters | |
req:JSON | The request to store. |
ts:float | The timestamp of the request. |
| Returns | |
bool | Boolean value to indicate success or failure. |
Insert a resource into the database.
| Parameters | |
resource:JSON | The resource to insert. |
ri:str | The resource ID of the resource. |
Remove an action representation.
| Parameters | |
ri:str | The action's resource ID. |
| Returns | |
bool | True if the action representation was removed, False otherwise. |
Remove the batch notifications for a resource and notification URI.
| Parameters | |
ri:str | The resource ID of the resource. |
nu:str | The notification URI. |
| Returns | |
bool | True if the batch notifications were removed, False otherwise. |
Remove a child resource from the childResources DB.
| Parameters | |
ri:str | The resource ID of the resource. |
pi:str | The resource ID of the parent resource. |
Remove old requests from the database.
| Parameters | |
maxint | The maximum number of requests to keep. |
Remove an originator from the database.
| Parameters | |
originator:str | The originator to remove. |
| Returns | |
bool | Boolean value to indicate success or failure. |
Remove a schedule from the database.
| Parameters | |
ri:str | The resource ID of the schedule to remove. |
| Returns | |
bool | True if the schedule was removed, False otherwise. |
Remove a subscription representation from the database.
| Parameters | |
ri:str | The resource ID of the original SUB resource. |
| Returns | |
bool | True if the subscription representation was removed, False otherwise. |
Search for action representations by subject.
| Parameters | |
subjectstr | The resource ID of the action representation's subject. |
| Returns | |
Sequence[ | A list of action representations, or an empty list if not found. |
Search and return all resources that match the given dictionary/document.
| Parameters | |
dct:dict | The dictionary/document to search for. |
| Returns | |
list[ | A list of found resources, or an empty list. |
str, ty: ResourceTypes | list[ ResourceTypes] | None = None) -> list[ str]:
¶
Search for child resources by parent resource ID and optional type.
| Parameters | |
pi:str | The parent resource ID. |
ty:ResourceTypes | list[ | The resource type of the child resources to search for, or a list of resource types. |
| Returns | |
list[ | A list of child resource IDs, or an empty list if not found. |
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 | None | Resource ID to search for. |
srn:str | None | Structured path to search for. |
| Returns | |
list[ | A list of found identifier documents (see upsertIdentifier), or an empty list if not found. |
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 | None | A resource ID. |
csi:str | None | A CSE ID. |
srn:str | None | A structured resource name. |
pi:str | None | A parent resource ID. |
ty:int | None | A resource type. |
aei:str | None | An application entity ID. |
| Returns | |
list[ | A list of found resource documents, or an empty list. |
Search for schedules in the database.
| Parameters | |
pi:str | The resource ID of the parent resource. |
| Returns | |
list[ | List of Documents. May be empty. |
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 | None | A resource ID. |
pi:str | None | A parent resource ID. |
| Returns | |
list[ | A list of found subscription representations, or None. |
Update an action representation.
| Parameters | |
actionJSON | The action representation to update. |
| Returns | |
bool | True if the action representation was updated, False otherwise. |
Update or insert an action representation.
| Parameters | |
actionJSON | The action representation to update or insert. |
ri:str | The resource ID of the action representation. |
| Returns | |
bool | True if the action representation was updated or inserted, False otherwise. |
Add a child resource to the childResources DB.
| Parameters | |
childJSON | The resource to add as a child. |
ri:str | The resource ID of the resource. |
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 | |
identifierJSON | The identifier mapping to insert. |
structuredJSON | The structured path mapping to insert. |
ri:str | The resource ID of the resource. |
srn:str | The structured resource name of the resource. |
Update or insert a resource into the database.
| Parameters | |
resource:JSON | The resource to upate or insert. |
ri:str | The resource ID of the resource. |
Add or update a schedule in the database.
| Parameters | |
schedule:JSON | The schedule to store. |
ri:str | The resource ID of the schedule. |
| Returns | |
bool | True if the schedule was added or updated, False otherwise. |
Update or insert statistics.
| Parameters | |
stats:JSON | The statistics to update or insert. |
| Returns | |
bool | True if the statistics were updated or inserted, False otherwise. |
Callback method for the validation phase of the plugin lifecycle.
| Parameters | |
config:Configuration | The configuration object containing the configuration settings for the plugin. |