class documentation

class ManagementSupport:

View In Hierarchy

Management support class. Provides functions for accessing and managing CSE internal functions. Also provides functions for retrieving and formatting CSE status, statistics, and runtime information.

Method doExportInstances Export instances of a container resource to a CSV file in the tmp directory, or return as a string.
Method doExportResource Export a resource and its children to the tmp directory as a shell script with curl commands.
Method getConfig Get the current configuration of the CSE as a JSON string.
Method getCSEStatus Get the current status of the CSE.
Method getCSEStatusAsDict Get the status, statistics, and runtime information of the CSE.
Method getLogGenerator Get a generator that yields log entries as strings.
Method getLoglevel Get the current log level of the CSE.
Method getPlugins Get the current loaded plugins of the CSE.
Method getRegistrations Get the current registration status of the CSE as a JSON string.
Method getRegistrationsRich Create and return an overview about the registrar, registrees, and descendant CSE's.
Method getRegistrationStatus Return the registration status of the CSE, and registrations of CSEs and AEs.
Method getRequests Get the current requests of the CSE as a generator of JSON strings.
Method getRequestsRich Generate a Rich table with all requests and a PlantUML sequence diagram.
Method getResourceTreeRich This function will generate a Rich tree structure of a CSE's resource structure.
Method getResourceTreeText This function will generate a Text tree of a CSE's resource structure.
Method getServices Get the current registered services and their endpoints of the CSE.
Method getStatusRich Generate an overview about various resources, event counts, and more.
Method getStructurePuml The CSE, Type, http, port
Method refreshRegistrations Force the CSE to immediately check the registrations with the remote registrar(s).
Method resetCSE Reset the CSE to its initial state.
Method restartCSE Restart the CSE.
Method setLogLevel Set the log level of the CSE.
Method setRequestRecording Enable or disable request recording.
Method shutdownCSE Shutdown the CSE.
Class Variable cseForceShutdown Injected function to shutdown the CSE.
Class Variable cseReset Injected function to reset the CSE.
Class Variable dispatcher Injected Dispatcher instance.
Class Variable requestManager Injected RequestManager instance.
Class Variable storage Injected Storage instance.
Class Variable validator Injected Validator instance.
def doExportInstances(self, ri: str, asString: bool | None = False) -> tuple[int, str]:

Export instances of a container resource to a CSV file in the tmp directory, or return as a string.

Parameters
ri:strResource ID of the container resource.
asString:bool | NoneReturn the CSV string instead of writing to a file.
Returns
tuple[int, str]Tuple with the number of instances exported, and the filename of the exported file or the CSV string.
def doExportResource(self, ri: str, withChildResources: bool | None = False) -> tuple[int, str]:

Export a resource and its children to the tmp directory as a shell script with curl commands.

Parameters
ri:strResource ID of the resource to export.
withChildResources:bool | NoneIf True, also export child resources.
Returns
tuple[int, str]Tuple with the number of resources exported, and the filename of the exported file.
def getConfig(self) -> str:

Get the current configuration of the CSE as a JSON string.

Returns
strThe configuration of the CSE in JSON format.
def getCSEStatus(self) -> str:

Get the current status of the CSE.

Returns
strThe status of the CSE in JSON format.
def getCSEStatusAsDict(self) -> JSON:

Get the status, statistics, and runtime information of the CSE.

Returns
JSONStatus as JSON object.
def getLogGenerator(self) -> Generator[str, None, None]:

Get a generator that yields log entries as strings.

Returns
Generator[str, None, None]A generator that yields log entries as strings.
def getLoglevel(self) -> str:

Get the current log level of the CSE.

Returns
strThe current log level of the CSE.
def getPlugins(self) -> str:

Get the current loaded plugins of the CSE.

Returns
strThe loaded plugins of the CSE in JSON format.
def getRegistrations(self) -> str:

Get the current registration status of the CSE as a JSON string.

Returns
strThe registration status of the CSE in JSON format.
def getRegistrationsRich(self, style: Style | None = Style(), textStyle: Style | None = None) -> Table:

Create and return an overview about the registrar, registrees, and descendant CSE's.

Parameters
style:Style | NoneStyle for the general output.
textStyle:Style | NoneStyle for the text.
Returns
TableRich formatted string.
def getRegistrationStatus(self) -> JSON:

Return the registration status of the CSE, and registrations of CSEs and AEs.

Returns
JSONA JSON object with the registration status of the CSE, and registrations of CSEs and AEs.
def getRequests(self) -> Generator[str, None, None]:

Get the current requests of the CSE as a generator of JSON strings.

Returns
Generator[str, None, None]A generator that yields JSON strings of the request.
def getRequestsRich(self, id: str | None = None) -> tuple[Table, str]:

Generate a Rich table with all requests and a PlantUML sequence diagram.

Parameters
id:str | NoneIf set, then only the requests for this resource ID are returned.
Returns
tuple[Table, str]A tuple with a Rich Table object and a PlantUML sequence diagram string.
def getResourceTreeRich(self, maxLevel: int = 0, parent: str | None = None, style: Style | None = Style(), withProgress: bool | None = True, treeMode: TreeMode | None = TreeMode.NORMAL) -> Tree:

This function will generate a Rich tree structure of a CSE's resource structure.

Parameters
maxLevel:intThe maximum level for the result tree.
parent:str | NoneThe resource ID from where to start the tree. The default is the CSEBase.
style:Style | NoneThe Rich Style to use.
withProgress:bool | NoneDisplay a progress indicator while gathering the tree.
treeMode:TreeMode | NoneUndocumented
Returns
TreeReturn a Rich Tree object.
def getResourceTreeText(self, maxLevel: int = 0) -> str:

This function will generate a Text tree of a CSE's resource structure.

Todo

Support the maxLevel parameter.

Parameters
maxLevel:intMaximum tree level to render. Currently not supported.
Returns
strPure text rendering of the resource tree.
def getServices(self) -> str:

Get the current registered services and their endpoints of the CSE.

Returns
strThe registered services and their endpoints of the CSE in JSON format.
def getStatusRich(self, style: Style | None = Style(), withProgress: bool | None = True, textStyle: Style | None = None) -> Table:

Generate an overview about various resources, event counts, and more.

Parameters
style:Style | NoneRich style.
withProgress:bool | NoneDisplay with progress indicator.
textStyle:Style | NoneRich text style. If this is not set then the style is used for the text as well.
Returns
TableRich Table object.
def getStructurePuml(self, maxLevel: int | None = 0) -> str:

This function will generate a PlanUML graph of a CSE's structure, including:
  • The CSE, Type, http, port
  • The CSE's resource tree
  • The Registrar CSE (if any)
  • A list of descendant CSE's (if any)

This function calls itself recursively to generate the tree structure.

Parameters
maxLevel:int | NoneThe maximum level of the tree to print. 0 means all levels.
Returns
strThe PlanUML graph as a string.
def refreshRegistrations(self) -> str:

Force the CSE to immediately check the registrations with the remote registrar(s).

This is useful for testing purposes, e.g. when the CSE is started and the registration is not done automatically.

Returns
strA message indicating the result of the registration.
def resetCSE(self):

Reset the CSE to its initial state.

def restartCSE(self):

Restart the CSE.

This is done by setting the CSE status to SHUTTINGDOWNRESTART and calling the forceShutdown method.

def setLogLevel(self, level: str) -> str:

Set the log level of the CSE.

Parameters
level:strThe log level to set. Should be one of the Logging levels.
Returns
strA response indicating the result
def setRequestRecording(self, param: str) -> str:

Enable or disable request recording.

Parameters
param:strThe parameter to set. Should be 'enable' or 'disable'.
Returns
strThe new status of the request recording.
def shutdownCSE(self):

Shutdown the CSE.

cseForceShutdown: Callable[[], None] =

Injected function to shutdown the CSE.

cseReset: Callable[[], None] =

Injected function to reset the CSE.

dispatcher: Dispatcher =

Injected Dispatcher instance.

requestManager: RequestManager =

Injected RequestManager instance.

storage: Storage =

Injected Storage instance.

validator: Validator =

Injected Validator instance.