class Dispatcher:
Dispatcher class. Handles all requests and dispatches them to the appropriate handlers. This includes requests for resources, requests for resource creation, and requests for resource deletion.
| Method | check |
Check request expiration timeout if a request timeout is give. |
| Method | check |
Check result expiration timeout if a result timeout is given. |
| Method | count |
Return the number of all child resources of resource, optionally filtered by type. |
| Method | count |
Return total number of resources. Optional filter by type. |
| Method | create |
Create a resource locally. |
| Method | create |
Create a resource from a JSON dictionary. |
| Method | delete |
Remove all child resources of a parent recursively. |
| Method | delete |
Delete a resource from the CSE. Call deactivate() and deleted() callbacks on the resource. |
| Method | delete |
Delete a resource from the CSE. |
| Method | direct |
Return the resourceIdentifiers of all child resources of a resource, optionally filtered by type. An empty list is returned if no child resource could be found. |
| Method | discover |
Discover child resources of a resource. |
| Method | discover |
Discover resources. This is the main function for resource discovery. |
| Method | handle |
Handle operation execution time and request expiration. If the OET is set then wait until the provided timestamp is reached. |
| Method | has |
Check if a resource has a direct child resource with a given resourceID |
| Method | initialize |
Initialize the Dispatcher. |
| Method | notify |
Notify a local resource. |
| Method | process |
Process a CREATE request. Create and register resource(s). |
| Method | process |
Process a DELETE request. Delete resource(s). |
| Method | process |
Process a NOTIFY request. Send notifications to resource(s). |
| Method | process |
Process a RETRIEVE request. Retrieve and discover resource(s). |
| Method | process |
Process a UPDATE request. Update resource(s). |
| Method | resource |
Recursively walk the results and build a sub-resource tree for each resource type. |
| Method | retrieve |
Return all child resources of a resource, optionally filtered by type. An empty list is returned if no child resource could be found. |
| Method | retrieve |
Get the latest or oldest x-Instance resource for a parent. |
| Method | retrieve |
Retrieve a resource locally. |
| Method | retrieve |
Retrieve a resource locally or from remote CSE. |
| Method | retrieve |
Retrieve all resources of a type. |
| Method | retrieve |
Retrieve a resource and check access for an originator. |
| Method | shutdown |
Shutdown the Dispatcher servide. |
| Method | update |
Update a resource in the CSE. Call update() and updated() callbacks on the resource. |
| Method | update |
Update a resource from a JSON dictionary. |
| Class Variable | __slots__ |
Slots of class attributes. |
| Class Variable | factory |
Injected Factory instance. |
| Class Variable | location |
Injected LocationManager instance. |
| Class Variable | registration |
Injected RegistrationManager instance. |
| Class Variable | remote |
Injected RemoteCSEManager instance. |
| Class Variable | request |
Injected RequestManager instance. |
| Class Variable | script |
Injected ScriptManager instance. |
| Class Variable | security |
Injected SecurityManager instance. |
| Class Variable | semantic |
Injected SemanticManager instance. |
| Class Variable | storage |
Injected Storage instance. |
| Class Variable | time |
Injected TimeManager instance. |
| Class Variable | validator |
Injected Validator instance. |
| Instance Variable | sort |
Sort the discovered resources. |
| Method | _check |
Check if the CSE is currently active according to its schedule. |
| Method | _check |
Return a corrected id and srn in case this is a hybrid ID. |
| Method | _child |
Retrieve child resources of a resource and add them to a new target resource instance as "children" |
| Method | _discover |
Discover resources recursively. This is a helper function for discoverResources(). |
| Method | _get |
Check whether the target resource contains a fanoutPoint along its path is a fanoutPoint. |
| Method | _get |
Check whether the target is a notificationTargetSelfReference virtual resource and return it. |
| Method | _get |
Check whether the target is a PollingChannelURI resource and return it. |
| Method | _get |
Check whether the target is a virtual resource and return it. |
| Method | _latest |
Check whether the target is a latest or oldest virtual resource and return it. |
| Method | _match |
Match a filter to a resource. |
| Method | _resources |
Create a m2m:uril structure from a list of resources. |
| Method | _resource |
Retrieve child resource references of a resource and add them to a new target resource instance as "children" |
Check request expiration timeout if a request timeout is give.
| Parameters | |
request:CSERequest | The request to check. |
| Raises | |
REQUEST_TIMEOUT | In case the request is expired |
Check result expiration timeout if a result timeout is given.
| Parameters | |
request:CSERequest | The request to check. |
| Raises | |
REQUEST_TIMEOUT | In case the result is expired |
BAD_REQUEST | In case the request expiration timestamp is greater than the result expiration timestamp. |
Return the number of all child resources of resource, optionally filtered by type.
| Parameters | |
pi:str | The parent's resourceIdentifier. |
ty:ResourceTypes | None | The resource type to filter for. |
| Returns | |
int | Number of child resources. |
Resource, parentResource: Resource, originator: str | None = None, rvi: str | None = None) -> Resource:
¶
Create a resource locally.
| Parameters | |
resource:Resource | The resource to create. |
parentResource | The parent resource. |
originator:str | None | The originator of the request. |
rvi:str | None | The release version identifier. This is only be present in a real CREATE request. |
| Returns | |
Resource | The created resource. |
| Raises | |
TARGET_NOT_SUBSCRIBABLE | If the parent resource is not subscribable. |
INVALID_CHILD_RESOURCE_TYPE | If the child resource type is invalid. |
JSON, parent: str | Resource, ty: ResourceTypes, originator: str, checkCreation: bool = True, trustedSource: bool = False, preCreateCB: Callable[ [ Resource], None] | None = None) -> tuple[ Resource | None, str, str, str]:
¶
Create a resource from a JSON dictionary.
| Parameters | |
dct:JSON | The dictionary. |
parent:str | Resource | The parent ID or parent resource. |
ty:ResourceTypes | The resource type. |
originator:str | The originator. |
checkbool | If True, then perform the resource creation check. |
trustedbool | If True, then the resource is created from a trusted source and some checks can be skipped. Note: Also access control is ignores. |
preCallable[ | A callback function that is called before the resource is created. The function takes the resource as an argument and can be used to modify the resource before it is created. |
| Returns | |
tuple[ | A tuple of (resource or None, resource ID, CSE-ID, parent ID). |
| Raises | |
INTERNAL_SERVER_ERROR | If an unknown/unsupported RSC is returned. |
ORIGINATOR_HAS_NO_PRIVILEGE | If the originator has no privilege. |
Resource, originator: str, ty: ResourceTypes | None = None, doDeleteCheck: bool | None = True):
¶
Remove all child resources of a parent recursively.
If ty is set only the resources of this type are removed.
Resource, originator: str | None = None, withDeregistration: bool | None = False, parentResource: Resource | None = None, doDeleteCheck: bool | None = True):
¶
Delete a resource from the CSE. Call deactivate() and deleted() callbacks on the resource.
| Parameters | |
resource:Resource | The resource to delete. |
originator:str | None | The originator of the request. |
withbool | None | If True, deregister the resource. |
parentResource | None | The parent resource. |
dobool | None | If True, call childRemoved() on the parent resource. Also, will call willbeDeactivated() on the resource. |
Delete a resource from the CSE.
| Parameters | |
id:str | The resource ID to delete. |
originator:str | None | The originator of the request. Defaults to None. |
| Raises | |
OPERATION_NOT_ALLOWED | If the resource is a CSEBase resource. |
NOT_FOUND | If the resource is not found. |
ORIGINATOR_HAS_NO_PRIVILEGE | If the originator has no DELETE access to the resource. |
str, ty: ResourceTypes | list[ ResourceTypes] | None = None) -> list[ str]:
¶
Return the resourceIdentifiers of all child resources of a resource, optionally filtered by type. An empty list is returned if no child resource could be found.
| Parameters | |
pi:str | The parent's resourceIdentifier. |
ty:ResourceTypes | list[ | The resource type or list of resource types to filter for. |
| Returns | |
list[ | A list of retrieved resourceIdentifiers. This list might be empty. |
str, resource: Resource, originator: str, filterCriteria: FilterCriteria, permission: Permission) -> list[ Resource] | None:
¶
Discover child resources of a resource.
| Parameters | |
id:str | The resourceIdentifier of the resource to discover the children for. |
resource:Resource | The resource to discover the children for. |
originator:str | The originator of the request. |
filterFilterCriteria | The filter criteria to use. |
permission:Permission | The permission to check. |
| Returns | |
list[ | A list of child resources. This list might be empty. |
str, originator: str, filterCriteria: FilterCriteria | None = None, rootResource: Resource | None = None, permission: Permission | None = Permission.DISCOVERY) -> list[ Resource]:
¶
Discover resources. This is the main function for resource discovery.
| Parameters | |
id:str | The ID of the resource to start discovery from. |
originator:str | The originator of the request. |
filterFilterCriteria | None | The filter criteria. |
rootResource | None | The root resource for discovery. |
permission:Permission | None | The permission to use. |
| Returns | |
list[ | A list of discovered resources. |
Handle operation execution time and request expiration. If the OET is set then wait until the provided timestamp is reached.
| Parameters | |
request:CSERequest | The request to check. |
Check if a resource has a direct child resource with a given resourceID
| Parameters | |
pi:str | The parent's resourceIdentifier. |
ri:str | The resourceIdentifier to check for. |
| Returns | |
bool | True if a direct child resource with the given resourceIdentifier exists, False otherwise. |
Notify a local resource.
| Parameters | |
ri:str | The resourceIdentifier of the resource to notify. |
originator:str | The originator of the request. |
content:JSON | The notification content. |
| Returns | |
Result | Result object. |
| Raises | |
ORIGINATOR_HAS_NO_PRIVILEGE | If the originator has no NOTIFY access to the resource. |
CSERequest, originator: str | None = None, id: str | None = None) -> Result:
¶
Process a CREATE request. Create and register resource(s).
| Parameters | |
request:CSERequest | The incoming request. |
originator:str | None | The requests originator. |
id:str | None | Optional ID of the request. |
| Returns | |
Result | Result object. |
| Raises | |
BAD_REQUEST | If the request is invalid. |
NOT_FOUND | If the resource cannot be found. |
OPERATION_NOT_ALLOWED | If the operation is not allowed. |
SECURITY_ASSOCIATION_REQUIRED | If a security association is required. |
ORIGINATOR_HAS_NO_PRIVILEGE | If the originator has no privilege. |
CONFLICT | If the resource already exists. |
CSERequest, originator: str, id: str | None = None) -> Result:
¶
Process a DELETE request. Delete resource(s).
| Parameters | |
request:CSERequest | The incoming request. |
originator:str | The requests originator. |
id:str | None | Optional ID of the request. |
| Returns | |
Result | Result object. |
| Raises | |
NOT_FOUND | If the resource cannot be found. |
ORIGINATOR_HAS_NO_PRIVILEGE | If the originator has no privilege. |
CSERequest, originator: str | None, id: str | None = None) -> Result:
¶
Process a NOTIFY request. Send notifications to resource(s).
| Parameters | |
request:CSERequest | The incoming request. |
originator:str | None | The requests originator. |
id:str | None | Optional ID of the request. |
| Returns | |
Result | Result object. |
| Raises | |
BAD_REQUEST | If the request is invalid. |
ORIGINATOR_HAS_NO_PRIVILEGE | If the originator has no privilege. |
CSERequest, originator: str, id: str | None = None) -> Result:
¶
Process a RETRIEVE request. Retrieve and discover resource(s).
| Parameters | |
request:CSERequest | The incoming request. |
originator:str | The requests originator. |
id:str | None | Optional ID of the request. |
| Returns | |
Result | Result object. |
| Raises | |
BAD_REQUEST | If the request is invalid. |
ORIGINATOR_HAS_NO_PRIVILEGE | If the originator has no privilege. |
INTERNAL_SERVER_ERROR | If an internal error occurred. |
CSERequest, originator: str, id: str | None = None) -> Result:
¶
Process a UPDATE request. Update resource(s).
| Parameters | |
request:CSERequest | The incoming request. |
originator:str | The requests originator. |
id:str | None | Optional ID of the request. |
| Returns | |
Result | Result object. |
| Raises | |
BAD_REQUEST | If the request is invalid. |
NOT_FOUND | If the resource cannot be found. |
OPERATION_NOT_ALLOWED | If the operation is not allowed. |
ORIGINATOR_HAS_NO_PRIVILEGE | If the originator has no privilege. |
str, ty: ResourceTypes | list[ ResourceTypes] | None = None) -> list[ Resource]:
¶
Return all child resources of a resource, optionally filtered by type. An empty list is returned if no child resource could be found.
| Parameters | |
pi:str | The parent's resourceIdentifier. This is the resourceID of resource. |
ty:ResourceTypes | list[ | The resource type or list of resource types to filter for. |
| Returns | |
list[ | A list of retrieved Resource objects. This list might be empty. |
str, ty: ResourceTypes, oldest: bool | None = False) -> Resource | None:
¶
Get the latest or oldest x-Instance resource for a parent.
This is done by searching through all resources once to find the fitting resource (parent + type) with the latest or oldest ct attribute.
| Parameters | |
pi:str | parent resourceIdentifier |
ty:ResourceTypes | resource type to look for |
oldest:bool | None | switch between oldest and latest search |
| Returns | |
Resource | None | Resource |
str | None = None, srn: str | None = None, originator: str | None = None, request: CSERequest | None = None) -> Resource:
¶
Retrieve a resource locally.
| Parameters | |
ri:str | None | The resource ID. |
srn:str | None | The structured resource name. |
originator:str | None | The originator of the request. |
request:CSERequest | None | The request. |
| Returns | |
Resource | The retrieved resource. |
| Raises | |
NOT_FOUND | If the resource cannot be found. |
str, originator: str | None = None, request: CSERequest | None = None, postRetrieveHook: bool | None = False) -> Resource:
¶
Retrieve a resource locally or from remote CSE.
| Parameters | |
id:str | If the id is in SP-relative format then first check whether this is for the local CSE. If yes, then adjust the ID and try to retrieve it. If no, then try to retrieve the resource from a connected (!) remote CSE. |
originator:str | None | The originator of the request. |
request:CSERequest | None | Undocumented |
postbool | None | Only when retrieving localls, invoke the Resource's willBeRetrieved() callback. |
| Returns | |
Resource | Result instance. |
| Raises | |
NOT_FOUND | If the resource cannot be found. |
Retrieve all resources of a type.
| Parameters | |
ty:ResourceTypes | Resouce type to search for. |
| Returns | |
list[ | A list of retrieved Resource objects. This list might be empty. |
str, originator: str, permission: Permission) -> Resource:
¶
Retrieve a resource and check access for an originator.
| Parameters | |
ri:str | Resource ID of the resource to be retrieved. |
originator:str | The originator to check the permission for. |
permission:Permission | The permission to check. |
| Returns | |
Resource | The retrieved resource. |
| Raises | |
NOT_FOUND | In case the resource could not be found. |
ORIGINATOR_HAS_NO_PRIVILEGE | In case the originator has not the required permission to the resoruce. |
Resource, dct: JSON | None = None, doUpdateCheck: bool | None = True, originator: str | None = None) -> Resource:
¶
Update a resource in the CSE. Call update() and updated() callbacks on the resource.
| Parameters | |
resource:Resource | Resource to update. |
dct:JSON | None | JSON dictionary with the updated attributes. |
dobool | None | Enable/disable a call to update(). |
originator:str | None | The request's originator. |
| Returns | |
Resource | Updated resource. |
JSON, id: str, originator: str | None = None, resource: Resource | None = None) -> Resource:
¶
Update a resource from a JSON dictionary.
| Parameters | |
dct:JSON | The dictionary. |
id:str | The resource ID. |
originator:str | None | The originator. |
resource:Resource | None | The resource to update. |
| Returns | |
Resource | The updated resource. |
| Raises | |
INTERNAL_SERVER_ERROR | If the resource cannot be updated. |
ORIGINATOR_HAS_NO_PRIVILEGE | If the originator has no UPDATE privileges. |
Check if the CSE is currently active according to its schedule.
| Raises | |
TARGET_NOT_REACHABLE | In case the CSE is not active. |
Return a corrected id and srn in case this is a hybrid ID.
| Parameters | |
request:CSERequest | A request object that provides id and srn. srn might be None. |
id:str | An ID which might be None. If it is not None, then it will be taken to generate the srn. |
| Returns | |
tuple[ | Tuple of srn and id |
Resource, originator: str, level: int, fo: int, allLen: int, dcrs: list[ Resource] | None = None, filterCriteria: FilterCriteria | None = None, permission: Permission | None = Permission.DISCOVERY) -> list[ Resource]:
¶
Discover resources recursively. This is a helper function for discoverResources().
| Parameters | |
rootResource | The root resource for discovery. |
originator:str | The originator of the request. |
level:int | The level of discovery. |
fo:int | The filter operation. |
allint | The length of all filter criteria. |
dcrs:list[ | The direct child resources of the root resource. |
filterFilterCriteria | None | The filter criteria. |
permission:Permission | None | The permission to use. |
| Returns | |
list[ | A list of discovered resources. |
Check whether the target resource contains a fanoutPoint along its path is a fanoutPoint.
| Parameters | |
id:str | the target's resource ID. |
| Returns | |
Resource | None | Return either the virtual fanoutPoint resource, or None in case of an error. |
Check whether the target is a notificationTargetSelfReference virtual resource and return it.
| Parameters | |
id:str | Target resource ID |
| Returns | |
NTSR | None | Return either the virtual resource, or None in case of an error. |
Check whether the target is a PollingChannelURI resource and return it.
| Parameters | |
id:str | Target resource ID |
| Returns | |
PCH_PCU | None | Return either the virtual PollingChannelURI resource or None. |
Check whether the target is a virtual resource and return it.
| Parameters | |
id:str | Target resource ID |
rn:str | tuple[ | The resource name to check for. Can be a tuple of names. Must begin with a slash. |
| Returns | |
Resource | None | Return either the virtual resource or None. |
Check whether the target is a latest or oldest virtual resource and return it.
| Parameters | |
id:str | Target resource ID |
| Returns | |
Resource | None | Return either the virtual resource, or None in case of an error. |
Resource, fo: int, allLen: int, filterCriteria: FilterCriteria) -> bool:
¶
Match a filter to a resource.
list[ Resource], targetResource: Resource | JSON, drt: DesiredIdentifierResultType | None = DesiredIdentifierResultType.structured, tp: str | None = 'm2m:rrl') -> Resource | JSON:
¶
Retrieve child resource references of a resource and add them to a new target resource instance as "children"
| Parameters | |
resources:list[ | A list of resources to retrieve the child resource references from. |
targetResource | JSON | The target resource to add the child resource references to. |
drt:DesiredIdentifierResultType | None | Either structured or unstructured. Defaults to structured. |
tp:str | None | The type of the target resource. Defaults to 'm2m:rrl'. |
| Returns | |
Resource | JSON | The target resource with the added child resource references. |