将聊天室移至其他版块

本指南介绍了如何使用 move 方法将项(例如聊天室)从 Google Chat API 的 SectionItem 资源中的一个部分移动到另一个部分。

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

前提条件

Python

将空间移动到其他部分

如需在进行 用户身份验证的情况下将空间移动到其他部分,请在请求中传递以下内容:

  • 指定 chat.users.sections 授权范围。
  • 调用 MoveSectionItem 方法。
  • 在请求正文中,指定要移动的部分项的 nametargetSection
    • name 设置为部分项的资源名称(例如 users/me/sections/default-spaces/items/spaces/123456)。
    • targetSection 设置为要将项移动到的部分的资源名称。

以下示例将空间移动到其他部分:

Python

from google.cloud import chat_v1

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

    # Initialize request
    request = chat_v1.MoveSectionItemRequest(
        name="SECTION_ITEM_NAME",
        target_section="TARGET_SECTION_NAME"
    )

    # Make the request
    response = client.move_section_item(request=request)

    print(response)

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

  • SECTION_ITEM_NAME:部分项的资源名称。
  • TARGET_SECTION_NAME:目标部分的资源名称。

Chat API 会返回 SectionItem的更新实例。