列出版块中的空间

本指南介绍了如何使用 Google Chat API 的 SectionItem 资源中的 list 方法列出某个部分中的项目(例如聊天室)。

只有聊天室可以作为版块项。如需了解详情,请参阅在 Google Chat 中创建和整理版块

前提条件

Python

列出版块中的空间

如需列出某个部分中需要用户身份验证的影音平台,请在请求中传递以下内容:

  • 指定 chat.users.sectionschat.users.sections.readonly 授权范围。
  • 调用 ListSectionItems 方法。
  • parent 设置为版块的资源名称。

以下示例列出了某个部分中的空间:

Python

from google.cloud import chat_v1

def list_section_items():
    # Create a client
    client = chat_v1.ChatServiceClient()

    # Initialize request
    request = chat_v1.ListSectionItemsRequest(
        parent="SECTION_NAME"
    )

    # Make the request
    page_result = client.list_section_items(request=request)

    # Handle the response
    for item in page_result:
        print(item)

如需运行此示例,请替换以下内容:

  • SECTION_NAME:版块的资源名称。您可以通过调用 ListSections 方法来获取资源名称。

Chat API 会返回 SectionItem 资源列表。