async def test_batch_run_pivot_reports_async(transport: str = "grpc_asyncio"): client = AlphaAnalyticsDataAsyncClient( 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 = analytics_data_api.BatchRunPivotReportsRequest() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client._client._transport.batch_run_pivot_reports), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_data_api.BatchRunPivotReportsResponse()) response = await client.batch_run_pivot_reports(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] assert args[0] == request # Establish that the response is the type that we expect. assert isinstance(response, analytics_data_api.BatchRunPivotReportsResponse)
def batch_run_pivot_reports( self, request: analytics_data_api.BatchRunPivotReportsRequest = None, *, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> analytics_data_api.BatchRunPivotReportsResponse: r"""Returns multiple pivot reports in a batch. All reports must be for the same Entity. Args: request (google.analytics.data_v1alpha.types.BatchRunPivotReportsRequest): The request object. The batch request containing multiple pivot report requests. 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.analytics.data_v1alpha.types.BatchRunPivotReportsResponse: The batch response containing multiple pivot reports. """ # Create or coerce a protobuf request object. # Minor optimization to avoid making a copy if the user passes # in a analytics_data_api.BatchRunPivotReportsRequest. # There's no risk of modifying the input as we've already verified # there are no flattened fields. if not isinstance(request, analytics_data_api.BatchRunPivotReportsRequest): request = analytics_data_api.BatchRunPivotReportsRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[ self._transport.batch_run_pivot_reports] # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
async def batch_run_pivot_reports( self, request: analytics_data_api.BatchRunPivotReportsRequest = None, *, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> analytics_data_api.BatchRunPivotReportsResponse: r"""Returns multiple pivot reports in a batch. All reports must be for the same Entity. Args: request (:class:`google.analytics.data_v1alpha.types.BatchRunPivotReportsRequest`): The request object. The batch request containing multiple pivot report requests. 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.analytics.data_v1alpha.types.BatchRunPivotReportsResponse: The batch response containing multiple pivot reports. """ # Create or coerce a protobuf request object. request = analytics_data_api.BatchRunPivotReportsRequest(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.batch_run_pivot_reports, default_timeout=60.0, client_info=DEFAULT_CLIENT_INFO, ) # Send the request. response = await rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response