Skip to content

Commit

Permalink
feat: Add Chat read state APIs (#7246)
Browse files Browse the repository at this point in the history
* feat: add UpdateMembership API
PiperOrigin-RevId: 625805898
Source-Link: googleapis/googleapis@c106d2f
Source-Link: googleapis/googleapis-gen@593bb0c
Copy-Tag: eyJwIjoiQXBwc0NoYXQvLk93bEJvdC55YW1sIiwiaCI6IjU5M2JiMGNiNmNhZmU3Y2I3MWMzNjc3NGYyNmM3ZjVjODhjYmI1ZDkifQ==

* feat: Add Chat read state APIs
PiperOrigin-RevId: 626377569
Source-Link: googleapis/googleapis@e9672e7
Source-Link: googleapis/googleapis-gen@50c8b6a
Copy-Tag: eyJwIjoiQXBwc0NoYXQvLk93bEJvdC55YW1sIiwiaCI6IjUwYzhiNmFmMTZiZWI3YzAzMDZkZmYxMjcxN2FiMmI5NzY2MDU3ZTAifQ==
  • Loading branch information
gcf-owl-bot[bot] committed Apr 19, 2024
1 parent f80eb13 commit ac1be59
Show file tree
Hide file tree
Showing 21 changed files with 1,865 additions and 4 deletions.
Binary file modified AppsChat/metadata/Chat/V1/ChatService.php
Binary file not shown.
Binary file modified AppsChat/metadata/Chat/V1/Membership.php
Binary file not shown.
41 changes: 41 additions & 0 deletions AppsChat/metadata/Chat/V1/SpaceReadState.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions AppsChat/metadata/Chat/V1/ThreadReadState.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

89 changes: 89 additions & 0 deletions AppsChat/samples/V1/ChatServiceClient/get_space_read_state.php
@@ -0,0 +1,89 @@
<?php
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START chat_v1_generated_ChatService_GetSpaceReadState_sync]
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\GetSpaceReadStateRequest;
use Google\Apps\Chat\V1\SpaceReadState;

/**
* Returns details about a user's read state within a space, used to identify
* read and unread messages.
*
* Requires [user
* authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
*
* @param string $formattedName Resource name of the space read state to retrieve.
*
* Only supports getting read state for the calling user.
*
* To refer to the calling user, set one of the following:
*
* - The `me` alias. For example, `users/me/spaces/{space}/spaceReadState`.
*
* - Their Workspace email address. For example,
* `users/user&#64;example.com/spaces/{space}/spaceReadState`.
*
* - Their user id. For example,
* `users/123456789/spaces/{space}/spaceReadState`.
*
* Format: users/{user}/spaces/{space}/spaceReadState
* Please see {@see ChatServiceClient::spaceReadStateName()} for help formatting this field.
*/
function get_space_read_state_sample(string $formattedName): void
{
// Create a client.
$chatServiceClient = new ChatServiceClient();

// Prepare the request message.
$request = (new GetSpaceReadStateRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var SpaceReadState $response */
$response = $chatServiceClient->getSpaceReadState($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = ChatServiceClient::spaceReadStateName('[USER]', '[SPACE]');

get_space_read_state_sample($formattedName);
}
// [END chat_v1_generated_ChatService_GetSpaceReadState_sync]
90 changes: 90 additions & 0 deletions AppsChat/samples/V1/ChatServiceClient/get_thread_read_state.php
@@ -0,0 +1,90 @@
<?php
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START chat_v1_generated_ChatService_GetThreadReadState_sync]
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\GetThreadReadStateRequest;
use Google\Apps\Chat\V1\ThreadReadState;

/**
* Returns details about a user's read state within a thread, used to identify
* read and unread messages.
*
* Requires [user
* authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
*
* @param string $formattedName Resource name of the thread read state to retrieve.
*
* Only supports getting read state for the calling user.
*
* To refer to the calling user, set one of the following:
*
* - The `me` alias. For example,
* `users/me/spaces/{space}/threads/{thread}/threadReadState`.
*
* - Their Workspace email address. For example,
* `users/user&#64;example.com/spaces/{space}/threads/{thread}/threadReadState`.
*
* - Their user id. For example,
* `users/123456789/spaces/{space}/threads/{thread}/threadReadState`.
*
* Format: users/{user}/spaces/{space}/threads/{thread}/threadReadState
* Please see {@see ChatServiceClient::threadReadStateName()} for help formatting this field.
*/
function get_thread_read_state_sample(string $formattedName): void
{
// Create a client.
$chatServiceClient = new ChatServiceClient();

// Prepare the request message.
$request = (new GetThreadReadStateRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var ThreadReadState $response */
$response = $chatServiceClient->getThreadReadState($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}

/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = ChatServiceClient::threadReadStateName('[USER]', '[SPACE]', '[THREAD]');

get_thread_read_state_sample($formattedName);
}
// [END chat_v1_generated_ChatService_GetThreadReadState_sync]
63 changes: 63 additions & 0 deletions AppsChat/samples/V1/ChatServiceClient/update_membership.php
@@ -0,0 +1,63 @@
<?php
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START chat_v1_generated_ChatService_UpdateMembership_sync]
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\Membership;
use Google\Apps\Chat\V1\UpdateMembershipRequest;
use Google\Protobuf\FieldMask;

/**
* Updates a membership. Requires [user
* authentication](https://developers.google.com/chat/api/guides/auth/users).
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function update_membership_sample(): void
{
// Create a client.
$chatServiceClient = new ChatServiceClient();

// Prepare the request message.
$membership = new Membership();
$updateMask = new FieldMask();
$request = (new UpdateMembershipRequest())
->setMembership($membership)
->setUpdateMask($updateMask);

// Call the API and handle any network failures.
try {
/** @var Membership $response */
$response = $chatServiceClient->updateMembership($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
// [END chat_v1_generated_ChatService_UpdateMembership_sync]
66 changes: 66 additions & 0 deletions AppsChat/samples/V1/ChatServiceClient/update_space_read_state.php
@@ -0,0 +1,66 @@
<?php
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START chat_v1_generated_ChatService_UpdateSpaceReadState_sync]
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\SpaceReadState;
use Google\Apps\Chat\V1\UpdateSpaceReadStateRequest;
use Google\Protobuf\FieldMask;

/**
* Updates a user's read state within a space, used to identify read and
* unread messages.
*
* Requires [user
* authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function update_space_read_state_sample(): void
{
// Create a client.
$chatServiceClient = new ChatServiceClient();

// Prepare the request message.
$spaceReadState = new SpaceReadState();
$updateMask = new FieldMask();
$request = (new UpdateSpaceReadStateRequest())
->setSpaceReadState($spaceReadState)
->setUpdateMask($updateMask);

// Call the API and handle any network failures.
try {
/** @var SpaceReadState $response */
$response = $chatServiceClient->updateSpaceReadState($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
// [END chat_v1_generated_ChatService_UpdateSpaceReadState_sync]

0 comments on commit ac1be59

Please sign in to comment.