class Storage:
This class implements the entry points to the CSE's underlying database functions.
| Method | add |
Add a batch notification to the DB. |
| Method | add |
Add an originator to the database. |
| Method | add |
Add a request to the requests database. |
| Method | backup |
Creating a backup from the DB to a sub directory. |
| Method | count |
Count the number of batch notifications for a target resource and a notification URI. |
| Method | count |
Count the number of direct child resources. |
| Method | count |
Count the overall number of CSE resources. |
| Method | create |
Create a new resource in the database. |
| Method | delete |
Delete all requests from the database. |
| Method | delete |
Delete a resource from the database. |
| Method | direct |
Return a list of direct child resources, or an empty list |
| Method | direct |
Return a list of direct child resource IDs, or an empty list |
| Method | get |
Retrieve an action representation from the DB. |
| Method | get |
Retrieve all action representations from the DB. |
| Method | get |
Retrieve the batch notifications for a target resource and a 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 |
Retrieve the schedules data from the DB. |
| Method | get |
Retrieve the statistics data from the DB. |
| Method | get |
Retrieve a subscription representation (not a oneM2M Resource object) from the DB. |
| Method | get |
Retrieve all subscriptions representations (not oneM2M Resource objects) for a parent resource. |
| Method | has |
Check whether a resource with either the ri or the srn already exists. |
| Method | identifier |
Search for the resource identifer mapping with the given unstructured resource ID. |
| Method | initialize |
Initialization of the storage manager. |
| Method | purge |
Reset and clear the databases. |
| Method | purge |
Purge the statistics DB. |
| Method | remove |
Remove an action representation from the DB. |
| Method | remove |
Remove the batch notifications for a target resource and a notification URI. |
| Method | remove |
Remove an originator from the database. |
| Method | remove |
Remove a schedule from the DB. |
| Method | remove |
Remove a subscription from the DB. |
| Method | retrieve |
Return a resource via different addressing methods. |
| Method | retrieve |
Retrieve a resource as a raw dictionary. |
| Method | retrieve |
Return all resources of a certain type. |
| Method | search |
Search for action representation for a subject resource. |
| Method | search |
Return a list of resources that match the given filter, or an empty list. |
| Method | search |
Search and return all resources that match the given fragment dictionary/document. |
| Method | search |
Search for schedules for a target resource. |
| Method | shutdown |
Shutdown the storage manager. |
| Method | structured |
Search for the resource identifer mapping with the given structured resource ID. |
| Method | update |
Update an action representation (not an actual action) in the DB. |
| Method | update |
Update a resource in the database. |
| Method | update |
Update the statistics DB with new data. |
| Method | upsert |
Update or add an action as an action representation in the DB. |
| Method | upsert |
Add or update a schedule in the DB. |
| Method | upsert |
Add or update a subscription to the DB. |
| Class Variable | __slots__ |
Define slots for instance variables. |
| Class Variable | factory |
Injected Factory instance. |
| Class Variable | postgre |
Injected PostgreSQLBinding instance. |
| Class Variable | tiny |
Injected TinyDBBinding instance. |
| Instance Variable | db |
The database object. |
| Method | _validate |
Trying to validate the database files. |
Add a batch notification to the DB.
| Parameters | |
ri:str | The resource ID of the target resource. |
nu:str | The notification URI. |
request:JSON | The request to store. |
| Returns | |
bool | Boolean value to indicate success or failure. |
Add an originator to the database.
| Parameters | |
originator:str | The originator to add. |
type:OriginatorType | The type of the originator. |
| Returns | |
bool | Boolean value to indicate success or failure. |
Operation, ri: str, srn: str, originator: str, outgoing: bool, ot: str, request: JSON, response: JSON, additionalCB: Callable | None = None) -> bool:
¶
Add a request to the requests database.
| Parameters | |
op:Operation | Operation. |
ri:str | Resource ID of a request's target resource. |
srn:str | Structured resource ID of a request's target resource. |
originator:str | Request originator. |
outgoing:bool | If true, then this is a request sent by the CSE. |
ot:str | Request creation time. |
request:JSON | The request to store. |
response:JSON | The response to store. |
additionalCallable | None | Undocumented |
| Returns | |
bool | Boolean value to indicate success or failure. |
Creating a backup from the DB to a sub directory.
| Returns | |
bool | Boolean indicating the success of the backup operation. |
Count the number of batch notifications for a target resource and a notification URI.
| Parameters | |
ri:str | The resource ID of the target resource. |
nu:str | The notification URI. |
| Returns | |
int | The number of matching batch notifications. |
Count the number of direct child resources.
| Parameters | |
pi:str | The parent resource's Resource ID. |
ty:ResourceTypes | None | Optional resource type to filter the result. |
| Returns | |
int | The number of child resources. |
Delete all requests from the database.
| Parameters | |
ri:str | None | Optional resouce ID. Only requests for this resource ID will be deleted. |
str, ty: ResourceTypes | list[ ResourceTypes] | None = None, raw: bool | None = False) -> list[ JSON] | list[ Resource]:
¶
Return a list of direct child resources, or an empty list
| Parameters | |
pi:str | The parent resource's Resource ID. |
ty:ResourceTypes | list[ | Optional resource type or list of resource types to filter the result. |
raw:bool | None | When "True" then return the child resources as resource dictionary instead of resources. |
| Returns | |
list[ | Return a list of resources, or a list of raw resource dictionaries. |
str, ty: ResourceTypes | list[ ResourceTypes] | None = None) -> list[ str]:
¶
Return a list of direct child resource IDs, or an empty list
| Parameters | |
pi:str | The parent resource's Resource ID. |
ty:ResourceTypes | list[ | Optional resource type or list of resource types to filter the result. |
| Returns | |
list[ | Return a list of resource IDs. |
Retrieve an action representation from the DB.
| Parameters | |
ri:str | The action's resource ID. |
| Returns | |
JSON | None | The action's data as a Document, or None. |
Retrieve the batch notifications for a target resource and a notification URI.
| Parameters | |
ri:str | The resource ID of the target resource. |
nu:str | The notification URI. |
| Returns | |
list[ | List of batch notifications. |
Get an originator and its information from the database.
| Parameters | |
originator:str | The originator to search for. |
| Returns | |
tuple[ | Tuple of the originator and its type. |
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 |
sortedbool | If true, then the requests are sorted by their creation time. |
| Returns | |
list[ | List of Documents. May be empty. |
Check whether a resource with either the ri or the srn already exists.
Either one of ri or srn must be provided.
| Parameters | |
ri:str | None | Optional resource ID. |
srn:str | None | Optional structured resource name. |
| Returns | |
bool | True when a resource with the ID or name exists. |
Search for the resource identifer mapping with the given unstructured resource ID.
| Parameters | |
ri:str | Unstructured resource ID for the mapping to look for. |
| Returns | |
list[ | List of found resources identifier mappings, or an empty list. |
Remove an action representation from the DB.
| Parameters | |
ri:str | The action's resource ID. |
| Returns | |
bool | Boolean value to indicate success or failure. |
Remove the batch notifications for a target resource and a notification URI.
| Parameters | |
ri:str | The resource ID of the target resource. |
nu:str | The notification URI. |
| Returns | |
bool | Boolean value to indicate success or failure. |
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 DB.
| Parameters | |
schedule:SCH | The schedule to remove. |
| Returns | |
bool | Boolean value to indicate success or failure. |
str | None = None, csi: str | None = None, srn: str | None = None, aei: str | None = None) -> Resource:
¶
Return a resource via different addressing methods.
Either one of ri, srn, csi, or aei must be provided.
| Parameters | |
ri:str | None | The resource is retrieved via its rersource ID. |
csi:str | None | The resource is retrieved via its CSE-ID. |
srn:str | None | The resource is retrieved via its structured resource name. |
aei:str | None | The resource is retrieved via its AE-ID. |
| Returns | |
Resource | The resource. |
| Raises | |
NOT_FOUND | In case the resource does not exist. |
INTENRAL_SERVER_ERROR | In case of a database inconsistency. |
Return all resources of a certain type.
| Parameters | |
ty:ResourceTypes | resource type to retrieve. |
| Returns | |
list[ | List of resource JSON objects, not Resource objects. |
Search for action representation for a subject resource.
| Parameters | |
subjectstr | The subject resource's resource ID. |
| Returns | |
Sequence[ | List of matching action representations. |
dict, filter: Callable[ [ JSON], bool] | None = None) -> list[ Resource]:
¶
Search and return all resources that match the given fragment dictionary/document.
| Parameters | |
dct:dict | A fragment dictionary to use as a filter for the search. |
filter:Callable[ | An optional callback to provide additional filter functionality. |
| Returns | |
list[ | List of Resource objects. |
Search for schedules for a target resource.
| Parameters | |
pi:str | The target resource's resource ID. |
| Returns | |
list[ | List of schedule resource IDs. |
Search for the resource identifer mapping with the given structured resource ID.
| Parameters | |
srn:str | Structured resource ID for the mapping to look for. |
| Returns | |
list[ | List of found resources identifier mappings, or an empty list. |
Update an action representation (not an actual action) in the DB.
| Parameters | |
actionJSON | The action representation to update. |
| Returns | |
bool | Boolean value to indicate success or failure. |
Update the statistics DB with new data.
| Parameters | |
stats:JSON | The statistics data to store. |
| Returns | |
bool | Boolean value to indicate success or failure. |
Update or add an action as an action representation in the DB.
| Parameters | |
action:ACTR | The action to update or insert. |
periodfloat | The period for the action. |
count:int | The run count for the action. |
| Returns | |
bool | Boolean value to indicate success or failure. |
Add or update a schedule in the DB.
| Parameters | |
schedule:SCH | The schedule to add or update. |
| Returns | |
bool | Boolean value to indicate success or failure. |