From 9989992ca27ef42c47de38340e1595ba2364c09c Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 6 Jan 2021 08:49:00 -0800 Subject: [PATCH] feat: add from_service_account_info factory and fix sphinx identifiers (#27) feat: add 'from_service_account_info' factory to clients fix: fix sphinx identifiers PiperOrigin-RevId: 350246057 Source-Author: Google APIs Source-Date: Tue Jan 5 16:44:11 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 520682435235d9c503983a360a2090025aa47cd1 Source-Link: https://github.com/googleapis/googleapis/commit/520682435235d9c503983a360a2090025aa47cd1 --- .../data_v1alpha/alpha_analytics_data.rst | 6 + .../docs/data_v1alpha/services.rst | 6 +- .../docs/data_v1alpha/types.rst | 1 + .../alpha_analytics_data/async_client.py | 26 +++-- .../services/alpha_analytics_data/client.py | 49 +++++--- .../data_v1alpha/types/analytics_data_api.py | 106 +++++++++--------- .../analytics/data_v1alpha/types/data.py | 80 ++++++------- packages/google-analytics-data/synth.metadata | 8 +- .../data_v1alpha/test_alpha_analytics_data.py | 28 ++++- 9 files changed, 177 insertions(+), 133 deletions(-) create mode 100644 packages/google-analytics-data/docs/data_v1alpha/alpha_analytics_data.rst diff --git a/packages/google-analytics-data/docs/data_v1alpha/alpha_analytics_data.rst b/packages/google-analytics-data/docs/data_v1alpha/alpha_analytics_data.rst new file mode 100644 index 000000000000..a59186bcc1fc --- /dev/null +++ b/packages/google-analytics-data/docs/data_v1alpha/alpha_analytics_data.rst @@ -0,0 +1,6 @@ +AlphaAnalyticsData +------------------------------------ + +.. automodule:: google.analytics.data_v1alpha.services.alpha_analytics_data + :members: + :inherited-members: diff --git a/packages/google-analytics-data/docs/data_v1alpha/services.rst b/packages/google-analytics-data/docs/data_v1alpha/services.rst index 58e994d92885..607505d6bd7f 100644 --- a/packages/google-analytics-data/docs/data_v1alpha/services.rst +++ b/packages/google-analytics-data/docs/data_v1alpha/services.rst @@ -1,6 +1,6 @@ Services for Google Analytics Data v1alpha API ============================================== +.. toctree:: + :maxdepth: 2 -.. automodule:: google.analytics.data_v1alpha.services.alpha_analytics_data - :members: - :inherited-members: + alpha_analytics_data diff --git a/packages/google-analytics-data/docs/data_v1alpha/types.rst b/packages/google-analytics-data/docs/data_v1alpha/types.rst index c0378d5ba6e3..84982530bfeb 100644 --- a/packages/google-analytics-data/docs/data_v1alpha/types.rst +++ b/packages/google-analytics-data/docs/data_v1alpha/types.rst @@ -3,4 +3,5 @@ Types for Google Analytics Data v1alpha API .. automodule:: google.analytics.data_v1alpha.types :members: + :undoc-members: :show-inheritance: diff --git a/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/async_client.py b/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/async_client.py index 6d78d4bb1037..cf5ba1ba81aa 100644 --- a/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/async_client.py +++ b/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/async_client.py @@ -76,6 +76,7 @@ class AlphaAnalyticsDataAsyncClient: AlphaAnalyticsDataClient.parse_common_location_path ) + from_service_account_info = AlphaAnalyticsDataClient.from_service_account_info from_service_account_file = AlphaAnalyticsDataClient.from_service_account_file from_service_account_json = from_service_account_file @@ -160,7 +161,7 @@ async def run_report( criteria, such as country or event name. Args: - request (:class:`~.analytics_data_api.RunReportRequest`): + request (:class:`google.analytics.data_v1alpha.types.RunReportRequest`): The request object. The request to generate a report. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -170,7 +171,7 @@ async def run_report( sent along with the request as metadata. Returns: - ~.analytics_data_api.RunReportResponse: + google.analytics.data_v1alpha.types.RunReportResponse: The response report table corresponding to a request. @@ -209,7 +210,7 @@ async def run_pivot_report( dissect your data. Args: - request (:class:`~.analytics_data_api.RunPivotReportRequest`): + request (:class:`google.analytics.data_v1alpha.types.RunPivotReportRequest`): The request object. The request to generate a pivot report. @@ -220,7 +221,7 @@ async def run_pivot_report( sent along with the request as metadata. Returns: - ~.analytics_data_api.RunPivotReportResponse: + google.analytics.data_v1alpha.types.RunPivotReportResponse: The response pivot report table corresponding to a pivot request. @@ -255,7 +256,7 @@ async def batch_run_reports( be for the same Entity. Args: - request (:class:`~.analytics_data_api.BatchRunReportsRequest`): + request (:class:`google.analytics.data_v1alpha.types.BatchRunReportsRequest`): The request object. The batch request containing multiple report requests. @@ -266,7 +267,7 @@ async def batch_run_reports( sent along with the request as metadata. Returns: - ~.analytics_data_api.BatchRunReportsResponse: + google.analytics.data_v1alpha.types.BatchRunReportsResponse: The batch response containing multiple reports. @@ -301,7 +302,7 @@ async def batch_run_pivot_reports( reports must be for the same Entity. Args: - request (:class:`~.analytics_data_api.BatchRunPivotReportsRequest`): + request (:class:`google.analytics.data_v1alpha.types.BatchRunPivotReportsRequest`): The request object. The batch request containing multiple pivot report requests. @@ -312,7 +313,7 @@ async def batch_run_pivot_reports( sent along with the request as metadata. Returns: - ~.analytics_data_api.BatchRunPivotReportsResponse: + google.analytics.data_v1alpha.types.BatchRunPivotReportsResponse: The batch response containing multiple pivot reports. @@ -357,7 +358,7 @@ async def get_metadata( such as ``country`` and ``totalUsers``. Args: - request (:class:`~.analytics_data_api.GetMetadataRequest`): + request (:class:`google.analytics.data_v1alpha.types.GetMetadataRequest`): The request object. Request for a property's dimension and metric metadata. name (:class:`str`): @@ -373,6 +374,7 @@ async def get_metadata( Set the Property ID to 0 for dimensions and metrics common to all properties. In this special mode, this method will not return custom dimensions and metrics. + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -384,7 +386,7 @@ async def get_metadata( sent along with the request as metadata. Returns: - ~.analytics_data_api.Metadata: + google.analytics.data_v1alpha.types.Metadata: The dimensions and metrics currently accepted in reporting methods. @@ -441,7 +443,7 @@ async def run_realtime_report( last 30 minutes. Args: - request (:class:`~.analytics_data_api.RunRealtimeReportRequest`): + request (:class:`google.analytics.data_v1alpha.types.RunRealtimeReportRequest`): The request object. The request to generate a realtime report. @@ -452,7 +454,7 @@ async def run_realtime_report( sent along with the request as metadata. Returns: - ~.analytics_data_api.RunRealtimeReportResponse: + google.analytics.data_v1alpha.types.RunRealtimeReportResponse: The response realtime report table corresponding to a request. diff --git a/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/client.py b/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/client.py index c9423d697266..682c278d513c 100644 --- a/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/client.py +++ b/packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/client.py @@ -112,6 +112,22 @@ def _get_default_mtls_endpoint(api_endpoint): DEFAULT_ENDPOINT ) + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + AlphaAnalyticsDataClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_info(info) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials @@ -124,7 +140,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): kwargs: Additional arguments to pass to the constructor. Returns: - {@api.name}: The constructed client. + AlphaAnalyticsDataClient: The constructed client. """ credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials @@ -227,10 +243,10 @@ def __init__( credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment. - transport (Union[str, ~.AlphaAnalyticsDataTransport]): The + transport (Union[str, AlphaAnalyticsDataTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (client_options_lib.ClientOptions): Custom options for the + client_options (google.api_core.client_options.ClientOptions): Custom options for the client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT @@ -347,7 +363,7 @@ def run_report( criteria, such as country or event name. Args: - request (:class:`~.analytics_data_api.RunReportRequest`): + request (google.analytics.data_v1alpha.types.RunReportRequest): The request object. The request to generate a report. retry (google.api_core.retry.Retry): Designation of what errors, if any, @@ -357,7 +373,7 @@ def run_report( sent along with the request as metadata. Returns: - ~.analytics_data_api.RunReportResponse: + google.analytics.data_v1alpha.types.RunReportResponse: The response report table corresponding to a request. @@ -397,7 +413,7 @@ def run_pivot_report( dissect your data. Args: - request (:class:`~.analytics_data_api.RunPivotReportRequest`): + request (google.analytics.data_v1alpha.types.RunPivotReportRequest): The request object. The request to generate a pivot report. @@ -408,7 +424,7 @@ def run_pivot_report( sent along with the request as metadata. Returns: - ~.analytics_data_api.RunPivotReportResponse: + google.analytics.data_v1alpha.types.RunPivotReportResponse: The response pivot report table corresponding to a pivot request. @@ -444,7 +460,7 @@ def batch_run_reports( be for the same Entity. Args: - request (:class:`~.analytics_data_api.BatchRunReportsRequest`): + request (google.analytics.data_v1alpha.types.BatchRunReportsRequest): The request object. The batch request containing multiple report requests. @@ -455,7 +471,7 @@ def batch_run_reports( sent along with the request as metadata. Returns: - ~.analytics_data_api.BatchRunReportsResponse: + google.analytics.data_v1alpha.types.BatchRunReportsResponse: The batch response containing multiple reports. @@ -491,7 +507,7 @@ def batch_run_pivot_reports( reports must be for the same Entity. Args: - request (:class:`~.analytics_data_api.BatchRunPivotReportsRequest`): + request (google.analytics.data_v1alpha.types.BatchRunPivotReportsRequest): The request object. The batch request containing multiple pivot report requests. @@ -502,7 +518,7 @@ def batch_run_pivot_reports( sent along with the request as metadata. Returns: - ~.analytics_data_api.BatchRunPivotReportsResponse: + google.analytics.data_v1alpha.types.BatchRunPivotReportsResponse: The batch response containing multiple pivot reports. @@ -548,10 +564,10 @@ def get_metadata( such as ``country`` and ``totalUsers``. Args: - request (:class:`~.analytics_data_api.GetMetadataRequest`): + request (google.analytics.data_v1alpha.types.GetMetadataRequest): The request object. Request for a property's dimension and metric metadata. - name (:class:`str`): + name (str): Required. The resource name of the metadata to retrieve. This name field is specified in the URL path and not URL parameters. Property is a numeric Google Analytics GA4 @@ -564,6 +580,7 @@ def get_metadata( Set the Property ID to 0 for dimensions and metrics common to all properties. In this special mode, this method will not return custom dimensions and metrics. + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -575,7 +592,7 @@ def get_metadata( sent along with the request as metadata. Returns: - ~.analytics_data_api.Metadata: + google.analytics.data_v1alpha.types.Metadata: The dimensions and metrics currently accepted in reporting methods. @@ -633,7 +650,7 @@ def run_realtime_report( last 30 minutes. Args: - request (:class:`~.analytics_data_api.RunRealtimeReportRequest`): + request (google.analytics.data_v1alpha.types.RunRealtimeReportRequest): The request object. The request to generate a realtime report. @@ -644,7 +661,7 @@ def run_realtime_report( sent along with the request as metadata. Returns: - ~.analytics_data_api.RunRealtimeReportResponse: + google.analytics.data_v1alpha.types.RunRealtimeReportResponse: The response realtime report table corresponding to a request. diff --git a/packages/google-analytics-data/google/analytics/data_v1alpha/types/analytics_data_api.py b/packages/google-analytics-data/google/analytics/data_v1alpha/types/analytics_data_api.py index 725b51013d5e..30a98d8c2f04 100644 --- a/packages/google-analytics-data/google/analytics/data_v1alpha/types/analytics_data_api.py +++ b/packages/google-analytics-data/google/analytics/data_v1alpha/types/analytics_data_api.py @@ -47,9 +47,9 @@ class Metadata(proto.Message): Attributes: name (str): Resource name of this metadata. - dimensions (Sequence[~.data.DimensionMetadata]): + dimensions (Sequence[google.analytics.data_v1alpha.types.DimensionMetadata]): The dimension descriptions. - metrics (Sequence[~.data.MetricMetadata]): + metrics (Sequence[google.analytics.data_v1alpha.types.MetricMetadata]): The metric descriptions. """ @@ -66,16 +66,16 @@ class RunReportRequest(proto.Message): r"""The request to generate a report. Attributes: - entity (~.data.Entity): + entity (google.analytics.data_v1alpha.types.Entity): A property whose events are tracked. Within a batch request, this entity should either be unspecified or consistent with the batch-level entity. - dimensions (Sequence[~.data.Dimension]): + dimensions (Sequence[google.analytics.data_v1alpha.types.Dimension]): The dimensions requested and displayed. - metrics (Sequence[~.data.Metric]): + metrics (Sequence[google.analytics.data_v1alpha.types.Metric]): The metrics requested and displayed. - date_ranges (Sequence[~.data.DateRange]): + date_ranges (Sequence[google.analytics.data_v1alpha.types.DateRange]): Date ranges of data to read. If multiple date ranges are requested, each response row will contain a zero based date range index. If two date ranges overlap, the event data for @@ -94,28 +94,28 @@ class RunReportRequest(proto.Message): To learn more about this pagination parameter, see `Pagination `__. - metric_aggregations (Sequence[~.data.MetricAggregation]): + metric_aggregations (Sequence[google.analytics.data_v1alpha.types.MetricAggregation]): Aggregation of metrics. Aggregated metric values will be shown in rows where the dimension_values are set to "RESERVED_(MetricAggregation)". - dimension_filter (~.data.FilterExpression): + dimension_filter (google.analytics.data_v1alpha.types.FilterExpression): The filter clause of dimensions. Dimensions must be requested to be used in this filter. Metrics cannot be used in this filter. - metric_filter (~.data.FilterExpression): + metric_filter (google.analytics.data_v1alpha.types.FilterExpression): The filter clause of metrics. Applied at post aggregation phase, similar to SQL having-clause. Metrics must be requested to be used in this filter. Dimensions cannot be used in this filter. - order_bys (Sequence[~.data.OrderBy]): + order_bys (Sequence[google.analytics.data_v1alpha.types.OrderBy]): Specifies how rows are ordered in the response. currency_code (str): A currency code in ISO4217 format, such as "AED", "USD", "JPY". If the field is empty, the report uses the entity's default currency. - cohort_spec (~.data.CohortSpec): + cohort_spec (google.analytics.data_v1alpha.types.CohortSpec): Cohort group associated with this request. If there is a cohort group in the request the 'cohort' dimension must be present. @@ -167,23 +167,23 @@ class RunReportResponse(proto.Message): r"""The response report table corresponding to a request. Attributes: - dimension_headers (Sequence[~.data.DimensionHeader]): + dimension_headers (Sequence[google.analytics.data_v1alpha.types.DimensionHeader]): Describes dimension columns. The number of DimensionHeaders and ordering of DimensionHeaders matches the dimensions present in rows. - metric_headers (Sequence[~.data.MetricHeader]): + metric_headers (Sequence[google.analytics.data_v1alpha.types.MetricHeader]): Describes metric columns. The number of MetricHeaders and ordering of MetricHeaders matches the metrics present in rows. - rows (Sequence[~.data.Row]): + rows (Sequence[google.analytics.data_v1alpha.types.Row]): Rows of dimension value combinations and metric values in the report. - totals (Sequence[~.data.Row]): + totals (Sequence[google.analytics.data_v1alpha.types.Row]): If requested, the totaled values of metrics. - maximums (Sequence[~.data.Row]): + maximums (Sequence[google.analytics.data_v1alpha.types.Row]): If requested, the maximum values of metrics. - minimums (Sequence[~.data.Row]): + minimums (Sequence[google.analytics.data_v1alpha.types.Row]): If requested, the minimum values of metrics. row_count (int): The total number of rows in the query result, regardless of @@ -194,9 +194,9 @@ class RunReportResponse(proto.Message): To learn more about this pagination parameter, see `Pagination `__. - metadata (~.data.ResponseMetaData): + metadata (google.analytics.data_v1alpha.types.ResponseMetaData): Metadata for the report. - property_quota (~.data.PropertyQuota): + property_quota (google.analytics.data_v1alpha.types.PropertyQuota): This Analytics Property's quota state including this request. """ @@ -228,30 +228,30 @@ class RunPivotReportRequest(proto.Message): r"""The request to generate a pivot report. Attributes: - entity (~.data.Entity): + entity (google.analytics.data_v1alpha.types.Entity): A property whose events are tracked. Within a batch request, this entity should either be unspecified or consistent with the batch-level entity. - dimensions (Sequence[~.data.Dimension]): + dimensions (Sequence[google.analytics.data_v1alpha.types.Dimension]): The dimensions requested. All defined dimensions must be used by one of the following: dimension_expression, dimension_filter, pivots, order_bys. - metrics (Sequence[~.data.Metric]): + metrics (Sequence[google.analytics.data_v1alpha.types.Metric]): The metrics requested, at least one metric needs to be specified. All defined metrics must be used by one of the following: metric_expression, metric_filter, order_bys. - dimension_filter (~.data.FilterExpression): + dimension_filter (google.analytics.data_v1alpha.types.FilterExpression): The filter clause of dimensions. Dimensions must be requested to be used in this filter. Metrics cannot be used in this filter. - metric_filter (~.data.FilterExpression): + metric_filter (google.analytics.data_v1alpha.types.FilterExpression): The filter clause of metrics. Applied at post aggregation phase, similar to SQL having-clause. Metrics must be requested to be used in this filter. Dimensions cannot be used in this filter. - pivots (Sequence[~.data.Pivot]): + pivots (Sequence[google.analytics.data_v1alpha.types.Pivot]): Describes the visual format of the report's dimensions in columns or rows. The union of the fieldNames (dimension names) in all pivots must @@ -259,7 +259,7 @@ class RunPivotReportRequest(proto.Message): Dimensions. No two pivots can share a dimension. A dimension is only visible if it appears in a pivot. - date_ranges (Sequence[~.data.DateRange]): + date_ranges (Sequence[google.analytics.data_v1alpha.types.DateRange]): The date range to retrieve event data for the report. If multiple date ranges are specified, event data from each date range is used in the report. A special dimension with @@ -271,7 +271,7 @@ class RunPivotReportRequest(proto.Message): A currency code in ISO4217 format, such as "AED", "USD", "JPY". If the field is empty, the report uses the entity's default currency. - cohort_spec (~.data.CohortSpec): + cohort_spec (google.analytics.data_v1alpha.types.CohortSpec): Cohort group associated with this request. If there is a cohort group in the request the 'cohort' dimension must be present. @@ -316,7 +316,7 @@ class RunPivotReportResponse(proto.Message): request. Attributes: - pivot_headers (Sequence[~.data.PivotHeader]): + pivot_headers (Sequence[google.analytics.data_v1alpha.types.PivotHeader]): Summarizes the columns and rows created by a pivot. Each pivot in the request produces one header in the response. If we have a request like this: @@ -357,27 +357,27 @@ class RunPivotReportResponse(proto.Message): "dimensionValues": [{ "value": "scroll" }] }] }] - dimension_headers (Sequence[~.data.DimensionHeader]): + dimension_headers (Sequence[google.analytics.data_v1alpha.types.DimensionHeader]): Describes dimension columns. The number of DimensionHeaders and ordering of DimensionHeaders matches the dimensions present in rows. - metric_headers (Sequence[~.data.MetricHeader]): + metric_headers (Sequence[google.analytics.data_v1alpha.types.MetricHeader]): Describes metric columns. The number of MetricHeaders and ordering of MetricHeaders matches the metrics present in rows. - rows (Sequence[~.data.Row]): + rows (Sequence[google.analytics.data_v1alpha.types.Row]): Rows of dimension value combinations and metric values in the report. - aggregates (Sequence[~.data.Row]): + aggregates (Sequence[google.analytics.data_v1alpha.types.Row]): Aggregation of metric values. Can be totals, minimums, or maximums. The returned aggregations are controlled by the metric_aggregations in the pivot. The type of aggregation returned in each row is shown by the dimension_values which are set to "RESERVED\_". - metadata (~.data.ResponseMetaData): + metadata (google.analytics.data_v1alpha.types.ResponseMetaData): Metadata for the report. - property_quota (~.data.PropertyQuota): + property_quota (google.analytics.data_v1alpha.types.PropertyQuota): This Analytics Property's quota state including this request. """ @@ -407,12 +407,12 @@ class BatchRunReportsRequest(proto.Message): r"""The batch request containing multiple report requests. Attributes: - entity (~.data.Entity): + entity (google.analytics.data_v1alpha.types.Entity): A property whose events are tracked. This entity must be specified for the batch. The entity within RunReportRequest may either be unspecified or consistent with this entity. - requests (Sequence[~.analytics_data_api.RunReportRequest]): + requests (Sequence[google.analytics.data_v1alpha.types.RunReportRequest]): Individual requests. Each request has a separate report response. Each batch request is allowed up to 5 requests. @@ -427,7 +427,7 @@ class BatchRunReportsResponse(proto.Message): r"""The batch response containing multiple reports. Attributes: - reports (Sequence[~.analytics_data_api.RunReportResponse]): + reports (Sequence[google.analytics.data_v1alpha.types.RunReportResponse]): Individual responses. Each response has a separate report request. """ @@ -439,12 +439,12 @@ class BatchRunPivotReportsRequest(proto.Message): r"""The batch request containing multiple pivot report requests. Attributes: - entity (~.data.Entity): + entity (google.analytics.data_v1alpha.types.Entity): A property whose events are tracked. This entity must be specified for the batch. The entity within RunPivotReportRequest may either be unspecified or consistent with this entity. - requests (Sequence[~.analytics_data_api.RunPivotReportRequest]): + requests (Sequence[google.analytics.data_v1alpha.types.RunPivotReportRequest]): Individual requests. Each request has a separate pivot report response. Each batch request is allowed up to 5 requests. @@ -461,7 +461,7 @@ class BatchRunPivotReportsResponse(proto.Message): r"""The batch response containing multiple pivot reports. Attributes: - pivot_reports (Sequence[~.analytics_data_api.RunPivotReportResponse]): + pivot_reports (Sequence[google.analytics.data_v1alpha.types.RunPivotReportResponse]): Individual responses. Each response has a separate pivot report request. """ @@ -504,29 +504,29 @@ class RunRealtimeReportRequest(proto.Message): ID `__. Example: properties/1234 - dimensions (Sequence[~.data.Dimension]): + dimensions (Sequence[google.analytics.data_v1alpha.types.Dimension]): The dimensions requested and displayed. - metrics (Sequence[~.data.Metric]): + metrics (Sequence[google.analytics.data_v1alpha.types.Metric]): The metrics requested and displayed. limit (int): The number of rows to return. If unspecified, 10 rows are returned. If -1, all rows are returned. - dimension_filter (~.data.FilterExpression): + dimension_filter (google.analytics.data_v1alpha.types.FilterExpression): The filter clause of dimensions. Dimensions must be requested to be used in this filter. Metrics cannot be used in this filter. - metric_filter (~.data.FilterExpression): + metric_filter (google.analytics.data_v1alpha.types.FilterExpression): The filter clause of metrics. Applied at post aggregation phase, similar to SQL having-clause. Metrics must be requested to be used in this filter. Dimensions cannot be used in this filter. - metric_aggregations (Sequence[~.data.MetricAggregation]): + metric_aggregations (Sequence[google.analytics.data_v1alpha.types.MetricAggregation]): Aggregation of metrics. Aggregated metric values will be shown in rows where the dimension_values are set to "RESERVED_(MetricAggregation)". - order_bys (Sequence[~.data.OrderBy]): + order_bys (Sequence[google.analytics.data_v1alpha.types.OrderBy]): Specifies how rows are ordered in the response. return_property_quota (bool): @@ -563,23 +563,23 @@ class RunRealtimeReportResponse(proto.Message): request. Attributes: - dimension_headers (Sequence[~.data.DimensionHeader]): + dimension_headers (Sequence[google.analytics.data_v1alpha.types.DimensionHeader]): Describes dimension columns. The number of DimensionHeaders and ordering of DimensionHeaders matches the dimensions present in rows. - metric_headers (Sequence[~.data.MetricHeader]): + metric_headers (Sequence[google.analytics.data_v1alpha.types.MetricHeader]): Describes metric columns. The number of MetricHeaders and ordering of MetricHeaders matches the metrics present in rows. - rows (Sequence[~.data.Row]): + rows (Sequence[google.analytics.data_v1alpha.types.Row]): Rows of dimension value combinations and metric values in the report. - totals (Sequence[~.data.Row]): + totals (Sequence[google.analytics.data_v1alpha.types.Row]): If requested, the totaled values of metrics. - maximums (Sequence[~.data.Row]): + maximums (Sequence[google.analytics.data_v1alpha.types.Row]): If requested, the maximum values of metrics. - minimums (Sequence[~.data.Row]): + minimums (Sequence[google.analytics.data_v1alpha.types.Row]): If requested, the minimum values of metrics. row_count (int): The total number of rows in the query result, regardless of @@ -587,7 +587,7 @@ class RunRealtimeReportResponse(proto.Message): a query returns 175 rows and includes limit = 50 in the API request, the response will contain row_count = 175 but only 50 rows. - property_quota (~.data.PropertyQuota): + property_quota (google.analytics.data_v1alpha.types.PropertyQuota): This Analytics Property's Realtime quota state including this request. """ diff --git a/packages/google-analytics-data/google/analytics/data_v1alpha/types/data.py b/packages/google-analytics-data/google/analytics/data_v1alpha/types/data.py index fdfe828927b4..05606cbe2578 100644 --- a/packages/google-analytics-data/google/analytics/data_v1alpha/types/data.py +++ b/packages/google-analytics-data/google/analytics/data_v1alpha/types/data.py @@ -147,7 +147,7 @@ class Dimension(proto.Message): Dimensions are referenced by ``name`` in ``dimensionFilter``, ``orderBys``, ``dimensionExpression``, and ``pivots``. - dimension_expression (~.data.DimensionExpression): + dimension_expression (google.analytics.data_v1alpha.types.DimensionExpression): One dimension can be the result of an expression of multiple dimensions. For example, dimension "country, city": concatenate(country, @@ -169,13 +169,13 @@ class DimensionExpression(proto.Message): 2) concatenate(dimension1, symbol, dimension2). Attributes: - lower_case (~.data.DimensionExpression.CaseExpression): + lower_case (google.analytics.data_v1alpha.types.DimensionExpression.CaseExpression): Used to convert a dimension value to lower case. - upper_case (~.data.DimensionExpression.CaseExpression): + upper_case (google.analytics.data_v1alpha.types.DimensionExpression.CaseExpression): Used to convert a dimension value to upper case. - concatenate (~.data.DimensionExpression.ConcatenateExpression): + concatenate (google.analytics.data_v1alpha.types.DimensionExpression.ConcatenateExpression): Used to combine dimension values to a single dimension. For example, dimension "country, city": concatenate(country, ", ", city). @@ -270,13 +270,13 @@ class FilterExpression(proto.Message): dimensions or all metrics. Attributes: - and_group (~.data.FilterExpressionList): + and_group (google.analytics.data_v1alpha.types.FilterExpressionList): The FilterExpressions in and_group have an AND relationship. - or_group (~.data.FilterExpressionList): + or_group (google.analytics.data_v1alpha.types.FilterExpressionList): The FilterExpressions in or_group have an OR relationship. - not_expression (~.data.FilterExpression): + not_expression (google.analytics.data_v1alpha.types.FilterExpression): The FilterExpression is NOT of not_expression. - filter (~.data.Filter): + filter (google.analytics.data_v1alpha.types.Filter): A primitive filter. All fields in filter in same FilterExpression needs to be either all dimensions or metrics. @@ -301,7 +301,7 @@ class FilterExpressionList(proto.Message): r"""A list of filter expressions. Attributes: - expressions (Sequence[~.data.FilterExpression]): + expressions (Sequence[google.analytics.data_v1alpha.types.FilterExpression]): A list of filter expressions. """ @@ -324,13 +324,13 @@ class Filter(proto.Message): expression. For example, a NOT expression of a null filter removes rows when a dimension is null. - string_filter (~.data.Filter.StringFilter): + string_filter (google.analytics.data_v1alpha.types.Filter.StringFilter): Strings related filter. - in_list_filter (~.data.Filter.InListFilter): + in_list_filter (google.analytics.data_v1alpha.types.Filter.InListFilter): A filter for in list values. - numeric_filter (~.data.Filter.NumericFilter): + numeric_filter (google.analytics.data_v1alpha.types.Filter.NumericFilter): A filter for numeric or date values. - between_filter (~.data.Filter.BetweenFilter): + between_filter (google.analytics.data_v1alpha.types.Filter.BetweenFilter): A filter for two values. """ @@ -338,7 +338,7 @@ class StringFilter(proto.Message): r"""The filter for string Attributes: - match_type (~.data.Filter.StringFilter.MatchType): + match_type (google.analytics.data_v1alpha.types.Filter.StringFilter.MatchType): The match type for this filter. value (str): The string value used for the matching. @@ -383,9 +383,9 @@ class NumericFilter(proto.Message): r"""Filters for numeric or date values. Attributes: - operation (~.data.Filter.NumericFilter.Operation): + operation (google.analytics.data_v1alpha.types.Filter.NumericFilter.Operation): The operation type for this filter. - value (~.data.NumericValue): + value (google.analytics.data_v1alpha.types.NumericValue): A numeric value or a date value. """ @@ -409,9 +409,9 @@ class BetweenFilter(proto.Message): (inclusive). Attributes: - from_value (~.data.NumericValue): + from_value (google.analytics.data_v1alpha.types.NumericValue): Begins with this number. - to_value (~.data.NumericValue): + to_value (google.analytics.data_v1alpha.types.NumericValue): Ends with this number. """ @@ -444,11 +444,11 @@ class OrderBy(proto.Message): r"""The sort options. Attributes: - metric (~.data.OrderBy.MetricOrderBy): + metric (google.analytics.data_v1alpha.types.OrderBy.MetricOrderBy): Sorts results by a metric's values. - dimension (~.data.OrderBy.DimensionOrderBy): + dimension (google.analytics.data_v1alpha.types.OrderBy.DimensionOrderBy): Sorts results by a dimension's values. - pivot (~.data.OrderBy.PivotOrderBy): + pivot (google.analytics.data_v1alpha.types.OrderBy.PivotOrderBy): Sorts results by a metric's values within a pivot column group. desc (bool): @@ -471,7 +471,7 @@ class DimensionOrderBy(proto.Message): Attributes: dimension_name (str): A dimension name in the request to order by. - order_type (~.data.OrderBy.DimensionOrderBy.OrderType): + order_type (google.analytics.data_v1alpha.types.OrderBy.DimensionOrderBy.OrderType): Controls the rule for dimension value ordering. """ @@ -497,7 +497,7 @@ class PivotOrderBy(proto.Message): In the response to order by, order rows by this column. Must be a metric name from the request. - pivot_selections (Sequence[~.data.OrderBy.PivotOrderBy.PivotSelection]): + pivot_selections (Sequence[google.analytics.data_v1alpha.types.OrderBy.PivotOrderBy.PivotSelection]): Used to select a dimension name and value pivot. If multiple pivot selections are given, the sort occurs on rows where all pivot @@ -570,7 +570,7 @@ class Pivot(proto.Message): response, dimension values in the date range column will indicate the corresponding date range from the request. - order_bys (Sequence[~.data.OrderBy]): + order_bys (Sequence[google.analytics.data_v1alpha.types.OrderBy]): Specifies how dimensions are ordered in the pivot. In the first Pivot, the OrderBys determine Row and PivotDimensionHeader ordering; in subsequent Pivots, the @@ -584,7 +584,7 @@ class Pivot(proto.Message): The number of rows to return in this pivot. If unspecified, 10 rows are returned. If -1, all rows are returned. - metric_aggregations (Sequence[~.data.MetricAggregation]): + metric_aggregations (Sequence[google.analytics.data_v1alpha.types.MetricAggregation]): Aggregate the metrics by dimensions in this pivot using the specified metric_aggregations. """ @@ -619,18 +619,18 @@ class CohortSpec(proto.Message): separate rows in the report. Attributes: - cohorts (Sequence[~.data.Cohort]): + cohorts (Sequence[google.analytics.data_v1alpha.types.Cohort]): Defines the selection criteria to group users into cohorts. Most cohort reports define only a single cohort. If multiple cohorts are specified, each cohort can be recognized in the report by their name. - cohorts_range (~.data.CohortsRange): + cohorts_range (google.analytics.data_v1alpha.types.CohortsRange): Cohort reports follow cohorts over an extended reporting date range. This range specifies an offset duration to follow the cohorts over. - cohort_report_settings (~.data.CohortReportSettings): + cohort_report_settings (google.analytics.data_v1alpha.types.CohortReportSettings): Optional settings for a cohort report. """ @@ -658,7 +658,7 @@ class Cohort(proto.Message): dimension (str): Dimension used by the cohort. Required and only supports ``firstTouchDate``. - date_range (~.data.DateRange): + date_range (google.analytics.data_v1alpha.types.DateRange): The cohort selects users whose first touch date is between start date and end date defined in the ``dateRange``. This ``dateRange`` does not specify the full date range of event @@ -694,7 +694,7 @@ class CohortsRange(proto.Message): report. Specifies an offset duration to follow the cohorts over. Attributes: - granularity (~.data.CohortsRange.Granularity): + granularity (google.analytics.data_v1alpha.types.CohortsRange.Granularity): The granularity used to interpret the ``startOffset`` and ``endOffset`` for the extended reporting date range for a cohort report. @@ -803,7 +803,7 @@ class MetricHeader(proto.Message): Attributes: name (str): The metric's name. - type_ (~.data.MetricType): + type_ (google.analytics.data_v1alpha.types.MetricType): The metric's data type. """ @@ -816,7 +816,7 @@ class PivotHeader(proto.Message): r"""Dimensions' values in a single pivot. Attributes: - pivot_dimension_headers (Sequence[~.data.PivotDimensionHeader]): + pivot_dimension_headers (Sequence[google.analytics.data_v1alpha.types.PivotDimensionHeader]): The size is the same as the cardinality of the corresponding dimension combinations. row_count (int): @@ -838,7 +838,7 @@ class PivotDimensionHeader(proto.Message): r"""Summarizes dimension values from a row for this pivot. Attributes: - dimension_values (Sequence[~.data.DimensionValue]): + dimension_values (Sequence[google.analytics.data_v1alpha.types.DimensionValue]): Values of multiple dimensions in a pivot. """ @@ -886,11 +886,11 @@ class Row(proto.Message): ] Attributes: - dimension_values (Sequence[~.data.DimensionValue]): + dimension_values (Sequence[google.analytics.data_v1alpha.types.DimensionValue]): List of requested dimension values. In a PivotReport, dimension_values are only listed for dimensions included in a pivot. - metric_values (Sequence[~.data.MetricValue]): + metric_values (Sequence[google.analytics.data_v1alpha.types.MetricValue]): List of requested visible metric values. """ @@ -945,23 +945,23 @@ class PropertyQuota(proto.Message): property will return Resource Exhausted errors. Attributes: - tokens_per_day (~.data.QuotaStatus): + tokens_per_day (google.analytics.data_v1alpha.types.QuotaStatus): Standard Analytics Properties can use up to 25,000 tokens per day; Analytics 360 Properties can use 250,000 tokens per day. Most requests consume fewer than 10 tokens. - tokens_per_hour (~.data.QuotaStatus): + tokens_per_hour (google.analytics.data_v1alpha.types.QuotaStatus): Standard Analytics Properties can use up to 5,000 tokens per day; Analytics 360 Properties can use 50,000 tokens per day. An API request consumes a single number of tokens, and that number is deducted from both the hourly and daily quotas. - concurrent_requests (~.data.QuotaStatus): + concurrent_requests (google.analytics.data_v1alpha.types.QuotaStatus): Standard Analytics Properties can send up to 10 concurrent requests; Analytics 360 Properties can use up to 50 concurrent requests. - server_errors_per_project_per_hour (~.data.QuotaStatus): + server_errors_per_project_per_hour (google.analytics.data_v1alpha.types.QuotaStatus): Standard Analytics Properties and cloud project pairs can have up to 10 server errors per hour; Analytics 360 Properties and cloud @@ -1050,7 +1050,7 @@ class MetricMetadata(proto.Message): one of ``deprecatedApiNames`` for a period of time. After the deprecation period, the metric will be available only by ``apiName``. - type_ (~.data.MetricType): + type_ (google.analytics.data_v1alpha.types.MetricType): The type of this metric. expression (str): The mathematical expression for this derived metric. Can be diff --git a/packages/google-analytics-data/synth.metadata b/packages/google-analytics-data/synth.metadata index 48b68973ad50..2197936a2a97 100644 --- a/packages/google-analytics-data/synth.metadata +++ b/packages/google-analytics-data/synth.metadata @@ -4,15 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/python-analytics-data.git", - "sha": "da441177164284a1262e44d9165d735fa83b352b" + "sha": "054c81a64157c0a8ab213daac262e51ea5dfb072" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "dd372aa22ded7a8ba6f0e03a80e06358a3fa0907", - "internalRef": "347055288" + "sha": "520682435235d9c503983a360a2090025aa47cd1", + "internalRef": "350246057" } }, { @@ -42,6 +42,7 @@ } ], "generatedFiles": [ + ".coveragerc", ".flake8", ".github/CONTRIBUTING.md", ".github/ISSUE_TEMPLATE/bug_report.md", @@ -94,6 +95,7 @@ "docs/_static/custom.css", "docs/_templates/layout.html", "docs/conf.py", + "docs/data_v1alpha/alpha_analytics_data.rst", "docs/data_v1alpha/services.rst", "docs/data_v1alpha/types.rst", "docs/multiprocessing.rst", diff --git a/packages/google-analytics-data/tests/unit/gapic/data_v1alpha/test_alpha_analytics_data.py b/packages/google-analytics-data/tests/unit/gapic/data_v1alpha/test_alpha_analytics_data.py index bf5fea1d9af9..17c8aac94199 100644 --- a/packages/google-analytics-data/tests/unit/gapic/data_v1alpha/test_alpha_analytics_data.py +++ b/packages/google-analytics-data/tests/unit/gapic/data_v1alpha/test_alpha_analytics_data.py @@ -89,8 +89,21 @@ def test__get_default_mtls_endpoint(): ) +def test_alpha_analytics_data_client_from_service_account_info(): + creds = credentials.AnonymousCredentials() + with mock.patch.object( + service_account.Credentials, "from_service_account_info" + ) as factory: + factory.return_value = creds + info = {"valid": True} + client = AlphaAnalyticsDataClient.from_service_account_info(info) + assert client.transport._credentials == creds + + assert client.transport._host == "analyticsdata.googleapis.com:443" + + @pytest.mark.parametrize( - "client_class", [AlphaAnalyticsDataClient, AlphaAnalyticsDataAsyncClient] + "client_class", [AlphaAnalyticsDataClient, AlphaAnalyticsDataAsyncClient,] ) def test_alpha_analytics_data_client_from_service_account_file(client_class): creds = credentials.AnonymousCredentials() @@ -109,7 +122,10 @@ def test_alpha_analytics_data_client_from_service_account_file(client_class): def test_alpha_analytics_data_client_get_transport_class(): transport = AlphaAnalyticsDataClient.get_transport_class() - assert transport == transports.AlphaAnalyticsDataGrpcTransport + available_transports = [ + transports.AlphaAnalyticsDataGrpcTransport, + ] + assert transport in available_transports transport = AlphaAnalyticsDataClient.get_transport_class("grpc") assert transport == transports.AlphaAnalyticsDataGrpcTransport @@ -1269,7 +1285,7 @@ def test_alpha_analytics_data_host_with_port(): def test_alpha_analytics_data_grpc_transport_channel(): - channel = grpc.insecure_channel("http://localhost/") + channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.AlphaAnalyticsDataGrpcTransport( @@ -1281,7 +1297,7 @@ def test_alpha_analytics_data_grpc_transport_channel(): def test_alpha_analytics_data_grpc_asyncio_transport_channel(): - channel = aio.insecure_channel("http://localhost/") + channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.AlphaAnalyticsDataGrpcAsyncIOTransport( @@ -1306,7 +1322,7 @@ def test_alpha_analytics_data_transport_channel_mtls_with_client_cert_source( "grpc.ssl_channel_credentials", autospec=True ) as grpc_ssl_channel_cred: with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_ssl_cred = mock.Mock() grpc_ssl_channel_cred.return_value = mock_ssl_cred @@ -1362,7 +1378,7 @@ def test_alpha_analytics_data_transport_channel_mtls_with_adc(transport_class): ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), ): with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel