This guide explains how to use the move method on the SectionItem resource of the Google Chat API to move an item (such as a space) from one section to another.
Для получения дополнительной информации см. раздел «Создание и организация разделов в Google Chat» .
Предварительные требования
Python
- Корпоративный аккаунт Google Workspace с доступом к Google Chat .
- Настройте свою среду:
- Создайте проект в Google Cloud .
- Настройте экран согласия OAuth .
- Включите и настройте API Google Chat, указав имя, значок и описание для вашего приложения чата.
- Установите библиотеку Python Cloud Client .
- Создайте учетные данные клиента OAuth для настольного приложения. Чтобы запустить пример из этого руководства, сохраните учетные данные в виде JSON-файла с именем
credentials.jsonв локальной директории.
- Выберите область авторизации , которая поддерживает аутентификацию пользователей.
Переместите пробел в другой раздел.
To move a space to a different section with user authentication , pass the following in your request:
- Укажите область авторизации
chat.users.sections. - Вызовите метод
MoveSectionItem. - In the request body, specify the
nameof the section item to move and thetargetSection:- Set
nameto the resource name of the section item (for example,users/me/sections/default-spaces/items/spaces/123456). - Set
targetSectionto the resource name of the section you want to move the item to.
- Set
The following example moves a space to a different section:
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: The resource name of the section item. -
TARGET_SECTION_NAME: The resource name of the target section.
The Chat API returns the updated instance of SectionItem .
Связанные темы
- Создать раздел
- Обновить раздел
- Удалить раздел
- Изменить положение раздела
- Список разделов
- Список пробелов в разделе