events

package
v1.43.1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package events implements the domain rules for the Workspace Events API: GA-only target and event-type validation, least-privilege scope selection per subscription class and auth mode, Pub/Sub topic format validation, and CloudEvent notification decoding.

Index

Constants

View Source
const (
	TargetChatSpace     = "chat-space"      // //chat.googleapis.com/spaces/{space}
	TargetChatAllSpaces = "chat-all-spaces" // //chat.googleapis.com/spaces/-
	TargetUser          = "user"            // //cloudidentity.googleapis.com/users/{user}
	TargetDriveFile     = "drive-file"      // //drive.googleapis.com/files/{file}
	TargetSharedDrive   = "shared-drive"    // //drive.googleapis.com/drives/{drive}
	TargetMeetSpace     = "meet-space"      // //meet.googleapis.com/spaces/{space}
)

Subscription target kinds (GA only — customer-wide Chat targets are Developer Preview and rejected).

View Source
const ChatBotScope = scopePrefix + "chat.bot"

ChatBotScope is the Chat app scope used for read/delete lifecycle operations under app auth.

View Source
const MeetCreatedScope = scopePrefix + "meetings.space.created"

MeetCreatedScope is the narrower Meet scope covering only meeting spaces the authenticated user created.

Variables

This section is empty.

Functions

func ClassifyTarget

func ClassifyTarget(target string) (string, error)

ClassifyTarget parses a subscription target resource and returns its kind. Prefix-only targets with an empty resource ID are rejected.

func ReadLifecycleScopes

func ReadLifecycleScopes(authMode string) []string

ReadLifecycleScopes returns the scopes for read/delete lifecycle operations (list, get, delete), where the subscription's event class is irrelevant. User modes use the union of least-privilege user-auth event scopes; app mode uses chat.bot per the official contract.

Mutating operations (create, update/renew, reactivate) never use this: they must go through PlanSubscription with the subscription's exact target and event types so only the matching granular scope(s) are minted — under app auth, callers first Get the existing subscription with chat.bot to derive that plan.

func SupportedEventTypes

func SupportedEventTypes() []string

SupportedEventTypes returns the sorted list of supported GA event types (for help text and docs).

func ValidateTopic

func ValidateTopic(topic string) error

ValidateTopic checks the Pub/Sub topic resource name format. gws never creates or replaces topics — the topic must already exist in the same Cloud project as the subscription.

Types

type CloudEvent

type CloudEvent struct {
	EventType          string            `json:"event_type,omitempty"`
	Subscription       string            `json:"subscription,omitempty"`
	Target             string            `json:"target,omitempty"`
	Time               string            `json:"time,omitempty"`
	Attributes         map[string]string `json:"attributes,omitempty"`
	MessageID          string            `json:"message_id,omitempty"`
	PublishTime        string            `json:"publish_time,omitempty"`
	PubsubSubscription string            `json:"pubsub_subscription,omitempty"`
	Data               json.RawMessage   `json:"data,omitempty"`
}

CloudEvent is a decoded Pub/Sub notification from a Workspace Events subscription. Subscription comes from the ce-source attribute (the Workspace subscription resource); Target comes from ce-subject (the changed target resource).

func DecodeCloudEvent

func DecodeCloudEvent(r io.Reader) (*CloudEvent, error)

DecodeCloudEvent reads a Pub/Sub JSON notification (push envelope or bare message) and decodes the CloudEvent attributes plus the base64 event data.

type Plan

type Plan struct {
	TargetKind string
	EventTypes []string
	Scopes     []string
}

Plan is a validated subscription request: the target kind, the event classes involved, and the least-privilege scopes the credentials need.

func PlanSubscription

func PlanSubscription(target string, eventTypes []string, authMode string, meetCreatedScope bool) (*Plan, error)

PlanSubscription validates a target + event-type combination against the GA boundary and the auth mode, returning the least-privilege scopes. meetCreatedScope narrows the Meet scope to meetings.space.created.

Jump to

Keyboard shortcuts

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