Skip to main content

Create Event

Description

Creates event via the web service.

Function Signature:

def create_event(ws_config: WebServiceConfig, device_id: int, device_serial: str, agent_type: str, event_type: str, server_event: int = 0, event_parameters: str = '', priority: int = 1, max_attempts: int = 0, expiration_epoch: int = 0) -> StandardResult:

Parameters

  • ws_config (WebServiceConfig): Configuration for the web service connection.
  • device_id (int): Device identifier.
  • device_serial (str): Device serial number.
  • agent_type (str): Agent type name.
  • event_type (str): Event type name.
  • server_event (int): Input value for server_event.
  • event_parameters (str): Event parameters payload.
  • priority (int): Priority value.
  • max_attempts (int): Maximum attempt count.
  • expiration_epoch (int): Expiration timestamp (Unix epoch seconds).

Returns

  • StandardResult: A result object containing:
    • code: HTTP status code (200 for success, -1 for exceptions).
    • description: Response body or error message.

Example Usage

# Example usage
ws_config = WebServiceConfig(access_key="key", secret_key="secret", base_url="https://api.example.com/")
device_id = 1
device_serial = "example"
agent_type = "example"
event_type = "example"
server_event = 1
event_parameters = "example"
priority = 1
max_attempts = 1
expiration_epoch = 1
result = create_event(ws_config, device_id, device_serial, agent_type, event_type, server_event, event_parameters, priority, max_attempts, expiration_epoch)
print(result)

Behavior

  • Sends a signed request to the web service.
  • On success, returns the computed value or result object.

Error Handling

  • Exceptions set the result code to -1 and include an error message when implemented.