Skip to content

Commit

Permalink
feat: [google-apps-chat] add UpdateMembership API (#12589)
Browse files Browse the repository at this point in the history
- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 625805898

Source-Link:
googleapis/googleapis@c106d2f

Source-Link:
googleapis/googleapis-gen@593bb0c
Copy-Tag:
eyJwIjoicGFja2FnZXMvZ29vZ2xlLWFwcHMtY2hhdC8uT3dsQm90LnlhbWwiLCJoIjoiNTkzYmIwY2I2Y2FmZTdjYjcxYzM2Nzc0ZjI2YzdmNWM4OGNiYjVkOSJ9

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
3 people authored Apr 18, 2024
1 parent e19f79f commit 187a036
Show file tree
Hide file tree
Showing 18 changed files with 1,976 additions and 499 deletions.
2 changes: 2 additions & 0 deletions packages/google-apps-chat/google/apps/chat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
ListMembershipsRequest,
ListMembershipsResponse,
Membership,
UpdateMembershipRequest,
)
from google.apps.chat_v1.types.message import (
AccessoryWidget,
Expand Down Expand Up @@ -123,6 +124,7 @@
"ListMembershipsRequest",
"ListMembershipsResponse",
"Membership",
"UpdateMembershipRequest",
"AccessoryWidget",
"ActionResponse",
"AttachedGif",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.1.3" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
2 changes: 2 additions & 0 deletions packages/google-apps-chat/google/apps/chat_v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
ListMembershipsRequest,
ListMembershipsResponse,
Membership,
UpdateMembershipRequest,
)
from .types.message import (
AccessoryWidget,
Expand Down Expand Up @@ -150,6 +151,7 @@
"SlashCommandMetadata",
"Space",
"Thread",
"UpdateMembershipRequest",
"UpdateMessageRequest",
"UpdateSpaceRequest",
"UploadAttachmentRequest",
Expand Down
15 changes: 15 additions & 0 deletions packages/google-apps-chat/google/apps/chat_v1/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@
"set_up_space"
]
},
"UpdateMembership": {
"methods": [
"update_membership"
]
},
"UpdateMessage": {
"methods": [
"update_message"
Expand Down Expand Up @@ -220,6 +225,11 @@
"set_up_space"
]
},
"UpdateMembership": {
"methods": [
"update_membership"
]
},
"UpdateMessage": {
"methods": [
"update_message"
Expand Down Expand Up @@ -335,6 +345,11 @@
"set_up_space"
]
},
"UpdateMembership": {
"methods": [
"update_membership"
]
},
"UpdateMessage": {
"methods": [
"update_message"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.1.3" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -2638,6 +2638,139 @@ async def sample_create_membership():
# Done; return the response.
return response

async def update_membership(
self,
request: Optional[Union[gc_membership.UpdateMembershipRequest, dict]] = None,
*,
membership: Optional[gc_membership.Membership] = None,
update_mask: Optional[field_mask_pb2.FieldMask] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> gc_membership.Membership:
r"""Updates a membership. Requires `user
authentication <https://developers.google.com/chat/api/guides/auth/users>`__.
.. code-block:: python
# This snippet 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 as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.apps import chat_v1
async def sample_update_membership():
# Create a client
client = chat_v1.ChatServiceAsyncClient()
# Initialize request argument(s)
request = chat_v1.UpdateMembershipRequest(
)
# Make the request
response = await client.update_membership(request=request)
# Handle the response
print(response)
Args:
request (Optional[Union[google.apps.chat_v1.types.UpdateMembershipRequest, dict]]):
The request object. Request message for updating a
membership.
membership (:class:`google.apps.chat_v1.types.Membership`):
Required. The membership to update. Only fields
specified by ``update_mask`` are updated.
This corresponds to the ``membership`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
Required. The field paths to update. Separate multiple
values with commas or use ``*`` to update all field
paths.
Currently supported field paths:
- ``role``
This corresponds to the ``update_mask`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
google.apps.chat_v1.types.Membership:
Represents a membership relation in
Google Chat, such as whether a user or
Chat app is invited to, part of, or
absent from a space.
"""
# Create or coerce a protobuf request object.
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([membership, update_mask])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

request = gc_membership.UpdateMembershipRequest(request)

# If we have keyword arguments corresponding to fields on the
# request, apply these.
if membership is not None:
request.membership = membership
if update_mask is not None:
request.update_mask = update_mask

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = gapic_v1.method_async.wrap_method(
self._client._transport.update_membership,
default_retry=retries.AsyncRetry(
initial=1.0,
maximum=10.0,
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.ServiceUnavailable,
),
deadline=30.0,
),
default_timeout=30.0,
client_info=DEFAULT_CLIENT_INFO,
)

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("membership.name", request.membership.name),)
),
)

# Validate the universe domain.
self._client._validate_universe_domain()

# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

async def delete_membership(
self,
request: Optional[Union[membership.DeleteMembershipRequest, dict]] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2987,6 +2987,130 @@ def sample_create_membership():
# Done; return the response.
return response

def update_membership(
self,
request: Optional[Union[gc_membership.UpdateMembershipRequest, dict]] = None,
*,
membership: Optional[gc_membership.Membership] = None,
update_mask: Optional[field_mask_pb2.FieldMask] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> gc_membership.Membership:
r"""Updates a membership. Requires `user
authentication <https://developers.google.com/chat/api/guides/auth/users>`__.
.. code-block:: python
# This snippet 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 as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.apps import chat_v1
def sample_update_membership():
# Create a client
client = chat_v1.ChatServiceClient()
# Initialize request argument(s)
request = chat_v1.UpdateMembershipRequest(
)
# Make the request
response = client.update_membership(request=request)
# Handle the response
print(response)
Args:
request (Union[google.apps.chat_v1.types.UpdateMembershipRequest, dict]):
The request object. Request message for updating a
membership.
membership (google.apps.chat_v1.types.Membership):
Required. The membership to update. Only fields
specified by ``update_mask`` are updated.
This corresponds to the ``membership`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
update_mask (google.protobuf.field_mask_pb2.FieldMask):
Required. The field paths to update. Separate multiple
values with commas or use ``*`` to update all field
paths.
Currently supported field paths:
- ``role``
This corresponds to the ``update_mask`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.
Returns:
google.apps.chat_v1.types.Membership:
Represents a membership relation in
Google Chat, such as whether a user or
Chat app is invited to, part of, or
absent from a space.
"""
# Create or coerce a protobuf request object.
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([membership, update_mask])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
)

# Minor optimization to avoid making a copy if the user passes
# in a gc_membership.UpdateMembershipRequest.
# There's no risk of modifying the input as we've already verified
# there are no flattened fields.
if not isinstance(request, gc_membership.UpdateMembershipRequest):
request = gc_membership.UpdateMembershipRequest(request)
# If we have keyword arguments corresponding to fields on the
# request, apply these.
if membership is not None:
request.membership = membership
if update_mask is not None:
request.update_mask = update_mask

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.update_membership]

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("membership.name", request.membership.name),)
),
)

# Validate the universe domain.
self._validate_universe_domain()

# Send the request.
response = rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

def delete_membership(
self,
request: Optional[Union[membership.DeleteMembershipRequest, dict]] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,20 @@ def _prep_wrapped_messages(self, client_info):
default_timeout=30.0,
client_info=client_info,
),
self.update_membership: gapic_v1.method.wrap_method(
self.update_membership,
default_retry=retries.Retry(
initial=1.0,
maximum=10.0,
multiplier=1.3,
predicate=retries.if_exception_type(
core_exceptions.ServiceUnavailable,
),
deadline=30.0,
),
default_timeout=30.0,
client_info=client_info,
),
self.delete_membership: gapic_v1.method.wrap_method(
self.delete_membership,
default_retry=retries.Retry(
Expand Down Expand Up @@ -633,6 +647,15 @@ def create_membership(
]:
raise NotImplementedError()

@property
def update_membership(
self,
) -> Callable[
[gc_membership.UpdateMembershipRequest],
Union[gc_membership.Membership, Awaitable[gc_membership.Membership]],
]:
raise NotImplementedError()

@property
def delete_membership(
self,
Expand Down
Loading

0 comments on commit 187a036

Please sign in to comment.