PY-SIL API Reference
The pysil library defines following classes
PYSILModuleBase
The pysil library defines a class PYSILModuleBase. This is a base class responsible for callback registration and cleanup. It register all callback specified in configuration during init phase 1 and unregister them during cleanup phase.
- class pysil.module.PYSILModuleBase(config)
Bases:
PYSILBase
Base Python module for PY-SIL-APP Registers all callbacks, intialize, etc.
- flag_internal_error() ENUM_STATUS_T_
Add log information about file, method and line with an error and return ERR_INTERNAL_VAL
- log(msg: str, log_level: str = 'INFO')
logging data from the module
- send_notification(name: str, data: dict | None = None, stream_name: str | None = None) None
@brief Send a notification.
Create an internal notification message (agt_not_msg_t) and queue
it for delivery to client sessions.
- timer_create(timer_fn: callable, seconds: int, cookie: dict | None = None, is_periodic: bool = False)
Creates a timer
- timer_delete(timer_id: int)
Deletes a periodic timer
SILCbGet
- class pysil.module.SILCbGet(scb: LP_STRUCT_SES_CB_T_, msg: LP_STRUCT_RPC_MSG_T_, get2cb: LP_STRUCT_GETCB_GET2_T_, module_name: str, callback_info: dict)
Bases:
SILCbBase
The
SILCbGet
class is a comprehensive control block used in GET2 callbacks. It encapsulates all necessary pointers and information required for the execution of the GET2 callback methods.- add_return_data(data: list | dict | str | int, has_more: bool = False) ENUM_STATUS_T_
Adds data to return
- Parameters:
data (dict, list, str or int) -- provide return data here list (for list of objects), dict (for single object), str or int (for simple leaf nodes)
has_more (bool) -- set to True if has more data to return
- Returns:
Status
- property ancestor_keys: dict
Ancestors keys for silcb
- property callback_info: dict
Property to get callback_info
- property cbmode: int
Reason for the callback (get or getnext), compare with GETCB_MODE_T values
- property choice_active_case: str
FOR CHOICES ONLY! Current active case
- property client_addr: str
This field contains the client address involved in the transaction. or None
- property get2cb: LP_STRUCT_GETCB_GET2_T_
Contains a pointer to the session control block that initiated the request, representing the current session's context.
- property local_keys: dict
Local keys for silcb
- property local_keys_fixed: list
Local keys fixed for silcb
- property local_keys_present: list
Local keys present for silcb
- log(msg: str, log_level: str = 'INFO') None
Adds message to log
- property module_name: str
- property msg: LP_STRUCT_RPC_MSG_T_
Pointer to incoming XML message header
- scb() LP_STRUCT_SES_CB_T_
Pointer to scb
- send_terminal_message(message: str) ENUM_STATUS_T_
Sends message to terminal
- set_choice_active_case(active_case: str) ENUM_STATUS_T_
FOR CHOICES ONLY! Sets active_case to specific value for choices.
- Parameters:
active_case (str) -- Provide active case string here
- Returns:
Status
- property username: str
user_id value or None
- property utils: PYSILUtils
returns utils for the silcb
SILCbEdit
This class describes control block which is pivotal in managing the intricacies of EDIT3 callbacks, ensuring that all necessary data and context are readily available for efficient processing.
- class pysil.module.SILCbEdit(editcb: LP_STRUCT_AGT_EDITCB_T_, module_name: str, callback_info: dict)
Bases:
SILCbBase
The
SILCbEdit
class is a comprehensive control block used in EDIT3 callbacks. It encapsulates all necessary pointers and information required for the execution of the EDIT3 callback methods.- property ancestor_keys: dict
Ancestors keys for silcb
- property callback_info: dict
Property to get callback_info
- property cbtyp: c_uint
Indicates the reason for the callback, which could be one of several types from AGT_CBTYP_T, such as:
AGT_CB_VALIDATE
AGT_CB_APPLY
AGT_CB_COMMIT
AGT_CB_ROLLBACK
- property client_addr: str
This field contains the client address involved in the transaction. or None
- property curval: LP_STRUCT_VAL_VALUE_T_
This field refers to the current container/list values from either the <running> or <candidate> configuration, which could be None for certain operations like create.
- property curval_json: dict
This field refers to the current container/list values from either the <running> or <candidate> configuration, which could be None for certain operations like create.
- property editop: c_ubyte
This enumerator represents the parent edit-config operation type, affecting how the callback operates on objects. Possible types from OP_EDITOP_T include:
OP_EDITOP_LOAD
OP_EDITOP_MERGE
OP_EDITOP_REPLACE
OP_EDITOP_CREATE
OP_EDITOP_DELETE
- property local_keys: dict
Local keys for silcb
- log(msg: str, log_level: str = 'INFO') None
Adds message to log
- property module_name: str
- property msg: LP_STRUCT_RPC_MSG_T_
This pointer refers to the incoming RPC message in progress, detailing the specific request being processed.
- property msg_id: str
txid_str value or None
- property newval: LP_STRUCT_VAL_VALUE_T_
This field contains object that holds the proposed changes to be applied to the current configuration, varying based on the editop value.
- property newval_json: dict
This field contains object that holds the proposed changes to be applied to the current configuration, varying based on the editop value.
- property scb: LP_STRUCT_SES_CB_T_
This field contains a pointer to the session control block that initiated the request, representing the current session's context.
- send_terminal_message(message: str) ENUM_STATUS_T_
Sends message to terminal
- property update: LP_STRUCT_VAL_VALUE_T_
This field contains a merged value of all new and current values from the datastore, streamlining the update process.
- property update_json: dict
This field contains a merged value of all new and current values from the datastore, streamlining the update process.
- property username: str
user_id value or None
- property utils: PYSILUtils
returns utils for the silcb
SILCbValidate
- class pysil.module.SILCbValidate(scb: LP_STRUCT_SES_CB_T_, msg: LP_STRUCT_RPC_MSG_T_, methnode: LP_STRUCT_XML_NODE_T_, module_name: str, callback_info: dict, nsid: int)
Bases:
SILCbValidateInvokeBase
The
SILCbValidate
class is a comprehensive control block used in RPC Validate callbacks. It encapsulates all necessary pointers and information required for the execution of the RPC Validate callback methods.- property callback_info: dict
Property to get callback_info
- property client_addr: str
This field contains the client address involved in the transaction. or None
- property errorval
Property errorval recorded by set_errorval method
- property input_params: dict
Returns dict with all parameters for callback object
- log(msg: str, log_level: str = 'INFO') None
Adds message to log
- property methnode: LP_STRUCT_XML_NODE_T_
This pointer refers to the XML-specific node being parsed if available. This can be used for error reporting if no 'val' or 'obj' parameters are available (from the request message).
- property module_name: str
- property msg: LP_STRUCT_RPC_MSG_T_
This pointer refers to the incoming RPC message in progress, detailing the specific request being processed.
- property nsid: int
namespace ID for silcb
- property scb: LP_STRUCT_SES_CB_T_
This field contains a pointer to the session control block that initiated the request, representing the current session's context.
- send_terminal_message(message: str) ENUM_STATUS_T_
Sends message to terminal
- set_errorval(data)
Use method if you would like to set an errorval when error returned. The errorval will be recorded to the server.
- property username: str
user_id value or None
- property utils: PYSILUtils
returns utils for the silcb
SILCbInvoke
- class pysil.module.SILCbInvoke(scb: LP_STRUCT_SES_CB_T_, msg: LP_STRUCT_RPC_MSG_T_, methnode: LP_STRUCT_XML_NODE_T_, module_name: str, callback_info: dict, nsid: int)
Bases:
SILCbValidate
The
SILCbInvoke
class is a comprehensive control block used in RPC Invoke callbacks. It encapsulates all necessary pointers and information required for the execution of the RPC Invoke callback methods.- add_return_data(data: dict) ENUM_STATUS_T_
Adds data to return
- Parameters:
data (dict) -- provide return data dict here
- Returns:
Status
- property callback_info: dict
Property to get callback_info
- property client_addr: str
This field contains the client address involved in the transaction. or None
- property errorval
Property errorval recorded by set_errorval method
- property input_params: dict
Returns dict with all parameters for callback object
- log(msg: str, log_level: str = 'INFO') None
Adds message to log
- property methnode: LP_STRUCT_XML_NODE_T_
This pointer refers to the XML-specific node being parsed if available. This can be used for error reporting if no 'val' or 'obj' parameters are available (from the request message).
- property module_name: str
- property msg: LP_STRUCT_RPC_MSG_T_
This pointer refers to the incoming RPC message in progress, detailing the specific request being processed.
- property nsid: int
namespace ID for silcb
- property scb: LP_STRUCT_SES_CB_T_
This field contains a pointer to the session control block that initiated the request, representing the current session's context.
- send_terminal_message(message: str) ENUM_STATUS_T_
Sends message to terminal
- set_errorval(data)
Use method if you would like to set an errorval when error returned. The errorval will be recorded to the server.
- property username: str
user_id value or None
- property utils: PYSILUtils
returns utils for the silcb
SILCbActionValidate
- class pysil.module.SILCbActionValidate(scb: LP_STRUCT_SES_CB_T_, msg: LP_STRUCT_RPC_MSG_T_, methnode: LP_STRUCT_XML_NODE_T_, actionval: LP_STRUCT_VAL_VALUE_T_, module_name: str, callback_info: dict, nsid: int)
Bases:
SILCbValidateInvokeBase
The
SILCbActionValidate
class is a comprehensive control block used in Action Validate callbacks. It encapsulates all necessary pointers and information required for the execution of the Action Validate callback methods.- property actionval: LP_STRUCT_VAL_VALUE_T_
Pointer to the input node represents the start of the specific action being invoked. The auto-generated SIL code can derive all the ancestor keys from this data structure.
- property ancestor_keys: dict
Ancestors keys for silcb
- property callback_info: dict
Property to get callback_info
- property client_addr: str
This field contains the client address involved in the transaction. or None
- property errorval
Property errorval recorded by set_errorval method
- property input_params: dict
Returns dict with all parameters for callback object
- log(msg: str, log_level: str = 'INFO') None
Adds message to log
- property methnode: LP_STRUCT_XML_NODE_T_
This pointer refers to the XML-specific node being parsed if available. This can be used for error reporting if no 'val' or 'obj' parameters are available (from the request message).
- property module_name: str
- property msg: LP_STRUCT_RPC_MSG_T_
This pointer refers to the incoming RPC message in progress, detailing the specific request being processed.
- property nsid: int
namespace ID for silcb
- property scb: LP_STRUCT_SES_CB_T_
This field contains a pointer to the session control block that initiated the request, representing the current session's context.
- send_terminal_message(message: str) ENUM_STATUS_T_
Sends message to terminal
- set_errorval(data)
Use method if you would like to set an errorval when error returned. The errorval will be recorded to the server.
- property username: str
user_id value or None
- property utils: PYSILUtils
returns utils for the silcb
SILCbActionInvoke
- class pysil.module.SILCbActionInvoke(scb: LP_STRUCT_SES_CB_T_, msg: LP_STRUCT_RPC_MSG_T_, methnode: LP_STRUCT_XML_NODE_T_, actionval: LP_STRUCT_VAL_VALUE_T_, module_name: str, callback_info: dict, nsid: int)
Bases:
SILCbActionValidate
The
SILCbActionInvoke
class is a comprehensive control block used in Action Invoke callbacks. It encapsulates all necessary pointers and information required for the execution of the Action Invoke callback methods.- property actionval: LP_STRUCT_VAL_VALUE_T_
Pointer to the input node represents the start of the specific action being invoked. The auto-generated SIL code can derive all the ancestor keys from this data structure.
- add_return_data(data)
Adds data to return
- Parameters:
data (dict) -- provide return data dict here
- Returns:
Status
- property ancestor_keys: dict
Ancestors keys for silcb
- property callback_info: dict
Property to get callback_info
- property client_addr: str
This field contains the client address involved in the transaction. or None
- property errorval
Property errorval recorded by set_errorval method
- property input_params: dict
Returns dict with all parameters for callback object
- log(msg: str, log_level: str = 'INFO') None
Adds message to log
- property methnode: LP_STRUCT_XML_NODE_T_
This pointer refers to the XML-specific node being parsed if available. This can be used for error reporting if no 'val' or 'obj' parameters are available (from the request message).
- property module_name: str
- property msg: LP_STRUCT_RPC_MSG_T_
This pointer refers to the incoming RPC message in progress, detailing the specific request being processed.
- property nsid: int
namespace ID for silcb
- property scb: LP_STRUCT_SES_CB_T_
This field contains a pointer to the session control block that initiated the request, representing the current session's context.
- send_terminal_message(message: str) ENUM_STATUS_T_
Sends message to terminal
- set_errorval(data)
Use method if you would like to set an errorval when error returned. The errorval will be recorded to the server.
- property username: str
user_id value or None
- property utils: PYSILUtils
returns utils for the silcb