Skip to content

Commit 7df87f1

Browse files
feat: [AppsChat] Support app authentication with admin-consent scopes for Chat API ListMessages, GetMessage, GetSpaceEvent and ListSpaceEvents (#9076)
* feat: Addition of Section and SectionItem APIs PiperOrigin-RevId: 893488928 Source-Link: googleapis/googleapis@76fdbf7 Source-Link: googleapis/googleapis-gen@b4ed902 Copy-Tag: eyJwIjoiQXBwc0NoYXQvLk93bEJvdC55YW1sIiwiaCI6ImI0ZWQ5MDI0OTcxN2MxNzk5YWI1M2YzM2MxNDI4ZjJmNWE4OTExOGYifQ== * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * feat: Support app authentication with admin-consent scopes for Chat API ListMessages, GetMessage, GetSpaceEvent and ListSpaceEvents docs: Update reference documentation for Chat API ListMessages, GetMessage, GetSpaceEvent and ListSpaceEvents. PiperOrigin-RevId: 893619899 Source-Link: googleapis/googleapis@8d52a0b Source-Link: googleapis/googleapis-gen@eeac8ca Copy-Tag: eyJwIjoiQXBwc0NoYXQvLk93bEJvdC55YW1sIiwiaCI6ImVlYWM4Y2E2NjEzYTliY2ZkOTBjMDdkZTc4Y2E3NmQ1OGMwMGJiYmYifQ== * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent e379546 commit 7df87f1

34 files changed

Lines changed: 3730 additions & 17 deletions

AppsChat/metadata/Chat/V1/ChatService.php

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AppsChat/metadata/Chat/V1/Section.php

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php
2+
/*
3+
* Copyright 2026 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START chat_v1_generated_ChatService_CreateSection_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Apps\Chat\V1\Client\ChatServiceClient;
28+
use Google\Apps\Chat\V1\CreateSectionRequest;
29+
use Google\Apps\Chat\V1\Section;
30+
use Google\Apps\Chat\V1\Section\SectionType;
31+
32+
/**
33+
* Creates a section in Google Chat. Sections help users group conversations
34+
* and customize the list of spaces displayed in Chat navigation panel. Only
35+
* sections of type `CUSTOM_SECTION` can be created. For details, see [Create
36+
* and organize sections in Google
37+
* Chat](https://support.google.com/chat/answer/16059854).
38+
*
39+
* Requires [user
40+
* authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
41+
* with the [authorization
42+
* scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
43+
*
44+
* - `https://www.googleapis.com/auth/chat.users.sections`
45+
*
46+
* @param string $formattedParent The parent resource name where the section is created.
47+
*
48+
* Format: `users/{user}`
49+
* Please see {@see ChatServiceClient::userName()} for help formatting this field.
50+
* @param int $sectionType The type of the section.
51+
*/
52+
function create_section_sample(string $formattedParent, int $sectionType): void
53+
{
54+
// Create a client.
55+
$chatServiceClient = new ChatServiceClient();
56+
57+
// Prepare the request message.
58+
$section = (new Section())
59+
->setType($sectionType);
60+
$request = (new CreateSectionRequest())
61+
->setParent($formattedParent)
62+
->setSection($section);
63+
64+
// Call the API and handle any network failures.
65+
try {
66+
/** @var Section $response */
67+
$response = $chatServiceClient->createSection($request);
68+
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
69+
} catch (ApiException $ex) {
70+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
71+
}
72+
}
73+
74+
/**
75+
* Helper to execute the sample.
76+
*
77+
* This sample has been automatically generated and should be regarded as a code
78+
* template only. It will require modifications to work:
79+
* - It may require correct/in-range values for request initialization.
80+
* - It may require specifying regional endpoints when creating the service client,
81+
* please see the apiEndpoint client configuration option for more details.
82+
*/
83+
function callSample(): void
84+
{
85+
$formattedParent = ChatServiceClient::userName('[USER]');
86+
$sectionType = SectionType::SECTION_TYPE_UNSPECIFIED;
87+
88+
create_section_sample($formattedParent, $sectionType);
89+
}
90+
// [END chat_v1_generated_ChatService_CreateSection_sync]
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
/*
3+
* Copyright 2026 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START chat_v1_generated_ChatService_DeleteSection_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Apps\Chat\V1\Client\ChatServiceClient;
28+
use Google\Apps\Chat\V1\DeleteSectionRequest;
29+
30+
/**
31+
* Deletes a section of type `CUSTOM_SECTION`.
32+
*
33+
* If the section contains items, such as spaces, the items are moved to
34+
* Google Chat's default sections and are not deleted.
35+
*
36+
* For details, see [Create and organize sections in Google
37+
* Chat](https://support.google.com/chat/answer/16059854).
38+
*
39+
* Requires [user
40+
* authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
41+
* with the [authorization
42+
* scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
43+
*
44+
* - `https://www.googleapis.com/auth/chat.users.sections`
45+
*
46+
* @param string $formattedName The name of the section to delete.
47+
*
48+
* Format: `users/{user}/sections/{section}`
49+
* Please see {@see ChatServiceClient::sectionName()} for help formatting this field.
50+
*/
51+
function delete_section_sample(string $formattedName): void
52+
{
53+
// Create a client.
54+
$chatServiceClient = new ChatServiceClient();
55+
56+
// Prepare the request message.
57+
$request = (new DeleteSectionRequest())
58+
->setName($formattedName);
59+
60+
// Call the API and handle any network failures.
61+
try {
62+
$chatServiceClient->deleteSection($request);
63+
printf('Call completed successfully.' . PHP_EOL);
64+
} catch (ApiException $ex) {
65+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
66+
}
67+
}
68+
69+
/**
70+
* Helper to execute the sample.
71+
*
72+
* This sample has been automatically generated and should be regarded as a code
73+
* template only. It will require modifications to work:
74+
* - It may require correct/in-range values for request initialization.
75+
* - It may require specifying regional endpoints when creating the service client,
76+
* please see the apiEndpoint client configuration option for more details.
77+
*/
78+
function callSample(): void
79+
{
80+
$formattedName = ChatServiceClient::sectionName('[USER]', '[SECTION]');
81+
82+
delete_section_sample($formattedName);
83+
}
84+
// [END chat_v1_generated_ChatService_DeleteSection_sync]

AppsChat/samples/V1/ChatServiceClient/get_message.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@
4646
* that invoke the Chat app.
4747
* - `https://www.googleapis.com/auth/chat.app.messages.readonly`
4848
* with [administrator
49-
* approval](https://support.google.com/a?p=chat-app-auth) (available in
50-
* [Developer Preview](https://developers.google.com/workspace/preview)).
49+
* approval](https://support.google.com/a?p=chat-app-auth).
5150
* When using this authentication scope,
5251
* this method returns details about a public message in a space.
5352
*

AppsChat/samples/V1/ChatServiceClient/get_space_event.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@
4949
* - [App
5050
* authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
5151
* with [administrator
52-
* approval](https://support.google.com/a?p=chat-app-auth) in
53-
* [Developer Preview](https://developers.google.com/workspace/preview)
52+
* approval](https://support.google.com/a?p=chat-app-auth)
5453
* with one of the following authorization scopes:
5554
* - `https://www.googleapis.com/auth/chat.app.spaces`
55+
* - `https://www.googleapis.com/auth/chat.app.spaces.readonly`
5656
* - `https://www.googleapis.com/auth/chat.app.messages.readonly`
5757
* - `https://www.googleapis.com/auth/chat.app.memberships`
58+
* - `https://www.googleapis.com/auth/chat.app.memberships.readonly`
5859
*
5960
* - [User
6061
* authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)

AppsChat/samples/V1/ChatServiceClient/list_messages.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@
4545
* - [App
4646
* authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app)
4747
* with [administrator
48-
* approval](https://support.google.com/a?p=chat-app-auth) in
49-
* [Developer Preview](https://developers.google.com/workspace/preview)
48+
* approval](https://support.google.com/a?p=chat-app-auth)
5049
* with the authorization scope:
5150
* - `https://www.googleapis.com/auth/chat.app.messages.readonly`. When
5251
* using this authentication scope, this method only returns public
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
/*
3+
* Copyright 2026 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START chat_v1_generated_ChatService_ListSectionItems_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\PagedListResponse;
28+
use Google\Apps\Chat\V1\Client\ChatServiceClient;
29+
use Google\Apps\Chat\V1\ListSectionItemsRequest;
30+
use Google\Apps\Chat\V1\SectionItem;
31+
32+
/**
33+
* Lists items in a section.
34+
*
35+
* Only spaces can be section items. For details, see [Create and organize
36+
* sections in Google Chat](https://support.google.com/chat/answer/16059854).
37+
*
38+
* Requires [user
39+
* authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
40+
* with the [authorization
41+
* scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
42+
*
43+
* - `https://www.googleapis.com/auth/chat.users.sections`
44+
* - `https://www.googleapis.com/auth/chat.users.sections.readonly`
45+
*
46+
* @param string $formattedParent The parent, which is the section resource name that owns this
47+
* collection of section items. Only supports listing section items for the
48+
* calling user.
49+
*
50+
* When you're filtering by space, use the wildcard `-` to search across all
51+
* sections. For example, `users/{user}/sections/-`.
52+
*
53+
* Format: `users/{user}/sections/{section}`
54+
* Please see {@see ChatServiceClient::sectionName()} for help formatting this field.
55+
*/
56+
function list_section_items_sample(string $formattedParent): void
57+
{
58+
// Create a client.
59+
$chatServiceClient = new ChatServiceClient();
60+
61+
// Prepare the request message.
62+
$request = (new ListSectionItemsRequest())
63+
->setParent($formattedParent);
64+
65+
// Call the API and handle any network failures.
66+
try {
67+
/** @var PagedListResponse $response */
68+
$response = $chatServiceClient->listSectionItems($request);
69+
70+
/** @var SectionItem $element */
71+
foreach ($response as $element) {
72+
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
73+
}
74+
} catch (ApiException $ex) {
75+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
76+
}
77+
}
78+
79+
/**
80+
* Helper to execute the sample.
81+
*
82+
* This sample has been automatically generated and should be regarded as a code
83+
* template only. It will require modifications to work:
84+
* - It may require correct/in-range values for request initialization.
85+
* - It may require specifying regional endpoints when creating the service client,
86+
* please see the apiEndpoint client configuration option for more details.
87+
*/
88+
function callSample(): void
89+
{
90+
$formattedParent = ChatServiceClient::sectionName('[USER]', '[SECTION]');
91+
92+
list_section_items_sample($formattedParent);
93+
}
94+
// [END chat_v1_generated_ChatService_ListSectionItems_sync]

0 commit comments

Comments
 (0)