删除章节

本指南介绍了如何使用 Google Chat API 的 Section 资源中的 delete 方法删除 Google Chat 中的自定义栏目。

删除版块后,其中的项目(例如聊天室)会移至 Google Chat 的默认版块,而不会被删除。

只能删除类型为 CUSTOM_SECTION 的部分。如需了解详情,请参阅在 Google Chat 中创建和整理版块

前提条件

Python

删除版块

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

  • 指定 chat.users.sections 授权范围。
  • 调用 DeleteSection 方法。
  • 在请求正文中,将 name 设置为要删除的部分的资源名称。

以下示例演示了如何删除部分内容:

Python

from google.cloud import chat_v1

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

    # Initialize request
    request = chat_v1.DeleteSectionRequest(
        name="SECTION_NAME"
    )

    # Make the request
    client.delete_section(request=request)

    print("Section deleted")

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

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