Skip to main content

Dequeue Event

Description

The dequeue_event function sends a POST request to the web service to dequeue an event for a specified device and agent type. It returns a WebServiceResult object containing the response code, response string, and parsed JSON data.

Function Signature:

def dequeue_event(ws_config: WebServiceConfig, device_name: str, agent_type: str) -> WebServiceResult:

Parameters

  • ws_config (WebServiceConfig): Configuration for the web service connection.
  • device_name (str): The name of the device for which to dequeue an event.
  • agent_type (str): The type of the agent involved in the event.

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, or None 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"
agent_type = "agentA"
result = dequeue_event(ws_config, device_name, agent_type)
print(result.http_response_code)
print(result.json_data)

Behavior

  • The function sends a POST request to the web service with the device name and agent type in the body to dequeue the event.
  • 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.