gws-events-subscribe

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

events +subscribe

events +subscribe

PREREQUISITE: Read
../gws-shared/SKILL.md
for auth, global flags, and security rules. If missing, run
gws generate-skills
to create it.
Subscribe to Workspace events and stream them as NDJSON
前置要求: 阅读
../gws-shared/SKILL.md
了解认证、全局标志和安全规则。如果该文件缺失,请运行
gws generate-skills
创建它。
订阅Workspace事件并以NDJSON格式流式输出

Usage

使用方法

bash
gws events +subscribe
bash
gws events +subscribe

Flags

标志参数

FlagRequiredDefaultDescription
--target
Workspace resource URI (e.g., //chat.googleapis.com/spaces/SPACE_ID)
--event-types
Comma-separated CloudEvents types to subscribe to
--project
GCP project ID for Pub/Sub resources
--subscription
Existing Pub/Sub subscription name (skip setup)
--max-messages
10Max messages per pull batch (default: 10)
--poll-interval
5Seconds between pulls (default: 5)
--once
Pull once and exit
--cleanup
Delete created Pub/Sub resources on exit
--no-ack
Don't auto-acknowledge messages
--output-dir
Write each event to a separate JSON file in this directory
标志是否必填默认值描述
--target
Workspace资源URI(例如://chat.googleapis.com/spaces/SPACE_ID)
--event-types
要订阅的CloudEvents类型,以逗号分隔
--project
Pub/Sub资源对应的GCP项目ID
--subscription
已有的Pub/Sub订阅名称(跳过设置步骤)
--max-messages
10每次拉取的最大消息数(默认值:10)
--poll-interval
5拉取间隔时间(秒,默认值:5)
--once
仅拉取一次后退出
--cleanup
退出时删除创建的Pub/Sub资源
--no-ack
不自动确认消息
--output-dir
将每个事件写入该目录下的独立JSON文件

Examples

示例

bash
gws events +subscribe --target '//chat.googleapis.com/spaces/SPACE' --event-types 'google.workspace.chat.message.v1.created' --project my-project
gws events +subscribe --subscription projects/p/subscriptions/my-sub --once
gws events +subscribe ... --cleanup --output-dir ./events
bash
gws events +subscribe --target '//chat.googleapis.com/spaces/SPACE' --event-types 'google.workspace.chat.message.v1.created' --project my-project
gws events +subscribe --subscription projects/p/subscriptions/my-sub --once
gws events +subscribe ... --cleanup --output-dir ./events

Tips

提示

  • Without --cleanup, Pub/Sub resources persist for reconnection.
  • Press Ctrl-C to stop gracefully.
[!CAUTION] This is a write command — confirm with the user before executing.
  • 如果不使用
    --cleanup
    ,Pub/Sub资源会保留以便重新连接。
  • 按Ctrl-C可优雅停止程序。
[!注意] 这是一个写入类命令——执行前请与用户确认。

See Also

另请参阅

  • gws-shared — Global flags and auth
  • gws-events — All subscribe to google workspace events commands
  • gws-shared — 全局标志和认证
  • gws-events — 所有Google Workspace事件订阅相关命令