Skip to content

Commit

Permalink
feat: [AppsChat] Addition of space notification setting Chat API (#8139)
Browse files Browse the repository at this point in the history
* feat: Addition of space notification setting Chat API

PiperOrigin-RevId: 734264583

Source-Link: googleapis/googleapis@76254e6

Source-Link: googleapis/googleapis-gen@63109f6
Copy-Tag: eyJwIjoiQXBwc0NoYXQvLk93bEJvdC55YW1sIiwiaCI6IjYzMTA5ZjYwY2Y1ZmQ3NmRiZmIxMTUxMzM5ZWUxNzQwNjY1MTg1MjIifQ==

* 🦉 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>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Mar 7, 2025
1 parent eb6f007 commit 9409cd0
Show file tree
Hide file tree
Showing 15 changed files with 1,025 additions and 0 deletions.
Binary file modified AppsChat/metadata/Chat/V1/ChatService.php
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
/*
* Copyright 2025 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_GetSpaceNotificationSetting_sync]
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\GetSpaceNotificationSettingRequest;
use Google\Apps\Chat\V1\SpaceNotificationSetting;

/**
* Gets the space notification setting. For an example, see [Get the
* caller's space notification
* setting](https://developers.google.com/workspace/chat/get-space-notification-setting).
*
* Requires [user
* authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
*
* @param string $formattedName Format: users/{user}/spaces/{space}/spaceNotificationSetting
*
* - `users/me/spaces/{space}/spaceNotificationSetting`, OR
* - `users/user&#64;example.com/spaces/{space}/spaceNotificationSetting`, OR
* - `users/123456789/spaces/{space}/spaceNotificationSetting`.
* Note: Only the caller's user id or email is allowed in the path. Please see
* {@see ChatServiceClient::spaceNotificationSettingName()} for help formatting this field.
*/
function get_space_notification_setting_sample(string $formattedName): void
{
// Create a client.
$chatServiceClient = new ChatServiceClient();

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

// Call the API and handle any network failures.
try {
/** @var SpaceNotificationSetting $response */
$response = $chatServiceClient->getSpaceNotificationSetting($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::spaceNotificationSettingName('[USER]', '[SPACE]');

get_space_notification_setting_sample($formattedName);
}
// [END chat_v1_generated_ChatService_GetSpaceNotificationSetting_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php
/*
* Copyright 2025 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_UpdateSpaceNotificationSetting_sync]
use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\SpaceNotificationSetting;
use Google\Apps\Chat\V1\UpdateSpaceNotificationSettingRequest;
use Google\Protobuf\FieldMask;

/**
* Updates the space notification setting. For an example, see [Update
* the caller's space notification
* setting](https://developers.google.com/workspace/chat/update-space-notification-setting).
*
* 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_notification_setting_sample(): void
{
// Create a client.
$chatServiceClient = new ChatServiceClient();

// Prepare the request message.
$spaceNotificationSetting = new SpaceNotificationSetting();
$updateMask = new FieldMask();
$request = (new UpdateSpaceNotificationSettingRequest())
->setSpaceNotificationSetting($spaceNotificationSetting)
->setUpdateMask($updateMask);

// Call the API and handle any network failures.
try {
/** @var SpaceNotificationSetting $response */
$response = $chatServiceClient->updateSpaceNotificationSetting($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_UpdateSpaceNotificationSetting_sync]
92 changes: 92 additions & 0 deletions AppsChat/src/Chat/V1/Client/ChatServiceClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
use Google\Apps\Chat\V1\GetMembershipRequest;
use Google\Apps\Chat\V1\GetMessageRequest;
use Google\Apps\Chat\V1\GetSpaceEventRequest;
use Google\Apps\Chat\V1\GetSpaceNotificationSettingRequest;
use Google\Apps\Chat\V1\GetSpaceReadStateRequest;
use Google\Apps\Chat\V1\GetSpaceRequest;
use Google\Apps\Chat\V1\GetThreadReadStateRequest;
Expand All @@ -63,10 +64,12 @@
use Google\Apps\Chat\V1\SetUpSpaceRequest;
use Google\Apps\Chat\V1\Space;
use Google\Apps\Chat\V1\SpaceEvent;
use Google\Apps\Chat\V1\SpaceNotificationSetting;
use Google\Apps\Chat\V1\SpaceReadState;
use Google\Apps\Chat\V1\ThreadReadState;
use Google\Apps\Chat\V1\UpdateMembershipRequest;
use Google\Apps\Chat\V1\UpdateMessageRequest;
use Google\Apps\Chat\V1\UpdateSpaceNotificationSettingRequest;
use Google\Apps\Chat\V1\UpdateSpaceReadStateRequest;
use Google\Apps\Chat\V1\UpdateSpaceRequest;
use Google\Apps\Chat\V1\UploadAttachmentRequest;
Expand Down Expand Up @@ -102,6 +105,7 @@
* @method PromiseInterface<Message> getMessageAsync(GetMessageRequest $request, array $optionalArgs = [])
* @method PromiseInterface<Space> getSpaceAsync(GetSpaceRequest $request, array $optionalArgs = [])
* @method PromiseInterface<SpaceEvent> getSpaceEventAsync(GetSpaceEventRequest $request, array $optionalArgs = [])
* @method PromiseInterface<SpaceNotificationSetting> getSpaceNotificationSettingAsync(GetSpaceNotificationSettingRequest $request, array $optionalArgs = [])
* @method PromiseInterface<SpaceReadState> getSpaceReadStateAsync(GetSpaceReadStateRequest $request, array $optionalArgs = [])
* @method PromiseInterface<ThreadReadState> getThreadReadStateAsync(GetThreadReadStateRequest $request, array $optionalArgs = [])
* @method PromiseInterface<PagedListResponse> listMembershipsAsync(ListMembershipsRequest $request, array $optionalArgs = [])
Expand All @@ -114,6 +118,7 @@
* @method PromiseInterface<Membership> updateMembershipAsync(UpdateMembershipRequest $request, array $optionalArgs = [])
* @method PromiseInterface<Message> updateMessageAsync(UpdateMessageRequest $request, array $optionalArgs = [])
* @method PromiseInterface<Space> updateSpaceAsync(UpdateSpaceRequest $request, array $optionalArgs = [])
* @method PromiseInterface<SpaceNotificationSetting> updateSpaceNotificationSettingAsync(UpdateSpaceNotificationSettingRequest $request, array $optionalArgs = [])
* @method PromiseInterface<SpaceReadState> updateSpaceReadStateAsync(UpdateSpaceReadStateRequest $request, array $optionalArgs = [])
* @method PromiseInterface<UploadAttachmentResponse> uploadAttachmentAsync(UploadAttachmentRequest $request, array $optionalArgs = [])
*/
Expand Down Expand Up @@ -165,6 +170,7 @@ final class ChatServiceClient
'https://www.googleapis.com/auth/chat.spaces.readonly',
'https://www.googleapis.com/auth/chat.users.readstate',
'https://www.googleapis.com/auth/chat.users.readstate.readonly',
'https://www.googleapis.com/auth/chat.users.spacesettings',
];

private static function getClientDefaults()
Expand Down Expand Up @@ -312,6 +318,23 @@ public static function spaceEventName(string $space, string $spaceEvent): string
]);
}

/**
* Formats a string containing the fully-qualified path to represent a
* space_notification_setting resource.
*
* @param string $user
* @param string $space
*
* @return string The formatted space_notification_setting resource.
*/
public static function spaceNotificationSettingName(string $user, string $space): string
{
return self::getPathTemplate('spaceNotificationSetting')->render([
'user' => $user,
'space' => $space,
]);
}

/**
* Formats a string containing the fully-qualified path to represent a
* space_read_state resource.
Expand Down Expand Up @@ -376,6 +399,7 @@ public static function threadReadStateName(string $user, string $space, string $
* - reaction: spaces/{space}/messages/{message}/reactions/{reaction}
* - space: spaces/{space}
* - spaceEvent: spaces/{space}/spaceEvents/{space_event}
* - spaceNotificationSetting: users/{user}/spaces/{space}/spaceNotificationSetting
* - spaceReadState: users/{user}/spaces/{space}/spaceReadState
* - thread: spaces/{space}/threads/{thread}
* - threadReadState: users/{user}/spaces/{space}/threads/{thread}/threadReadState
Expand Down Expand Up @@ -1093,6 +1117,40 @@ public function getSpaceEvent(GetSpaceEventRequest $request, array $callOptions
return $this->startApiCall('GetSpaceEvent', $request, $callOptions)->wait();
}

/**
* Gets the space notification setting. For an example, see [Get the
* caller's space notification
* setting](https://developers.google.com/workspace/chat/get-space-notification-setting).
*
* Requires [user
* authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
*
* The async variant is
* {@see ChatServiceClient::getSpaceNotificationSettingAsync()} .
*
* @example samples/V1/ChatServiceClient/get_space_notification_setting.php
*
* @param GetSpaceNotificationSettingRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
* associative array of retry settings parameters. See the documentation on
* {@see RetrySettings} for example usage.
* }
*
* @return SpaceNotificationSetting
*
* @throws ApiException Thrown if the API call fails.
*/
public function getSpaceNotificationSetting(
GetSpaceNotificationSettingRequest $request,
array $callOptions = []
): SpaceNotificationSetting {
return $this->startApiCall('GetSpaceNotificationSetting', $request, $callOptions)->wait();
}

/**
* Returns details about a user's read state within a space, used to identify
* read and unread messages. For an example, see [Get details about a user's
Expand Down Expand Up @@ -1588,6 +1646,40 @@ public function updateSpace(UpdateSpaceRequest $request, array $callOptions = []
return $this->startApiCall('UpdateSpace', $request, $callOptions)->wait();
}

/**
* Updates the space notification setting. For an example, see [Update
* the caller's space notification
* setting](https://developers.google.com/workspace/chat/update-space-notification-setting).
*
* Requires [user
* authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
*
* The async variant is
* {@see ChatServiceClient::updateSpaceNotificationSettingAsync()} .
*
* @example samples/V1/ChatServiceClient/update_space_notification_setting.php
*
* @param UpdateSpaceNotificationSettingRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
* associative array of retry settings parameters. See the documentation on
* {@see RetrySettings} for example usage.
* }
*
* @return SpaceNotificationSetting
*
* @throws ApiException Thrown if the API call fails.
*/
public function updateSpaceNotificationSetting(
UpdateSpaceNotificationSettingRequest $request,
array $callOptions = []
): SpaceNotificationSetting {
return $this->startApiCall('UpdateSpaceNotificationSetting', $request, $callOptions)->wait();
}

/**
* Updates a user's read state within a space, used to identify read and
* unread messages. For an example, see [Update a user's space read
Expand Down
Loading

0 comments on commit 9409cd0

Please sign in to comment.