セクションの位置を変更する

このガイドでは、Google Chat API の Section リソースで position メソッドを使用して、Google Chat のセクションの並べ替え順序を変更する方法について説明します。

詳細については、 Google Chat でセクションを作成して整理するをご覧ください。

前提条件

Python

セクションの位置を変更する

ユーザー認証を使用してセクションの位置を変更するには、リクエストで次の情報を渡します。

  • chat.users.sections 認可スコープを指定します。
  • PositionSection メソッドを呼び出します。
  • リクエストの本文で、配置するセクションの name と新しい位置を指定します。
    • sortOrder を絶対位置(0 より大きい)に設定します。
    • または、relativePositionSTART または END に設定します。

次の例では、セクションをリストの先頭に移動します。

Python

from google.cloud import chat_v1

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

    # Initialize request
    request = chat_v1.PositionSectionRequest(
        name="SECTION_NAME",
        relative_position=chat_v1.PositionSectionRequest.Position.START
    )

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

    print(response)

このサンプルを実行するには、次の値を置き換えます。

  • SECTION_NAME: セクションのリソース名。リソース名は、 ListSections メソッドを呼び出すことで取得できます。

Chat API は、更新されたインスタンスを返します Section