class documentation

class ActionManager:

View In Hierarchy

This class defines functionalities to handle action triggerings, dependancies and other action related functionalities

Method checkAttributeOperator Check the operator for the given subject attribute.
Method checkAttributeThreshold Check the threshold value for the given subject attribute.
Method checkEvalCriteria Check the evaluation criteria for a given subject resource.
Method enterActiveState Enter the active state for a resource.
Method enterDisabledState Enter the disabled state for a resource.
Method enterPauseState Enter the pause state for a resource.
Method evaluateActions Eventhandler to evaluate actions for a resource in case a resource changes.
Method evaluateDependencies Evaluate the dependencies of an action.
Method evaluateSingleAction Evaluate a single action for a resource.
Method restart Restart the ActionManager service.
Method scheduleAction Schedule an action for execution.
Method shutdown Shutdown the Action Manager.
Method start Initialization of an ActionManager instance.
Method unscheduleAction Unschedule an action.
Method updateAction Update an existing action.
Class Variable dispatcher Injected Dispatcher instance.
Class Variable requestManager Injected RequestManager instance.
Class Variable storage Injected Storage instance.
Class Variable validator Injected Validator instance.
Method _evaluateEVC Evaluate a single evaluation criteria.
def checkAttributeOperator(self, optr: EvalCriteriaOperator, dataType: BasicType, sbjt: str):

Check the operator for the given subject attribute.

Parameters
optr:EvalCriteriaOperatorThe operator.
dataType:BasicTypeThe basic type of the attribute value.
sbjt:strThe subject attribute name.
Raises
BAD_REQUESTIf the operator is not allowed for the given data type.
def checkAttributeThreshold(self, sbjt: str, thld: Any, rtype: ResourceTypes) -> BasicType:

Check the threshold value for the given subject attribute.

Parameters
sbjt:strThe subject attribute name
thld:AnyThe threshold value.
rtype:ResourceTypesThe resource type of the subject attribute.
Returns
BasicTypeThe basic type of the attribute value.
Raises
BAD_REQUESTIf the threshold value is invalid.
def checkEvalCriteria(self, evc: JSON, subject: str | Resource, originator: str, checkEvc: bool = True):

Check the evaluation criteria for a given subject resource.

Parameters
evc:JSONThe evaluation criteria to check.
subject:str | ResourceThe subject resource ID or the subject resource itself.
originator:strThe originator of the request.
checkEvc:boolCheck the evaluation criteria. Default is True.
Returns
A tuple with a boolean indicating the success of the check and a possible error message.
Raises
BAD_REQUESTIf the evaluation criteria is invalid.
Originator_HAS_NO_PRIVILEGEIf the originator has no access to the subject resource.
NOT_FOUNDIf the subject resource does not exist.
def enterActiveState(self, resource: Resource):

Enter the active state for a resource.

Parameters
resource:ResourceThe resource to enter the active state.
def enterDisabledState(self, resource: Resource):

Enter the disabled state for a resource.

Parameters
resource:ResourceThe resource to enter the disabled state.
def enterPauseState(self, resource: Resource):

Enter the pause state for a resource.

Parameters
resource:ResourceThe resource to enter the pause state.
@onEvent(eventManager.changeResource)
def evaluateActions(self, eventData: EventData):

Eventhandler to evaluate actions for a resource in case a resource changes.

Parameters
eventData:EventDataThe event data containing the resource and the real resource ID in the payload.
def evaluateDependencies(self, action: JSON) -> bool:

Evaluate the dependencies of an action.

Parameters
action:JSONThe action to evaluate.
Returns
boolBoolean that indicates the success of the evaluation.
def evaluateSingleAction(self, resource: Resource, action: JSON, nowTS: float) -> bool:

Evaluate a single action for a resource.

Parameters
resource:ResourceThe resource to evaluate against.
action:JSONThe action to evaluate.
nowTS:floatThe current timestamp.
Returns
boolBoolean that indicates the success of the evaluation.
def restart(self):

Restart the ActionManager service.

def scheduleAction(self, action: ACTR):

Schedule an action for execution.

Parameters
action:ACTRThe action to schedule.
@stop
def shutdown(self):

Shutdown the Action Manager.

def start(self):

Initialization of an ActionManager instance.

def unscheduleAction(self, action: ACTR):

Unschedule an action.

Parameters
action:ACTRThe action to unschedule.
def updateAction(self, actr: ACTR):

Update an existing action.

Parameters
actr:ACTRThe action to update.
dispatcher: Dispatcher =

Injected Dispatcher instance.

requestManager: RequestManager =

Injected RequestManager instance.

storage: Storage =

Injected Storage instance.

validator: Validator =

Injected Validator instance.

def _evaluateEVC(self, resource: Resource, evc: JSON) -> bool:

Evaluate a single evaluation criteria.

Parameters
resource:ResourceThe resource to evaluate against.
evc:JSONThe evaluation criteria to evaluate.
Returns
boolBoolean that indicates the success of the evaluation.