def test_preview_realm_update(transport: str = "grpc"): client = RealmsServiceClient( credentials=credentials.AnonymousCredentials(), transport=transport) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. request = realms.PreviewRealmUpdateRequest() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client._transport.preview_realm_update), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = realms.PreviewRealmUpdateResponse( etag="etag_value") response = client.preview_realm_update(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] assert args[0] == request # Establish that the response is the type that we expect. assert isinstance(response, realms.PreviewRealmUpdateResponse) assert response.etag == "etag_value"
async def preview_realm_update( self, request: realms.PreviewRealmUpdateRequest = None, *, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> realms.PreviewRealmUpdateResponse: r"""Previews patches to a single realm. Args: request (:class:`google.cloud.gaming_v1.types.PreviewRealmUpdateRequest`): The request object. Request message for RealmsService.PreviewRealmUpdate. 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.cloud.gaming_v1.types.PreviewRealmUpdateResponse: Response message for RealmsService.PreviewRealmUpdate. """ # Create or coerce a protobuf request object. request = realms.PreviewRealmUpdateRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = gapic_v1.method_async.wrap_method( self._client._transport.preview_realm_update, default_retry=retries.Retry( initial=1.0, maximum=10.0, multiplier=1.3, predicate=retries.if_exception_type( core_exceptions.ServiceUnavailable, ), deadline=60.0, ), default_timeout=60.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( (("realm.name", request.realm.name), )), ) # Send the request. response = await rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
def preview_realm_update( self, request: realms.PreviewRealmUpdateRequest = None, *, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> realms.PreviewRealmUpdateResponse: r"""Previews patches to a single realm. Args: request (:class:`~.realms.PreviewRealmUpdateRequest`): The request object. Request message for RealmsService.PreviewRealmUpdate. 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: ~.realms.PreviewRealmUpdateResponse: Response message for RealmsService.PreviewRealmUpdate. """ # Create or coerce a protobuf request object. # Minor optimization to avoid making a copy if the user passes # in a realms.PreviewRealmUpdateRequest. # There's no risk of modifying the input as we've already verified # there are no flattened fields. if not isinstance(request, realms.PreviewRealmUpdateRequest): request = realms.PreviewRealmUpdateRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[ self._transport.preview_realm_update] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + (gapic_v1.routing_header.to_grpc_metadata( (("realm.name", request.realm.name), )), ) # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
def preview_realm_update( self, request: realms.PreviewRealmUpdateRequest = None, *, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> realms.PreviewRealmUpdateResponse: r"""Previews patches to a single Realm. Args: request (:class:`~.realms.PreviewRealmUpdateRequest`): The request object. Request message for RealmsService.PreviewRealmUpdate. 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: ~.realms.PreviewRealmUpdateResponse: Response message for RealmsService.PreviewRealmUpdate. """ # Create or coerce a protobuf request object. request = realms.PreviewRealmUpdateRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = gapic_v1.method.wrap_method( self._transport.preview_realm_update, default_timeout=None, client_info=_client_info, ) # Send the request. response = rpc(request, retry=retry, timeout=timeout, metadata=metadata) # Done; return the response. return response
def preview_realm_update( self, request: Union[realms.PreviewRealmUpdateRequest, dict] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> realms.PreviewRealmUpdateResponse: r"""Previews patches to a single realm. .. code-block:: python from google.cloud import gaming_v1 def sample_preview_realm_update(): # Create a client client = gaming_v1.RealmsServiceClient() # Initialize request argument(s) realm = gaming_v1.Realm() realm.time_zone = "time_zone_value" request = gaming_v1.PreviewRealmUpdateRequest( realm=realm, ) # Make the request response = client.preview_realm_update(request=request) # Handle the response print(response) Args: request (Union[google.cloud.gaming_v1.types.PreviewRealmUpdateRequest, dict]): The request object. Request message for RealmsService.PreviewRealmUpdate. 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.cloud.gaming_v1.types.PreviewRealmUpdateResponse: Response message for RealmsService.PreviewRealmUpdate. """ # Create or coerce a protobuf request object. # Minor optimization to avoid making a copy if the user passes # in a realms.PreviewRealmUpdateRequest. # There's no risk of modifying the input as we've already verified # there are no flattened fields. if not isinstance(request, realms.PreviewRealmUpdateRequest): request = realms.PreviewRealmUpdateRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[ self._transport.preview_realm_update] # Certain fields should be provided within the metadata header; # add these here. metadata = tuple(metadata) + (gapic_v1.routing_header.to_grpc_metadata( (("realm.name", request.realm.name), )), ) # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response