From 8fd57a340b7e052dc9c4d6c33882add75405eb8b Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 12 Mar 2021 09:15:26 -0800 Subject: [PATCH] chore: get changes from googleapis fix(v1beta): (BREAKING) rename the 'page_size', 'page_token', 'total_size' fields to 'limit', 'offset' and 'row_count' respectively PiperOrigin-RevId: 361182102 Source-Author: Google APIs Source-Date: Fri Mar 5 11:01:21 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: d4cd8d96ed6eb5dd7c997aab68a1d6bb0825090c Source-Link: https://github.com/googleapis/googleapis/commit/d4cd8d96ed6eb5dd7c997aab68a1d6bb0825090c chore: upgrade gapic-generator-python to 0.42.2 PiperOrigin-RevId: 361662015 Source-Author: Google APIs Source-Date: Mon Mar 8 14:47:18 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 28a591963253d52ce3a25a918cafbdd9928de8cf Source-Link: https://github.com/googleapis/googleapis/commit/28a591963253d52ce3a25a918cafbdd9928de8cf --- docs/data_v1beta/beta_analytics_data.rst | 5 - .../analytics/data_v1alpha/types/__init__.py | 120 ++++++------ .../beta_analytics_data/async_client.py | 14 +- .../services/beta_analytics_data/client.py | 14 +- .../services/beta_analytics_data/pagers.py | 158 ---------------- .../analytics/data_v1beta/types/__init__.py | 116 ++++++------ .../data_v1beta/types/analytics_data_api.py | 116 +++++------- synth.metadata | 7 +- .../data_v1beta/test_beta_analytics_data.py | 177 +----------------- 9 files changed, 184 insertions(+), 543 deletions(-) delete mode 100644 google/analytics/data_v1beta/services/beta_analytics_data/pagers.py diff --git a/docs/data_v1beta/beta_analytics_data.rst b/docs/data_v1beta/beta_analytics_data.rst index bcdd65e..7bcaa51 100644 --- a/docs/data_v1beta/beta_analytics_data.rst +++ b/docs/data_v1beta/beta_analytics_data.rst @@ -4,8 +4,3 @@ BetaAnalyticsData .. automodule:: google.analytics.data_v1beta.services.beta_analytics_data :members: :inherited-members: - - -.. automodule:: google.analytics.data_v1beta.services.beta_analytics_data.pagers - :members: - :inherited-members: diff --git a/google/analytics/data_v1alpha/types/__init__.py b/google/analytics/data_v1alpha/types/__init__.py index ca30e25..298cbc2 100644 --- a/google/analytics/data_v1alpha/types/__init__.py +++ b/google/analytics/data_v1alpha/types/__init__.py @@ -15,92 +15,92 @@ # limitations under the License. # +from .analytics_data_api import ( + BatchRunPivotReportsRequest, + BatchRunPivotReportsResponse, + BatchRunReportsRequest, + BatchRunReportsResponse, + GetMetadataRequest, + Metadata, + RunPivotReportRequest, + RunPivotReportResponse, + RunRealtimeReportRequest, + RunRealtimeReportResponse, + RunReportRequest, + RunReportResponse, +) from .data import ( + Cohort, + CohortReportSettings, + CohortSpec, + CohortsRange, DateRange, - Entity, Dimension, DimensionExpression, - Metric, + DimensionHeader, + DimensionMetadata, + DimensionValue, + Entity, + Filter, FilterExpression, FilterExpressionList, - Filter, - OrderBy, - Pivot, - CohortSpec, - Cohort, - CohortsRange, - CohortReportSettings, - ResponseMetaData, - DimensionHeader, + Metric, MetricHeader, - PivotHeader, - PivotDimensionHeader, - Row, - DimensionValue, + MetricMetadata, MetricValue, NumericValue, + OrderBy, + Pivot, + PivotDimensionHeader, + PivotHeader, PropertyQuota, QuotaStatus, - DimensionMetadata, - MetricMetadata, + ResponseMetaData, + Row, MetricAggregation, MetricType, ) -from .analytics_data_api import ( - Metadata, - RunReportRequest, - RunReportResponse, - RunPivotReportRequest, - RunPivotReportResponse, - BatchRunReportsRequest, - BatchRunReportsResponse, - BatchRunPivotReportsRequest, - BatchRunPivotReportsResponse, - GetMetadataRequest, - RunRealtimeReportRequest, - RunRealtimeReportResponse, -) __all__ = ( + "BatchRunPivotReportsRequest", + "BatchRunPivotReportsResponse", + "BatchRunReportsRequest", + "BatchRunReportsResponse", + "GetMetadataRequest", + "Metadata", + "RunPivotReportRequest", + "RunPivotReportResponse", + "RunRealtimeReportRequest", + "RunRealtimeReportResponse", + "RunReportRequest", + "RunReportResponse", + "Cohort", + "CohortReportSettings", + "CohortSpec", + "CohortsRange", "DateRange", - "Entity", "Dimension", "DimensionExpression", - "Metric", + "DimensionHeader", + "DimensionMetadata", + "DimensionValue", + "Entity", + "Filter", "FilterExpression", "FilterExpressionList", - "Filter", - "OrderBy", - "Pivot", - "CohortSpec", - "Cohort", - "CohortsRange", - "CohortReportSettings", - "ResponseMetaData", - "DimensionHeader", + "Metric", "MetricHeader", - "PivotHeader", - "PivotDimensionHeader", - "Row", - "DimensionValue", + "MetricMetadata", "MetricValue", "NumericValue", + "OrderBy", + "Pivot", + "PivotDimensionHeader", + "PivotHeader", "PropertyQuota", "QuotaStatus", - "DimensionMetadata", - "MetricMetadata", + "ResponseMetaData", + "Row", "MetricAggregation", "MetricType", - "Metadata", - "RunReportRequest", - "RunReportResponse", - "RunPivotReportRequest", - "RunPivotReportResponse", - "BatchRunReportsRequest", - "BatchRunReportsResponse", - "BatchRunPivotReportsRequest", - "BatchRunPivotReportsResponse", - "GetMetadataRequest", - "RunRealtimeReportRequest", - "RunRealtimeReportResponse", ) diff --git a/google/analytics/data_v1beta/services/beta_analytics_data/async_client.py b/google/analytics/data_v1beta/services/beta_analytics_data/async_client.py index 523b0f4..a23ad74 100644 --- a/google/analytics/data_v1beta/services/beta_analytics_data/async_client.py +++ b/google/analytics/data_v1beta/services/beta_analytics_data/async_client.py @@ -28,7 +28,6 @@ from google.auth import credentials # type: ignore from google.oauth2 import service_account # type: ignore -from google.analytics.data_v1beta.services.beta_analytics_data import pagers from google.analytics.data_v1beta.types import analytics_data_api from google.analytics.data_v1beta.types import data @@ -177,7 +176,7 @@ async def run_report( retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.RunReportAsyncPager: + ) -> analytics_data_api.RunReportResponse: r"""Returns a customized report of your Google Analytics event data. Reports contain statistics derived from data collected by the Google Analytics tracking code. The @@ -199,12 +198,9 @@ async def run_report( sent along with the request as metadata. Returns: - google.analytics.data_v1beta.services.beta_analytics_data.pagers.RunReportAsyncPager: + google.analytics.data_v1beta.types.RunReportResponse: The response report table corresponding to a request. - Iterating over this object will yield - results and resolve additional pages - automatically. """ # Create or coerce a protobuf request object. @@ -228,12 +224,6 @@ async def run_report( # Send the request. response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - # This method is paged; wrap the response in a pager, which provides - # an `__aiter__` convenience method. - response = pagers.RunReportAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, - ) - # Done; return the response. return response diff --git a/google/analytics/data_v1beta/services/beta_analytics_data/client.py b/google/analytics/data_v1beta/services/beta_analytics_data/client.py index c26aa32..fe5592b 100644 --- a/google/analytics/data_v1beta/services/beta_analytics_data/client.py +++ b/google/analytics/data_v1beta/services/beta_analytics_data/client.py @@ -32,7 +32,6 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore -from google.analytics.data_v1beta.services.beta_analytics_data import pagers from google.analytics.data_v1beta.types import analytics_data_api from google.analytics.data_v1beta.types import data @@ -348,7 +347,7 @@ def run_report( retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> pagers.RunReportPager: + ) -> analytics_data_api.RunReportResponse: r"""Returns a customized report of your Google Analytics event data. Reports contain statistics derived from data collected by the Google Analytics tracking code. The @@ -370,12 +369,9 @@ def run_report( sent along with the request as metadata. Returns: - google.analytics.data_v1beta.services.beta_analytics_data.pagers.RunReportPager: + google.analytics.data_v1beta.types.RunReportResponse: The response report table corresponding to a request. - Iterating over this object will yield - results and resolve additional pages - automatically. """ # Create or coerce a protobuf request object. @@ -400,12 +396,6 @@ def run_report( # Send the request. response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) - # This method is paged; wrap the response in a pager, which provides - # an `__iter__` convenience method. - response = pagers.RunReportPager( - method=rpc, request=request, response=response, metadata=metadata, - ) - # Done; return the response. return response diff --git a/google/analytics/data_v1beta/services/beta_analytics_data/pagers.py b/google/analytics/data_v1beta/services/beta_analytics_data/pagers.py deleted file mode 100644 index 6361325..0000000 --- a/google/analytics/data_v1beta/services/beta_analytics_data/pagers.py +++ /dev/null @@ -1,158 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2020 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -from typing import ( - Any, - AsyncIterable, - Awaitable, - Callable, - Iterable, - Sequence, - Tuple, - Optional, -) - -from google.analytics.data_v1beta.types import analytics_data_api -from google.analytics.data_v1beta.types import data - - -class RunReportPager: - """A pager for iterating through ``run_report`` requests. - - This class thinly wraps an initial - :class:`google.analytics.data_v1beta.types.RunReportResponse` object, and - provides an ``__iter__`` method to iterate through its - ``dimension_headers`` field. - - If there are more pages, the ``__iter__`` method will make additional - ``RunReport`` requests and continue to iterate - through the ``dimension_headers`` field on the - corresponding responses. - - All the usual :class:`google.analytics.data_v1beta.types.RunReportResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - - def __init__( - self, - method: Callable[..., analytics_data_api.RunReportResponse], - request: analytics_data_api.RunReportRequest, - response: analytics_data_api.RunReportResponse, - *, - metadata: Sequence[Tuple[str, str]] = () - ): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.data_v1beta.types.RunReportRequest): - The initial request object. - response (google.analytics.data_v1beta.types.RunReportResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = analytics_data_api.RunReportRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - def pages(self) -> Iterable[analytics_data_api.RunReportResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = self._method(self._request, metadata=self._metadata) - yield self._response - - def __iter__(self) -> Iterable[data.DimensionHeader]: - for page in self.pages: - yield from page.dimension_headers - - def __repr__(self) -> str: - return "{0}<{1!r}>".format(self.__class__.__name__, self._response) - - -class RunReportAsyncPager: - """A pager for iterating through ``run_report`` requests. - - This class thinly wraps an initial - :class:`google.analytics.data_v1beta.types.RunReportResponse` object, and - provides an ``__aiter__`` method to iterate through its - ``dimension_headers`` field. - - If there are more pages, the ``__aiter__`` method will make additional - ``RunReport`` requests and continue to iterate - through the ``dimension_headers`` field on the - corresponding responses. - - All the usual :class:`google.analytics.data_v1beta.types.RunReportResponse` - attributes are available on the pager. If multiple requests are made, only - the most recent response is retained, and thus used for attribute lookup. - """ - - def __init__( - self, - method: Callable[..., Awaitable[analytics_data_api.RunReportResponse]], - request: analytics_data_api.RunReportRequest, - response: analytics_data_api.RunReportResponse, - *, - metadata: Sequence[Tuple[str, str]] = () - ): - """Instantiate the pager. - - Args: - method (Callable): The method that was originally called, and - which instantiated this pager. - request (google.analytics.data_v1beta.types.RunReportRequest): - The initial request object. - response (google.analytics.data_v1beta.types.RunReportResponse): - The initial response object. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. - """ - self._method = method - self._request = analytics_data_api.RunReportRequest(request) - self._response = response - self._metadata = metadata - - def __getattr__(self, name: str) -> Any: - return getattr(self._response, name) - - @property - async def pages(self) -> AsyncIterable[analytics_data_api.RunReportResponse]: - yield self._response - while self._response.next_page_token: - self._request.page_token = self._response.next_page_token - self._response = await self._method(self._request, metadata=self._metadata) - yield self._response - - def __aiter__(self) -> AsyncIterable[data.DimensionHeader]: - async def async_generator(): - async for page in self.pages: - for response in page.dimension_headers: - yield response - - return async_generator() - - def __repr__(self) -> str: - return "{0}<{1!r}>".format(self.__class__.__name__, self._response) diff --git a/google/analytics/data_v1beta/types/__init__.py b/google/analytics/data_v1beta/types/__init__.py index 6b5beb8..faa4850 100644 --- a/google/analytics/data_v1beta/types/__init__.py +++ b/google/analytics/data_v1beta/types/__init__.py @@ -15,90 +15,90 @@ # limitations under the License. # +from .analytics_data_api import ( + BatchRunPivotReportsRequest, + BatchRunPivotReportsResponse, + BatchRunReportsRequest, + BatchRunReportsResponse, + GetMetadataRequest, + Metadata, + RunPivotReportRequest, + RunPivotReportResponse, + RunRealtimeReportRequest, + RunRealtimeReportResponse, + RunReportRequest, + RunReportResponse, +) from .data import ( + Cohort, + CohortReportSettings, + CohortSpec, + CohortsRange, DateRange, Dimension, DimensionExpression, - Metric, + DimensionHeader, + DimensionMetadata, + DimensionValue, + Filter, FilterExpression, FilterExpressionList, - Filter, - OrderBy, - Pivot, - CohortSpec, - Cohort, - CohortsRange, - CohortReportSettings, - ResponseMetaData, - DimensionHeader, + Metric, MetricHeader, - PivotHeader, - PivotDimensionHeader, - Row, - DimensionValue, + MetricMetadata, MetricValue, NumericValue, + OrderBy, + Pivot, + PivotDimensionHeader, + PivotHeader, PropertyQuota, QuotaStatus, - DimensionMetadata, - MetricMetadata, + ResponseMetaData, + Row, MetricAggregation, MetricType, ) -from .analytics_data_api import ( - Metadata, - RunReportRequest, - RunReportResponse, - RunPivotReportRequest, - RunPivotReportResponse, - BatchRunReportsRequest, - BatchRunReportsResponse, - BatchRunPivotReportsRequest, - BatchRunPivotReportsResponse, - GetMetadataRequest, - RunRealtimeReportRequest, - RunRealtimeReportResponse, -) __all__ = ( + "BatchRunPivotReportsRequest", + "BatchRunPivotReportsResponse", + "BatchRunReportsRequest", + "BatchRunReportsResponse", + "GetMetadataRequest", + "Metadata", + "RunPivotReportRequest", + "RunPivotReportResponse", + "RunRealtimeReportRequest", + "RunRealtimeReportResponse", + "RunReportRequest", + "RunReportResponse", + "Cohort", + "CohortReportSettings", + "CohortSpec", + "CohortsRange", "DateRange", "Dimension", "DimensionExpression", - "Metric", + "DimensionHeader", + "DimensionMetadata", + "DimensionValue", + "Filter", "FilterExpression", "FilterExpressionList", - "Filter", - "OrderBy", - "Pivot", - "CohortSpec", - "Cohort", - "CohortsRange", - "CohortReportSettings", - "ResponseMetaData", - "DimensionHeader", + "Metric", "MetricHeader", - "PivotHeader", - "PivotDimensionHeader", - "Row", - "DimensionValue", + "MetricMetadata", "MetricValue", "NumericValue", + "OrderBy", + "Pivot", + "PivotDimensionHeader", + "PivotHeader", "PropertyQuota", "QuotaStatus", - "DimensionMetadata", - "MetricMetadata", + "ResponseMetaData", + "Row", "MetricAggregation", "MetricType", - "Metadata", - "RunReportRequest", - "RunReportResponse", - "RunPivotReportRequest", - "RunPivotReportResponse", - "BatchRunReportsRequest", - "BatchRunReportsResponse", - "BatchRunPivotReportsRequest", - "BatchRunPivotReportsResponse", - "GetMetadataRequest", - "RunRealtimeReportRequest", - "RunRealtimeReportResponse", ) diff --git a/google/analytics/data_v1beta/types/analytics_data_api.py b/google/analytics/data_v1beta/types/analytics_data_api.py index b12602b..8f8a10b 100644 --- a/google/analytics/data_v1beta/types/analytics_data_api.py +++ b/google/analytics/data_v1beta/types/analytics_data_api.py @@ -96,31 +96,30 @@ class RunReportRequest(proto.Message): Metrics must be requested to be used in this filter. Dimensions cannot be used in this filter. - page_size (int): - Page size is for paging and specifies maximum number of rows - to return. The API returns a maximum of 200,000 rows per - request, no matter how many you ask for. Page size must be - positive. + offset (int): + The row count of the start row. The first row is counted as + row 0. - The API can also return fewer rows than the requested - ``pageSize``, if there aren't as many dimension values as - the ``pageSize``. For instance, there are fewer than 300 - possible values for the dimension ``country``, so when - reporting on only ``country``, you can't get more than 300 - rows, even if you set ``pageSize`` to a higher value. + When paging, the first request does not specify offset; or + equivalently, sets offset to 0; the first request returns + the first ``limit`` of rows. The second request sets offset + to the ``limit`` of the first request; the second request + returns the second ``limit`` of rows. To learn more about this pagination parameter, see `Pagination `__. - page_token (str): - A continuation token to get the next page of the results. - Adding this to the request will return the next page of rows - after the ``pageToken``. The ``pageToken`` should be the - value returned in the ``nextPageToken`` parameter in the - response. + limit (int): + The number of rows to return. If unspecified, 10,000 rows + are returned. The API returns a maximum of 100,000 rows per + request, no matter how many you ask for. ``limit`` must be + positive. - When paginating, all other parameters specified in - ``RunReportRequest`` must match the call that provided the - page token. + The API can also return fewer rows than the requested + ``limit``, if there aren't as many dimension values as the + ``limit``. For instance, there are fewer than 300 possible + values for the dimension ``country``, so when reporting on + only ``country``, you can't get more than 300 rows, even if + you set ``limit`` to a higher value. To learn more about this pagination parameter, see `Pagination `__. @@ -164,9 +163,9 @@ class RunReportRequest(proto.Message): metric_filter = proto.Field(proto.MESSAGE, number=6, message=data.FilterExpression,) - page_size = proto.Field(proto.INT32, number=7) + offset = proto.Field(proto.INT64, number=7) - page_token = proto.Field(proto.STRING, number=8) + limit = proto.Field(proto.INT64, number=8) metric_aggregations = proto.RepeatedField( proto.ENUM, number=9, enum=data.MetricAggregation, @@ -205,22 +204,14 @@ class RunReportResponse(proto.Message): If requested, the maximum values of metrics. minimums (Sequence[google.analytics.data_v1beta.types.Row]): If requested, the minimum values of metrics. - next_page_token (str): - A token that can be sent as ``pageToken`` in a subsequent - ``RunReportRequest`` call to retrieve the next page of - report rows. If this field is omitted, there are no - subsequent pages of report rows. - - To learn more about this pagination parameter, see - `Pagination `__. - total_size (int): - The total number of rows in the query result. ``totalSize`` + row_count (int): + The total number of rows in the query result. ``rowCount`` is independent of the number of rows returned in the - response, the ``pageSize`` request parameter, and the - ``pageToken`` request parameter. For example if a query - returns 175 rows and includes ``pageSize`` of 50 in the API - request, the response will contain ``totalSize`` of 175 but - only 50 rows. + response, the ``limit`` request parameter, and the + ``offset`` request parameter. For example if a query returns + 175 rows and includes ``limit`` of 50 in the API request, + the response will contain ``rowCount`` of 175 but only 50 + rows. To learn more about this pagination parameter, see `Pagination `__. @@ -231,10 +222,6 @@ class RunReportResponse(proto.Message): including this request. """ - @property - def raw_page(self): - return self - dimension_headers = proto.RepeatedField( proto.MESSAGE, number=1, message=data.DimensionHeader, ) @@ -251,13 +238,11 @@ def raw_page(self): minimums = proto.RepeatedField(proto.MESSAGE, number=6, message=data.Row,) - next_page_token = proto.Field(proto.STRING, number=7) - - total_size = proto.Field(proto.INT32, number=8) + row_count = proto.Field(proto.INT32, number=7) - metadata = proto.Field(proto.MESSAGE, number=9, message=data.ResponseMetaData,) + metadata = proto.Field(proto.MESSAGE, number=8, message=data.ResponseMetaData,) - property_quota = proto.Field(proto.MESSAGE, number=10, message=data.PropertyQuota,) + property_quota = proto.Field(proto.MESSAGE, number=9, message=data.PropertyQuota,) class RunPivotReportRequest(proto.Message): @@ -568,21 +553,18 @@ class RunRealtimeReportRequest(proto.Message): Metrics must be requested to be used in this filter. Dimensions cannot be used in this filter. - page_size (int): - Page size specifies maximum number of rows to return. If - unspecified, up to 10,000 rows are returned. The API returns - a maximum of 100,000 rows per request, no matter how many - you ask for. Page size must be positive. + limit (int): + The number of rows to return. If unspecified, 10,000 rows + are returned. The API returns a maximum of 100,000 rows per + request, no matter how many you ask for. ``limit`` must be + positive. The API can also return fewer rows than the requested - ``pageSize``, if there aren't as many dimension values as - the ``pageSize``. For instance, there are fewer than 300 - possible values for the dimension ``country``, so when - reporting on only ``country``, you can't get more than 300 - rows, even if you set ``pageSize`` to a higher value. - - To learn more about this pagination parameter, see - `Pagination `__. + ``limit``, if there aren't as many dimension values as the + ``limit``. For instance, there are fewer than 300 possible + values for the dimension ``country``, so when reporting on + only ``country``, you can't get more than 300 rows, even if + you set ``limit`` to a higher value. metric_aggregations (Sequence[google.analytics.data_v1beta.types.MetricAggregation]): Aggregation of metrics. Aggregated metric values will be shown in rows where the dimension_values are set to @@ -608,7 +590,7 @@ class RunRealtimeReportRequest(proto.Message): metric_filter = proto.Field(proto.MESSAGE, number=5, message=data.FilterExpression,) - page_size = proto.Field(proto.INT32, number=6) + limit = proto.Field(proto.INT64, number=6) metric_aggregations = proto.RepeatedField( proto.ENUM, number=7, enum=data.MetricAggregation, @@ -642,13 +624,13 @@ class RunRealtimeReportResponse(proto.Message): If requested, the maximum values of metrics. minimums (Sequence[google.analytics.data_v1beta.types.Row]): If requested, the minimum values of metrics. - total_size (int): - The total number of rows in the query result. ``totalSize`` + row_count (int): + The total number of rows in the query result. ``rowCount`` is independent of the number of rows returned in the - response and the ``pageSize`` request parameter. For example - if a query returns 175 rows and includes ``pageSize`` of 50 - in the API request, the response will contain ``totalSize`` - of 175 but only 50 rows. + response and the ``limit`` request parameter. For example if + a query returns 175 rows and includes ``limit`` of 50 in the + API request, the response will contain ``rowCount`` of 175 + but only 50 rows. property_quota (google.analytics.data_v1beta.types.PropertyQuota): This Analytics Property's Realtime quota state including this request. @@ -670,7 +652,7 @@ class RunRealtimeReportResponse(proto.Message): minimums = proto.RepeatedField(proto.MESSAGE, number=6, message=data.Row,) - total_size = proto.Field(proto.INT32, number=7) + row_count = proto.Field(proto.INT32, number=7) property_quota = proto.Field(proto.MESSAGE, number=8, message=data.PropertyQuota,) diff --git a/synth.metadata b/synth.metadata index 2e3e66a..0afde4f 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/python-analytics-data.git", - "sha": "58f834e80510abdcbb49801e2901e1ee44653396" + "sha": "fdebf9b96e915a06fecaeb83c1ca59de077249a8" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "8f117308d5bb55816953a0d6ad1a7d27a69a7d3f", - "internalRef": "361084441" + "sha": "28a591963253d52ce3a25a918cafbdd9928de8cf", + "internalRef": "361662015" } }, { @@ -133,7 +133,6 @@ "google/analytics/data_v1beta/services/beta_analytics_data/__init__.py", "google/analytics/data_v1beta/services/beta_analytics_data/async_client.py", "google/analytics/data_v1beta/services/beta_analytics_data/client.py", - "google/analytics/data_v1beta/services/beta_analytics_data/pagers.py", "google/analytics/data_v1beta/services/beta_analytics_data/transports/__init__.py", "google/analytics/data_v1beta/services/beta_analytics_data/transports/base.py", "google/analytics/data_v1beta/services/beta_analytics_data/transports/grpc.py", diff --git a/tests/unit/gapic/data_v1beta/test_beta_analytics_data.py b/tests/unit/gapic/data_v1beta/test_beta_analytics_data.py index e43b775..810069d 100644 --- a/tests/unit/gapic/data_v1beta/test_beta_analytics_data.py +++ b/tests/unit/gapic/data_v1beta/test_beta_analytics_data.py @@ -31,7 +31,6 @@ from google.analytics.data_v1beta.services.beta_analytics_data import ( BetaAnalyticsDataClient, ) -from google.analytics.data_v1beta.services.beta_analytics_data import pagers from google.analytics.data_v1beta.services.beta_analytics_data import transports from google.analytics.data_v1beta.types import analytics_data_api from google.analytics.data_v1beta.types import data @@ -472,9 +471,7 @@ def test_run_report( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.run_report), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = analytics_data_api.RunReportResponse( - next_page_token="next_page_token_value", total_size=1086, - ) + call.return_value = analytics_data_api.RunReportResponse(row_count=992,) response = client.run_report(request) @@ -486,11 +483,9 @@ def test_run_report( # Establish that the response is the type that we expect. - assert isinstance(response, pagers.RunReportPager) - - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, analytics_data_api.RunReportResponse) - assert response.total_size == 1086 + assert response.row_count == 992 def test_run_report_from_dict(): @@ -529,9 +524,7 @@ async def test_run_report_async( with mock.patch.object(type(client.transport.run_report), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - analytics_data_api.RunReportResponse( - next_page_token="next_page_token_value", total_size=1086, - ) + analytics_data_api.RunReportResponse(row_count=992,) ) response = await client.run_report(request) @@ -543,11 +536,9 @@ async def test_run_report_async( assert args[0] == analytics_data_api.RunReportRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.RunReportAsyncPager) - - assert response.next_page_token == "next_page_token_value" + assert isinstance(response, analytics_data_api.RunReportResponse) - assert response.total_size == 1086 + assert response.row_count == 992 @pytest.mark.asyncio @@ -608,152 +599,6 @@ async def test_run_report_field_headers_async(): assert ("x-goog-request-params", "property=property/value",) in kw["metadata"] -def test_run_report_pager(): - client = BetaAnalyticsDataClient(credentials=credentials.AnonymousCredentials,) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.run_report), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_data_api.RunReportResponse( - dimension_headers=[ - data.DimensionHeader(), - data.DimensionHeader(), - data.DimensionHeader(), - ], - next_page_token="abc", - ), - analytics_data_api.RunReportResponse( - dimension_headers=[], next_page_token="def", - ), - analytics_data_api.RunReportResponse( - dimension_headers=[data.DimensionHeader(),], next_page_token="ghi", - ), - analytics_data_api.RunReportResponse( - dimension_headers=[data.DimensionHeader(), data.DimensionHeader(),], - ), - RuntimeError, - ) - - metadata = () - metadata = tuple(metadata) + ( - gapic_v1.routing_header.to_grpc_metadata((("property", ""),)), - ) - pager = client.run_report(request={}) - - assert pager._metadata == metadata - - results = [i for i in pager] - assert len(results) == 6 - assert all(isinstance(i, data.DimensionHeader) for i in results) - - -def test_run_report_pages(): - client = BetaAnalyticsDataClient(credentials=credentials.AnonymousCredentials,) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client.transport.run_report), "__call__") as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_data_api.RunReportResponse( - dimension_headers=[ - data.DimensionHeader(), - data.DimensionHeader(), - data.DimensionHeader(), - ], - next_page_token="abc", - ), - analytics_data_api.RunReportResponse( - dimension_headers=[], next_page_token="def", - ), - analytics_data_api.RunReportResponse( - dimension_headers=[data.DimensionHeader(),], next_page_token="ghi", - ), - analytics_data_api.RunReportResponse( - dimension_headers=[data.DimensionHeader(), data.DimensionHeader(),], - ), - RuntimeError, - ) - pages = list(client.run_report(request={}).pages) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - -@pytest.mark.asyncio -async def test_run_report_async_pager(): - client = BetaAnalyticsDataAsyncClient(credentials=credentials.AnonymousCredentials,) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.run_report), "__call__", new_callable=mock.AsyncMock - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_data_api.RunReportResponse( - dimension_headers=[ - data.DimensionHeader(), - data.DimensionHeader(), - data.DimensionHeader(), - ], - next_page_token="abc", - ), - analytics_data_api.RunReportResponse( - dimension_headers=[], next_page_token="def", - ), - analytics_data_api.RunReportResponse( - dimension_headers=[data.DimensionHeader(),], next_page_token="ghi", - ), - analytics_data_api.RunReportResponse( - dimension_headers=[data.DimensionHeader(), data.DimensionHeader(),], - ), - RuntimeError, - ) - async_pager = await client.run_report(request={},) - assert async_pager.next_page_token == "abc" - responses = [] - async for response in async_pager: - responses.append(response) - - assert len(responses) == 6 - assert all(isinstance(i, data.DimensionHeader) for i in responses) - - -@pytest.mark.asyncio -async def test_run_report_async_pages(): - client = BetaAnalyticsDataAsyncClient(credentials=credentials.AnonymousCredentials,) - - # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client.transport.run_report), "__call__", new_callable=mock.AsyncMock - ) as call: - # Set the response to a series of pages. - call.side_effect = ( - analytics_data_api.RunReportResponse( - dimension_headers=[ - data.DimensionHeader(), - data.DimensionHeader(), - data.DimensionHeader(), - ], - next_page_token="abc", - ), - analytics_data_api.RunReportResponse( - dimension_headers=[], next_page_token="def", - ), - analytics_data_api.RunReportResponse( - dimension_headers=[data.DimensionHeader(),], next_page_token="ghi", - ), - analytics_data_api.RunReportResponse( - dimension_headers=[data.DimensionHeader(), data.DimensionHeader(),], - ), - RuntimeError, - ) - pages = [] - async for page_ in (await client.run_report(request={})).pages: - pages.append(page_) - for page_, token in zip(pages, ["abc", "def", "ghi", ""]): - assert page_.raw_page.next_page_token == token - - def test_run_pivot_report( transport: str = "grpc", request_type=analytics_data_api.RunPivotReportRequest ): @@ -1420,9 +1265,7 @@ def test_run_realtime_report( type(client.transport.run_realtime_report), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = analytics_data_api.RunRealtimeReportResponse( - total_size=1086, - ) + call.return_value = analytics_data_api.RunRealtimeReportResponse(row_count=992,) response = client.run_realtime_report(request) @@ -1436,7 +1279,7 @@ def test_run_realtime_report( assert isinstance(response, analytics_data_api.RunRealtimeReportResponse) - assert response.total_size == 1086 + assert response.row_count == 992 def test_run_realtime_report_from_dict(): @@ -1480,7 +1323,7 @@ async def test_run_realtime_report_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - analytics_data_api.RunRealtimeReportResponse(total_size=1086,) + analytics_data_api.RunRealtimeReportResponse(row_count=992,) ) response = await client.run_realtime_report(request) @@ -1494,7 +1337,7 @@ async def test_run_realtime_report_async( # Establish that the response is the type that we expect. assert isinstance(response, analytics_data_api.RunRealtimeReportResponse) - assert response.total_size == 1086 + assert response.row_count == 992 @pytest.mark.asyncio