Skip to content

Commit cc88dbc

Browse files
fix: fix from_service_account_info for async clients (#44)
* test: install pyopenssl for mtls testing Source-Author: arithmetic1728 <[email protected]> Source-Date: Tue Mar 2 12:27:56 2021 -0800 Source-Repo: googleapis/synthtool Source-Sha: 0780323da96d5a53925fe0547757181fe76e8f1e Source-Link: googleapis/synthtool@0780323
1 parent 8464436 commit cc88dbc

File tree

8 files changed

+433
-12
lines changed

8 files changed

+433
-12
lines changed

packages/google-analytics-data/google/analytics/data_v1alpha/services/alpha_analytics_data/async_client.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,36 @@ class AlphaAnalyticsDataAsyncClient:
7676
AlphaAnalyticsDataClient.parse_common_location_path
7777
)
7878

79-
from_service_account_info = AlphaAnalyticsDataClient.from_service_account_info
80-
from_service_account_file = AlphaAnalyticsDataClient.from_service_account_file
79+
@classmethod
80+
def from_service_account_info(cls, info: dict, *args, **kwargs):
81+
"""Creates an instance of this client using the provided credentials info.
82+
83+
Args:
84+
info (dict): The service account private key info.
85+
args: Additional arguments to pass to the constructor.
86+
kwargs: Additional arguments to pass to the constructor.
87+
88+
Returns:
89+
AlphaAnalyticsDataAsyncClient: The constructed client.
90+
"""
91+
return AlphaAnalyticsDataClient.from_service_account_info.__func__(AlphaAnalyticsDataAsyncClient, info, *args, **kwargs) # type: ignore
92+
93+
@classmethod
94+
def from_service_account_file(cls, filename: str, *args, **kwargs):
95+
"""Creates an instance of this client using the provided credentials
96+
file.
97+
98+
Args:
99+
filename (str): The path to the service account private key json
100+
file.
101+
args: Additional arguments to pass to the constructor.
102+
kwargs: Additional arguments to pass to the constructor.
103+
104+
Returns:
105+
AlphaAnalyticsDataAsyncClient: The constructed client.
106+
"""
107+
return AlphaAnalyticsDataClient.from_service_account_file.__func__(AlphaAnalyticsDataAsyncClient, filename, *args, **kwargs) # type: ignore
108+
81109
from_service_account_json = from_service_account_file
82110

83111
@property

packages/google-analytics-data/google/analytics/data_v1beta/services/beta_analytics_data/async_client.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,36 @@ class BetaAnalyticsDataAsyncClient:
7777
BetaAnalyticsDataClient.parse_common_location_path
7878
)
7979

80-
from_service_account_info = BetaAnalyticsDataClient.from_service_account_info
81-
from_service_account_file = BetaAnalyticsDataClient.from_service_account_file
80+
@classmethod
81+
def from_service_account_info(cls, info: dict, *args, **kwargs):
82+
"""Creates an instance of this client using the provided credentials info.
83+
84+
Args:
85+
info (dict): The service account private key info.
86+
args: Additional arguments to pass to the constructor.
87+
kwargs: Additional arguments to pass to the constructor.
88+
89+
Returns:
90+
BetaAnalyticsDataAsyncClient: The constructed client.
91+
"""
92+
return BetaAnalyticsDataClient.from_service_account_info.__func__(BetaAnalyticsDataAsyncClient, info, *args, **kwargs) # type: ignore
93+
94+
@classmethod
95+
def from_service_account_file(cls, filename: str, *args, **kwargs):
96+
"""Creates an instance of this client using the provided credentials
97+
file.
98+
99+
Args:
100+
filename (str): The path to the service account private key json
101+
file.
102+
args: Additional arguments to pass to the constructor.
103+
kwargs: Additional arguments to pass to the constructor.
104+
105+
Returns:
106+
BetaAnalyticsDataAsyncClient: The constructed client.
107+
"""
108+
return BetaAnalyticsDataClient.from_service_account_file.__func__(BetaAnalyticsDataAsyncClient, filename, *args, **kwargs) # type: ignore
109+
82110
from_service_account_json = from_service_account_file
83111

84112
@property

packages/google-analytics-data/noxfile.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ def system(session):
123123
# Sanity check: Only run tests if the environment variable is set.
124124
if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""):
125125
session.skip("Credentials must be set via environment variable")
126+
# Install pyopenssl for mTLS testing.
127+
if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true":
128+
session.install("pyopenssl")
126129

127130
system_test_exists = os.path.exists(system_test_path)
128131
system_test_folder_exists = os.path.exists(system_test_folder_path)

packages/google-analytics-data/synth.metadata

Lines changed: 120 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,30 @@
33
{
44
"git": {
55
"name": ".",
6-
"remote": "[email protected]:googleapis/python-analytics-data",
7-
"sha": "3b9a193edfba38c9e8f72580f400514fa283a79c"
6+
"remote": "https://github.com/googleapis/python-analytics-data.git",
7+
"sha": "58f834e80510abdcbb49801e2901e1ee44653396"
8+
}
9+
},
10+
{
11+
"git": {
12+
"name": "googleapis",
13+
"remote": "https://github.com/googleapis/googleapis.git",
14+
"sha": "8f117308d5bb55816953a0d6ad1a7d27a69a7d3f",
15+
"internalRef": "361084441"
816
}
917
},
1018
{
1119
"git": {
1220
"name": "synthtool",
1321
"remote": "https://github.com/googleapis/synthtool.git",
14-
"sha": "0199c79b8324fba66476300824aa931788c47e2d"
22+
"sha": "0780323da96d5a53925fe0547757181fe76e8f1e"
1523
}
1624
},
1725
{
1826
"git": {
1927
"name": "synthtool",
2028
"remote": "https://github.com/googleapis/synthtool.git",
21-
"sha": "0199c79b8324fba66476300824aa931788c47e2d"
29+
"sha": "0780323da96d5a53925fe0547757181fe76e8f1e"
2230
}
2331
}
2432
],
@@ -41,5 +49,113 @@
4149
"generator": "bazel"
4250
}
4351
}
52+
],
53+
"generatedFiles": [
54+
".coveragerc",
55+
".flake8",
56+
".github/CONTRIBUTING.md",
57+
".github/ISSUE_TEMPLATE/bug_report.md",
58+
".github/ISSUE_TEMPLATE/feature_request.md",
59+
".github/ISSUE_TEMPLATE/support_request.md",
60+
".github/PULL_REQUEST_TEMPLATE.md",
61+
".github/header-checker-lint.yml",
62+
".github/release-please.yml",
63+
".github/snippet-bot.yml",
64+
".gitignore",
65+
".kokoro/build.sh",
66+
".kokoro/continuous/common.cfg",
67+
".kokoro/continuous/continuous.cfg",
68+
".kokoro/docker/docs/Dockerfile",
69+
".kokoro/docker/docs/fetch_gpg_keys.sh",
70+
".kokoro/docs/common.cfg",
71+
".kokoro/docs/docs-presubmit.cfg",
72+
".kokoro/docs/docs.cfg",
73+
".kokoro/populate-secrets.sh",
74+
".kokoro/presubmit/common.cfg",
75+
".kokoro/presubmit/presubmit.cfg",
76+
".kokoro/publish-docs.sh",
77+
".kokoro/release.sh",
78+
".kokoro/release/common.cfg",
79+
".kokoro/release/release.cfg",
80+
".kokoro/samples/lint/common.cfg",
81+
".kokoro/samples/lint/continuous.cfg",
82+
".kokoro/samples/lint/periodic.cfg",
83+
".kokoro/samples/lint/presubmit.cfg",
84+
".kokoro/samples/python3.6/common.cfg",
85+
".kokoro/samples/python3.6/continuous.cfg",
86+
".kokoro/samples/python3.6/periodic.cfg",
87+
".kokoro/samples/python3.6/presubmit.cfg",
88+
".kokoro/samples/python3.7/common.cfg",
89+
".kokoro/samples/python3.7/continuous.cfg",
90+
".kokoro/samples/python3.7/periodic.cfg",
91+
".kokoro/samples/python3.7/presubmit.cfg",
92+
".kokoro/samples/python3.8/common.cfg",
93+
".kokoro/samples/python3.8/continuous.cfg",
94+
".kokoro/samples/python3.8/periodic.cfg",
95+
".kokoro/samples/python3.8/presubmit.cfg",
96+
".kokoro/test-samples.sh",
97+
".kokoro/trampoline.sh",
98+
".kokoro/trampoline_v2.sh",
99+
".pre-commit-config.yaml",
100+
".trampolinerc",
101+
"CODE_OF_CONDUCT.md",
102+
"CONTRIBUTING.rst",
103+
"LICENSE",
104+
"MANIFEST.in",
105+
"docs/_static/custom.css",
106+
"docs/_templates/layout.html",
107+
"docs/conf.py",
108+
"docs/data_v1alpha/alpha_analytics_data.rst",
109+
"docs/data_v1alpha/services.rst",
110+
"docs/data_v1alpha/types.rst",
111+
"docs/data_v1beta/beta_analytics_data.rst",
112+
"docs/data_v1beta/services.rst",
113+
"docs/data_v1beta/types.rst",
114+
"docs/multiprocessing.rst",
115+
"google/analytics/data/__init__.py",
116+
"google/analytics/data/py.typed",
117+
"google/analytics/data_v1alpha/__init__.py",
118+
"google/analytics/data_v1alpha/py.typed",
119+
"google/analytics/data_v1alpha/services/__init__.py",
120+
"google/analytics/data_v1alpha/services/alpha_analytics_data/__init__.py",
121+
"google/analytics/data_v1alpha/services/alpha_analytics_data/async_client.py",
122+
"google/analytics/data_v1alpha/services/alpha_analytics_data/client.py",
123+
"google/analytics/data_v1alpha/services/alpha_analytics_data/transports/__init__.py",
124+
"google/analytics/data_v1alpha/services/alpha_analytics_data/transports/base.py",
125+
"google/analytics/data_v1alpha/services/alpha_analytics_data/transports/grpc.py",
126+
"google/analytics/data_v1alpha/services/alpha_analytics_data/transports/grpc_asyncio.py",
127+
"google/analytics/data_v1alpha/types/__init__.py",
128+
"google/analytics/data_v1alpha/types/analytics_data_api.py",
129+
"google/analytics/data_v1alpha/types/data.py",
130+
"google/analytics/data_v1beta/__init__.py",
131+
"google/analytics/data_v1beta/py.typed",
132+
"google/analytics/data_v1beta/services/__init__.py",
133+
"google/analytics/data_v1beta/services/beta_analytics_data/__init__.py",
134+
"google/analytics/data_v1beta/services/beta_analytics_data/async_client.py",
135+
"google/analytics/data_v1beta/services/beta_analytics_data/client.py",
136+
"google/analytics/data_v1beta/services/beta_analytics_data/pagers.py",
137+
"google/analytics/data_v1beta/services/beta_analytics_data/transports/__init__.py",
138+
"google/analytics/data_v1beta/services/beta_analytics_data/transports/base.py",
139+
"google/analytics/data_v1beta/services/beta_analytics_data/transports/grpc.py",
140+
"google/analytics/data_v1beta/services/beta_analytics_data/transports/grpc_asyncio.py",
141+
"google/analytics/data_v1beta/types/__init__.py",
142+
"google/analytics/data_v1beta/types/analytics_data_api.py",
143+
"google/analytics/data_v1beta/types/data.py",
144+
"mypy.ini",
145+
"noxfile.py",
146+
"renovate.json",
147+
"scripts/decrypt-secrets.sh",
148+
"scripts/readme-gen/readme_gen.py",
149+
"scripts/readme-gen/templates/README.tmpl.rst",
150+
"scripts/readme-gen/templates/auth.tmpl.rst",
151+
"scripts/readme-gen/templates/auth_api_key.tmpl.rst",
152+
"scripts/readme-gen/templates/install_deps.tmpl.rst",
153+
"scripts/readme-gen/templates/install_portaudio.tmpl.rst",
154+
"setup.cfg",
155+
"testing/.gitignore",
156+
"tests/unit/gapic/data_v1alpha/__init__.py",
157+
"tests/unit/gapic/data_v1alpha/test_alpha_analytics_data.py",
158+
"tests/unit/gapic/data_v1beta/__init__.py",
159+
"tests/unit/gapic/data_v1beta/test_beta_analytics_data.py"
44160
]
45161
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
1+
# -*- coding: utf-8 -*-
12

3+
# Copyright 2020 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#

0 commit comments

Comments
 (0)