Method: spaces.spaceEvents.list

列出 Google Chat 聊天室的事件。每個事件的酬載都包含最新版本的 Chat 資源。舉例來說,如果您列出有關新空間成員的事件,伺服器會傳回包含最新成員詳細資料的 Membership 資源。如果新成員在要求期間遭到移除,活動酬載會包含空白的 Membership 資源。

支援下列類型的驗證,並提供適當的授權範圍,可讀取所要求的資料:

  • 應用程式驗證 (須經管理員核准) 開發人員預覽版,並使用下列其中一個授權範圍:

    • https://www.googleapis.com/auth/chat.app.spaces
    • https://www.googleapis.com/auth/chat.app.messages.readonly
    • https://www.googleapis.com/auth/chat.app.memberships
  • 使用者驗證,並使用下列其中一個授權範圍:

    • https://www.googleapis.com/auth/chat.spaces.readonly
    • https://www.googleapis.com/auth/chat.spaces
    • https://www.googleapis.com/auth/chat.messages.readonly
    • https://www.googleapis.com/auth/chat.messages
    • https://www.googleapis.com/auth/chat.messages.reactions.readonly
    • https://www.googleapis.com/auth/chat.messages.reactions
    • https://www.googleapis.com/auth/chat.memberships.readonly
    • https://www.googleapis.com/auth/chat.memberships

如要列出活動,已驗證的呼叫者必須是聊天室成員。

如需範例,請參閱「列出 Google Chat 聊天室中的活動」。

HTTP 要求

GET https://chat.googleapis.com/v1/{parent=spaces/*}/spaceEvents

這個網址使用 gRPC 轉碼語法。

路徑參數

參數
parent

string

必要欄位。發生事件的 Google Chat 聊天室資源名稱。

格式:spaces/{space}

查詢參數

參數
pageSize

integer

(選用步驟) 傳回的即時通訊空間事件數量上限。服務傳回的產品數量可能會少於這個值。

負值會傳回 INVALID_ARGUMENT 錯誤。

pageToken

string

(選用步驟) 這是接收自前一個 list space events 呼叫的網頁權杖。提供此項目即可擷取後續網頁。

進行分頁時,提供至清單空間事件的所有其他參數,須與提供網頁權杖的呼叫相符。將不同值傳遞至其他參數可能會導致非預期的結果。

filter

string

必要欄位。查詢篩選器。

您必須使用 has : 運算子指定至少一個事件類型 (eventType)。如要依多個事件類型篩選,請使用 OR 運算子。在篩選器中省略批次事件類型。要求會自動傳回任何相關的批次事件。舉例來說,如果您依新回應 (google.workspace.chat.reaction.v1.created) 篩選,伺服器也會傳回批次新回應事件 (google.workspace.chat.reaction.v1.batchCreated)。如需支援的事件類型清單,請參閱 SpaceEvents 參考文件

你也可以選擇依開始時間 (startTime) 和結束時間 (endTime) 篩選:

  • startTime:開始列出即時活動的時間戳記 (不含該時間)。最多可列出 28 天前發生的事件。如果未指定,則會列出過去 28 天的空間事件。
  • endTime:列出空間活動的時間戳記 (含該時間)。如未指定,則會列出要求時間之前的事件。

如要指定開始或結束時間,請使用等號 = 運算子,並採用 RFC-3339 格式。如要同時依 startTimeendTime 篩選,請使用 AND 運算子。

舉例來說,下列查詢皆有效:

startTime="2023-08-23T19:20:33+00:00" AND
endTime="2023-08-23T19:21:54+00:00"
startTime="2023-08-23T19:20:33+00:00" AND
(eventTypes:"google.workspace.chat.space.v1.updated" OR
eventTypes:"google.workspace.chat.message.v1.created")

下列查詢無效:

startTime="2023-08-23T19:20:33+00:00" OR
endTime="2023-08-23T19:21:54+00:00"
eventTypes:"google.workspace.chat.space.v1.updated" AND
eventTypes:"google.workspace.chat.message.v1.created"

伺服器會拒絕無效的查詢,並傳回 INVALID_ARGUMENT 錯誤。

要求主體

要求主體必須為空白。

回應主體

列出聊天室活動的回覆訊息。

如果成功,回應主體會含有以下結構的資料:

JSON 表示法
{
  "spaceEvents": [
    {
      object (SpaceEvent)
    }
  ],
  "nextPageToken": string
}
欄位
spaceEvents[]

object (SpaceEvent)

系統會依時間順序傳回結果 (最舊的事件在前)。注意:系統不會在清單要求的 Space 物件中傳回 permissionSettings 欄位。

nextPageToken

string

用來擷取更多事件的接續權杖。如果省略這個欄位,就不會有後續頁面。

授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/chat.app.memberships
  • https://www.googleapis.com/auth/chat.app.messages.readonly
  • https://www.googleapis.com/auth/chat.app.spaces
  • https://www.googleapis.com/auth/chat.spaces
  • https://www.googleapis.com/auth/chat.spaces.readonly
  • https://www.googleapis.com/auth/chat.messages
  • https://www.googleapis.com/auth/chat.messages.readonly
  • https://www.googleapis.com/auth/chat.memberships
  • https://www.googleapis.com/auth/chat.memberships.readonly
  • https://www.googleapis.com/auth/chat.messages.reactions
  • https://www.googleapis.com/auth/chat.messages.reactions.readonly

詳情請參閱授權指南