class documentation

Base class for all announceable resources.

Method __init__ Initialization of a Resource instance.
Method activate This method is called to activate a resource, usually in a CREATE request.
Method addAnnouncementToResource Add anouncement information to the resource. These are a list of tuples of the csi to which the resource is registered and the CSE-relative ri of the resource on the remote CSE. Also, add the reference in the at attribute.
Method createAnnouncedResourceDict Create the dict stub for the announced resource.
Method deactivate Deactivate an active resource.
Method getAnnouncedTo Return the internal announcedTo list attribute of a resource.
Method removeAnnouncementFromResource Remove anouncement information from the resource. These are a list of tuples of the csi to which the resource is registered and the CSE-relative ri of the resource on the remote CSE. Also, remove the reference from the at attribute.
Method setAnnouncedTo Set the internal announcedTo list attribute of a resource.
Method update Update, add or remove resource attributes.
Method validate Validate a resource.
Method validateAnnouncedDict Possibility to add or modify the announced Dict. This can be implemented in the child classes.
Class Variable announcementManager Injected AnnouncementManager instance.
Class Variable validator Injected Validator instance.
Method _createAnnouncedDict Actually create the resource dict.
Method _getAnnouncedAttributes Return a list of mandatory and optional announced attributes. The function only returns those attributes that are also present in the resource!
Instance Variable _origAA Store the original announceableAttributes for later use in the update so that we can check whether they are removed.
Instance Variable _origAT Store the original at attribute for later use in the update so that we can check whether it is removed.

Inherited from Resource:

Method __contains__ Implementation of the membership test operator.
Method __delitem__ Implementation of the self[key| operation for deleting attributes.
Method __eq__ Test for equality of the resource to another resource.
Method __getattr__ Map the normal object attribute access to the internal resource attribute dictionary.
Method __getitem__ Implementation of the self[key| operation for retrieving attributes.
Method __repr__ Object representation as string.
Method __setitem__ Implementation of the self[key] operation for assigning to attributes.
Method __str__ String representation of the resource's attributes.
Method asDict Get the JSON resource representation.
Method attribute Return the value of an attribute.
Method canHaveChild Check whether resource is a valild child resource for this resource.
Method childAdded Called after a child resource was added to the resource.
Method childRemoved Called when a child resource of the resource was removed.
Method childUpdated Called when a child resource was updated.
Method childWillBeAdded Called before a child will be added to a resource.
Method createChildResourceFromDict Create a child resource from a JSON dictionary.
Method dbCreate Add the resource to the database.
Method dbDelete Delete the resource from the database.
Method dbReload Load a new copy of the same resource from the database.
Method dbReloadDict Reload the resource instance from the database.
Method dbUpdate Update the resource in the database.
Method decrementSubscriptionCounter Decrement the subscription counter for the resource.
Method delAttribute Delete the attribute 'key' from the resource.
Method getAttributes Get all attributes of the resource.
Method getCurrentOriginator Retrieve the current originator. This could be different from the originator / creator of the resource in case of the custodian attribute is set.
Method getFinalResourceAttribute Determine and return the final value of an attribute during an update.
Method getLocationCoordinates Retrieve a resource's location coordinates (internal attribute).
Method getOriginator Retrieve a resource's originator.
Method getRVI Retrieve a resource's release version indicator.
Method getSrn Retrieve a resource's full structured resource name.
Method getSubscriptionCounter Retrieve the subscription counter for the resource.
Method handleCreateRequest Process a CREATE request that is directed to a virtual resource.
Method handleDeleteRequest Process a DELETE request that is directed to a virtual resource.
Method handleNotification Process a notification request that is directed to a resource.
Method handleRetrieveRequest Process a RETRIEVE request that is directed to a virtual resource.
Method handleUpdateRequest Process a UPDATE request that is directed to a virtual resource.
Method hasAttribute Check whether an attribute exists for the resource.
Method hasAttributeDefined Test whether a resource supports the specified attribute. This method may be overwritten in sub-classes, for example for virtual resources.
Method incrementSubscriptionCounter Increment the subscription counter for the resource.
Method initialize This method is called when a new resource is created and before written to the database.
Method isAnnounced Test whether a the resource's type is an announced type.
Method isCreatedInternally Test whether a resource has been created for another resource.
Method isModifiedAfter Test whether this resource has been modified after another resource.
Method isVirtual Test whether the resource is a virtual resource.
Method retrieveParentResource Retrieve the parent resource of this resouce.
Method retrieveParentResourceRaw Retrieve the raw (!) parent resource of this resouce.
Method selectAttributes Determine the selected attributes for a partial retrieve of a resource.
Method setAttribute Assign a value to a resource attribute.
Method setCreatedInternally Save the resource ID for which this resource was created for.
Method setLocationCoordinates Set a resource's location coordinates (internal attribute).
Method setOriginator Set a resource's originator.
Method setResourceID Set the resource ID for the resource if not already set.
Method setResourceName Set the resource name.
Method setRVI Assign the release version for a resource.
Method setSrn Set a resource's full structured resource name.
Method structuredPath Determine the structured path of a resource.
Method typeAsString Return the resource type as a string. If the resource is a flex container, the specialization is added.
Method updated Signal to a resource that is was successfully updated.
Method willBeDeactivated This method is called before a resource will be deactivated.
Method willBeRetrieved This method is called before a resource will be send back in a RETRIEVE response.
Method willBeUpdated This method is called before a resource will be updated and before calling the update() method.
Class Variable __slots__ Slots for the class.
Class Variable dispatcher Injected Dispatcher instance.
Class Variable factory Injected Factory instance.
Class Variable importer Injected Importer instance.
Class Variable notificationManager Injected NotificationManager instance.
Class Variable requestManager Injected RequestManager instance.
Class Variable storage Injected Storage instance.
Instance Variable dict Dictionary for public and internal resource attributes.
Method _checkAndFixACPIreferences Check whether a referenced ACP resoure exists, and if yes, change the ID in the list to CSE relative unstructured format.
Method _normalizeURIAttribute Normalize the URLs in the given attribute.
Class Variable _excludeFromUpdate Resource attributes that are excluded when updating the resource
Instance Variable _originalDict Original dictionary as it was created. This is used for validation in activate() later.
def __init__(self, dct: JSON | None = None, create: bool | None = False):

Initialization of a Resource instance.

Parameters
dct:JSON | NoneMandatory resource attributes.
create:bool | NoneUndocumented
def activate(self, parentResource: Resource, originator: str):

This method is called to activate a resource, usually in a CREATE request.

This is not always the case, e.g. when a resource object is just used temporarly. NO notification on activation/creation happens in this method!

This method is implemented in sub-classes as well.

Parameters
parentResource:ResourceThe resource's parent resource.
originator:strThe request's originator.
Raises
BAD_REQUESTIn case of an invalid attribute.
def addAnnouncementToResource(self, csi: str, remoteRI: str):

Add anouncement information to the resource. These are a list of tuples of the csi to which the resource is registered and the CSE-relative ri of the resource on the remote CSE. Also, add the reference in the at attribute.

Parameters
csi:strcsi of the remote CSE
remoteRI:strri of the announced resource on the remote CSE
def createAnnouncedResourceDict(self, isCreate: bool | None = False, announceTo: str | None = None) -> JSON:

Create the dict stub for the announced resource.

def deactivate(self, originator: str, parentResource: Resource):

Deactivate an active resource.

This usually happens when creating the resource via a request. A subscription check for deletion is performed.

This method is implemented in sub-classes as well.

Parameters
originator:strThe requests originator that let to the deletion of the resource.
parentResource:ResourceThe resource's parent resource.
def getAnnouncedTo(self) -> list[tuple[str, str]]:

Return the internal announcedTo list attribute of a resource.

Returns
list[tuple[str, str]]The internal list of announcedTo tupples (csi, remote resource ID) for this resource.
def removeAnnouncementFromResource(self, csi: str) -> str | None:

Remove anouncement information from the resource. These are a list of tuples of the csi to which the resource is registered and the CSE-relative ri of the resource on the remote CSE. Also, remove the reference from the at attribute.

Parameters
csi:strcsi of the remote CSE
Returns
str | NoneUndocumented
def setAnnouncedTo(self, announcedTo: list[tuple[str, str]]):

Set the internal announcedTo list attribute of a resource.

Parameters
announcedTo:list[tuple[str, str]]The list of announcedTo tupples (csi, remote resource ID) to assign to a resource.
def update(self, dct: JSON = None, originator: str | None = None, doValidateAttributes: bool | None = True):

Update, add or remove resource attributes.

A subscription check for update is performed.

This method is implemented in sub-classes as well.

Note

This method updates the resource in the database. It should be called only after all other checks where performed.

Parameters
dct:JSONAn optional JSON dictionary with the attributes to be updated.
originator:str | NoneThe optional requests originator that let to the update of the resource.
doValidateAttributes:bool | NoneIf True optionally call the resource's validate() method.
Raises
CONTENTS_UNACCEPTABLEIn case of a resource mismatch.
BAD_REQUESTIn case of an invalid attribute.
INTERNAL_SERVER_ERRORIn case the parent resource coudln't be retrieved.
def validate(self, originator: str | None = None, dct: JSON | None = None, parentResource: Resource | None = None):

Validate a resource.

Usually called within activate() or update() methods.

This method is implemented in some sub-classes.

Raises
BAD_REQUEST: In case of a validation error.
Parameters
originator:str | NoneOptional request originator
dct:JSON | NoneUpdated attributes to validate
parentResource:Resource | NoneThe parent resource
def validateAnnouncedDict(self, dct: JSON) -> JSON:

Possibility to add or modify the announced Dict. This can be implemented in the child classes.

announcementManager: AnnouncementManager | None =

Injected AnnouncementManager instance.

def _createAnnouncedDict(self, attributes: AttributePolicyDict, isCreate: bool, isRemoteSP: bool) -> JSON:

Actually create the resource dict.

def _getAnnouncedAttributes(self, attributes: AttributePolicyDict) -> list[str]:

Return a list of mandatory and optional announced attributes. The function only returns those attributes that are also present in the resource!

_origAA =

Store the original announceableAttributes for later use in the update so that we can check whether they are removed.

_origAT =

Store the original at attribute for later use in the update so that we can check whether it is removed.