Get Pending Event List
Description
The get_pending_event_list
function retrieves a list of pending events for a specific device by sending a POST request to the web service. It returns a WebServiceResult
object containing the response code, response string, and parsed JSON data.
Function Signature:
def get_pending_event_list(ws_config: WebServiceConfig, device_name: str) -> WebServiceResult:
Parameters
- ws_config (WebServiceConfig): Configuration for the web service connection.
- device_name (str): The name of the device for which to retrieve pending events.
Returns
- WebServiceResult: A result object containing:
http_response_code
: The response code from the web service.http_response_string
: The response string from the web service.json_data
: The parsed JSON response from the web service, orNone
if there was an error.code
: A status code (0 for success, -1 for failure).description
: A description of any error that occurred.
Example Usage
ws_config = WebServiceConfig(base_url="https://api.actionstreamer.com")
device_name = "device123"
result = get_pending_event_list(ws_config, device_name)
print(result.http_response_code)
print(result.json_data)
Behavior
- The function sends a POST request to the web service with the device name in the body to retrieve the list of pending events.
- The response is parsed into a
WebServiceResult
object, which contains the response code, response string, and parsed JSON data. - If an error occurs, an exception is caught and the error details are included in the result.
Error Handling
- General Exception: Any errors during the request or JSON processing will be caught, and the error description will be included in the result.
- Exception Information: The function prints the filename and line number for easier debugging when an exception is encountered.