async def test_run_pivot_report_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.RunPivotReportRequest() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client._client._transport.run_pivot_report), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( analytics_data_api.RunPivotReportResponse()) response = await client.run_pivot_report(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.RunPivotReportResponse)
def run_pivot_report( self, request: analytics_data_api.RunPivotReportRequest = None, *, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> analytics_data_api.RunPivotReportResponse: r"""Returns a customized pivot report of your Google Analytics event data. Pivot reports are more advanced and expressive formats than regular reports. In a pivot report, dimensions are only visible if they are included in a pivot. Multiple pivots can be specified to further dissect your data. Args: request (google.analytics.data_v1alpha.types.RunPivotReportRequest): The request object. The request to generate a pivot report. 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.RunPivotReportResponse: The response pivot report table corresponding to a pivot request. """ # Create or coerce a protobuf request object. # Minor optimization to avoid making a copy if the user passes # in a analytics_data_api.RunPivotReportRequest. # 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.RunPivotReportRequest): request = analytics_data_api.RunPivotReportRequest(request) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. rpc = self._transport._wrapped_methods[ self._transport.run_pivot_report] # Send the request. response = rpc( request, retry=retry, timeout=timeout, metadata=metadata, ) # Done; return the response. return response
async def run_pivot_report( self, request: analytics_data_api.RunPivotReportRequest = None, *, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> analytics_data_api.RunPivotReportResponse: r"""Returns a customized pivot report of your Google Analytics event data. Pivot reports are more advanced and expressive formats than regular reports. In a pivot report, dimensions are only visible if they are included in a pivot. Multiple pivots can be specified to further dissect your data. Args: request (:class:`google.analytics.data_v1alpha.types.RunPivotReportRequest`): The request object. The request to generate a pivot report. 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.RunPivotReportResponse: The response pivot report table corresponding to a pivot request. """ # Create or coerce a protobuf request object. request = analytics_data_api.RunPivotReportRequest(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.run_pivot_report, 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