Skip to content

Commit 9e1e169

Browse files
feat: [AppsChat] Add Availability Api's (#9320)
* feat: Add Availability Api's PiperOrigin-RevId: 943880172 Source-Link: googleapis/googleapis@af2513f Source-Link: googleapis/googleapis-gen@0e9289a Copy-Tag: eyJwIjoiQXBwc0NoYXQvLk93bEJvdC55YW1sIiwiaCI6IjBlOTI4OWFjZjQyODU0NmNlMzA1ODkxY2I5NjhkN2Q1NzgyMzg2MDUifQ== * 🦉 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> Co-authored-by: Brent Shaffer <betterbrent@google.com>
1 parent 266495c commit 9e1e169

22 files changed

Lines changed: 2434 additions & 1 deletion

AppsChat/metadata/Chat/V1/Availability.php

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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_GetAvailability_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Apps\Chat\V1\Availability;
28+
use Google\Apps\Chat\V1\Client\ChatServiceClient;
29+
use Google\Apps\Chat\V1\GetAvailabilityRequest;
30+
31+
/**
32+
* Returns availability information for a human user in Google Chat. For
33+
* example, this can be used to check if a user is online or away, or to
34+
* retrieve their custom status message.
35+
*
36+
* This method only retrieves the authenticated user's availability.
37+
*
38+
* Requires [user
39+
* authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
40+
* with one of the following [authorization
41+
* scopes](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
42+
*
43+
* - `https://www.googleapis.com/auth/chat.users.availability.readonly`
44+
* - `https://www.googleapis.com/auth/chat.users.availability`
45+
*
46+
* @param string $formattedName The resource name of the availability to retrieve.
47+
*
48+
* Format: users/{user}/availability
49+
*
50+
* `{user}` is the id for the Person in the People API or Admin SDK directory
51+
* API. For example, `users/123456789`.
52+
*
53+
* The user's email address or `me` can also be used as an alias to refer to
54+
* the caller. For example, `users/user&#64;example.com` or `users/me`. Please see
55+
* {@see ChatServiceClient::availabilityName()} for help formatting this field.
56+
*/
57+
function get_availability_sample(string $formattedName): void
58+
{
59+
// Create a client.
60+
$chatServiceClient = new ChatServiceClient();
61+
62+
// Prepare the request message.
63+
$request = (new GetAvailabilityRequest())
64+
->setName($formattedName);
65+
66+
// Call the API and handle any network failures.
67+
try {
68+
/** @var Availability $response */
69+
$response = $chatServiceClient->getAvailability($request);
70+
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
71+
} catch (ApiException $ex) {
72+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
73+
}
74+
}
75+
76+
/**
77+
* Helper to execute the sample.
78+
*
79+
* This sample has been automatically generated and should be regarded as a code
80+
* template only. It will require modifications to work:
81+
* - It may require correct/in-range values for request initialization.
82+
* - It may require specifying regional endpoints when creating the service client,
83+
* please see the apiEndpoint client configuration option for more details.
84+
*/
85+
function callSample(): void
86+
{
87+
$formattedName = ChatServiceClient::availabilityName('[USER]');
88+
89+
get_availability_sample($formattedName);
90+
}
91+
// [END chat_v1_generated_ChatService_GetAvailability_sync]
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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_MarkAsActive_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Apps\Chat\V1\Availability;
28+
use Google\Apps\Chat\V1\Client\ChatServiceClient;
29+
use Google\Apps\Chat\V1\MarkAsActiveRequest;
30+
31+
/**
32+
* Marks user as `ACTIVE` in Google Chat.
33+
*
34+
* Sets the user's availability state to `ACTIVE`. The `ACTIVE` state
35+
* lasts until the specified expiration, at which point the user's state
36+
* becomes `AWAY`. Note that if the user is actively using Chat, the `ACTIVE`
37+
* state duration may extend beyond the provided expiration.
38+
*
39+
* This method only updates the authenticated user's availability.
40+
*
41+
* Requires [user
42+
* authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
43+
* with [authorization
44+
* scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
45+
*
46+
* - `https://www.googleapis.com/auth/chat.users.availability`
47+
*
48+
* @param string $formattedName The resource name of the availability to mark as active.
49+
* Format: users/{user}/availability
50+
*
51+
* `{user}` is the id for the Person in the People API or Admin SDK directory
52+
* API. For example, `users/123456789`.
53+
*
54+
* The user's email address or `me` can also be used as an alias to refer to
55+
* the caller. For example, `users/user&#64;example.com` or `users/me`. Please see
56+
* {@see ChatServiceClient::availabilityName()} for help formatting this field.
57+
*/
58+
function mark_as_active_sample(string $formattedName): void
59+
{
60+
// Create a client.
61+
$chatServiceClient = new ChatServiceClient();
62+
63+
// Prepare the request message.
64+
$request = (new MarkAsActiveRequest())
65+
->setName($formattedName);
66+
67+
// Call the API and handle any network failures.
68+
try {
69+
/** @var Availability $response */
70+
$response = $chatServiceClient->markAsActive($request);
71+
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
72+
} catch (ApiException $ex) {
73+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
74+
}
75+
}
76+
77+
/**
78+
* Helper to execute the sample.
79+
*
80+
* This sample has been automatically generated and should be regarded as a code
81+
* template only. It will require modifications to work:
82+
* - It may require correct/in-range values for request initialization.
83+
* - It may require specifying regional endpoints when creating the service client,
84+
* please see the apiEndpoint client configuration option for more details.
85+
*/
86+
function callSample(): void
87+
{
88+
$formattedName = ChatServiceClient::availabilityName('[USER]');
89+
90+
mark_as_active_sample($formattedName);
91+
}
92+
// [END chat_v1_generated_ChatService_MarkAsActive_sync]
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_MarkAsAway_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Apps\Chat\V1\Availability;
28+
use Google\Apps\Chat\V1\Client\ChatServiceClient;
29+
use Google\Apps\Chat\V1\MarkAsAwayRequest;
30+
31+
/**
32+
* Marks user as `AWAY` in Google Chat.
33+
*
34+
* Sets the user's state to away and is not affected by the user's
35+
* activity.
36+
*
37+
* This method only updates the authenticated user's availability.
38+
*
39+
* Requires [user
40+
* authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
41+
* with [authorization
42+
* scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
43+
*
44+
* - `https://www.googleapis.com/auth/chat.users.availability`
45+
*
46+
* @param string $formattedName The resource name of the availability to mark as away.
47+
* Format: users/{user}/availability
48+
*
49+
* `{user}` is the id for the Person in the People API or Admin SDK directory
50+
* API. For example, `users/123456789`.
51+
*
52+
* The user's email address or `me` can also be used as an alias to refer to
53+
* the caller. For example, `users/user&#64;example.com` or `users/me`. Please see
54+
* {@see ChatServiceClient::availabilityName()} for help formatting this field.
55+
*/
56+
function mark_as_away_sample(string $formattedName): void
57+
{
58+
// Create a client.
59+
$chatServiceClient = new ChatServiceClient();
60+
61+
// Prepare the request message.
62+
$request = (new MarkAsAwayRequest())
63+
->setName($formattedName);
64+
65+
// Call the API and handle any network failures.
66+
try {
67+
/** @var Availability $response */
68+
$response = $chatServiceClient->markAsAway($request);
69+
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
70+
} catch (ApiException $ex) {
71+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
72+
}
73+
}
74+
75+
/**
76+
* Helper to execute the sample.
77+
*
78+
* This sample has been automatically generated and should be regarded as a code
79+
* template only. It will require modifications to work:
80+
* - It may require correct/in-range values for request initialization.
81+
* - It may require specifying regional endpoints when creating the service client,
82+
* please see the apiEndpoint client configuration option for more details.
83+
*/
84+
function callSample(): void
85+
{
86+
$formattedName = ChatServiceClient::availabilityName('[USER]');
87+
88+
mark_as_away_sample($formattedName);
89+
}
90+
// [END chat_v1_generated_ChatService_MarkAsAway_sync]
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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_MarkAsDoNotDisturb_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\Apps\Chat\V1\Availability;
28+
use Google\Apps\Chat\V1\Client\ChatServiceClient;
29+
use Google\Apps\Chat\V1\MarkAsDoNotDisturbRequest;
30+
31+
/**
32+
* Marks user as `DO_NOT_DISTURB` in Google Chat.
33+
*
34+
* Sets a user's availability state to `DO_NOT_DISTURB` until a specified
35+
* expiration time.
36+
* When in `DO_NOT_DISTURB`, users typically won't receive notifications.
37+
*
38+
* This method only updates the authenticated user's availability.
39+
*
40+
* Requires [user
41+
* authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
42+
* with [authorization
43+
* scope](https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes):
44+
*
45+
* - `https://www.googleapis.com/auth/chat.users.availability`
46+
*
47+
* @param string $formattedName The resource name of the availability to mark as Do Not Disturb.
48+
* Format: users/{user}/availability
49+
*
50+
* `{user}` is the id for the Person in the People API or Admin SDK directory
51+
* API. For example, `users/123456789`.
52+
*
53+
* The user's email address or `me` can also be used as an alias to refer to
54+
* the caller. For example, `users/user&#64;example.com` or `users/me`. Please see
55+
* {@see ChatServiceClient::availabilityName()} for help formatting this field.
56+
*/
57+
function mark_as_do_not_disturb_sample(string $formattedName): void
58+
{
59+
// Create a client.
60+
$chatServiceClient = new ChatServiceClient();
61+
62+
// Prepare the request message.
63+
$request = (new MarkAsDoNotDisturbRequest())
64+
->setName($formattedName);
65+
66+
// Call the API and handle any network failures.
67+
try {
68+
/** @var Availability $response */
69+
$response = $chatServiceClient->markAsDoNotDisturb($request);
70+
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
71+
} catch (ApiException $ex) {
72+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
73+
}
74+
}
75+
76+
/**
77+
* Helper to execute the sample.
78+
*
79+
* This sample has been automatically generated and should be regarded as a code
80+
* template only. It will require modifications to work:
81+
* - It may require correct/in-range values for request initialization.
82+
* - It may require specifying regional endpoints when creating the service client,
83+
* please see the apiEndpoint client configuration option for more details.
84+
*/
85+
function callSample(): void
86+
{
87+
$formattedName = ChatServiceClient::availabilityName('[USER]');
88+
89+
mark_as_do_not_disturb_sample($formattedName);
90+
}
91+
// [END chat_v1_generated_ChatService_MarkAsDoNotDisturb_sync]

0 commit comments

Comments
 (0)