Skip to content

Commit a2113a8

Browse files
feat: [google-apps-chat] Launch AccessoryAction for GA (googleapis#12517)
- [ ] Regenerate this pull request now. docs: updated comments PiperOrigin-RevId: 619423474 Source-Link: googleapis/googleapis@e7b48a7 Source-Link: https://github.com/googleapis/googleapis-gen/commit/db29826e04de5c3c262f18c007512b86fec00564 Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFwcHMtY2hhdC8uT3dsQm90LnlhbWwiLCJoIjoiZGIyOTgyNmUwNGRlNWMzYzI2MmYxOGMwMDc1MTJiODZmZWMwMDU2NCJ9 --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parent ce2c9ed commit a2113a8

File tree

8 files changed

+110
-8
lines changed

8 files changed

+110
-8
lines changed

packages/google-apps-chat/google/apps/chat/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
Membership,
5454
)
5555
from google.apps.chat_v1.types.message import (
56+
AccessoryWidget,
5657
ActionResponse,
5758
AttachedGif,
5859
CardWithId,
@@ -122,6 +123,7 @@
122123
"ListMembershipsRequest",
123124
"ListMembershipsResponse",
124125
"Membership",
126+
"AccessoryWidget",
125127
"ActionResponse",
126128
"AttachedGif",
127129
"CardWithId",

packages/google-apps-chat/google/apps/chat_v1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
Membership,
5151
)
5252
from .types.message import (
53+
AccessoryWidget,
5354
ActionResponse,
5455
AttachedGif,
5556
CardWithId,
@@ -94,6 +95,7 @@
9495

9596
__all__ = (
9697
"ChatServiceAsyncClient",
98+
"AccessoryWidget",
9799
"ActionResponse",
98100
"ActionStatus",
99101
"Annotation",

packages/google-apps-chat/google/apps/chat_v1/services/chat_service/async_client.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,8 +1060,7 @@ async def sample_update_message():
10601060
- ``cards_v2`` (Requires `app
10611061
authentication </chat/api/guides/auth/service-accounts>`__.)
10621062
1063-
- Developer Preview: ``accessory_widgets`` (Requires
1064-
`app
1063+
- ``accessory_widgets`` (Requires `app
10651064
authentication </chat/api/guides/auth/service-accounts>`__.)
10661065
10671066
This corresponds to the ``update_mask`` field
@@ -1626,7 +1625,7 @@ async def sample_get_space():
16261625
The request object. A request to return a single space.
16271626
name (:class:`str`):
16281627
Required. Resource name of the space, in the form
1629-
"spaces/*".
1628+
`spaces/*`.
16301629
16311630
Format: ``spaces/{space}``
16321631

packages/google-apps-chat/google/apps/chat_v1/services/chat_service/client.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,8 +1521,7 @@ def sample_update_message():
15211521
- ``cards_v2`` (Requires `app
15221522
authentication </chat/api/guides/auth/service-accounts>`__.)
15231523
1524-
- Developer Preview: ``accessory_widgets`` (Requires
1525-
`app
1524+
- ``accessory_widgets`` (Requires `app
15261525
authentication </chat/api/guides/auth/service-accounts>`__.)
15271526
15281527
This corresponds to the ``update_mask`` field
@@ -2044,7 +2043,7 @@ def sample_get_space():
20442043
The request object. A request to return a single space.
20452044
name (str):
20462045
Required. Resource name of the space, in the form
2047-
"spaces/*".
2046+
`spaces/*`.
20482047
20492048
Format: ``spaces/{space}``
20502049

packages/google-apps-chat/google/apps/chat_v1/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
Membership,
4545
)
4646
from .message import (
47+
AccessoryWidget,
4748
ActionResponse,
4849
AttachedGif,
4950
CardWithId,
@@ -111,6 +112,7 @@
111112
"ListMembershipsRequest",
112113
"ListMembershipsResponse",
113114
"Membership",
115+
"AccessoryWidget",
114116
"ActionResponse",
115117
"AttachedGif",
116118
"CardWithId",

packages/google-apps-chat/google/apps/chat_v1/types/message.py

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"QuotedMessageMetadata",
4242
"Thread",
4343
"ActionResponse",
44+
"AccessoryWidget",
4445
"GetMessageRequest",
4546
"DeleteMessageRequest",
4647
"UpdateMessageRequest",
@@ -235,6 +236,73 @@ class Message(proto.Message):
235236
attached_gifs (MutableSequence[google.apps.chat_v1.types.AttachedGif]):
236237
Output only. GIF images that are attached to
237238
the message.
239+
accessory_widgets (MutableSequence[google.apps.chat_v1.types.AccessoryWidget]):
240+
One or more interactive widgets that appear at the bottom of
241+
a message. You can add accessory widgets to messages that
242+
contain text, cards, or both text and cards. Not supported
243+
for messages that contain dialogs.
244+
245+
Creating a message with accessory widgets requires [app
246+
authentication]
247+
(https://developers.google.com/chat/api/guides/auth/service-accounts).
248+
249+
The following example shows a Chat app that uses accessory
250+
widgets (thumbs up and thumbs down buttons) in a text
251+
message:
252+
253+
|Example accessory widgets message|
254+
255+
The JSON for this example message is the following:
256+
257+
::
258+
259+
{
260+
"text": "Rate your experience with this Chat app.",
261+
"accessoryWidgets": [
262+
{
263+
"buttonList": {
264+
"buttons": [
265+
{
266+
"icon": {
267+
"material_icon": {
268+
"name": "thumb_up"
269+
}
270+
},
271+
"color": {
272+
"red": 0,
273+
"blue": 255,
274+
"green": 0
275+
},
276+
"onClick": {
277+
"action": {
278+
"function": "doUpvote",
279+
}
280+
}
281+
},
282+
{
283+
"icon": {
284+
"material_icon": {
285+
"name": "thumb_down"
286+
}
287+
},
288+
"color": {
289+
"red": 0,
290+
"blue": 255,
291+
"green": 0
292+
},
293+
"onClick": {
294+
"action": {
295+
"function": "doDownvote",
296+
}
297+
}
298+
}
299+
]
300+
}
301+
}
302+
]
303+
}
304+
305+
.. |Example accessory widgets message| image:: https://developers.google.com/chat/images/message-accessory-widgets-reference.png
238306
"""
239307

240308
name: str = proto.Field(
@@ -359,6 +427,11 @@ class Message(proto.Message):
359427
number=42,
360428
message="AttachedGif",
361429
)
430+
accessory_widgets: MutableSequence["AccessoryWidget"] = proto.RepeatedField(
431+
proto.MESSAGE,
432+
number=44,
433+
message="AccessoryWidget",
434+
)
362435

363436

364437
class AttachedGif(proto.Message):
@@ -556,6 +629,29 @@ class UpdatedWidget(proto.Message):
556629
)
557630

558631

632+
class AccessoryWidget(proto.Message):
633+
r"""A borderless widget attached to the bottom of an app's
634+
message.
635+
636+
637+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
638+
639+
Attributes:
640+
button_list (google.apps.card_v1.types.ButtonList):
641+
A list of buttons that are displayed under
642+
the message.
643+
644+
This field is a member of `oneof`_ ``action``.
645+
"""
646+
647+
button_list: gac_card.ButtonList = proto.Field(
648+
proto.MESSAGE,
649+
number=1,
650+
oneof="action",
651+
message=gac_card.ButtonList,
652+
)
653+
654+
559655
class GetMessageRequest(proto.Message):
560656
r"""
561657
@@ -633,7 +729,7 @@ class UpdateMessageRequest(proto.Message):
633729
- ``cards_v2`` (Requires `app
634730
authentication </chat/api/guides/auth/service-accounts>`__.)
635731
636-
- Developer Preview: ``accessory_widgets`` (Requires `app
732+
- ``accessory_widgets`` (Requires `app
637733
authentication </chat/api/guides/auth/service-accounts>`__.)
638734
allow_missing (bool):
639735
Optional. If ``true`` and the message isn't found, a new

packages/google-apps-chat/google/apps/chat_v1/types/space.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ class GetSpaceRequest(proto.Message):
404404
Attributes:
405405
name (str):
406406
Required. Resource name of the space, in the form
407-
"spaces/*".
407+
`spaces/*`.
408408
409409
Format: ``spaces/{space}``
410410
"""

packages/google-apps-chat/tests/unit/gapic/chat_v1/test_chat_service.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8281,6 +8281,7 @@ def test_create_message_rest(request_type):
82818281
"deletion_metadata": {"deletion_type": 1},
82828282
"quoted_message_metadata": {"name": "name_value", "last_update_time": {}},
82838283
"attached_gifs": [{"uri": "uri_value"}],
8284+
"accessory_widgets": [{"button_list": {}}],
82848285
}
82858286
# The version of a generated dependency at test runtime may differ from the version used during generation.
82868287
# Delete any fields which are not present in the current runtime dependency
@@ -10223,6 +10224,7 @@ def test_update_message_rest(request_type):
1022310224
"deletion_metadata": {"deletion_type": 1},
1022410225
"quoted_message_metadata": {"name": "name_value", "last_update_time": {}},
1022510226
"attached_gifs": [{"uri": "uri_value"}],
10227+
"accessory_widgets": [{"button_list": {}}],
1022610228
}
1022710229
# The version of a generated dependency at test runtime may differ from the version used during generation.
1022810230
# Delete any fields which are not present in the current runtime dependency

0 commit comments

Comments
 (0)