delete_multiple_events#

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

Delete multiple events from an AMS instance.

Sends a request to the AMS API’s event/deleteAll endpoint to remove a list of events specified by their IDs, returning a message indicating success or failure. Requires valid authentication and a non-empty list of positive integer event_ids, obtainable via get_event_data. In interactive mode, prompts for confirmation and provides feedback. See Deleting Data for deletion workflows.

Parameters:
  • event_ids (List[int]) – List of event IDs to delete. Must be a non-empty list of positive integers (e.g., [134273, 134274]).

  • 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 3 events”). 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 3 events”

or “FAILURE: Could not delete events with IDs [134273, 134274]”.

Return type:

str

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

  • ValueError – If event_ids is empty or contains non-positive integers.

Examples

>>> from teamworksams import delete_multiple_events
>>> result = delete_multiple_events(
...     event_ids = [134273, 134274, 134275],
...     url = "https://example.smartabase.com/site",
...     username = "user",
...     password = "pass",
...     option = DeleteEventOption(interactive_mode = True)
... )
Are you sure you want to delete 3 events with IDs [134273, 134274, 134275]? (y/n): y
ℹ Deleting 3 events with IDs [134273, 134274, 134275]...
✔ SUCCESS: Deleted 3 events

Additional Notes#

  • Use get_event_data() to collect event_ids for batch deletion, ensuring all IDs are valid to avoid AMSError().

  • Batch deletion is more efficient than multiple calls to delete_event_data(), but confirmation prompts remain critical for safety.

  • The returned string (e.g., “SUCCESS: Deleted 3 events”) indicates the overall result; individual failures may require API-level debugging.

See Also#