列出部分

本指南介绍了如何使用 Google Chat API 的 Section 资源中的 list 方法列出 Google Chat 中可供已通过身份验证的用户使用的部分。

如需了解详情,请参阅在 Google Chat 中创建和整理版块

前提条件

Python

列出部分

如需列出包含用户身份验证的部分,请在请求中传递以下内容:

  • 指定 chat.users.sectionschat.users.sections.readonly 授权范围。
  • 调用 ListSections 方法。
  • parent 设置为 users/me

以下示例列出了各个部分:

Python

from google.cloud import chat_v1

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

    # Initialize request
    request = chat_v1.ListSectionsRequest(
        parent="users/me"
    )

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

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

Chat API 会返回 Section 资源列表。