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

fix: fix from_service_account_info for async clients #44

Merged
merged 2 commits into from Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -76,8 +76,36 @@ 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
@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:
AlphaAnalyticsDataAsyncClient: The constructed client.
"""
return AlphaAnalyticsDataClient.from_service_account_info.__func__(AlphaAnalyticsDataAsyncClient, info, *args, **kwargs) # type: ignore

@classmethod
def from_service_account_file(cls, filename: str, *args, **kwargs):
"""Creates an instance of this client using the provided credentials
file.

Args:
filename (str): The path to the service account private key json
file.
args: Additional arguments to pass to the constructor.
kwargs: Additional arguments to pass to the constructor.

Returns:
AlphaAnalyticsDataAsyncClient: The constructed client.
"""
return AlphaAnalyticsDataClient.from_service_account_file.__func__(AlphaAnalyticsDataAsyncClient, filename, *args, **kwargs) # type: ignore

from_service_account_json = from_service_account_file

@property
Expand Down
Expand Up @@ -77,8 +77,36 @@ class BetaAnalyticsDataAsyncClient:
BetaAnalyticsDataClient.parse_common_location_path
)

from_service_account_info = BetaAnalyticsDataClient.from_service_account_info
from_service_account_file = BetaAnalyticsDataClient.from_service_account_file
@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:
BetaAnalyticsDataAsyncClient: The constructed client.
"""
return BetaAnalyticsDataClient.from_service_account_info.__func__(BetaAnalyticsDataAsyncClient, info, *args, **kwargs) # type: ignore

@classmethod
def from_service_account_file(cls, filename: str, *args, **kwargs):
"""Creates an instance of this client using the provided credentials
file.

Args:
filename (str): The path to the service account private key json
file.
args: Additional arguments to pass to the constructor.
kwargs: Additional arguments to pass to the constructor.

Returns:
BetaAnalyticsDataAsyncClient: The constructed client.
"""
return BetaAnalyticsDataClient.from_service_account_file.__func__(BetaAnalyticsDataAsyncClient, filename, *args, **kwargs) # type: ignore

from_service_account_json = from_service_account_file

@property
Expand Down
3 changes: 3 additions & 0 deletions noxfile.py
Expand Up @@ -123,6 +123,9 @@ def system(session):
# Sanity check: Only run tests if the environment variable is set.
if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""):
session.skip("Credentials must be set via environment variable")
# Install pyopenssl for mTLS testing.
if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true":
session.install("pyopenssl")

system_test_exists = os.path.exists(system_test_path)
system_test_folder_exists = os.path.exists(system_test_folder_path)
Expand Down
124 changes: 120 additions & 4 deletions synth.metadata
Expand Up @@ -3,22 +3,30 @@
{
"git": {
"name": ".",
"remote": "git@github.com:googleapis/python-analytics-data",
"sha": "3b9a193edfba38c9e8f72580f400514fa283a79c"
"remote": "https://github.com/googleapis/python-analytics-data.git",
"sha": "58f834e80510abdcbb49801e2901e1ee44653396"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "8f117308d5bb55816953a0d6ad1a7d27a69a7d3f",
"internalRef": "361084441"
}
},
{
"git": {
"name": "synthtool",
"remote": "https://github.com/googleapis/synthtool.git",
"sha": "0199c79b8324fba66476300824aa931788c47e2d"
"sha": "0780323da96d5a53925fe0547757181fe76e8f1e"
}
},
{
"git": {
"name": "synthtool",
"remote": "https://github.com/googleapis/synthtool.git",
"sha": "0199c79b8324fba66476300824aa931788c47e2d"
"sha": "0780323da96d5a53925fe0547757181fe76e8f1e"
}
}
],
Expand All @@ -41,5 +49,113 @@
"generator": "bazel"
}
}
],
"generatedFiles": [
".coveragerc",
".flake8",
".github/CONTRIBUTING.md",
".github/ISSUE_TEMPLATE/bug_report.md",
".github/ISSUE_TEMPLATE/feature_request.md",
".github/ISSUE_TEMPLATE/support_request.md",
".github/PULL_REQUEST_TEMPLATE.md",
".github/header-checker-lint.yml",
".github/release-please.yml",
".github/snippet-bot.yml",
".gitignore",
".kokoro/build.sh",
".kokoro/continuous/common.cfg",
".kokoro/continuous/continuous.cfg",
".kokoro/docker/docs/Dockerfile",
".kokoro/docker/docs/fetch_gpg_keys.sh",
".kokoro/docs/common.cfg",
".kokoro/docs/docs-presubmit.cfg",
".kokoro/docs/docs.cfg",
".kokoro/populate-secrets.sh",
".kokoro/presubmit/common.cfg",
".kokoro/presubmit/presubmit.cfg",
".kokoro/publish-docs.sh",
".kokoro/release.sh",
".kokoro/release/common.cfg",
".kokoro/release/release.cfg",
".kokoro/samples/lint/common.cfg",
".kokoro/samples/lint/continuous.cfg",
".kokoro/samples/lint/periodic.cfg",
".kokoro/samples/lint/presubmit.cfg",
".kokoro/samples/python3.6/common.cfg",
".kokoro/samples/python3.6/continuous.cfg",
".kokoro/samples/python3.6/periodic.cfg",
".kokoro/samples/python3.6/presubmit.cfg",
".kokoro/samples/python3.7/common.cfg",
".kokoro/samples/python3.7/continuous.cfg",
".kokoro/samples/python3.7/periodic.cfg",
".kokoro/samples/python3.7/presubmit.cfg",
".kokoro/samples/python3.8/common.cfg",
".kokoro/samples/python3.8/continuous.cfg",
".kokoro/samples/python3.8/periodic.cfg",
".kokoro/samples/python3.8/presubmit.cfg",
".kokoro/test-samples.sh",
".kokoro/trampoline.sh",
".kokoro/trampoline_v2.sh",
".pre-commit-config.yaml",
".trampolinerc",
"CODE_OF_CONDUCT.md",
"CONTRIBUTING.rst",
"LICENSE",
"MANIFEST.in",
"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/data_v1beta/beta_analytics_data.rst",
"docs/data_v1beta/services.rst",
"docs/data_v1beta/types.rst",
"docs/multiprocessing.rst",
"google/analytics/data/__init__.py",
"google/analytics/data/py.typed",
"google/analytics/data_v1alpha/__init__.py",
"google/analytics/data_v1alpha/py.typed",
"google/analytics/data_v1alpha/services/__init__.py",
"google/analytics/data_v1alpha/services/alpha_analytics_data/__init__.py",
"google/analytics/data_v1alpha/services/alpha_analytics_data/async_client.py",
"google/analytics/data_v1alpha/services/alpha_analytics_data/client.py",
"google/analytics/data_v1alpha/services/alpha_analytics_data/transports/__init__.py",
"google/analytics/data_v1alpha/services/alpha_analytics_data/transports/base.py",
"google/analytics/data_v1alpha/services/alpha_analytics_data/transports/grpc.py",
"google/analytics/data_v1alpha/services/alpha_analytics_data/transports/grpc_asyncio.py",
"google/analytics/data_v1alpha/types/__init__.py",
"google/analytics/data_v1alpha/types/analytics_data_api.py",
"google/analytics/data_v1alpha/types/data.py",
"google/analytics/data_v1beta/__init__.py",
"google/analytics/data_v1beta/py.typed",
"google/analytics/data_v1beta/services/__init__.py",
"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",
"google/analytics/data_v1beta/services/beta_analytics_data/transports/grpc_asyncio.py",
"google/analytics/data_v1beta/types/__init__.py",
"google/analytics/data_v1beta/types/analytics_data_api.py",
"google/analytics/data_v1beta/types/data.py",
"mypy.ini",
"noxfile.py",
"renovate.json",
"scripts/decrypt-secrets.sh",
"scripts/readme-gen/readme_gen.py",
"scripts/readme-gen/templates/README.tmpl.rst",
"scripts/readme-gen/templates/auth.tmpl.rst",
"scripts/readme-gen/templates/auth_api_key.tmpl.rst",
"scripts/readme-gen/templates/install_deps.tmpl.rst",
"scripts/readme-gen/templates/install_portaudio.tmpl.rst",
"setup.cfg",
"testing/.gitignore",
"tests/unit/gapic/data_v1alpha/__init__.py",
"tests/unit/gapic/data_v1alpha/test_alpha_analytics_data.py",
"tests/unit/gapic/data_v1beta/__init__.py",
"tests/unit/gapic/data_v1beta/test_beta_analytics_data.py"
]
}
15 changes: 15 additions & 0 deletions tests/unit/gapic/data_v1alpha/__init__.py
@@ -1 +1,16 @@
# -*- 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.
#