delete_event_data#

teamworksams.delete_main.delete_event_data(event_id: int, url: str, username: str | None = None, password: str | None = None, option: DeleteEventOption | None = None, client: AMSClient | None = None) str[source]#

Delete a single event from an AMS instance.

Sends a request to the AMS API’s deleteevent endpoint to remove the event with the specified ID, returning a message indicating success or failure. Requires valid authentication and a positive integer event_id, obtainable via get_event_data(). In interactive mode, prompts for confirmation and provides feedback. See Deleting Data for deletion workflows.

Parameters:
  • event_id (int) – ID of the event to delete. Must be a positive integer (e.g., 134273).

  • url (str) – AMS instance URL (e.g., ‘https://example.smartabase.com/site’). Must include a valid site name.

  • username (Optional[str]) – Username for authentication. If None, uses AMS_USERNAME or keyring credentials. Defaults to None.

  • password (Optional[str]) – Password for authentication. If None, uses AMS_PASSWORD or keyring credentials. Defaults to None.

  • option (DeleteEventOption, optional) – Configuration options, including interactive_mode for confirmation prompts and status messages (e.g., “SUCCESS: Deleted 134273”). Defaults to None (uses default DeleteEventOption with interactive_mode=True).

  • client (AMSClient, optional) – Pre-authenticated client from get_client(). If None, a new client is created. Defaults to None.

Returns:

A message indicating the result of the deletion, e.g., “SUCCESS: Deleted 134273”

or “FAILURE: [error message]”.

Return type:

str

Raises:
  • AMSError – If authentication fails, the API request returns an error, the response is invalid, or the user cancels the operation in interactive mode.

  • ValueError – If event_id is not a positive integer.

Examples

>>> from teamworksams import delete_event_data, DeleteEventOption
>>> result = delete_event_data(
...     event_id = 134273,
...     url = "https://example.smartabase.com/site",
...     username = "user",
...     password = "pass",
...     option = DeleteEventOption(interactive_mode = True)
... )
Are you sure you want to delete event '134273'? (y/n): y
ℹ Deleting event with ID 134273...
✔ SUCCESS: Deleted 134273

Additional Notes#

  • Obtain valid event_id values using get_event_data() to avoid AMSError() for non-existent events.

  • The confirmation prompt in option.interactive_mode=True ensures safe deletion, critical for administrative tasks.

  • The returned string (e.g., “SUCCESS: Deleted 134273”) can be parsed for automation or logged for auditing.

See Also#