Method: spaces.search
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
根據管理員的搜尋條件,傳回 Google Workspace 機構中的空間清單。在要求中,將 useAdminAccess
設為 true
。如需範例,請參閱「搜尋及管理聊天室」。
需要具備管理員權限的使用者驗證,以及下列其中一個授權範圍:
https://www.googleapis.com/auth/chat.admin.spaces.readonly
https://www.googleapis.com/auth/chat.admin.spaces
HTTP 要求
GET https://chat.googleapis.com/v1/spaces:search
這個網址使用 gRPC 轉碼語法。
查詢參數
參數 |
useAdminAccess |
boolean
時,這個方法會使用使用者的 Google Workspace 管理員權限執行。true 通話使用者必須是具備「管理即時通訊和聊天室對話」權限的 Google Workspace 管理員。 需要 chat.admin.spaces.readonly 或 chat.admin.spaces OAuth 2.0 範圍。 這個方法目前僅支援管理員存取權,因此這個欄位只接受 true 。
|
pageSize |
integer
要傳回的空間數量上限。服務傳回的產品數量可能會少於這個值。 如未指定,最多將傳回 100 個空間。 值的上限為 1000。如果使用超過 1000 的值,系統會自動變更為 1000。
|
pageToken |
string
這是從先前的搜尋空間呼叫接收到的權杖。提供此參數即可擷取後續網頁。 進行分頁時,提供的所有其他參數應與提供網頁權杖的呼叫相符。將不同值傳遞至其他參數可能會導致非預期的結果。
|
query |
string
必要欄位。搜尋查詢。 您可以使用下列參數進行搜尋:
createTime
customer
displayName
externalUserAllowed
lastActiveTime
spaceHistoryState
spaceType
createTime 和 lastActiveTime 接受 RFC-3339 格式的時間戳記,支援的比較運算子為:= 、< 、> 、<= 、>= 。
customer 為必要欄位,用於指出要從哪個客戶擷取聊天室。目前唯一支援的值是 customers/my_customer 。
displayName 只接受 HAS (: ) 運算子。要比對的文字會先符記化為符記,然後系統會不區分大小寫,獨立比對每個符記是否為空間 displayName 中任何位置的子字串。舉例來說,Fun Eve 與 Fun event 或 The
evening was fun 相符,但與 notFun event 或 even 不相符。
externalUserAllowed 可接受 true 或 false 。
spaceHistoryState 只接受 space 資源的 historyState 欄位值。
spaceType 為必填欄位,且唯一有效值為 SPACE 。
不同欄位之間僅支援 AND 運算子。有效範例為 spaceType = "SPACE" AND displayName:"Hello" ,無效範例為 spaceType = "SPACE" OR displayName:"Hello" 。 在同一個欄位中,spaceType 不支援 AND 或 OR 運算子。「spaceHistoryState」和「externalUserAllowed」僅支援 OR 運算子。displayName lastActiveTime 和 createTime 支援 AND 和 OR 運算子。AND 只能用來表示間隔,例如 lastActiveTime
< "2022-01-01T00:00:00+00:00" AND lastActiveTime >
"2023-01-01T00:00:00+00:00" 。 以下是有效的查詢範例:
customer = "customers/my_customer" AND spaceType = "SPACE"
customer = "customers/my_customer" AND spaceType = "SPACE" AND
displayName:"Hello World"
customer = "customers/my_customer" AND spaceType = "SPACE" AND
(lastActiveTime < "2020-01-01T00:00:00+00:00" OR lastActiveTime >
"2022-01-01T00:00:00+00:00")
customer = "customers/my_customer" AND spaceType = "SPACE" AND
(displayName:"Hello World" OR displayName:"Fun event") AND
(lastActiveTime > "2020-01-01T00:00:00+00:00" AND lastActiveTime <
"2022-01-01T00:00:00+00:00")
customer = "customers/my_customer" AND spaceType = "SPACE" AND
(createTime > "2019-01-01T00:00:00+00:00" AND createTime <
"2020-01-01T00:00:00+00:00") AND (externalUserAllowed = "true") AND
(spaceHistoryState = "HISTORY_ON" OR spaceHistoryState = "HISTORY_OFF")
|
orderBy |
string
(選用步驟) 聊天室清單的排序方式。 支援的排序依據屬性如下:
membershipCount.joined_direct_human_user_count :直接加入聊天室的人類使用者人數。
lastActiveTime :表示最後一個符合資格的項目加入這個空間任何主題的時間。
createTime :表示聊天室的建立時間。
有效的排序作業值如下:
支援的語法如下:
membershipCount.joined_direct_human_user_count DESC
membershipCount.joined_direct_human_user_count ASC
lastActiveTime DESC
lastActiveTime ASC
createTime DESC
createTime ASC
|
回應主體
回應,其中包含與搜尋聊天室要求相應的聊天室清單。
如果成功,回應主體會含有以下結構的資料:
JSON 表示法 |
{
"spaces": [
{
object (Space )
}
],
"nextPageToken": string,
"totalSize": integer
} |
欄位 |
spaces[] |
object (Space )
所要求空間的頁面。
|
nextPageToken |
string
可用於擷取下一頁的權杖。如果這個欄位留空,表示沒有後續網頁。
|
totalSize |
integer
所有頁面中符合查詢條件的空間總數。如果結果超過 10,000 個空格,這個值就是估計值。
|
授權範圍
需要下列其中一種 OAuth 範圍:
https://www.googleapis.com/auth/chat.admin.spaces
https://www.googleapis.com/auth/chat.admin.spaces.readonly
詳情請參閱授權指南。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-20 (世界標準時間)。
[null,null,["上次更新時間:2025-08-20 (世界標準時間)。"],[[["\u003cp\u003eReturns a paginated list of Google Workspace spaces based on an administrator's search criteria, including parameters like displayName, createTime, and spaceType.\u003c/p\u003e\n"],["\u003cp\u003eRequires administrator privileges and the \u003ccode\u003euseAdminAccess\u003c/code\u003e parameter set to \u003ccode\u003etrue\u003c/code\u003e in the request.\u003c/p\u003e\n"],["\u003cp\u003eUtilizes the \u003ccode\u003eGET https://chat.googleapis.com/v1/spaces:search\u003c/code\u003e HTTP request with query parameters for customization.\u003c/p\u003e\n"],["\u003cp\u003eNeeds authorization with either the \u003ccode\u003echat.admin.spaces\u003c/code\u003e or \u003ccode\u003echat.admin.spaces.readonly\u003c/code\u003e OAuth scope.\u003c/p\u003e\n"],["\u003cp\u003eResponse body includes an array of spaces, a token for pagination, and an estimate of the total number of matching spaces.\u003c/p\u003e\n"]]],["To search for Google Workspace spaces, send a `GET` request to `https://chat.googleapis.com/v1/spaces:search`, ensuring admin privileges and setting `useAdminAccess` to `true`. Define the search using query parameters, including a required `query` to filter spaces (by `customer`, `displayName`, etc.), optional `pageSize` and `pageToken` for pagination, and optional `orderBy` for sorting. You must have one of the authorization scopes: `chat.admin.spaces` or `chat.admin.spaces.readonly`. The response will list spaces matching the query.\n"],null,[]]