將聊天室移至其他區段

本指南說明如何使用 Google Chat API 的 SectionItem 資源中的 move 方法,將項目 (例如空間) 從一個區段移至另一個區段。

詳情請參閱「在 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 執行個體。