events

package
v2.0.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2026 License: MPL-2.0 Imports: 6 Imported by: 0

README

Events

The Events module provides functionality to interact with the Webex Events API, allowing you to retrieve event data for activities that occur within your Webex organization.

Overview

Webex Events provide a way to track and collect information about activities that occur within your Webex organization. This module allows compliance officers and administrators to:

  1. List events with various filters (by resource type, event type, time range, etc.)
  2. Retrieve detailed information about specific events by ID

The Events API is primarily intended for compliance and administrative purposes, enabling you to audit user activities across your Webex organization.

Access Requirements

Important: The Events API is only available to Compliance Officers and administrators with the appropriate permissions in your Webex organization.

Installation

This module is part of the Webex Go SDK. To use it, import the SDK and the events package:

import (
    "github.com/WebexCommunity/webex-go-sdk/v2"
    "github.com/WebexCommunity/webex-go-sdk/v2/events"
)

Usage

Initializing the Client
client, err := webex.NewClient(accessToken, nil)
if err != nil {
    log.Fatalf("Error creating client: %v", err)
}

// Access the events client
eventsClient := client.Events()
Listing Events

To retrieve a list of events with optional filters:

// Calculate time 7 days ago
fromTime := time.Now().AddDate(0, 0, -7).Format(time.RFC3339)

eventsPage, err := client.Events().List(&events.ListOptions{
    Resource: "messages", // Filter for message events
    Type:     "created",  // Filter for created events
    From:     fromTime,   // Events from the last 7 days
    Max:      10,         // Limit to 10 events
})

if err != nil {
    log.Fatalf("Failed to list events: %v", err)
}

// Process the events
for _, event := range eventsPage.Items {
    fmt.Printf("Event: %s (%s)\n", event.Type, event.ID)
    fmt.Printf("Resource: %s\n", event.Resource)
    fmt.Printf("Created: %s\n", event.Created.Format(time.RFC3339))
    // ... process other event data
}
Retrieving a Specific Event

To retrieve details of a specific event by its ID:

eventDetails, err := client.Events().Get("EVENT_ID")
if err != nil {
    log.Fatalf("Failed to get event details: %v", err)
}

// Access event properties
fmt.Printf("Event ID: %s\n", eventDetails.ID)
fmt.Printf("Resource: %s\n", eventDetails.Resource)
fmt.Printf("Type: %s\n", eventDetails.Type)
// ... access other event properties

Data Structures

Event Structure

The Event structure contains the following fields:

Field Type Description
ID string Unique identifier for the event
Resource string The resource type the event is related to
Type string The type of event (e.g., "created", "updated")
AppID string The ID of the application that triggered the event
ActorID string The ID of the person who performed the action
OrgID string The organization ID where the event occurred
Created time.Time Timestamp when the event occurred
Data EventData Resource-specific data about the event

The EventData structure contains resource-specific data that varies depending on the event type and resource. Common fields include:

  • For message events: RoomID, RoomType, PersonID, PersonEmail, etc.
  • For meeting events: MeetingID, CreatorID, RecordingEnabled, etc.
  • For telephony events: CallType, CallDirection, CallDurationSeconds, etc.
ListOptions

When listing events, you can use the following filter options:

Option Type Description
Resource string Filter by resource type (e.g., "messages", "meetings")
Type string Filter by event type (e.g., "created", "updated")
ActorID string Filter by the ID of the person who performed the action
From string Filter events that occurred after this time (RFC3339 format)
To string Filter events that occurred before this time (RFC3339 format)
Max int Maximum number of events to return
Resource Types

Common resource types that can be monitored with the Events API include:

  • messages: Message-related events in spaces
  • meetings: Meeting creation, updates, and deletion
  • rooms: Space creation, updates, and deletion
  • memberships: Space membership changes
  • teams: Team creation, updates, and deletion
  • team.memberships: Team membership changes
  • telephony: Call events (for organizations with Webex Calling)
Event Types

Common event types include:

  • created: Resource creation events
  • updated: Resource update events
  • deleted: Resource deletion events

Complete Example

Here's a complete example that demonstrates listing events and retrieving event details:

package main

import (
    "fmt"
    "log"
    "os"
    "time"

    "github.com/WebexCommunity/webex-go-sdk/v2"
    "github.com/WebexCommunity/webex-go-sdk/v2/events"
)

func main() {
    // Get access token from environment variable
    accessToken := os.Getenv("WEBEX_ACCESS_TOKEN")
    if accessToken == "" {
        log.Fatalf("WEBEX_ACCESS_TOKEN environment variable is required")
    }

    // Create a new Webex client
    client, err := webex.NewClient(accessToken, nil)
    if err != nil {
        log.Fatalf("Failed to create client: %v", err)
    }

    // List Events with filters
    fromTime := time.Now().AddDate(0, 0, -7).Format(time.RFC3339)

    eventsPage, err := client.Events().List(&events.ListOptions{
        Resource: "messages", // Filter for message events
        Type:     "created",  // Filter for created events
        From:     fromTime,   // Events from the last 7 days
        Max:      10,         // Limit to 10 events
    })

    if err != nil {
        log.Fatalf("Failed to list events: %v", err)
    }

    fmt.Printf("Found %d events\n", len(eventsPage.Items))
    for i, event := range eventsPage.Items {
        fmt.Printf("%d. %s (%s)\n", i+1, event.Type, event.ID)
        fmt.Printf("   Resource: %s\n", event.Resource)
        fmt.Printf("   Created: %s\n", event.Created.Format(time.RFC3339))
        fmt.Printf("   Actor ID: %s\n", event.ActorID)
        if event.Data.RoomID != "" {
            fmt.Printf("   Room ID: %s\n", event.Data.RoomID)
        }
        fmt.Println()
    }

    // Get Event Details
    if len(eventsPage.Items) > 0 {
        eventID := eventsPage.Items[0].ID
        eventDetails, err := client.Events().Get(eventID)
        if err != nil {
            log.Printf("Failed to get event details: %v\n", err)
        } else {
            fmt.Printf("Event Details:\n")
            fmt.Printf("  ID: %s\n", eventDetails.ID)
            fmt.Printf("  Resource: %s\n", eventDetails.Resource)
            fmt.Printf("  Type: %s\n", eventDetails.Type)
            fmt.Printf("  Actor ID: %s\n", eventDetails.ActorID)
            fmt.Printf("  Created: %s\n", eventDetails.Created.Format(time.RFC3339))

            // Process data fields based on resource type
            if eventDetails.Resource == "messages" {
                fmt.Printf("  Room ID: %s\n", eventDetails.Data.RoomID)
                fmt.Printf("  Person ID: %s\n", eventDetails.Data.PersonID)
            } else if eventDetails.Resource == "meetings" {
                fmt.Printf("  Meeting ID: %s\n", eventDetails.Data.MeetingID)
                fmt.Printf("  Creator ID: %s\n", eventDetails.Data.CreatorID)
            }
        }
    }
}

Error Handling

All methods return structured errors from the webexsdk package. Use the convenience functions to check error types:

event, err := client.Events().Get("EVENT_ID")
if err != nil {
    switch {
    case webexsdk.IsNotFound(err):
        log.Println("Event not found")
    case webexsdk.IsAuthError(err):
        log.Println("Invalid or expired access token")
    case webexsdk.IsRateLimited(err):
        log.Println("Rate limited — SDK retries automatically")
    default:
        log.Printf("Error: %v", err)
    }
}

See webexsdk/Readme.md for the full error type reference.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the events API client

func New

func New(webexClient *webexsdk.Client, config *Config) *Client

New creates a new Events plugin

func (*Client) Get

func (c *Client) Get(eventID string) (*Event, error)

Get returns details for an event by ID

func (*Client) List

func (c *Client) List(options *ListOptions) (*EventsPage, error)

List returns a list of events with optional filters

type Config

type Config struct {
}

Config holds the configuration for the Events plugin

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration for the Events plugin

type Event

type Event struct {
	ID       string                  `json:"id,omitempty"`
	Resource string                  `json:"resource,omitempty"`
	Type     string                  `json:"type,omitempty"`
	AppID    string                  `json:"appId,omitempty"`
	ActorID  string                  `json:"actorId,omitempty"`
	OrgID    string                  `json:"orgId,omitempty"`
	Created  time.Time               `json:"created,omitempty"`
	Data     EventData               `json:"data,omitempty"`
	Errors   webexsdk.ResourceErrors `json:"errors,omitempty"`
}

Event represents a Webex event

type EventData

type EventData struct {
	ID                   string          `json:"id,omitempty"`
	RoomID               string          `json:"roomId,omitempty"`
	RoomType             string          `json:"roomType,omitempty"`
	OrgID                string          `json:"orgId,omitempty"`
	Text                 string          `json:"text,omitempty"`
	PersonID             string          `json:"personId,omitempty"`
	PersonEmail          string          `json:"personEmail,omitempty"`
	MeetingID            string          `json:"meetingId,omitempty"`
	CreatorID            string          `json:"creatorId,omitempty"`
	Host                 json.RawMessage `json:"host,omitempty"`
	Attendees            json.RawMessage `json:"attendees,omitempty"`
	TranscriptionEnabled string          `json:"transcriptionEnabled,omitempty"`
	RecordingEnabled     string          `json:"recordingEnabled,omitempty"`
	HasPostMeetingsChat  string          `json:"hasPostMeetingsChat,omitempty"`
	// Telephony-related fields
	CorrelationID         string `json:"corelationId,omitempty"`
	CallType              string `json:"callType,omitempty"`
	UserID                string `json:"userId,omitempty"`
	UserType              string `json:"userType,omitempty"`
	CallDirection         string `json:"callDirection,omitempty"`
	IsCallAnswered        string `json:"isCallAnswered,omitempty"`
	CallDurationSeconds   string `json:"callDurationSeconds,omitempty"`
	CallStartTime         string `json:"callStartTime,omitempty"`
	CallAnswerTime        string `json:"callAnswerTime,omitempty"`
	CallTransferTime      string `json:"callTransferTime,omitempty"`
	CallingNumber         string `json:"callingNumber,omitempty"`
	CallingLineID         string `json:"callingLineId,omitempty"`
	CalledNumber          string `json:"calledNumber,omitempty"`
	CalledLineID          string `json:"calledLineId,omitempty"`
	DialedDigits          string `json:"dialedDigits,omitempty"`
	CallRedirectingNumber string `json:"callRedirectingNumber,omitempty"`
	CallRedirectedReason  string `json:"callRedirectedReason,omitempty"`
	Created               string `json:"created,omitempty"`
}

EventData represents the data field of an event

type EventsPage

type EventsPage struct {
	Items []Event `json:"items"`
	*webexsdk.Page
}

EventsPage represents a paginated list of events

type ListOptions

type ListOptions struct {
	Resource string `url:"resource,omitempty"`
	Type     string `url:"type,omitempty"`
	ActorID  string `url:"actorId,omitempty"`
	From     string `url:"from,omitempty"`
	To       string `url:"to,omitempty"`
	Max      int    `url:"max,omitempty"`
}

ListOptions contains the options for listing events

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL