Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
feat: add from_service_account_info factory and fix sphinx identifiers (
Browse files Browse the repository at this point in the history
#27)

feat: add 'from_service_account_info' factory to clients
fix: fix sphinx identifiers
PiperOrigin-RevId: 350246057

Source-Author: Google APIs <noreply@google.com>
Source-Date: Tue Jan 5 16:44:11 2021 -0800
Source-Repo: googleapis/googleapis
Source-Sha: 520682435235d9c503983a360a2090025aa47cd1
Source-Link: googleapis/googleapis@5206824
  • Loading branch information
yoshi-automation committed Jan 6, 2021
1 parent 054c81a commit 2775104
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 133 deletions.
6 changes: 6 additions & 0 deletions docs/data_v1alpha/alpha_analytics_data.rst
@@ -0,0 +1,6 @@
AlphaAnalyticsData
------------------------------------

.. automodule:: google.analytics.data_v1alpha.services.alpha_analytics_data
:members:
:inherited-members:
6 changes: 3 additions & 3 deletions 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
1 change: 1 addition & 0 deletions docs/data_v1alpha/types.rst
Expand Up @@ -3,4 +3,5 @@ Types for Google Analytics Data v1alpha API

.. automodule:: google.analytics.data_v1alpha.types
:members:
:undoc-members:
:show-inheritance:
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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`):
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit 2775104

Please sign in to comment.