diff --git a/.coveragerc b/.coveragerc
index 9a9b9f3e..f72fce1e 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -2,7 +2,6 @@
branch = True
[report]
-fail_under = 100
show_missing = True
omit =
google/cloud/errorreporting/__init__.py
diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml
new file mode 100644
index 00000000..e2b39f94
--- /dev/null
+++ b/.github/.OwlBot.lock.yaml
@@ -0,0 +1,3 @@
+docker:
+ image: gcr.io/repo-automation-bots/owlbot-python:latest
+ digest: sha256:99d90d097e4a4710cc8658ee0b5b963f4426d0e424819787c3ac1405c9a26719
diff --git a/.github/.OwlBot.yaml b/.github/.OwlBot.yaml
new file mode 100644
index 00000000..051658f1
--- /dev/null
+++ b/.github/.OwlBot.yaml
@@ -0,0 +1,26 @@
+# Copyright 2021 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.
+
+docker:
+ image: gcr.io/repo-automation-bots/owlbot-python:latest
+
+deep-remove-regex:
+ - /owl-bot-staging
+
+deep-copy-regex:
+ - source: /google/devtools/clouderrorreporting/(v.*)/.*-py/(.*)
+ dest: /owl-bot-staging/$1/$2
+
+begin-after-commit-hash: b06c9034cfcbce180ba732d03be6526e5c8ea1bc
+
diff --git a/.github/header-checker-lint.yml b/.github/header-checker-lint.yml
index fc281c05..6fe78aa7 100644
--- a/.github/header-checker-lint.yml
+++ b/.github/header-checker-lint.yml
@@ -1,6 +1,6 @@
{"allowedCopyrightHolders": ["Google LLC"],
"allowedLicenses": ["Apache-2.0", "MIT", "BSD-3"],
- "ignoreFiles": ["**/requirements.txt", "**/requirements-test.txt"],
+ "ignoreFiles": ["**/requirements.txt", "**/requirements-test.txt", "**/__init__.py", "samples/**/constraints.txt", "samples/**/constraints-test.txt"],
"sourceFileExtensions": [
"ts",
"js",
diff --git a/.kokoro/release.sh b/.kokoro/release.sh
index 3a61da13..8a6d27b1 100755
--- a/.kokoro/release.sh
+++ b/.kokoro/release.sh
@@ -26,7 +26,7 @@ python3 -m pip install --upgrade twine wheel setuptools
export PYTHONUNBUFFERED=1
# Move into the package, build the distribution and upload.
-TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google_cloud_pypi_password")
+TWINE_PASSWORD=$(cat "${KOKORO_GFILE_DIR}/secret_manager/google-cloud-pypi-token")
cd github/python-error-reporting
python3 setup.py sdist bdist_wheel
-twine upload --username gcloudpypi --password "${TWINE_PASSWORD}" dist/*
+twine upload --username __token__ --password "${TWINE_PASSWORD}" dist/*
diff --git a/.kokoro/release/common.cfg b/.kokoro/release/common.cfg
index a0587682..beb4fc55 100644
--- a/.kokoro/release/common.cfg
+++ b/.kokoro/release/common.cfg
@@ -23,18 +23,8 @@ env_vars: {
value: "github/python-error-reporting/.kokoro/release.sh"
}
-# Fetch PyPI password
-before_action {
- fetch_keystore {
- keystore_resource {
- keystore_config_id: 73713
- keyname: "google_cloud_pypi_password"
- }
- }
-}
-
# Tokens needed to report release status back to GitHub
env_vars: {
key: "SECRET_MANAGER_KEYS"
- value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem"
-}
\ No newline at end of file
+ value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem,google-cloud-pypi-token"
+}
diff --git a/.kokoro/samples/python3.9/common.cfg b/.kokoro/samples/python3.9/common.cfg
new file mode 100644
index 00000000..4b7faa7c
--- /dev/null
+++ b/.kokoro/samples/python3.9/common.cfg
@@ -0,0 +1,40 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+# Build logs will be here
+action {
+ define_artifacts {
+ regex: "**/*sponge_log.xml"
+ }
+}
+
+# Specify which tests to run
+env_vars: {
+ key: "RUN_TESTS_SESSION"
+ value: "py-3.9"
+}
+
+# Declare build specific Cloud project.
+env_vars: {
+ key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
+ value: "python-docs-samples-tests-py39"
+}
+
+env_vars: {
+ key: "TRAMPOLINE_BUILD_FILE"
+ value: "github/python-error-reporting/.kokoro/test-samples.sh"
+}
+
+# Configure the docker image for kokoro-trampoline.
+env_vars: {
+ key: "TRAMPOLINE_IMAGE"
+ value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
+}
+
+# Download secrets for samples
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
+
+# Download trampoline resources.
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
+
+# Use the trampoline script to run in docker.
+build_file: "python-error-reporting/.kokoro/trampoline.sh"
\ No newline at end of file
diff --git a/.kokoro/samples/python3.9/continuous.cfg b/.kokoro/samples/python3.9/continuous.cfg
new file mode 100644
index 00000000..a1c8d975
--- /dev/null
+++ b/.kokoro/samples/python3.9/continuous.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "True"
+}
\ No newline at end of file
diff --git a/.kokoro/samples/python3.9/periodic-head.cfg b/.kokoro/samples/python3.9/periodic-head.cfg
new file mode 100644
index 00000000..f9cfcd33
--- /dev/null
+++ b/.kokoro/samples/python3.9/periodic-head.cfg
@@ -0,0 +1,11 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "True"
+}
+
+env_vars: {
+ key: "TRAMPOLINE_BUILD_FILE"
+ value: "github/python-pubsub/.kokoro/test-samples-against-head.sh"
+}
diff --git a/.kokoro/samples/python3.9/periodic.cfg b/.kokoro/samples/python3.9/periodic.cfg
new file mode 100644
index 00000000..50fec964
--- /dev/null
+++ b/.kokoro/samples/python3.9/periodic.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "False"
+}
\ No newline at end of file
diff --git a/.kokoro/samples/python3.9/presubmit.cfg b/.kokoro/samples/python3.9/presubmit.cfg
new file mode 100644
index 00000000..a1c8d975
--- /dev/null
+++ b/.kokoro/samples/python3.9/presubmit.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "True"
+}
\ No newline at end of file
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 32302e48..62eb5a77 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,8 +1,22 @@
+# Copyright 2021 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.
+#
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v3.4.0
+ rev: v4.0.1
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
@@ -12,6 +26,6 @@ repos:
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
- rev: 3.9.0
+ rev: 3.9.2
hooks:
- id: flake8
diff --git a/.repo-metadata.json b/.repo-metadata.json
index 549c632d..994505e1 100644
--- a/.repo-metadata.json
+++ b/.repo-metadata.json
@@ -6,6 +6,7 @@
"issue_tracker": "https://issuetracker.google.com/savedsearches/559780",
"release_level": "beta",
"language": "python",
+ "library_type": "GAPIC_COMBO",
"repo": "googleapis/python-error-reporting",
"distribution_name": "google-cloud-error-reporting",
"api_id": "clouderrorreporting.googleapis.com",
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3e874fd3..a9d149e2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,26 @@
[1]: https://pypi.org/project/google-cloud-error-reporting/#history
+## [1.2.0](https://www.github.com/googleapis/python-error-reporting/compare/v1.1.2...v1.2.0) (2021-07-01)
+
+
+### Features
+
+* add always_use_jwt_access ([#140](https://www.github.com/googleapis/python-error-reporting/issues/140)) ([2f8f790](https://www.github.com/googleapis/python-error-reporting/commit/2f8f790dd70646848afd5e5209a147b01c6f388b))
+
+
+### Bug Fixes
+
+* **deps:** add packaging requirement ([#124](https://www.github.com/googleapis/python-error-reporting/issues/124)) ([ed36389](https://www.github.com/googleapis/python-error-reporting/commit/ed3638946f8829c4d2b379785e38cc2a2228c688))
+* **deps:** widen version range on google-cloud-logging ([#133](https://www.github.com/googleapis/python-error-reporting/issues/133)) ([c5e87bb](https://www.github.com/googleapis/python-error-reporting/commit/c5e87bb8c177688833ca9524daa4e6229875627d))
+* disable always_use_jwt_access ([8aff323](https://www.github.com/googleapis/python-error-reporting/commit/8aff32330ebf544cc043bec0003140d61df7e7a1))
+* disable always_use_jwt_access ([#144](https://www.github.com/googleapis/python-error-reporting/issues/144)) ([8aff323](https://www.github.com/googleapis/python-error-reporting/commit/8aff32330ebf544cc043bec0003140d61df7e7a1))
+
+
+### Documentation
+
+* omit mention of Python 2.7 in 'CONTRIBUTING.rst' ([#1127](https://www.github.com/googleapis/python-error-reporting/issues/1127)) ([#137](https://www.github.com/googleapis/python-error-reporting/issues/137)) ([0ca7d43](https://www.github.com/googleapis/python-error-reporting/commit/0ca7d4385de86e7ff462322807a717345774c017))
+
### [1.1.2](https://www.github.com/googleapis/python-error-reporting/compare/v1.1.1...v1.1.2) (2021-04-05)
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index e3dee436..38c4688e 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -68,15 +68,12 @@ Using ``nox``
We use `nox `__ to instrument our tests.
- To test your changes, run unit tests with ``nox``::
+ $ nox -s unit
- $ nox -s unit-2.7
- $ nox -s unit-3.8
- $ ...
+- To run a single unit test::
-- Args to pytest can be passed through the nox command separated by a `--`. For
- example, to run a single test::
+ $ nox -s unit-3.9 -- -k
- $ nox -s unit-3.8 -- -k
.. note::
@@ -143,8 +140,7 @@ Running System Tests
- To run system tests, you can execute::
# Run all system tests
- $ nox -s system-3.8
- $ nox -s system-2.7
+ $ nox -s system
# Run a single system test
$ nox -s system-3.8 -- -k
@@ -152,29 +148,14 @@ Running System Tests
.. note::
- System tests are only configured to run under Python 2.7 and
- Python 3.8. For expediency, we do not run them in older versions
- of Python 3.
+ System tests are only configured to run under Python 3.8.
+ For expediency, we do not run them in older versions of Python 3.
This alone will not run the tests. You'll need to change some local
auth settings and change some configuration in your project to
run all the tests.
-- System tests will be run against an actual project and
- so you'll need to provide some environment variables to facilitate
- authentication to your project:
-
- - ``GOOGLE_APPLICATION_CREDENTIALS``: The path to a JSON key file;
- Such a file can be downloaded directly from the developer's console by clicking
- "Generate new JSON key". See private key
- `docs `__
- for more details.
-
-- Once you have downloaded your json keys, set the environment variable
- ``GOOGLE_APPLICATION_CREDENTIALS`` to the absolute path of the json file::
-
- $ export GOOGLE_APPLICATION_CREDENTIALS="/Users//path/to/app_credentials.json"
-
+- System tests will be run against an actual project. You should use local credentials from gcloud when possible. See `Best practices for application authentication `__. Some tests require a service account. For those tests see `Authenticating as a service account `__.
*************
Test Coverage
@@ -232,8 +213,8 @@ Supported versions can be found in our ``noxfile.py`` `config`_.
.. _config: https://github.com/googleapis/python-error-reporting/blob/master/noxfile.py
-We also explicitly decided to support Python 3 beginning with version
-3.6. Reasons for this include:
+We also explicitly decided to support Python 3 beginning with version 3.6.
+Reasons for this include:
- Encouraging use of newest versions of Python 3
- Taking the lead of `prominent`_ open-source `projects`_
diff --git a/SECURITY.md b/SECURITY.md
new file mode 100644
index 00000000..8b58ae9c
--- /dev/null
+++ b/SECURITY.md
@@ -0,0 +1,7 @@
+# Security Policy
+
+To report a security issue, please use [g.co/vulnz](https://g.co/vulnz).
+
+The Google Security Team will respond within 5 working days of your report on g.co/vulnz.
+
+We use g.co/vulnz for our intake, and do coordination and disclosure here using GitHub Security Advisory to privately discuss and fix the issue.
diff --git a/docs/_static/custom.css b/docs/_static/custom.css
index bcd37bbd..b0a29546 100644
--- a/docs/_static/custom.css
+++ b/docs/_static/custom.css
@@ -1,9 +1,20 @@
div#python2-eol {
border-color: red;
border-width: medium;
-}
+}
/* Ensure minimum width for 'Parameters' / 'Returns' column */
dl.field-list > dt {
min-width: 100px
}
+
+/* Insert space between methods for readability */
+dl.method {
+ padding-top: 10px;
+ padding-bottom: 10px
+}
+
+/* Insert empty space between classes */
+dl.class {
+ padding-bottom: 50px
+}
diff --git a/docs/conf.py b/docs/conf.py
index 6163e5d9..f16aa818 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -1,4 +1,17 @@
# -*- coding: utf-8 -*-
+# Copyright 2021 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.
#
# google-cloud-error-reporting documentation build configuration file
#
@@ -67,9 +80,9 @@
master_doc = "index"
# General information about the project.
-project = u"google-cloud-error-reporting"
-copyright = u"2019, Google"
-author = u"Google APIs"
+project = "google-cloud-error-reporting"
+copyright = "2019, Google"
+author = "Google APIs"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@@ -268,7 +281,7 @@
(
master_doc,
"google-cloud-error-reporting.tex",
- u"google-cloud-error-reporting Documentation",
+ "google-cloud-error-reporting Documentation",
author,
"manual",
)
@@ -303,7 +316,7 @@
(
master_doc,
"google-cloud-error-reporting",
- u"google-cloud-error-reporting Documentation",
+ "google-cloud-error-reporting Documentation",
[author],
1,
)
@@ -322,7 +335,7 @@
(
master_doc,
"google-cloud-error-reporting",
- u"google-cloud-error-reporting Documentation",
+ "google-cloud-error-reporting Documentation",
author,
"google-cloud-error-reporting",
"google-cloud-error-reporting Library",
@@ -350,6 +363,7 @@
"google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,),
"grpc": ("https://grpc.github.io/grpc/python/", None),
"proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None),
+ "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None),
}
diff --git a/docs/errorreporting_v1beta1/error_stats_service.rst b/docs/errorreporting_v1beta1/error_stats_service.rst
index 30d29e69..b798b28d 100644
--- a/docs/errorreporting_v1beta1/error_stats_service.rst
+++ b/docs/errorreporting_v1beta1/error_stats_service.rst
@@ -5,7 +5,6 @@ ErrorStatsService
:members:
:inherited-members:
-
.. automodule:: google.cloud.errorreporting_v1beta1.services.error_stats_service.pagers
:members:
:inherited-members:
diff --git a/docs/multiprocessing.rst b/docs/multiprocessing.rst
index 1cb29d4c..536d17b2 100644
--- a/docs/multiprocessing.rst
+++ b/docs/multiprocessing.rst
@@ -1,7 +1,7 @@
.. note::
- Because this client uses :mod:`grpcio` library, it is safe to
+ Because this client uses :mod:`grpc` library, it is safe to
share instances across threads. In multiprocessing scenarios, the best
practice is to create client instances *after* the invocation of
- :func:`os.fork` by :class:`multiprocessing.Pool` or
+ :func:`os.fork` by :class:`multiprocessing.pool.Pool` or
:class:`multiprocessing.Process`.
diff --git a/google/cloud/errorreporting_v1beta1/__init__.py b/google/cloud/errorreporting_v1beta1/__init__.py
index 56f82962..47c1a698 100644
--- a/google/cloud/errorreporting_v1beta1/__init__.py
+++ b/google/cloud/errorreporting_v1beta1/__init__.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,21 +15,24 @@
#
from .services.error_group_service import ErrorGroupServiceClient
+from .services.error_group_service import ErrorGroupServiceAsyncClient
from .services.error_stats_service import ErrorStatsServiceClient
+from .services.error_stats_service import ErrorStatsServiceAsyncClient
from .services.report_errors_service import ReportErrorsServiceClient
+from .services.report_errors_service import ReportErrorsServiceAsyncClient
+
from .types.common import ErrorContext
from .types.common import ErrorEvent
from .types.common import ErrorGroup
from .types.common import HttpRequestContext
-from .types.common import ResolutionStatus
from .types.common import ServiceContext
from .types.common import SourceLocation
from .types.common import TrackingIssue
+from .types.common import ResolutionStatus
from .types.error_group_service import GetGroupRequest
from .types.error_group_service import UpdateGroupRequest
from .types.error_stats_service import DeleteEventsRequest
from .types.error_stats_service import DeleteEventsResponse
-from .types.error_stats_service import ErrorGroupOrder
from .types.error_stats_service import ErrorGroupStats
from .types.error_stats_service import ListEventsRequest
from .types.error_stats_service import ListEventsResponse
@@ -39,19 +41,23 @@
from .types.error_stats_service import QueryTimeRange
from .types.error_stats_service import ServiceContextFilter
from .types.error_stats_service import TimedCount
+from .types.error_stats_service import ErrorGroupOrder
from .types.error_stats_service import TimedCountAlignment
+from .types.report_errors_service import ReportedErrorEvent
from .types.report_errors_service import ReportErrorEventRequest
from .types.report_errors_service import ReportErrorEventResponse
-from .types.report_errors_service import ReportedErrorEvent
-
__all__ = (
+ "ErrorGroupServiceAsyncClient",
+ "ErrorStatsServiceAsyncClient",
+ "ReportErrorsServiceAsyncClient",
"DeleteEventsRequest",
"DeleteEventsResponse",
"ErrorContext",
"ErrorEvent",
"ErrorGroup",
"ErrorGroupOrder",
+ "ErrorGroupServiceClient",
"ErrorGroupStats",
"ErrorStatsServiceClient",
"GetGroupRequest",
@@ -73,5 +79,4 @@
"TimedCountAlignment",
"TrackingIssue",
"UpdateGroupRequest",
- "ErrorGroupServiceClient",
)
diff --git a/google/cloud/errorreporting_v1beta1/gapic_metadata.json b/google/cloud/errorreporting_v1beta1/gapic_metadata.json
new file mode 100644
index 00000000..1b6fc5e2
--- /dev/null
+++ b/google/cloud/errorreporting_v1beta1/gapic_metadata.json
@@ -0,0 +1,111 @@
+ {
+ "comment": "This file maps proto services/RPCs to the corresponding library clients/methods",
+ "language": "python",
+ "libraryPackage": "google.cloud.errorreporting_v1beta1",
+ "protoPackage": "google.devtools.clouderrorreporting.v1beta1",
+ "schema": "1.0",
+ "services": {
+ "ErrorGroupService": {
+ "clients": {
+ "grpc": {
+ "libraryClient": "ErrorGroupServiceClient",
+ "rpcs": {
+ "GetGroup": {
+ "methods": [
+ "get_group"
+ ]
+ },
+ "UpdateGroup": {
+ "methods": [
+ "update_group"
+ ]
+ }
+ }
+ },
+ "grpc-async": {
+ "libraryClient": "ErrorGroupServiceAsyncClient",
+ "rpcs": {
+ "GetGroup": {
+ "methods": [
+ "get_group"
+ ]
+ },
+ "UpdateGroup": {
+ "methods": [
+ "update_group"
+ ]
+ }
+ }
+ }
+ }
+ },
+ "ErrorStatsService": {
+ "clients": {
+ "grpc": {
+ "libraryClient": "ErrorStatsServiceClient",
+ "rpcs": {
+ "DeleteEvents": {
+ "methods": [
+ "delete_events"
+ ]
+ },
+ "ListEvents": {
+ "methods": [
+ "list_events"
+ ]
+ },
+ "ListGroupStats": {
+ "methods": [
+ "list_group_stats"
+ ]
+ }
+ }
+ },
+ "grpc-async": {
+ "libraryClient": "ErrorStatsServiceAsyncClient",
+ "rpcs": {
+ "DeleteEvents": {
+ "methods": [
+ "delete_events"
+ ]
+ },
+ "ListEvents": {
+ "methods": [
+ "list_events"
+ ]
+ },
+ "ListGroupStats": {
+ "methods": [
+ "list_group_stats"
+ ]
+ }
+ }
+ }
+ }
+ },
+ "ReportErrorsService": {
+ "clients": {
+ "grpc": {
+ "libraryClient": "ReportErrorsServiceClient",
+ "rpcs": {
+ "ReportErrorEvent": {
+ "methods": [
+ "report_error_event"
+ ]
+ }
+ }
+ },
+ "grpc-async": {
+ "libraryClient": "ReportErrorsServiceAsyncClient",
+ "rpcs": {
+ "ReportErrorEvent": {
+ "methods": [
+ "report_error_event"
+ ]
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/google/cloud/errorreporting_v1beta1/proto/common.proto b/google/cloud/errorreporting_v1beta1/proto/common.proto
deleted file mode 100644
index e9bb321e..00000000
--- a/google/cloud/errorreporting_v1beta1/proto/common.proto
+++ /dev/null
@@ -1,196 +0,0 @@
-// Copyright 2021 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.
-
-syntax = "proto3";
-
-package google.devtools.clouderrorreporting.v1beta1;
-
-import "google/api/resource.proto";
-import "google/protobuf/timestamp.proto";
-import "google/api/annotations.proto";
-
-option cc_enable_arenas = true;
-option csharp_namespace = "Google.Cloud.ErrorReporting.V1Beta1";
-option go_package = "google.golang.org/genproto/googleapis/devtools/clouderrorreporting/v1beta1;clouderrorreporting";
-option java_multiple_files = true;
-option java_outer_classname = "CommonProto";
-option java_package = "com.google.devtools.clouderrorreporting.v1beta1";
-option php_namespace = "Google\\Cloud\\ErrorReporting\\V1beta1";
-option ruby_package = "Google::Cloud::ErrorReporting::V1beta1";
-
-// Description of a group of similar error events.
-message ErrorGroup {
- option (google.api.resource) = {
- type: "clouderrorreporting.googleapis.com/ErrorGroup"
- pattern: "projects/{project}/groups/{group}"
- };
-
- // The group resource name.
- // Example: projects/my-project-123/groups/CNSgkpnppqKCUw
- string name = 1;
-
- // Group IDs are unique for a given project. If the same kind of error
- // occurs in different service contexts, it will receive the same group ID.
- string group_id = 2;
-
- // Associated tracking issues.
- repeated TrackingIssue tracking_issues = 3;
-
- // Error group's resolution status.
- // An unspecified resolution status will be interpreted as OPEN
- ResolutionStatus resolution_status = 5;
-}
-
-// Information related to tracking the progress on resolving the error.
-message TrackingIssue {
- // A URL pointing to a related entry in an issue tracking system.
- // Example: `https://github.com/user/project/issues/4`
- string url = 1;
-}
-
-// An error event which is returned by the Error Reporting system.
-message ErrorEvent {
- // Time when the event occurred as provided in the error report.
- // If the report did not contain a timestamp, the time the error was received
- // by the Error Reporting system is used.
- google.protobuf.Timestamp event_time = 1;
-
- // The `ServiceContext` for which this error was reported.
- ServiceContext service_context = 2;
-
- // The stack trace that was reported or logged by the service.
- string message = 3;
-
- // Data about the context in which the error occurred.
- ErrorContext context = 5;
-}
-
-// Describes a running service that sends errors.
-// Its version changes over time and multiple versions can run in parallel.
-message ServiceContext {
- // An identifier of the service, such as the name of the
- // executable, job, or Google App Engine service name. This field is expected
- // to have a low number of values that are relatively stable over time, as
- // opposed to `version`, which can be changed whenever new code is deployed.
- //
- // Contains the service name for error reports extracted from Google
- // App Engine logs or `default` if the App Engine default service is used.
- string service = 2;
-
- // Represents the source code version that the developer provided,
- // which could represent a version label or a Git SHA-1 hash, for example.
- // For App Engine standard environment, the version is set to the version of
- // the app.
- string version = 3;
-
- // Type of the MonitoredResource. List of possible values:
- // https://cloud.google.com/monitoring/api/resources
- //
- // Value is set automatically for incoming errors and must not be set when
- // reporting errors.
- string resource_type = 4;
-}
-
-// A description of the context in which an error occurred.
-// This data should be provided by the application when reporting an error,
-// unless the
-// error report has been generated automatically from Google App Engine logs.
-message ErrorContext {
- // The HTTP request which was processed when the error was
- // triggered.
- HttpRequestContext http_request = 1;
-
- // The user who caused or was affected by the crash.
- // This can be a user ID, an email address, or an arbitrary token that
- // uniquely identifies the user.
- // When sending an error report, leave this field empty if the user was not
- // logged in. In this case the
- // Error Reporting system will use other data, such as remote IP address, to
- // distinguish affected users. See `affected_users_count` in
- // `ErrorGroupStats`.
- string user = 2;
-
- // The location in the source code where the decision was made to
- // report the error, usually the place where it was logged.
- // For a logged exception this would be the source line where the
- // exception is logged, usually close to the place where it was
- // caught.
- SourceLocation report_location = 3;
-}
-
-// HTTP request data that is related to a reported error.
-// This data should be provided by the application when reporting an error,
-// unless the
-// error report has been generated automatically from Google App Engine logs.
-message HttpRequestContext {
- // The type of HTTP request, such as `GET`, `POST`, etc.
- string method = 1;
-
- // The URL of the request.
- string url = 2;
-
- // The user agent information that is provided with the request.
- string user_agent = 3;
-
- // The referrer information that is provided with the request.
- string referrer = 4;
-
- // The HTTP response status code for the request.
- int32 response_status_code = 5;
-
- // The IP address from which the request originated.
- // This can be IPv4, IPv6, or a token which is derived from the
- // IP address, depending on the data that has been provided
- // in the error report.
- string remote_ip = 6;
-}
-
-// Indicates a location in the source code of the service for which errors are
-// reported. `functionName` must be provided by the application when reporting
-// an error, unless the error report contains a `message` with a supported
-// exception stack trace. All fields are optional for the later case.
-message SourceLocation {
- // The source code filename, which can include a truncated relative
- // path, or a full path from a production machine.
- string file_path = 1;
-
- // 1-based. 0 indicates that the line number is unknown.
- int32 line_number = 2;
-
- // Human-readable name of a function or method.
- // The value can include optional context like the class or package name.
- // For example, `my.package.MyClass.method` in case of Java.
- string function_name = 4;
-}
-
-// Resolution status of an error group.
-enum ResolutionStatus {
- // Status is unknown. When left unspecified in requests, it is treated like
- // OPEN.
- RESOLUTION_STATUS_UNSPECIFIED = 0;
-
- // The error group is not being addressed. This is the default for
- // new groups. It is also used for errors re-occurring after marked RESOLVED.
- OPEN = 1;
-
- // Error Group manually acknowledged, it can have an issue link attached.
- ACKNOWLEDGED = 2;
-
- // Error Group manually resolved, more events for this group are not expected
- // to occur.
- RESOLVED = 3;
-
- // The error group is muted and excluded by default on group stats requests.
- MUTED = 4;
-}
diff --git a/google/cloud/errorreporting_v1beta1/proto/error_group_service.proto b/google/cloud/errorreporting_v1beta1/proto/error_group_service.proto
deleted file mode 100644
index 0104b62d..00000000
--- a/google/cloud/errorreporting_v1beta1/proto/error_group_service.proto
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright 2021 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.
-
-syntax = "proto3";
-
-package google.devtools.clouderrorreporting.v1beta1;
-
-import "google/api/annotations.proto";
-import "google/api/client.proto";
-import "google/api/field_behavior.proto";
-import "google/api/resource.proto";
-import "google/devtools/clouderrorreporting/v1beta1/common.proto";
-
-option cc_enable_arenas = true;
-option csharp_namespace = "Google.Cloud.ErrorReporting.V1Beta1";
-option go_package = "google.golang.org/genproto/googleapis/devtools/clouderrorreporting/v1beta1;clouderrorreporting";
-option java_multiple_files = true;
-option java_outer_classname = "ErrorGroupServiceProto";
-option java_package = "com.google.devtools.clouderrorreporting.v1beta1";
-option php_namespace = "Google\\Cloud\\ErrorReporting\\V1beta1";
-option ruby_package = "Google::Cloud::ErrorReporting::V1beta1";
-
-// Service for retrieving and updating individual error groups.
-service ErrorGroupService {
- option (google.api.default_host) = "clouderrorreporting.googleapis.com";
- option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
-
- // Get the specified group.
- rpc GetGroup(GetGroupRequest) returns (ErrorGroup) {
- option (google.api.http) = {
- get: "/v1beta1/{group_name=projects/*/groups/*}"
- };
- option (google.api.method_signature) = "group_name";
- }
-
- // Replace the data for the specified group.
- // Fails if the group does not exist.
- rpc UpdateGroup(UpdateGroupRequest) returns (ErrorGroup) {
- option (google.api.http) = {
- put: "/v1beta1/{group.name=projects/*/groups/*}"
- body: "group"
- };
- option (google.api.method_signature) = "group";
- }
-}
-
-// A request to return an individual group.
-message GetGroupRequest {
- // Required. The group resource name. Written as
- // `projects/{projectID}/groups/{group_name}`. Call
- // [`groupStats.list`](https://cloud.google.com/error-reporting/reference/rest/v1beta1/projects.groupStats/list)
- // to return a list of groups belonging to this project.
- //
- // Example: `projects/my-project-123/groups/my-group`
- string group_name = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "clouderrorreporting.googleapis.com/ErrorGroup"
- }
- ];
-}
-
-// A request to replace the existing data for the given group.
-message UpdateGroupRequest {
- // Required. The group which replaces the resource on the server.
- ErrorGroup group = 1 [(google.api.field_behavior) = REQUIRED];
-}
diff --git a/google/cloud/errorreporting_v1beta1/proto/error_stats_service.proto b/google/cloud/errorreporting_v1beta1/proto/error_stats_service.proto
deleted file mode 100644
index 6c62edd9..00000000
--- a/google/cloud/errorreporting_v1beta1/proto/error_stats_service.proto
+++ /dev/null
@@ -1,376 +0,0 @@
-// Copyright 2021 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.
-
-syntax = "proto3";
-
-package google.devtools.clouderrorreporting.v1beta1;
-
-import "google/api/annotations.proto";
-import "google/api/client.proto";
-import "google/api/field_behavior.proto";
-import "google/api/resource.proto";
-import "google/devtools/clouderrorreporting/v1beta1/common.proto";
-import "google/protobuf/duration.proto";
-import "google/protobuf/timestamp.proto";
-
-option cc_enable_arenas = true;
-option csharp_namespace = "Google.Cloud.ErrorReporting.V1Beta1";
-option go_package = "google.golang.org/genproto/googleapis/devtools/clouderrorreporting/v1beta1;clouderrorreporting";
-option java_multiple_files = true;
-option java_outer_classname = "ErrorStatsServiceProto";
-option java_package = "com.google.devtools.clouderrorreporting.v1beta1";
-option php_namespace = "Google\\Cloud\\ErrorReporting\\V1beta1";
-option ruby_package = "Google::Cloud::ErrorReporting::V1beta1";
-
-// An API for retrieving and managing error statistics as well as data for
-// individual events.
-service ErrorStatsService {
- option (google.api.default_host) = "clouderrorreporting.googleapis.com";
- option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
-
- // Lists the specified groups.
- rpc ListGroupStats(ListGroupStatsRequest) returns (ListGroupStatsResponse) {
- option (google.api.http) = {
- get: "/v1beta1/{project_name=projects/*}/groupStats"
- };
- option (google.api.method_signature) = "project_name,time_range";
- }
-
- // Lists the specified events.
- rpc ListEvents(ListEventsRequest) returns (ListEventsResponse) {
- option (google.api.http) = {
- get: "/v1beta1/{project_name=projects/*}/events"
- };
- option (google.api.method_signature) = "project_name,group_id";
- }
-
- // Deletes all error events of a given project.
- rpc DeleteEvents(DeleteEventsRequest) returns (DeleteEventsResponse) {
- option (google.api.http) = {
- delete: "/v1beta1/{project_name=projects/*}/events"
- };
- option (google.api.method_signature) = "project_name";
- }
-}
-
-// Specifies a set of `ErrorGroupStats` to return.
-message ListGroupStatsRequest {
- // Required. The resource name of the Google Cloud Platform project. Written
- // as `projects/{projectID}` or `projects/{projectNumber}`, where `{projectID}`
- // and `{projectNumber}` can be found in the
- // [Google Cloud Console](https://support.google.com/cloud/answer/6158840).
- //
- // Examples: `projects/my-project-123`, `projects/5551234`.
- string project_name = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "cloudresourcemanager.googleapis.com/Project"
- }
- ];
-
- // Optional. List all ErrorGroupStats
with these IDs.
- repeated string group_id = 2 [(google.api.field_behavior) = OPTIONAL];
-
- // Optional. List only ErrorGroupStats
which belong to a service
- // context that matches the filter.
- // Data for all service contexts is returned if this field is not specified.
- ServiceContextFilter service_filter = 3 [(google.api.field_behavior) = OPTIONAL];
-
- // Optional. List data for the given time range.
- // If not set, a default time range is used. The field
- // time_range_begin
in the response will specify the beginning
- // of this time range.
- // Only ErrorGroupStats
with a non-zero count in the given time
- // range are returned, unless the request contains an explicit
- // group_id
list. If a group_id
list is given, also
- // ErrorGroupStats
with zero occurrences are returned.
- QueryTimeRange time_range = 5 [(google.api.field_behavior) = OPTIONAL];
-
- // Optional. The preferred duration for a single returned `TimedCount`.
- // If not set, no timed counts are returned.
- google.protobuf.Duration timed_count_duration = 6 [(google.api.field_behavior) = OPTIONAL];
-
- // Optional. The alignment of the timed counts to be returned.
- // Default is `ALIGNMENT_EQUAL_AT_END`.
- TimedCountAlignment alignment = 7 [(google.api.field_behavior) = OPTIONAL];
-
- // Optional. Time where the timed counts shall be aligned if rounded
- // alignment is chosen. Default is 00:00 UTC.
- google.protobuf.Timestamp alignment_time = 8 [(google.api.field_behavior) = OPTIONAL];
-
- // Optional. The sort order in which the results are returned.
- // Default is `COUNT_DESC`.
- ErrorGroupOrder order = 9 [(google.api.field_behavior) = OPTIONAL];
-
- // Optional. The maximum number of results to return per response.
- // Default is 20.
- int32 page_size = 11 [(google.api.field_behavior) = OPTIONAL];
-
- // Optional. A `next_page_token` provided by a previous response. To view
- // additional results, pass this token along with the identical query
- // parameters as the first request.
- string page_token = 12 [(google.api.field_behavior) = OPTIONAL];
-}
-
-// Contains a set of requested error group stats.
-message ListGroupStatsResponse {
- // The error group stats which match the given request.
- repeated ErrorGroupStats error_group_stats = 1;
-
- // If non-empty, more results are available.
- // Pass this token, along with the same query parameters as the first
- // request, to view the next page of results.
- string next_page_token = 2;
-
- // The timestamp specifies the start time to which the request was restricted.
- // The start time is set based on the requested time range. It may be adjusted
- // to a later time if a project has exceeded the storage quota and older data
- // has been deleted.
- google.protobuf.Timestamp time_range_begin = 4;
-}
-
-// Data extracted for a specific group based on certain filter criteria,
-// such as a given time period and/or service filter.
-message ErrorGroupStats {
- // Group data that is independent of the filter criteria.
- ErrorGroup group = 1;
-
- // Approximate total number of events in the given group that match
- // the filter criteria.
- int64 count = 2;
-
- // Approximate number of affected users in the given group that
- // match the filter criteria.
- // Users are distinguished by data in the `ErrorContext` of the
- // individual error events, such as their login name or their remote
- // IP address in case of HTTP requests.
- // The number of affected users can be zero even if the number of
- // errors is non-zero if no data was provided from which the
- // affected user could be deduced.
- // Users are counted based on data in the request
- // context that was provided in the error report. If more users are
- // implicitly affected, such as due to a crash of the whole service,
- // this is not reflected here.
- int64 affected_users_count = 3;
-
- // Approximate number of occurrences over time.
- // Timed counts returned by ListGroups are guaranteed to be:
- //
- // - Inside the requested time interval
- // - Non-overlapping, and
- // - Ordered by ascending time.
- repeated TimedCount timed_counts = 4;
-
- // Approximate first occurrence that was ever seen for this group
- // and which matches the given filter criteria, ignoring the
- // time_range that was specified in the request.
- google.protobuf.Timestamp first_seen_time = 5;
-
- // Approximate last occurrence that was ever seen for this group and
- // which matches the given filter criteria, ignoring the time_range
- // that was specified in the request.
- google.protobuf.Timestamp last_seen_time = 6;
-
- // Service contexts with a non-zero error count for the given filter
- // criteria. This list can be truncated if multiple services are affected.
- // Refer to `num_affected_services` for the total count.
- repeated ServiceContext affected_services = 7;
-
- // The total number of services with a non-zero error count for the given
- // filter criteria.
- int32 num_affected_services = 8;
-
- // An arbitrary event that is chosen as representative for the whole group.
- // The representative event is intended to be used as a quick preview for
- // the whole group. Events in the group are usually sufficiently similar
- // to each other such that showing an arbitrary representative provides
- // insight into the characteristics of the group as a whole.
- ErrorEvent representative = 9;
-}
-
-// The number of errors in a given time period.
-// All numbers are approximate since the error events are sampled
-// before counting them.
-message TimedCount {
- // Approximate number of occurrences in the given time period.
- int64 count = 1;
-
- // Start of the time period to which `count` refers (included).
- google.protobuf.Timestamp start_time = 2;
-
- // End of the time period to which `count` refers (excluded).
- google.protobuf.Timestamp end_time = 3;
-}
-
-// Specifies how the time periods of error group counts are aligned.
-enum TimedCountAlignment {
- // No alignment specified.
- ERROR_COUNT_ALIGNMENT_UNSPECIFIED = 0;
-
- // The time periods shall be consecutive, have width equal to the
- // requested duration, and be aligned at the `alignment_time` provided in
- // the request.
- // The `alignment_time` does not have to be inside the query period but
- // even if it is outside, only time periods are returned which overlap
- // with the query period.
- // A rounded alignment will typically result in a
- // different size of the first or the last time period.
- ALIGNMENT_EQUAL_ROUNDED = 1;
-
- // The time periods shall be consecutive, have width equal to the
- // requested duration, and be aligned at the end of the requested time
- // period. This can result in a different size of the
- // first time period.
- ALIGNMENT_EQUAL_AT_END = 2;
-}
-
-// A sorting order of error groups.
-enum ErrorGroupOrder {
- // No group order specified.
- GROUP_ORDER_UNSPECIFIED = 0;
-
- // Total count of errors in the given time window in descending order.
- COUNT_DESC = 1;
-
- // Timestamp when the group was last seen in the given time window
- // in descending order.
- LAST_SEEN_DESC = 2;
-
- // Timestamp when the group was created in descending order.
- CREATED_DESC = 3;
-
- // Number of affected users in the given time window in descending order.
- AFFECTED_USERS_DESC = 4;
-}
-
-// Specifies a set of error events to return.
-message ListEventsRequest {
- // Required. The resource name of the Google Cloud Platform project. Written
- // as `projects/{projectID}`, where `{projectID}` is the
- // [Google Cloud Platform project
- // ID](https://support.google.com/cloud/answer/6158840).
- //
- // Example: `projects/my-project-123`.
- string project_name = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "cloudresourcemanager.googleapis.com/Project"
- }
- ];
-
- // Required. The group for which events shall be returned.
- string group_id = 2 [(google.api.field_behavior) = REQUIRED];
-
- // Optional. List only ErrorGroups which belong to a service context that
- // matches the filter.
- // Data for all service contexts is returned if this field is not specified.
- ServiceContextFilter service_filter = 3 [(google.api.field_behavior) = OPTIONAL];
-
- // Optional. List only data for the given time range.
- // If not set a default time range is used. The field time_range_begin
- // in the response will specify the beginning of this time range.
- QueryTimeRange time_range = 4 [(google.api.field_behavior) = OPTIONAL];
-
- // Optional. The maximum number of results to return per response.
- int32 page_size = 6 [(google.api.field_behavior) = OPTIONAL];
-
- // Optional. A `next_page_token` provided by a previous response.
- string page_token = 7 [(google.api.field_behavior) = OPTIONAL];
-}
-
-// Contains a set of requested error events.
-message ListEventsResponse {
- // The error events which match the given request.
- repeated ErrorEvent error_events = 1;
-
- // If non-empty, more results are available.
- // Pass this token, along with the same query parameters as the first
- // request, to view the next page of results.
- string next_page_token = 2;
-
- // The timestamp specifies the start time to which the request was restricted.
- google.protobuf.Timestamp time_range_begin = 4;
-}
-
-// Requests might be rejected or the resulting timed count durations might be
-// adjusted for lower durations.
-message QueryTimeRange {
- // The supported time ranges.
- enum Period {
- // Do not use.
- PERIOD_UNSPECIFIED = 0;
-
- // Retrieve data for the last hour.
- // Recommended minimum timed count duration: 1 min.
- PERIOD_1_HOUR = 1;
-
- // Retrieve data for the last 6 hours.
- // Recommended minimum timed count duration: 10 min.
- PERIOD_6_HOURS = 2;
-
- // Retrieve data for the last day.
- // Recommended minimum timed count duration: 1 hour.
- PERIOD_1_DAY = 3;
-
- // Retrieve data for the last week.
- // Recommended minimum timed count duration: 6 hours.
- PERIOD_1_WEEK = 4;
-
- // Retrieve data for the last 30 days.
- // Recommended minimum timed count duration: 1 day.
- PERIOD_30_DAYS = 5;
- }
-
- // Restricts the query to the specified time range.
- Period period = 1;
-}
-
-// Specifies criteria for filtering a subset of service contexts.
-// The fields in the filter correspond to the fields in `ServiceContext`.
-// Only exact, case-sensitive matches are supported.
-// If a field is unset or empty, it matches arbitrary values.
-message ServiceContextFilter {
- // Optional. The exact value to match against
- // [`ServiceContext.service`](/error-reporting/reference/rest/v1beta1/ServiceContext#FIELDS.service).
- string service = 2 [(google.api.field_behavior) = OPTIONAL];
-
- // Optional. The exact value to match against
- // [`ServiceContext.version`](/error-reporting/reference/rest/v1beta1/ServiceContext#FIELDS.version).
- string version = 3 [(google.api.field_behavior) = OPTIONAL];
-
- // Optional. The exact value to match against
- // [`ServiceContext.resource_type`](/error-reporting/reference/rest/v1beta1/ServiceContext#FIELDS.resource_type).
- string resource_type = 4 [(google.api.field_behavior) = OPTIONAL];
-}
-
-// Deletes all events in the project.
-message DeleteEventsRequest {
- // Required. The resource name of the Google Cloud Platform project. Written
- // as `projects/{projectID}`, where `{projectID}` is the
- // [Google Cloud Platform project
- // ID](https://support.google.com/cloud/answer/6158840).
- //
- // Example: `projects/my-project-123`.
- string project_name = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "cloudresourcemanager.googleapis.com/Project"
- }
- ];
-}
-
-// Response message for deleting error events.
-message DeleteEventsResponse {
-
-}
diff --git a/google/cloud/errorreporting_v1beta1/proto/report_errors_service.proto b/google/cloud/errorreporting_v1beta1/proto/report_errors_service.proto
deleted file mode 100644
index cd1e5100..00000000
--- a/google/cloud/errorreporting_v1beta1/proto/report_errors_service.proto
+++ /dev/null
@@ -1,129 +0,0 @@
-// Copyright 2021 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.
-
-syntax = "proto3";
-
-package google.devtools.clouderrorreporting.v1beta1;
-
-import "google/api/annotations.proto";
-import "google/api/client.proto";
-import "google/api/field_behavior.proto";
-import "google/api/resource.proto";
-import "google/devtools/clouderrorreporting/v1beta1/common.proto";
-import "google/protobuf/timestamp.proto";
-
-option cc_enable_arenas = true;
-option csharp_namespace = "Google.Cloud.ErrorReporting.V1Beta1";
-option go_package = "google.golang.org/genproto/googleapis/devtools/clouderrorreporting/v1beta1;clouderrorreporting";
-option java_multiple_files = true;
-option java_outer_classname = "ReportErrorsServiceProto";
-option java_package = "com.google.devtools.clouderrorreporting.v1beta1";
-option php_namespace = "Google\\Cloud\\ErrorReporting\\V1beta1";
-option ruby_package = "Google::Cloud::ErrorReporting::V1beta1";
-
-// An API for reporting error events.
-service ReportErrorsService {
- option (google.api.default_host) = "clouderrorreporting.googleapis.com";
- option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
-
- // Report an individual error event and record the event to a log.
- //
- // This endpoint accepts **either** an OAuth token,
- // **or** an [API key](https://support.google.com/cloud/answer/6158862)
- // for authentication. To use an API key, append it to the URL as the value of
- // a `key` parameter. For example:
- //
- // `POST
- // https://clouderrorreporting.googleapis.com/v1beta1/{projectName}/events:report?key=123ABC456`
- //
- // **Note:** [Error Reporting](/error-reporting) is a global service built
- // on Cloud Logging and doesn't analyze logs stored
- // in regional log buckets or logs routed to other Google Cloud projects.
- //
- // For more information, see
- // [Using Error Reporting with regionalized
- // logs](/error-reporting/docs/regionalization).
- rpc ReportErrorEvent(ReportErrorEventRequest) returns (ReportErrorEventResponse) {
- option (google.api.http) = {
- post: "/v1beta1/{project_name=projects/*}/events:report"
- body: "event"
- };
- option (google.api.method_signature) = "project_name,event";
- }
-}
-
-// A request for reporting an individual error event.
-message ReportErrorEventRequest {
- // Required. The resource name of the Google Cloud Platform project. Written
- // as `projects/{projectId}`, where `{projectId}` is the
- // [Google Cloud Platform project
- // ID](https://support.google.com/cloud/answer/6158840).
- //
- // Example: // `projects/my-project-123`.
- string project_name = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "cloudresourcemanager.googleapis.com/Project"
- }
- ];
-
- // Required. The error event to be reported.
- ReportedErrorEvent event = 2 [(google.api.field_behavior) = REQUIRED];
-}
-
-// Response for reporting an individual error event.
-// Data may be added to this message in the future.
-message ReportErrorEventResponse {
-
-}
-
-// An error event which is reported to the Error Reporting system.
-message ReportedErrorEvent {
- // Optional. Time when the event occurred.
- // If not provided, the time when the event was received by the
- // Error Reporting system will be used.
- google.protobuf.Timestamp event_time = 1 [(google.api.field_behavior) = OPTIONAL];
-
- // Required. The service context in which this error has occurred.
- ServiceContext service_context = 2 [(google.api.field_behavior) = REQUIRED];
-
- // Required. The error message.
- // If no `context.reportLocation` is provided, the message must contain a
- // header (typically consisting of the exception type name and an error
- // message) and an exception stack trace in one of the supported programming
- // languages and formats.
- // Supported languages are Java, Python, JavaScript, Ruby, C#, PHP, and Go.
- // Supported stack trace formats are:
- //
- // * **Java**: Must be the return value of
- // [`Throwable.printStackTrace()`](https://docs.oracle.com/javase/7/docs/api/java/lang/Throwable.html#printStackTrace%28%29).
- // * **Python**: Must be the return value of
- // [`traceback.format_exc()`](https://docs.python.org/2/library/traceback.html#traceback.format_exc).
- // * **JavaScript**: Must be the value of
- // [`error.stack`](https://github.com/v8/v8/wiki/Stack-Trace-API) as returned
- // by V8.
- // * **Ruby**: Must contain frames returned by
- // [`Exception.backtrace`](https://ruby-doc.org/core-2.2.0/Exception.html#method-i-backtrace).
- // * **C#**: Must be the return value of
- // [`Exception.ToString()`](https://msdn.microsoft.com/en-us/library/system.exception.tostring.aspx).
- // * **PHP**: Must start with `PHP (Notice|Parse error|Fatal error|Warning)`
- // and contain the result of
- // [`(string)$exception`](http://php.net/manual/en/exception.tostring.php).
- // * **Go**: Must be the return value of
- // [`runtime.Stack()`](https://golang.org/pkg/runtime/debug/#Stack).
- string message = 3 [(google.api.field_behavior) = REQUIRED];
-
- // Optional. A description of the context in which the error occurred.
- ErrorContext context = 4 [(google.api.field_behavior) = OPTIONAL];
-}
diff --git a/google/cloud/errorreporting_v1beta1/services/__init__.py b/google/cloud/errorreporting_v1beta1/services/__init__.py
index 42ffdf2b..4de65971 100644
--- a/google/cloud/errorreporting_v1beta1/services/__init__.py
+++ b/google/cloud/errorreporting_v1beta1/services/__init__.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/google/cloud/errorreporting_v1beta1/services/error_group_service/__init__.py b/google/cloud/errorreporting_v1beta1/services/error_group_service/__init__.py
index aff59ad1..87f6a56f 100644
--- a/google/cloud/errorreporting_v1beta1/services/error_group_service/__init__.py
+++ b/google/cloud/errorreporting_v1beta1/services/error_group_service/__init__.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
from .client import ErrorGroupServiceClient
from .async_client import ErrorGroupServiceAsyncClient
diff --git a/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py b/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py
index e2af4bb2..21e47951 100644
--- a/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py
+++ b/google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
from collections import OrderedDict
import functools
import re
@@ -22,15 +20,14 @@
import pkg_resources
import google.api_core.client_options as ClientOptions # type: ignore
-from google.api_core import exceptions # type: ignore
+from google.api_core import exceptions as core_exceptions # type: ignore
from google.api_core import gapic_v1 # type: ignore
from google.api_core import retry as retries # type: ignore
-from google.auth import credentials # type: ignore
+from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore
from google.cloud.errorreporting_v1beta1.types import common
from google.cloud.errorreporting_v1beta1.types import error_group_service
-
from .transports.base import ErrorGroupServiceTransport, DEFAULT_CLIENT_INFO
from .transports.grpc_asyncio import ErrorGroupServiceGrpcAsyncIOTransport
from .client import ErrorGroupServiceClient
@@ -48,31 +45,26 @@ class ErrorGroupServiceAsyncClient:
parse_error_group_path = staticmethod(
ErrorGroupServiceClient.parse_error_group_path
)
-
common_billing_account_path = staticmethod(
ErrorGroupServiceClient.common_billing_account_path
)
parse_common_billing_account_path = staticmethod(
ErrorGroupServiceClient.parse_common_billing_account_path
)
-
common_folder_path = staticmethod(ErrorGroupServiceClient.common_folder_path)
parse_common_folder_path = staticmethod(
ErrorGroupServiceClient.parse_common_folder_path
)
-
common_organization_path = staticmethod(
ErrorGroupServiceClient.common_organization_path
)
parse_common_organization_path = staticmethod(
ErrorGroupServiceClient.parse_common_organization_path
)
-
common_project_path = staticmethod(ErrorGroupServiceClient.common_project_path)
parse_common_project_path = staticmethod(
ErrorGroupServiceClient.parse_common_project_path
)
-
common_location_path = staticmethod(ErrorGroupServiceClient.common_location_path)
parse_common_location_path = staticmethod(
ErrorGroupServiceClient.parse_common_location_path
@@ -80,7 +72,8 @@ class ErrorGroupServiceAsyncClient:
@classmethod
def from_service_account_info(cls, info: dict, *args, **kwargs):
- """Creates an instance of this client using the provided credentials info.
+ """Creates an instance of this client using the provided credentials
+ info.
Args:
info (dict): The service account private key info.
@@ -95,7 +88,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
@classmethod
def from_service_account_file(cls, filename: str, *args, **kwargs):
"""Creates an instance of this client using the provided credentials
- file.
+ file.
Args:
filename (str): The path to the service account private key json
@@ -112,7 +105,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
@property
def transport(self) -> ErrorGroupServiceTransport:
- """Return the transport used by the client instance.
+ """Returns the transport used by the client instance.
Returns:
ErrorGroupServiceTransport: The transport used by the client instance.
@@ -126,12 +119,12 @@ def transport(self) -> ErrorGroupServiceTransport:
def __init__(
self,
*,
- credentials: credentials.Credentials = None,
+ credentials: ga_credentials.Credentials = None,
transport: Union[str, ErrorGroupServiceTransport] = "grpc_asyncio",
client_options: ClientOptions = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
- """Instantiate the error group service client.
+ """Instantiates the error group service client.
Args:
credentials (Optional[google.auth.credentials.Credentials]): The
@@ -163,7 +156,6 @@ def __init__(
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
creation failed for any reason.
"""
-
self._client = ErrorGroupServiceClient(
credentials=credentials,
transport=transport,
@@ -197,7 +189,6 @@ async def get_group(
This corresponds to the ``group_name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
@@ -224,7 +215,6 @@ async def get_group(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
-
if group_name is not None:
request.group_name = group_name
@@ -273,7 +263,6 @@ async def update_group(
This corresponds to the ``group`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
@@ -300,7 +289,6 @@ async def update_group(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
-
if group is not None:
request.group = group
diff --git a/google/cloud/errorreporting_v1beta1/services/error_group_service/client.py b/google/cloud/errorreporting_v1beta1/services/error_group_service/client.py
index db374a93..969077fd 100644
--- a/google/cloud/errorreporting_v1beta1/services/error_group_service/client.py
+++ b/google/cloud/errorreporting_v1beta1/services/error_group_service/client.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
from collections import OrderedDict
from distutils import util
import os
@@ -23,10 +21,10 @@
import pkg_resources
from google.api_core import client_options as client_options_lib # type: ignore
-from google.api_core import exceptions # type: ignore
+from google.api_core import exceptions as core_exceptions # type: ignore
from google.api_core import gapic_v1 # type: ignore
from google.api_core import retry as retries # type: ignore
-from google.auth import credentials # type: ignore
+from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport import mtls # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
from google.auth.exceptions import MutualTLSChannelError # type: ignore
@@ -34,7 +32,6 @@
from google.cloud.errorreporting_v1beta1.types import common
from google.cloud.errorreporting_v1beta1.types import error_group_service
-
from .transports.base import ErrorGroupServiceTransport, DEFAULT_CLIENT_INFO
from .transports.grpc import ErrorGroupServiceGrpcTransport
from .transports.grpc_asyncio import ErrorGroupServiceGrpcAsyncIOTransport
@@ -57,7 +54,7 @@ class ErrorGroupServiceClientMeta(type):
def get_transport_class(
cls, label: str = None,
) -> Type[ErrorGroupServiceTransport]:
- """Return an appropriate transport class.
+ """Returns an appropriate transport class.
Args:
label: The name of the desired transport. If none is
@@ -80,7 +77,8 @@ class ErrorGroupServiceClient(metaclass=ErrorGroupServiceClientMeta):
@staticmethod
def _get_default_mtls_endpoint(api_endpoint):
- """Convert api endpoint to mTLS endpoint.
+ """Converts api endpoint to mTLS endpoint.
+
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
"*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
Args:
@@ -114,7 +112,8 @@ def _get_default_mtls_endpoint(api_endpoint):
@classmethod
def from_service_account_info(cls, info: dict, *args, **kwargs):
- """Creates an instance of this client using the provided credentials info.
+ """Creates an instance of this client using the provided credentials
+ info.
Args:
info (dict): The service account private key info.
@@ -131,7 +130,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
@classmethod
def from_service_account_file(cls, filename: str, *args, **kwargs):
"""Creates an instance of this client using the provided credentials
- file.
+ file.
Args:
filename (str): The path to the service account private key json
@@ -150,27 +149,28 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
@property
def transport(self) -> ErrorGroupServiceTransport:
- """Return the transport used by the client instance.
+ """Returns the transport used by the client instance.
Returns:
- ErrorGroupServiceTransport: The transport used by the client instance.
+ ErrorGroupServiceTransport: The transport used by the client
+ instance.
"""
return self._transport
@staticmethod
def error_group_path(project: str, group: str,) -> str:
- """Return a fully-qualified error_group string."""
+ """Returns a fully-qualified error_group string."""
return "projects/{project}/groups/{group}".format(project=project, group=group,)
@staticmethod
def parse_error_group_path(path: str) -> Dict[str, str]:
- """Parse a error_group path into its component segments."""
+ """Parses a error_group path into its component segments."""
m = re.match(r"^projects/(?P.+?)/groups/(?P.+?)$", path)
return m.groupdict() if m else {}
@staticmethod
def common_billing_account_path(billing_account: str,) -> str:
- """Return a fully-qualified billing_account string."""
+ """Returns a fully-qualified billing_account string."""
return "billingAccounts/{billing_account}".format(
billing_account=billing_account,
)
@@ -183,7 +183,7 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
@staticmethod
def common_folder_path(folder: str,) -> str:
- """Return a fully-qualified folder string."""
+ """Returns a fully-qualified folder string."""
return "folders/{folder}".format(folder=folder,)
@staticmethod
@@ -194,7 +194,7 @@ def parse_common_folder_path(path: str) -> Dict[str, str]:
@staticmethod
def common_organization_path(organization: str,) -> str:
- """Return a fully-qualified organization string."""
+ """Returns a fully-qualified organization string."""
return "organizations/{organization}".format(organization=organization,)
@staticmethod
@@ -205,7 +205,7 @@ def parse_common_organization_path(path: str) -> Dict[str, str]:
@staticmethod
def common_project_path(project: str,) -> str:
- """Return a fully-qualified project string."""
+ """Returns a fully-qualified project string."""
return "projects/{project}".format(project=project,)
@staticmethod
@@ -216,7 +216,7 @@ def parse_common_project_path(path: str) -> Dict[str, str]:
@staticmethod
def common_location_path(project: str, location: str,) -> str:
- """Return a fully-qualified location string."""
+ """Returns a fully-qualified location string."""
return "projects/{project}/locations/{location}".format(
project=project, location=location,
)
@@ -230,12 +230,12 @@ def parse_common_location_path(path: str) -> Dict[str, str]:
def __init__(
self,
*,
- credentials: Optional[credentials.Credentials] = None,
+ credentials: Optional[ga_credentials.Credentials] = None,
transport: Union[str, ErrorGroupServiceTransport, None] = None,
client_options: Optional[client_options_lib.ClientOptions] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
- """Instantiate the error group service client.
+ """Instantiates the error group service client.
Args:
credentials (Optional[google.auth.credentials.Credentials]): The
@@ -290,9 +290,10 @@ def __init__(
client_cert_source_func = client_options.client_cert_source
else:
is_mtls = mtls.has_default_client_cert_source()
- client_cert_source_func = (
- mtls.default_client_cert_source() if is_mtls else None
- )
+ if is_mtls:
+ client_cert_source_func = mtls.default_client_cert_source()
+ else:
+ client_cert_source_func = None
# Figure out which api endpoint to use.
if client_options.api_endpoint is not None:
@@ -304,12 +305,14 @@ def __init__(
elif use_mtls_env == "always":
api_endpoint = self.DEFAULT_MTLS_ENDPOINT
elif use_mtls_env == "auto":
- api_endpoint = (
- self.DEFAULT_MTLS_ENDPOINT if is_mtls else self.DEFAULT_ENDPOINT
- )
+ if is_mtls:
+ api_endpoint = self.DEFAULT_MTLS_ENDPOINT
+ else:
+ api_endpoint = self.DEFAULT_ENDPOINT
else:
raise MutualTLSChannelError(
- "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted values: never, auto, always"
+ "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted "
+ "values: never, auto, always"
)
# Save or instantiate the transport.
@@ -324,8 +327,8 @@ def __init__(
)
if client_options.scopes:
raise ValueError(
- "When providing a transport instance, "
- "provide its scopes directly."
+ "When providing a transport instance, provide its scopes "
+ "directly."
)
self._transport = transport
else:
@@ -366,7 +369,6 @@ def get_group(
This corresponds to the ``group_name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
@@ -395,10 +397,8 @@ def get_group(
# there are no flattened fields.
if not isinstance(request, error_group_service.GetGroupRequest):
request = error_group_service.GetGroupRequest(request)
-
# If we have keyword arguments corresponding to fields on the
# request, apply these.
-
if group_name is not None:
request.group_name = group_name
@@ -443,7 +443,6 @@ def update_group(
This corresponds to the ``group`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
@@ -472,10 +471,8 @@ def update_group(
# there are no flattened fields.
if not isinstance(request, error_group_service.UpdateGroupRequest):
request = error_group_service.UpdateGroupRequest(request)
-
# If we have keyword arguments corresponding to fields on the
# request, apply these.
-
if group is not None:
request.group = group
diff --git a/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/__init__.py b/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/__init__.py
index cbf9008a..6e4ee23e 100644
--- a/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/__init__.py
+++ b/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/__init__.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
from collections import OrderedDict
from typing import Dict, Type
diff --git a/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/base.py b/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/base.py
index 45260605..54ecd8e8 100644
--- a/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/base.py
+++ b/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/base.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,21 +13,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
import abc
-import typing
+from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
+import packaging.version
import pkg_resources
-from google import auth # type: ignore
-from google.api_core import exceptions # type: ignore
+import google.auth # type: ignore
+import google.api_core # type: ignore
+from google.api_core import exceptions as core_exceptions # type: ignore
from google.api_core import gapic_v1 # type: ignore
from google.api_core import retry as retries # type: ignore
-from google.auth import credentials # type: ignore
+from google.auth import credentials as ga_credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
from google.cloud.errorreporting_v1beta1.types import common
from google.cloud.errorreporting_v1beta1.types import error_group_service
-
try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
@@ -38,27 +38,40 @@
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+try:
+ # google.auth.__version__ was added in 1.26.0
+ _GOOGLE_AUTH_VERSION = google.auth.__version__
+except AttributeError:
+ try: # try pkg_resources if it is available
+ _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version
+ except pkg_resources.DistributionNotFound: # pragma: NO COVER
+ _GOOGLE_AUTH_VERSION = None
+
class ErrorGroupServiceTransport(abc.ABC):
"""Abstract transport class for ErrorGroupService."""
AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",)
+ DEFAULT_HOST: str = "clouderrorreporting.googleapis.com"
+
def __init__(
self,
*,
- host: str = "clouderrorreporting.googleapis.com",
- credentials: credentials.Credentials = None,
- credentials_file: typing.Optional[str] = None,
- scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES,
- quota_project_id: typing.Optional[str] = None,
+ host: str = DEFAULT_HOST,
+ credentials: ga_credentials.Credentials = None,
+ credentials_file: Optional[str] = None,
+ scopes: Optional[Sequence[str]] = None,
+ quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
Args:
- host (Optional[str]): The hostname to connect to.
+ host (Optional[str]):
+ The hostname to connect to.
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service; if none
@@ -67,7 +80,7 @@ def __init__(
credentials_file (Optional[str]): A file with credentials that can
be loaded with :func:`google.auth.load_credentials_from_file`.
This argument is mutually exclusive with credentials.
- scope (Optional[Sequence[str]]): A list of scopes.
+ scopes (Optional[Sequence[str]]): A list of scopes.
quota_project_id (Optional[str]): An optional project to use for billing
and quota.
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
@@ -75,35 +88,70 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
host += ":443"
self._host = host
+ scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
+
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
if credentials and credentials_file:
- raise exceptions.DuplicateCredentialArgs(
+ raise core_exceptions.DuplicateCredentialArgs(
"'credentials_file' and 'credentials' are mutually exclusive"
)
if credentials_file is not None:
- credentials, _ = auth.load_credentials_from_file(
- credentials_file, scopes=self._scopes, quota_project_id=quota_project_id
+ credentials, _ = google.auth.load_credentials_from_file(
+ credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
)
elif credentials is None:
- credentials, _ = auth.default(
- scopes=self._scopes, quota_project_id=quota_project_id
+ credentials, _ = google.auth.default(
+ **scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
+ # TODO(busunkim): This method is in the base transport
+ # to avoid duplicating code across the transport classes. These functions
+ # should be deleted once the minimum required versions of google-auth is increased.
+
+ # TODO: Remove this function once google-auth >= 1.25.0 is required
+ @classmethod
+ def _get_scopes_kwargs(
+ cls, host: str, scopes: Optional[Sequence[str]]
+ ) -> Dict[str, Optional[Sequence[str]]]:
+ """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version"""
+
+ scopes_kwargs = {}
+
+ if _GOOGLE_AUTH_VERSION and (
+ packaging.version.parse(_GOOGLE_AUTH_VERSION)
+ >= packaging.version.parse("1.25.0")
+ ):
+ scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES}
+ else:
+ scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES}
+
+ return scopes_kwargs
+
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
@@ -118,18 +166,18 @@ def _prep_wrapped_messages(self, client_info):
@property
def get_group(
self,
- ) -> typing.Callable[
+ ) -> Callable[
[error_group_service.GetGroupRequest],
- typing.Union[common.ErrorGroup, typing.Awaitable[common.ErrorGroup]],
+ Union[common.ErrorGroup, Awaitable[common.ErrorGroup]],
]:
raise NotImplementedError()
@property
def update_group(
self,
- ) -> typing.Callable[
+ ) -> Callable[
[error_group_service.UpdateGroupRequest],
- typing.Union[common.ErrorGroup, typing.Awaitable[common.ErrorGroup]],
+ Union[common.ErrorGroup, Awaitable[common.ErrorGroup]],
]:
raise NotImplementedError()
diff --git a/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/grpc.py b/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/grpc.py
index 8514d3d7..e5f620d1 100644
--- a/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/grpc.py
+++ b/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/grpc.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,21 +13,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
import warnings
-from typing import Callable, Dict, Optional, Sequence, Tuple
+from typing import Callable, Dict, Optional, Sequence, Tuple, Union
from google.api_core import grpc_helpers # type: ignore
from google.api_core import gapic_v1 # type: ignore
-from google import auth # type: ignore
-from google.auth import credentials # type: ignore
+import google.auth # type: ignore
+from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
import grpc # type: ignore
from google.cloud.errorreporting_v1beta1.types import common
from google.cloud.errorreporting_v1beta1.types import error_group_service
-
from .base import ErrorGroupServiceTransport, DEFAULT_CLIENT_INFO
@@ -51,7 +48,7 @@ def __init__(
self,
*,
host: str = "clouderrorreporting.googleapis.com",
- credentials: credentials.Credentials = None,
+ credentials: ga_credentials.Credentials = None,
credentials_file: str = None,
scopes: Sequence[str] = None,
channel: grpc.Channel = None,
@@ -61,11 +58,13 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
Args:
- host (Optional[str]): The hostname to connect to.
+ host (Optional[str]):
+ The hostname to connect to.
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service; if none
@@ -100,6 +99,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -152,6 +153,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -175,7 +177,7 @@ def __init__(
def create_channel(
cls,
host: str = "clouderrorreporting.googleapis.com",
- credentials: credentials.Credentials = None,
+ credentials: ga_credentials.Credentials = None,
credentials_file: str = None,
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
@@ -206,13 +208,15 @@ def create_channel(
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
and ``credentials_file`` are passed.
"""
- scopes = scopes or cls.AUTH_SCOPES
+
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
- scopes=scopes,
quota_project_id=quota_project_id,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/grpc_asyncio.py b/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/grpc_asyncio.py
index d09a346b..7ea9c77a 100644
--- a/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/grpc_asyncio.py
+++ b/google/cloud/errorreporting_v1beta1/services/error_group_service/transports/grpc_asyncio.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,22 +13,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
import warnings
-from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple
+from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union
from google.api_core import gapic_v1 # type: ignore
from google.api_core import grpc_helpers_async # type: ignore
-from google import auth # type: ignore
-from google.auth import credentials # type: ignore
+from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
+import packaging.version
import grpc # type: ignore
from grpc.experimental import aio # type: ignore
from google.cloud.errorreporting_v1beta1.types import common
from google.cloud.errorreporting_v1beta1.types import error_group_service
-
from .base import ErrorGroupServiceTransport, DEFAULT_CLIENT_INFO
from .grpc import ErrorGroupServiceGrpcTransport
@@ -54,7 +51,7 @@ class ErrorGroupServiceGrpcAsyncIOTransport(ErrorGroupServiceTransport):
def create_channel(
cls,
host: str = "clouderrorreporting.googleapis.com",
- credentials: credentials.Credentials = None,
+ credentials: ga_credentials.Credentials = None,
credentials_file: Optional[str] = None,
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
@@ -81,13 +78,15 @@ def create_channel(
Returns:
aio.Channel: A gRPC AsyncIO channel object.
"""
- scopes = scopes or cls.AUTH_SCOPES
+
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
- scopes=scopes,
quota_project_id=quota_project_id,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -95,7 +94,7 @@ def __init__(
self,
*,
host: str = "clouderrorreporting.googleapis.com",
- credentials: credentials.Credentials = None,
+ credentials: ga_credentials.Credentials = None,
credentials_file: Optional[str] = None,
scopes: Optional[Sequence[str]] = None,
channel: aio.Channel = None,
@@ -105,11 +104,13 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
Args:
- host (Optional[str]): The hostname to connect to.
+ host (Optional[str]):
+ The hostname to connect to.
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service; if none
@@ -145,6 +146,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -167,7 +170,6 @@ def __init__(
# If a channel was explicitly provided, set it.
self._grpc_channel = channel
self._ssl_channel_credentials = None
-
else:
if api_mtls_endpoint:
host = api_mtls_endpoint
@@ -197,6 +199,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/__init__.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/__init__.py
index 53872971..24c61076 100644
--- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/__init__.py
+++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/__init__.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
from .client import ErrorStatsServiceClient
from .async_client import ErrorStatsServiceAsyncClient
diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py
index ca116141..b13a76d4 100644
--- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py
+++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
from collections import OrderedDict
import functools
import re
@@ -22,16 +20,15 @@
import pkg_resources
import google.api_core.client_options as ClientOptions # type: ignore
-from google.api_core import exceptions # type: ignore
+from google.api_core import exceptions as core_exceptions # type: ignore
from google.api_core import gapic_v1 # type: ignore
from google.api_core import retry as retries # type: ignore
-from google.auth import credentials # type: ignore
+from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore
from google.cloud.errorreporting_v1beta1.services.error_stats_service import pagers
from google.cloud.errorreporting_v1beta1.types import common
from google.cloud.errorreporting_v1beta1.types import error_stats_service
-
from .transports.base import ErrorStatsServiceTransport, DEFAULT_CLIENT_INFO
from .transports.grpc_asyncio import ErrorStatsServiceGrpcAsyncIOTransport
from .client import ErrorStatsServiceClient
@@ -51,31 +48,26 @@ class ErrorStatsServiceAsyncClient:
parse_error_group_path = staticmethod(
ErrorStatsServiceClient.parse_error_group_path
)
-
common_billing_account_path = staticmethod(
ErrorStatsServiceClient.common_billing_account_path
)
parse_common_billing_account_path = staticmethod(
ErrorStatsServiceClient.parse_common_billing_account_path
)
-
common_folder_path = staticmethod(ErrorStatsServiceClient.common_folder_path)
parse_common_folder_path = staticmethod(
ErrorStatsServiceClient.parse_common_folder_path
)
-
common_organization_path = staticmethod(
ErrorStatsServiceClient.common_organization_path
)
parse_common_organization_path = staticmethod(
ErrorStatsServiceClient.parse_common_organization_path
)
-
common_project_path = staticmethod(ErrorStatsServiceClient.common_project_path)
parse_common_project_path = staticmethod(
ErrorStatsServiceClient.parse_common_project_path
)
-
common_location_path = staticmethod(ErrorStatsServiceClient.common_location_path)
parse_common_location_path = staticmethod(
ErrorStatsServiceClient.parse_common_location_path
@@ -83,7 +75,8 @@ class ErrorStatsServiceAsyncClient:
@classmethod
def from_service_account_info(cls, info: dict, *args, **kwargs):
- """Creates an instance of this client using the provided credentials info.
+ """Creates an instance of this client using the provided credentials
+ info.
Args:
info (dict): The service account private key info.
@@ -98,7 +91,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
@classmethod
def from_service_account_file(cls, filename: str, *args, **kwargs):
"""Creates an instance of this client using the provided credentials
- file.
+ file.
Args:
filename (str): The path to the service account private key json
@@ -115,7 +108,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
@property
def transport(self) -> ErrorStatsServiceTransport:
- """Return the transport used by the client instance.
+ """Returns the transport used by the client instance.
Returns:
ErrorStatsServiceTransport: The transport used by the client instance.
@@ -129,12 +122,12 @@ def transport(self) -> ErrorStatsServiceTransport:
def __init__(
self,
*,
- credentials: credentials.Credentials = None,
+ credentials: ga_credentials.Credentials = None,
transport: Union[str, ErrorStatsServiceTransport] = "grpc_asyncio",
client_options: ClientOptions = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
- """Instantiate the error stats service client.
+ """Instantiates the error stats service client.
Args:
credentials (Optional[google.auth.credentials.Credentials]): The
@@ -166,7 +159,6 @@ def __init__(
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
creation failed for any reason.
"""
-
self._client = ErrorStatsServiceClient(
credentials=credentials,
transport=transport,
@@ -216,7 +208,6 @@ async def list_group_stats(
This corresponds to the ``time_range`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
@@ -246,7 +237,6 @@ async def list_group_stats(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
-
if project_name is not None:
request.project_name = project_name
if time_range is not None:
@@ -314,7 +304,6 @@ async def list_events(
This corresponds to the ``group_id`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
@@ -344,7 +333,6 @@ async def list_events(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
-
if project_name is not None:
request.project_name = project_name
if group_id is not None:
@@ -403,7 +391,6 @@ async def delete_events(
This corresponds to the ``project_name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
@@ -430,7 +417,6 @@ async def delete_events(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
-
if project_name is not None:
request.project_name = project_name
diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/client.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/client.py
index 7178412c..60414659 100644
--- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/client.py
+++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/client.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
from collections import OrderedDict
from distutils import util
import os
@@ -23,10 +21,10 @@
import pkg_resources
from google.api_core import client_options as client_options_lib # type: ignore
-from google.api_core import exceptions # type: ignore
+from google.api_core import exceptions as core_exceptions # type: ignore
from google.api_core import gapic_v1 # type: ignore
from google.api_core import retry as retries # type: ignore
-from google.auth import credentials # type: ignore
+from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport import mtls # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
from google.auth.exceptions import MutualTLSChannelError # type: ignore
@@ -35,7 +33,6 @@
from google.cloud.errorreporting_v1beta1.services.error_stats_service import pagers
from google.cloud.errorreporting_v1beta1.types import common
from google.cloud.errorreporting_v1beta1.types import error_stats_service
-
from .transports.base import ErrorStatsServiceTransport, DEFAULT_CLIENT_INFO
from .transports.grpc import ErrorStatsServiceGrpcTransport
from .transports.grpc_asyncio import ErrorStatsServiceGrpcAsyncIOTransport
@@ -58,7 +55,7 @@ class ErrorStatsServiceClientMeta(type):
def get_transport_class(
cls, label: str = None,
) -> Type[ErrorStatsServiceTransport]:
- """Return an appropriate transport class.
+ """Returns an appropriate transport class.
Args:
label: The name of the desired transport. If none is
@@ -83,7 +80,8 @@ class ErrorStatsServiceClient(metaclass=ErrorStatsServiceClientMeta):
@staticmethod
def _get_default_mtls_endpoint(api_endpoint):
- """Convert api endpoint to mTLS endpoint.
+ """Converts api endpoint to mTLS endpoint.
+
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
"*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
Args:
@@ -117,7 +115,8 @@ def _get_default_mtls_endpoint(api_endpoint):
@classmethod
def from_service_account_info(cls, info: dict, *args, **kwargs):
- """Creates an instance of this client using the provided credentials info.
+ """Creates an instance of this client using the provided credentials
+ info.
Args:
info (dict): The service account private key info.
@@ -134,7 +133,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
@classmethod
def from_service_account_file(cls, filename: str, *args, **kwargs):
"""Creates an instance of this client using the provided credentials
- file.
+ file.
Args:
filename (str): The path to the service account private key json
@@ -153,27 +152,28 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
@property
def transport(self) -> ErrorStatsServiceTransport:
- """Return the transport used by the client instance.
+ """Returns the transport used by the client instance.
Returns:
- ErrorStatsServiceTransport: The transport used by the client instance.
+ ErrorStatsServiceTransport: The transport used by the client
+ instance.
"""
return self._transport
@staticmethod
def error_group_path(project: str, group: str,) -> str:
- """Return a fully-qualified error_group string."""
+ """Returns a fully-qualified error_group string."""
return "projects/{project}/groups/{group}".format(project=project, group=group,)
@staticmethod
def parse_error_group_path(path: str) -> Dict[str, str]:
- """Parse a error_group path into its component segments."""
+ """Parses a error_group path into its component segments."""
m = re.match(r"^projects/(?P.+?)/groups/(?P.+?)$", path)
return m.groupdict() if m else {}
@staticmethod
def common_billing_account_path(billing_account: str,) -> str:
- """Return a fully-qualified billing_account string."""
+ """Returns a fully-qualified billing_account string."""
return "billingAccounts/{billing_account}".format(
billing_account=billing_account,
)
@@ -186,7 +186,7 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
@staticmethod
def common_folder_path(folder: str,) -> str:
- """Return a fully-qualified folder string."""
+ """Returns a fully-qualified folder string."""
return "folders/{folder}".format(folder=folder,)
@staticmethod
@@ -197,7 +197,7 @@ def parse_common_folder_path(path: str) -> Dict[str, str]:
@staticmethod
def common_organization_path(organization: str,) -> str:
- """Return a fully-qualified organization string."""
+ """Returns a fully-qualified organization string."""
return "organizations/{organization}".format(organization=organization,)
@staticmethod
@@ -208,7 +208,7 @@ def parse_common_organization_path(path: str) -> Dict[str, str]:
@staticmethod
def common_project_path(project: str,) -> str:
- """Return a fully-qualified project string."""
+ """Returns a fully-qualified project string."""
return "projects/{project}".format(project=project,)
@staticmethod
@@ -219,7 +219,7 @@ def parse_common_project_path(path: str) -> Dict[str, str]:
@staticmethod
def common_location_path(project: str, location: str,) -> str:
- """Return a fully-qualified location string."""
+ """Returns a fully-qualified location string."""
return "projects/{project}/locations/{location}".format(
project=project, location=location,
)
@@ -233,12 +233,12 @@ def parse_common_location_path(path: str) -> Dict[str, str]:
def __init__(
self,
*,
- credentials: Optional[credentials.Credentials] = None,
+ credentials: Optional[ga_credentials.Credentials] = None,
transport: Union[str, ErrorStatsServiceTransport, None] = None,
client_options: Optional[client_options_lib.ClientOptions] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
- """Instantiate the error stats service client.
+ """Instantiates the error stats service client.
Args:
credentials (Optional[google.auth.credentials.Credentials]): The
@@ -293,9 +293,10 @@ def __init__(
client_cert_source_func = client_options.client_cert_source
else:
is_mtls = mtls.has_default_client_cert_source()
- client_cert_source_func = (
- mtls.default_client_cert_source() if is_mtls else None
- )
+ if is_mtls:
+ client_cert_source_func = mtls.default_client_cert_source()
+ else:
+ client_cert_source_func = None
# Figure out which api endpoint to use.
if client_options.api_endpoint is not None:
@@ -307,12 +308,14 @@ def __init__(
elif use_mtls_env == "always":
api_endpoint = self.DEFAULT_MTLS_ENDPOINT
elif use_mtls_env == "auto":
- api_endpoint = (
- self.DEFAULT_MTLS_ENDPOINT if is_mtls else self.DEFAULT_ENDPOINT
- )
+ if is_mtls:
+ api_endpoint = self.DEFAULT_MTLS_ENDPOINT
+ else:
+ api_endpoint = self.DEFAULT_ENDPOINT
else:
raise MutualTLSChannelError(
- "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted values: never, auto, always"
+ "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted "
+ "values: never, auto, always"
)
# Save or instantiate the transport.
@@ -327,8 +330,8 @@ def __init__(
)
if client_options.scopes:
raise ValueError(
- "When providing a transport instance, "
- "provide its scopes directly."
+ "When providing a transport instance, provide its scopes "
+ "directly."
)
self._transport = transport
else:
@@ -385,7 +388,6 @@ def list_group_stats(
This corresponds to the ``time_range`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
@@ -417,10 +419,8 @@ def list_group_stats(
# there are no flattened fields.
if not isinstance(request, error_stats_service.ListGroupStatsRequest):
request = error_stats_service.ListGroupStatsRequest(request)
-
# If we have keyword arguments corresponding to fields on the
# request, apply these.
-
if project_name is not None:
request.project_name = project_name
if time_range is not None:
@@ -484,7 +484,6 @@ def list_events(
This corresponds to the ``group_id`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
@@ -516,10 +515,8 @@ def list_events(
# there are no flattened fields.
if not isinstance(request, error_stats_service.ListEventsRequest):
request = error_stats_service.ListEventsRequest(request)
-
# If we have keyword arguments corresponding to fields on the
# request, apply these.
-
if project_name is not None:
request.project_name = project_name
if group_id is not None:
@@ -574,7 +571,6 @@ def delete_events(
This corresponds to the ``project_name`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
@@ -603,10 +599,8 @@ def delete_events(
# there are no flattened fields.
if not isinstance(request, error_stats_service.DeleteEventsRequest):
request = error_stats_service.DeleteEventsRequest(request)
-
# If we have keyword arguments corresponding to fields on the
# request, apply these.
-
if project_name is not None:
request.project_name = project_name
diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/pagers.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/pagers.py
index a5d6c02f..02be9c53 100644
--- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/pagers.py
+++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/pagers.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
from typing import (
Any,
AsyncIterable,
@@ -118,7 +116,7 @@ def __init__(
*,
metadata: Sequence[Tuple[str, str]] = ()
):
- """Instantiate the pager.
+ """Instantiates the pager.
Args:
method (Callable): The method that was originally called, and
@@ -246,7 +244,7 @@ def __init__(
*,
metadata: Sequence[Tuple[str, str]] = ()
):
- """Instantiate the pager.
+ """Instantiates the pager.
Args:
method (Callable): The method that was originally called, and
diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/__init__.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/__init__.py
index 9d9ed280..8a9987b9 100644
--- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/__init__.py
+++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/__init__.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
from collections import OrderedDict
from typing import Dict, Type
diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/base.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/base.py
index 18470b15..2081bb5d 100644
--- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/base.py
+++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/base.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,20 +13,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
import abc
-import typing
+from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
+import packaging.version
import pkg_resources
-from google import auth # type: ignore
-from google.api_core import exceptions # type: ignore
+import google.auth # type: ignore
+import google.api_core # type: ignore
+from google.api_core import exceptions as core_exceptions # type: ignore
from google.api_core import gapic_v1 # type: ignore
from google.api_core import retry as retries # type: ignore
-from google.auth import credentials # type: ignore
+from google.auth import credentials as ga_credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
from google.cloud.errorreporting_v1beta1.types import error_stats_service
-
try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
@@ -37,27 +37,40 @@
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+try:
+ # google.auth.__version__ was added in 1.26.0
+ _GOOGLE_AUTH_VERSION = google.auth.__version__
+except AttributeError:
+ try: # try pkg_resources if it is available
+ _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version
+ except pkg_resources.DistributionNotFound: # pragma: NO COVER
+ _GOOGLE_AUTH_VERSION = None
+
class ErrorStatsServiceTransport(abc.ABC):
"""Abstract transport class for ErrorStatsService."""
AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",)
+ DEFAULT_HOST: str = "clouderrorreporting.googleapis.com"
+
def __init__(
self,
*,
- host: str = "clouderrorreporting.googleapis.com",
- credentials: credentials.Credentials = None,
- credentials_file: typing.Optional[str] = None,
- scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES,
- quota_project_id: typing.Optional[str] = None,
+ host: str = DEFAULT_HOST,
+ credentials: ga_credentials.Credentials = None,
+ credentials_file: Optional[str] = None,
+ scopes: Optional[Sequence[str]] = None,
+ quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
Args:
- host (Optional[str]): The hostname to connect to.
+ host (Optional[str]):
+ The hostname to connect to.
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service; if none
@@ -66,7 +79,7 @@ def __init__(
credentials_file (Optional[str]): A file with credentials that can
be loaded with :func:`google.auth.load_credentials_from_file`.
This argument is mutually exclusive with credentials.
- scope (Optional[Sequence[str]]): A list of scopes.
+ scopes (Optional[Sequence[str]]): A list of scopes.
quota_project_id (Optional[str]): An optional project to use for billing
and quota.
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
@@ -74,35 +87,70 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
host += ":443"
self._host = host
+ scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
+
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
if credentials and credentials_file:
- raise exceptions.DuplicateCredentialArgs(
+ raise core_exceptions.DuplicateCredentialArgs(
"'credentials_file' and 'credentials' are mutually exclusive"
)
if credentials_file is not None:
- credentials, _ = auth.load_credentials_from_file(
- credentials_file, scopes=self._scopes, quota_project_id=quota_project_id
+ credentials, _ = google.auth.load_credentials_from_file(
+ credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
)
elif credentials is None:
- credentials, _ = auth.default(
- scopes=self._scopes, quota_project_id=quota_project_id
+ credentials, _ = google.auth.default(
+ **scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
+ # TODO(busunkim): This method is in the base transport
+ # to avoid duplicating code across the transport classes. These functions
+ # should be deleted once the minimum required versions of google-auth is increased.
+
+ # TODO: Remove this function once google-auth >= 1.25.0 is required
+ @classmethod
+ def _get_scopes_kwargs(
+ cls, host: str, scopes: Optional[Sequence[str]]
+ ) -> Dict[str, Optional[Sequence[str]]]:
+ """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version"""
+
+ scopes_kwargs = {}
+
+ if _GOOGLE_AUTH_VERSION and (
+ packaging.version.parse(_GOOGLE_AUTH_VERSION)
+ >= packaging.version.parse("1.25.0")
+ ):
+ scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES}
+ else:
+ scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES}
+
+ return scopes_kwargs
+
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
@@ -120,11 +168,11 @@ def _prep_wrapped_messages(self, client_info):
@property
def list_group_stats(
self,
- ) -> typing.Callable[
+ ) -> Callable[
[error_stats_service.ListGroupStatsRequest],
- typing.Union[
+ Union[
error_stats_service.ListGroupStatsResponse,
- typing.Awaitable[error_stats_service.ListGroupStatsResponse],
+ Awaitable[error_stats_service.ListGroupStatsResponse],
],
]:
raise NotImplementedError()
@@ -132,11 +180,11 @@ def list_group_stats(
@property
def list_events(
self,
- ) -> typing.Callable[
+ ) -> Callable[
[error_stats_service.ListEventsRequest],
- typing.Union[
+ Union[
error_stats_service.ListEventsResponse,
- typing.Awaitable[error_stats_service.ListEventsResponse],
+ Awaitable[error_stats_service.ListEventsResponse],
],
]:
raise NotImplementedError()
@@ -144,11 +192,11 @@ def list_events(
@property
def delete_events(
self,
- ) -> typing.Callable[
+ ) -> Callable[
[error_stats_service.DeleteEventsRequest],
- typing.Union[
+ Union[
error_stats_service.DeleteEventsResponse,
- typing.Awaitable[error_stats_service.DeleteEventsResponse],
+ Awaitable[error_stats_service.DeleteEventsResponse],
],
]:
raise NotImplementedError()
diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/grpc.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/grpc.py
index 1e033169..be6d42a4 100644
--- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/grpc.py
+++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/grpc.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,20 +13,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
import warnings
-from typing import Callable, Dict, Optional, Sequence, Tuple
+from typing import Callable, Dict, Optional, Sequence, Tuple, Union
from google.api_core import grpc_helpers # type: ignore
from google.api_core import gapic_v1 # type: ignore
-from google import auth # type: ignore
-from google.auth import credentials # type: ignore
+import google.auth # type: ignore
+from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
import grpc # type: ignore
from google.cloud.errorreporting_v1beta1.types import error_stats_service
-
from .base import ErrorStatsServiceTransport, DEFAULT_CLIENT_INFO
@@ -51,7 +48,7 @@ def __init__(
self,
*,
host: str = "clouderrorreporting.googleapis.com",
- credentials: credentials.Credentials = None,
+ credentials: ga_credentials.Credentials = None,
credentials_file: str = None,
scopes: Sequence[str] = None,
channel: grpc.Channel = None,
@@ -61,11 +58,13 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
Args:
- host (Optional[str]): The hostname to connect to.
+ host (Optional[str]):
+ The hostname to connect to.
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service; if none
@@ -100,6 +99,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -152,6 +153,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -175,7 +177,7 @@ def __init__(
def create_channel(
cls,
host: str = "clouderrorreporting.googleapis.com",
- credentials: credentials.Credentials = None,
+ credentials: ga_credentials.Credentials = None,
credentials_file: str = None,
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
@@ -206,13 +208,15 @@ def create_channel(
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
and ``credentials_file`` are passed.
"""
- scopes = scopes or cls.AUTH_SCOPES
+
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
- scopes=scopes,
quota_project_id=quota_project_id,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/grpc_asyncio.py b/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/grpc_asyncio.py
index 402abb49..65b32b0f 100644
--- a/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/grpc_asyncio.py
+++ b/google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/grpc_asyncio.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,21 +13,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
import warnings
-from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple
+from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union
from google.api_core import gapic_v1 # type: ignore
from google.api_core import grpc_helpers_async # type: ignore
-from google import auth # type: ignore
-from google.auth import credentials # type: ignore
+from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
+import packaging.version
import grpc # type: ignore
from grpc.experimental import aio # type: ignore
from google.cloud.errorreporting_v1beta1.types import error_stats_service
-
from .base import ErrorStatsServiceTransport, DEFAULT_CLIENT_INFO
from .grpc import ErrorStatsServiceGrpcTransport
@@ -54,7 +51,7 @@ class ErrorStatsServiceGrpcAsyncIOTransport(ErrorStatsServiceTransport):
def create_channel(
cls,
host: str = "clouderrorreporting.googleapis.com",
- credentials: credentials.Credentials = None,
+ credentials: ga_credentials.Credentials = None,
credentials_file: Optional[str] = None,
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
@@ -81,13 +78,15 @@ def create_channel(
Returns:
aio.Channel: A gRPC AsyncIO channel object.
"""
- scopes = scopes or cls.AUTH_SCOPES
+
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
- scopes=scopes,
quota_project_id=quota_project_id,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -95,7 +94,7 @@ def __init__(
self,
*,
host: str = "clouderrorreporting.googleapis.com",
- credentials: credentials.Credentials = None,
+ credentials: ga_credentials.Credentials = None,
credentials_file: Optional[str] = None,
scopes: Optional[Sequence[str]] = None,
channel: aio.Channel = None,
@@ -105,11 +104,13 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
Args:
- host (Optional[str]): The hostname to connect to.
+ host (Optional[str]):
+ The hostname to connect to.
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service; if none
@@ -145,6 +146,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -167,7 +170,6 @@ def __init__(
# If a channel was explicitly provided, set it.
self._grpc_channel = channel
self._ssl_channel_credentials = None
-
else:
if api_mtls_endpoint:
host = api_mtls_endpoint
@@ -197,6 +199,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/google/cloud/errorreporting_v1beta1/services/report_errors_service/__init__.py b/google/cloud/errorreporting_v1beta1/services/report_errors_service/__init__.py
index 0a9dd71e..dc391175 100644
--- a/google/cloud/errorreporting_v1beta1/services/report_errors_service/__init__.py
+++ b/google/cloud/errorreporting_v1beta1/services/report_errors_service/__init__.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
from .client import ReportErrorsServiceClient
from .async_client import ReportErrorsServiceAsyncClient
diff --git a/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py b/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py
index 61f223b6..7528086c 100644
--- a/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py
+++ b/google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
from collections import OrderedDict
import functools
import re
@@ -22,14 +20,13 @@
import pkg_resources
import google.api_core.client_options as ClientOptions # type: ignore
-from google.api_core import exceptions # type: ignore
+from google.api_core import exceptions as core_exceptions # type: ignore
from google.api_core import gapic_v1 # type: ignore
from google.api_core import retry as retries # type: ignore
-from google.auth import credentials # type: ignore
+from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore
from google.cloud.errorreporting_v1beta1.types import report_errors_service
-
from .transports.base import ReportErrorsServiceTransport, DEFAULT_CLIENT_INFO
from .transports.grpc_asyncio import ReportErrorsServiceGrpcAsyncIOTransport
from .client import ReportErrorsServiceClient
@@ -49,24 +46,20 @@ class ReportErrorsServiceAsyncClient:
parse_common_billing_account_path = staticmethod(
ReportErrorsServiceClient.parse_common_billing_account_path
)
-
common_folder_path = staticmethod(ReportErrorsServiceClient.common_folder_path)
parse_common_folder_path = staticmethod(
ReportErrorsServiceClient.parse_common_folder_path
)
-
common_organization_path = staticmethod(
ReportErrorsServiceClient.common_organization_path
)
parse_common_organization_path = staticmethod(
ReportErrorsServiceClient.parse_common_organization_path
)
-
common_project_path = staticmethod(ReportErrorsServiceClient.common_project_path)
parse_common_project_path = staticmethod(
ReportErrorsServiceClient.parse_common_project_path
)
-
common_location_path = staticmethod(ReportErrorsServiceClient.common_location_path)
parse_common_location_path = staticmethod(
ReportErrorsServiceClient.parse_common_location_path
@@ -74,7 +67,8 @@ class ReportErrorsServiceAsyncClient:
@classmethod
def from_service_account_info(cls, info: dict, *args, **kwargs):
- """Creates an instance of this client using the provided credentials info.
+ """Creates an instance of this client using the provided credentials
+ info.
Args:
info (dict): The service account private key info.
@@ -89,7 +83,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
@classmethod
def from_service_account_file(cls, filename: str, *args, **kwargs):
"""Creates an instance of this client using the provided credentials
- file.
+ file.
Args:
filename (str): The path to the service account private key json
@@ -106,7 +100,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
@property
def transport(self) -> ReportErrorsServiceTransport:
- """Return the transport used by the client instance.
+ """Returns the transport used by the client instance.
Returns:
ReportErrorsServiceTransport: The transport used by the client instance.
@@ -121,12 +115,12 @@ def transport(self) -> ReportErrorsServiceTransport:
def __init__(
self,
*,
- credentials: credentials.Credentials = None,
+ credentials: ga_credentials.Credentials = None,
transport: Union[str, ReportErrorsServiceTransport] = "grpc_asyncio",
client_options: ClientOptions = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
- """Instantiate the report errors service client.
+ """Instantiates the report errors service client.
Args:
credentials (Optional[google.auth.credentials.Credentials]): The
@@ -158,7 +152,6 @@ def __init__(
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
creation failed for any reason.
"""
-
self._client = ReportErrorsServiceClient(
credentials=credentials,
transport=transport,
@@ -215,7 +208,6 @@ async def report_error_event(
This corresponds to the ``event`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
@@ -243,7 +235,6 @@ async def report_error_event(
# If we have keyword arguments corresponding to fields on the
# request, apply these.
-
if project_name is not None:
request.project_name = project_name
if event is not None:
diff --git a/google/cloud/errorreporting_v1beta1/services/report_errors_service/client.py b/google/cloud/errorreporting_v1beta1/services/report_errors_service/client.py
index 840e449f..4ed19dd1 100644
--- a/google/cloud/errorreporting_v1beta1/services/report_errors_service/client.py
+++ b/google/cloud/errorreporting_v1beta1/services/report_errors_service/client.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
from collections import OrderedDict
from distutils import util
import os
@@ -23,17 +21,16 @@
import pkg_resources
from google.api_core import client_options as client_options_lib # type: ignore
-from google.api_core import exceptions # type: ignore
+from google.api_core import exceptions as core_exceptions # type: ignore
from google.api_core import gapic_v1 # type: ignore
from google.api_core import retry as retries # type: ignore
-from google.auth import credentials # type: ignore
+from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport import mtls # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
from google.auth.exceptions import MutualTLSChannelError # type: ignore
from google.oauth2 import service_account # type: ignore
from google.cloud.errorreporting_v1beta1.types import report_errors_service
-
from .transports.base import ReportErrorsServiceTransport, DEFAULT_CLIENT_INFO
from .transports.grpc import ReportErrorsServiceGrpcTransport
from .transports.grpc_asyncio import ReportErrorsServiceGrpcAsyncIOTransport
@@ -56,7 +53,7 @@ class ReportErrorsServiceClientMeta(type):
def get_transport_class(
cls, label: str = None,
) -> Type[ReportErrorsServiceTransport]:
- """Return an appropriate transport class.
+ """Returns an appropriate transport class.
Args:
label: The name of the desired transport. If none is
@@ -79,7 +76,8 @@ class ReportErrorsServiceClient(metaclass=ReportErrorsServiceClientMeta):
@staticmethod
def _get_default_mtls_endpoint(api_endpoint):
- """Convert api endpoint to mTLS endpoint.
+ """Converts api endpoint to mTLS endpoint.
+
Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
"*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
Args:
@@ -113,7 +111,8 @@ def _get_default_mtls_endpoint(api_endpoint):
@classmethod
def from_service_account_info(cls, info: dict, *args, **kwargs):
- """Creates an instance of this client using the provided credentials info.
+ """Creates an instance of this client using the provided credentials
+ info.
Args:
info (dict): The service account private key info.
@@ -130,7 +129,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs):
@classmethod
def from_service_account_file(cls, filename: str, *args, **kwargs):
"""Creates an instance of this client using the provided credentials
- file.
+ file.
Args:
filename (str): The path to the service account private key json
@@ -149,16 +148,17 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
@property
def transport(self) -> ReportErrorsServiceTransport:
- """Return the transport used by the client instance.
+ """Returns the transport used by the client instance.
Returns:
- ReportErrorsServiceTransport: The transport used by the client instance.
+ ReportErrorsServiceTransport: The transport used by the client
+ instance.
"""
return self._transport
@staticmethod
def common_billing_account_path(billing_account: str,) -> str:
- """Return a fully-qualified billing_account string."""
+ """Returns a fully-qualified billing_account string."""
return "billingAccounts/{billing_account}".format(
billing_account=billing_account,
)
@@ -171,7 +171,7 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
@staticmethod
def common_folder_path(folder: str,) -> str:
- """Return a fully-qualified folder string."""
+ """Returns a fully-qualified folder string."""
return "folders/{folder}".format(folder=folder,)
@staticmethod
@@ -182,7 +182,7 @@ def parse_common_folder_path(path: str) -> Dict[str, str]:
@staticmethod
def common_organization_path(organization: str,) -> str:
- """Return a fully-qualified organization string."""
+ """Returns a fully-qualified organization string."""
return "organizations/{organization}".format(organization=organization,)
@staticmethod
@@ -193,7 +193,7 @@ def parse_common_organization_path(path: str) -> Dict[str, str]:
@staticmethod
def common_project_path(project: str,) -> str:
- """Return a fully-qualified project string."""
+ """Returns a fully-qualified project string."""
return "projects/{project}".format(project=project,)
@staticmethod
@@ -204,7 +204,7 @@ def parse_common_project_path(path: str) -> Dict[str, str]:
@staticmethod
def common_location_path(project: str, location: str,) -> str:
- """Return a fully-qualified location string."""
+ """Returns a fully-qualified location string."""
return "projects/{project}/locations/{location}".format(
project=project, location=location,
)
@@ -218,12 +218,12 @@ def parse_common_location_path(path: str) -> Dict[str, str]:
def __init__(
self,
*,
- credentials: Optional[credentials.Credentials] = None,
+ credentials: Optional[ga_credentials.Credentials] = None,
transport: Union[str, ReportErrorsServiceTransport, None] = None,
client_options: Optional[client_options_lib.ClientOptions] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
- """Instantiate the report errors service client.
+ """Instantiates the report errors service client.
Args:
credentials (Optional[google.auth.credentials.Credentials]): The
@@ -278,9 +278,10 @@ def __init__(
client_cert_source_func = client_options.client_cert_source
else:
is_mtls = mtls.has_default_client_cert_source()
- client_cert_source_func = (
- mtls.default_client_cert_source() if is_mtls else None
- )
+ if is_mtls:
+ client_cert_source_func = mtls.default_client_cert_source()
+ else:
+ client_cert_source_func = None
# Figure out which api endpoint to use.
if client_options.api_endpoint is not None:
@@ -292,12 +293,14 @@ def __init__(
elif use_mtls_env == "always":
api_endpoint = self.DEFAULT_MTLS_ENDPOINT
elif use_mtls_env == "auto":
- api_endpoint = (
- self.DEFAULT_MTLS_ENDPOINT if is_mtls else self.DEFAULT_ENDPOINT
- )
+ if is_mtls:
+ api_endpoint = self.DEFAULT_MTLS_ENDPOINT
+ else:
+ api_endpoint = self.DEFAULT_ENDPOINT
else:
raise MutualTLSChannelError(
- "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted values: never, auto, always"
+ "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted "
+ "values: never, auto, always"
)
# Save or instantiate the transport.
@@ -312,8 +315,8 @@ def __init__(
)
if client_options.scopes:
raise ValueError(
- "When providing a transport instance, "
- "provide its scopes directly."
+ "When providing a transport instance, provide its scopes "
+ "directly."
)
self._transport = transport
else:
@@ -377,7 +380,6 @@ def report_error_event(
This corresponds to the ``event`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
-
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
@@ -407,10 +409,8 @@ def report_error_event(
# there are no flattened fields.
if not isinstance(request, report_errors_service.ReportErrorEventRequest):
request = report_errors_service.ReportErrorEventRequest(request)
-
# If we have keyword arguments corresponding to fields on the
# request, apply these.
-
if project_name is not None:
request.project_name = project_name
if event is not None:
diff --git a/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/__init__.py b/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/__init__.py
index 194962a3..9c967744 100644
--- a/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/__init__.py
+++ b/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/__init__.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
from collections import OrderedDict
from typing import Dict, Type
diff --git a/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/base.py b/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/base.py
index 4adbb0d1..645915d1 100644
--- a/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/base.py
+++ b/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/base.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,20 +13,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
import abc
-import typing
+from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
+import packaging.version
import pkg_resources
-from google import auth # type: ignore
-from google.api_core import exceptions # type: ignore
+import google.auth # type: ignore
+import google.api_core # type: ignore
+from google.api_core import exceptions as core_exceptions # type: ignore
from google.api_core import gapic_v1 # type: ignore
from google.api_core import retry as retries # type: ignore
-from google.auth import credentials # type: ignore
+from google.auth import credentials as ga_credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
from google.cloud.errorreporting_v1beta1.types import report_errors_service
-
try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
@@ -37,27 +37,40 @@
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+try:
+ # google.auth.__version__ was added in 1.26.0
+ _GOOGLE_AUTH_VERSION = google.auth.__version__
+except AttributeError:
+ try: # try pkg_resources if it is available
+ _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version
+ except pkg_resources.DistributionNotFound: # pragma: NO COVER
+ _GOOGLE_AUTH_VERSION = None
+
class ReportErrorsServiceTransport(abc.ABC):
"""Abstract transport class for ReportErrorsService."""
AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",)
+ DEFAULT_HOST: str = "clouderrorreporting.googleapis.com"
+
def __init__(
self,
*,
- host: str = "clouderrorreporting.googleapis.com",
- credentials: credentials.Credentials = None,
- credentials_file: typing.Optional[str] = None,
- scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES,
- quota_project_id: typing.Optional[str] = None,
+ host: str = DEFAULT_HOST,
+ credentials: ga_credentials.Credentials = None,
+ credentials_file: Optional[str] = None,
+ scopes: Optional[Sequence[str]] = None,
+ quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
**kwargs,
) -> None:
"""Instantiate the transport.
Args:
- host (Optional[str]): The hostname to connect to.
+ host (Optional[str]):
+ The hostname to connect to.
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service; if none
@@ -66,7 +79,7 @@ def __init__(
credentials_file (Optional[str]): A file with credentials that can
be loaded with :func:`google.auth.load_credentials_from_file`.
This argument is mutually exclusive with credentials.
- scope (Optional[Sequence[str]]): A list of scopes.
+ scopes (Optional[Sequence[str]]): A list of scopes.
quota_project_id (Optional[str]): An optional project to use for billing
and quota.
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
@@ -74,35 +87,70 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
host += ":443"
self._host = host
+ scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
+
# Save the scopes.
- self._scopes = scopes or self.AUTH_SCOPES
+ self._scopes = scopes
# If no credentials are provided, then determine the appropriate
# defaults.
if credentials and credentials_file:
- raise exceptions.DuplicateCredentialArgs(
+ raise core_exceptions.DuplicateCredentialArgs(
"'credentials_file' and 'credentials' are mutually exclusive"
)
if credentials_file is not None:
- credentials, _ = auth.load_credentials_from_file(
- credentials_file, scopes=self._scopes, quota_project_id=quota_project_id
+ credentials, _ = google.auth.load_credentials_from_file(
+ credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
)
elif credentials is None:
- credentials, _ = auth.default(
- scopes=self._scopes, quota_project_id=quota_project_id
+ credentials, _ = google.auth.default(
+ **scopes_kwargs, quota_project_id=quota_project_id
)
+ # If the credentials is service account credentials, then always try to use self signed JWT.
+ if (
+ always_use_jwt_access
+ and isinstance(credentials, service_account.Credentials)
+ and hasattr(service_account.Credentials, "with_always_use_jwt_access")
+ ):
+ credentials = credentials.with_always_use_jwt_access(True)
+
# Save the credentials.
self._credentials = credentials
+ # TODO(busunkim): This method is in the base transport
+ # to avoid duplicating code across the transport classes. These functions
+ # should be deleted once the minimum required versions of google-auth is increased.
+
+ # TODO: Remove this function once google-auth >= 1.25.0 is required
+ @classmethod
+ def _get_scopes_kwargs(
+ cls, host: str, scopes: Optional[Sequence[str]]
+ ) -> Dict[str, Optional[Sequence[str]]]:
+ """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version"""
+
+ scopes_kwargs = {}
+
+ if _GOOGLE_AUTH_VERSION and (
+ packaging.version.parse(_GOOGLE_AUTH_VERSION)
+ >= packaging.version.parse("1.25.0")
+ ):
+ scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES}
+ else:
+ scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES}
+
+ return scopes_kwargs
+
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
@@ -114,11 +162,11 @@ def _prep_wrapped_messages(self, client_info):
@property
def report_error_event(
self,
- ) -> typing.Callable[
+ ) -> Callable[
[report_errors_service.ReportErrorEventRequest],
- typing.Union[
+ Union[
report_errors_service.ReportErrorEventResponse,
- typing.Awaitable[report_errors_service.ReportErrorEventResponse],
+ Awaitable[report_errors_service.ReportErrorEventResponse],
],
]:
raise NotImplementedError()
diff --git a/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc.py b/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc.py
index 8ae306d9..452d2b3d 100644
--- a/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc.py
+++ b/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,20 +13,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
import warnings
-from typing import Callable, Dict, Optional, Sequence, Tuple
+from typing import Callable, Dict, Optional, Sequence, Tuple, Union
from google.api_core import grpc_helpers # type: ignore
from google.api_core import gapic_v1 # type: ignore
-from google import auth # type: ignore
-from google.auth import credentials # type: ignore
+import google.auth # type: ignore
+from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
import grpc # type: ignore
from google.cloud.errorreporting_v1beta1.types import report_errors_service
-
from .base import ReportErrorsServiceTransport, DEFAULT_CLIENT_INFO
@@ -50,7 +47,7 @@ def __init__(
self,
*,
host: str = "clouderrorreporting.googleapis.com",
- credentials: credentials.Credentials = None,
+ credentials: ga_credentials.Credentials = None,
credentials_file: str = None,
scopes: Sequence[str] = None,
channel: grpc.Channel = None,
@@ -60,11 +57,13 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
Args:
- host (Optional[str]): The hostname to connect to.
+ host (Optional[str]):
+ The hostname to connect to.
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service; if none
@@ -99,6 +98,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
@@ -151,6 +152,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
@@ -174,7 +176,7 @@ def __init__(
def create_channel(
cls,
host: str = "clouderrorreporting.googleapis.com",
- credentials: credentials.Credentials = None,
+ credentials: ga_credentials.Credentials = None,
credentials_file: str = None,
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
@@ -205,13 +207,15 @@ def create_channel(
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
and ``credentials_file`` are passed.
"""
- scopes = scopes or cls.AUTH_SCOPES
+
return grpc_helpers.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
- scopes=scopes,
quota_project_id=quota_project_id,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
diff --git a/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc_asyncio.py b/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc_asyncio.py
index 115e2446..8b0da7a2 100644
--- a/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc_asyncio.py
+++ b/google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc_asyncio.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,21 +13,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
import warnings
-from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple
+from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union
from google.api_core import gapic_v1 # type: ignore
from google.api_core import grpc_helpers_async # type: ignore
-from google import auth # type: ignore
-from google.auth import credentials # type: ignore
+from google.auth import credentials as ga_credentials # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore
+import packaging.version
import grpc # type: ignore
from grpc.experimental import aio # type: ignore
from google.cloud.errorreporting_v1beta1.types import report_errors_service
-
from .base import ReportErrorsServiceTransport, DEFAULT_CLIENT_INFO
from .grpc import ReportErrorsServiceGrpcTransport
@@ -53,7 +50,7 @@ class ReportErrorsServiceGrpcAsyncIOTransport(ReportErrorsServiceTransport):
def create_channel(
cls,
host: str = "clouderrorreporting.googleapis.com",
- credentials: credentials.Credentials = None,
+ credentials: ga_credentials.Credentials = None,
credentials_file: Optional[str] = None,
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
@@ -80,13 +77,15 @@ def create_channel(
Returns:
aio.Channel: A gRPC AsyncIO channel object.
"""
- scopes = scopes or cls.AUTH_SCOPES
+
return grpc_helpers_async.create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
- scopes=scopes,
quota_project_id=quota_project_id,
+ default_scopes=cls.AUTH_SCOPES,
+ scopes=scopes,
+ default_host=cls.DEFAULT_HOST,
**kwargs,
)
@@ -94,7 +93,7 @@ def __init__(
self,
*,
host: str = "clouderrorreporting.googleapis.com",
- credentials: credentials.Credentials = None,
+ credentials: ga_credentials.Credentials = None,
credentials_file: Optional[str] = None,
scopes: Optional[Sequence[str]] = None,
channel: aio.Channel = None,
@@ -104,11 +103,13 @@ def __init__(
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id=None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ always_use_jwt_access: Optional[bool] = False,
) -> None:
"""Instantiate the transport.
Args:
- host (Optional[str]): The hostname to connect to.
+ host (Optional[str]):
+ The hostname to connect to.
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service; if none
@@ -144,6 +145,8 @@ def __init__(
API requests. If ``None``, then default info will be used.
Generally, you only need to set this if you're developing
your own client library.
+ always_use_jwt_access (Optional[bool]): Whether self signed JWT should
+ be used for service account credentials.
Raises:
google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
@@ -166,7 +169,6 @@ def __init__(
# If a channel was explicitly provided, set it.
self._grpc_channel = channel
self._ssl_channel_credentials = None
-
else:
if api_mtls_endpoint:
host = api_mtls_endpoint
@@ -196,6 +198,7 @@ def __init__(
scopes=scopes,
quota_project_id=quota_project_id,
client_info=client_info,
+ always_use_jwt_access=always_use_jwt_access,
)
if not self._grpc_channel:
diff --git a/google/cloud/errorreporting_v1beta1/types/__init__.py b/google/cloud/errorreporting_v1beta1/types/__init__.py
index 9cf5a255..cca266b6 100644
--- a/google/cloud/errorreporting_v1beta1/types/__init__.py
+++ b/google/cloud/errorreporting_v1beta1/types/__init__.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
from .common import (
ErrorContext,
ErrorEvent,
diff --git a/google/cloud/errorreporting_v1beta1/types/common.py b/google/cloud/errorreporting_v1beta1/types/common.py
index e0d1a7eb..5facb352 100644
--- a/google/cloud/errorreporting_v1beta1/types/common.py
+++ b/google/cloud/errorreporting_v1beta1/types/common.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,11 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
import proto # type: ignore
-
-from google.protobuf import timestamp_pb2 as timestamp # type: ignore
+from google.protobuf import timestamp_pb2 # type: ignore
__protobuf__ = proto.module(
@@ -47,7 +44,6 @@ class ResolutionStatus(proto.Enum):
class ErrorGroup(proto.Message):
r"""Description of a group of similar error events.
-
Attributes:
name (str):
The group resource name.
@@ -66,14 +62,11 @@ class ErrorGroup(proto.Message):
interpreted as OPEN
"""
- name = proto.Field(proto.STRING, number=1)
-
- group_id = proto.Field(proto.STRING, number=2)
-
+ name = proto.Field(proto.STRING, number=1,)
+ group_id = proto.Field(proto.STRING, number=2,)
tracking_issues = proto.RepeatedField(
proto.MESSAGE, number=3, message="TrackingIssue",
)
-
resolution_status = proto.Field(proto.ENUM, number=5, enum="ResolutionStatus",)
@@ -88,7 +81,7 @@ class TrackingIssue(proto.Message):
``https://github.com/user/project/issues/4``
"""
- url = proto.Field(proto.STRING, number=1)
+ url = proto.Field(proto.STRING, number=1,)
class ErrorEvent(proto.Message):
@@ -111,12 +104,9 @@ class ErrorEvent(proto.Message):
occurred.
"""
- event_time = proto.Field(proto.MESSAGE, number=1, message=timestamp.Timestamp,)
-
+ event_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,)
service_context = proto.Field(proto.MESSAGE, number=2, message="ServiceContext",)
-
- message = proto.Field(proto.STRING, number=3)
-
+ message = proto.Field(proto.STRING, number=3,)
context = proto.Field(proto.MESSAGE, number=5, message="ErrorContext",)
@@ -150,11 +140,9 @@ class ServiceContext(proto.Message):
and must not be set when reporting errors.
"""
- service = proto.Field(proto.STRING, number=2)
-
- version = proto.Field(proto.STRING, number=3)
-
- resource_type = proto.Field(proto.STRING, number=4)
+ service = proto.Field(proto.STRING, number=2,)
+ version = proto.Field(proto.STRING, number=3,)
+ resource_type = proto.Field(proto.STRING, number=4,)
class ErrorContext(proto.Message):
@@ -186,9 +174,7 @@ class ErrorContext(proto.Message):
"""
http_request = proto.Field(proto.MESSAGE, number=1, message="HttpRequestContext",)
-
- user = proto.Field(proto.STRING, number=2)
-
+ user = proto.Field(proto.STRING, number=2,)
report_location = proto.Field(proto.MESSAGE, number=3, message="SourceLocation",)
@@ -221,17 +207,12 @@ class HttpRequestContext(proto.Message):
report.
"""
- method = proto.Field(proto.STRING, number=1)
-
- url = proto.Field(proto.STRING, number=2)
-
- user_agent = proto.Field(proto.STRING, number=3)
-
- referrer = proto.Field(proto.STRING, number=4)
-
- response_status_code = proto.Field(proto.INT32, number=5)
-
- remote_ip = proto.Field(proto.STRING, number=6)
+ method = proto.Field(proto.STRING, number=1,)
+ url = proto.Field(proto.STRING, number=2,)
+ user_agent = proto.Field(proto.STRING, number=3,)
+ referrer = proto.Field(proto.STRING, number=4,)
+ response_status_code = proto.Field(proto.INT32, number=5,)
+ remote_ip = proto.Field(proto.STRING, number=6,)
class SourceLocation(proto.Message):
@@ -255,11 +236,9 @@ class SourceLocation(proto.Message):
example, ``my.package.MyClass.method`` in case of Java.
"""
- file_path = proto.Field(proto.STRING, number=1)
-
- line_number = proto.Field(proto.INT32, number=2)
-
- function_name = proto.Field(proto.STRING, number=4)
+ file_path = proto.Field(proto.STRING, number=1,)
+ line_number = proto.Field(proto.INT32, number=2,)
+ function_name = proto.Field(proto.STRING, number=4,)
__all__ = tuple(sorted(__protobuf__.manifest))
diff --git a/google/cloud/errorreporting_v1beta1/types/error_group_service.py b/google/cloud/errorreporting_v1beta1/types/error_group_service.py
index e36854b6..4865d99c 100644
--- a/google/cloud/errorreporting_v1beta1/types/error_group_service.py
+++ b/google/cloud/errorreporting_v1beta1/types/error_group_service.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,10 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
import proto # type: ignore
-
from google.cloud.errorreporting_v1beta1.types import common
@@ -29,7 +26,6 @@
class GetGroupRequest(proto.Message):
r"""A request to return an individual group.
-
Attributes:
group_name (str):
Required. The group resource name. Written as
@@ -40,12 +36,11 @@ class GetGroupRequest(proto.Message):
Example: ``projects/my-project-123/groups/my-group``
"""
- group_name = proto.Field(proto.STRING, number=1)
+ group_name = proto.Field(proto.STRING, number=1,)
class UpdateGroupRequest(proto.Message):
r"""A request to replace the existing data for the given group.
-
Attributes:
group (google.cloud.errorreporting_v1beta1.types.ErrorGroup):
Required. The group which replaces the
diff --git a/google/cloud/errorreporting_v1beta1/types/error_stats_service.py b/google/cloud/errorreporting_v1beta1/types/error_stats_service.py
index 3973ca04..08b5aba9 100644
--- a/google/cloud/errorreporting_v1beta1/types/error_stats_service.py
+++ b/google/cloud/errorreporting_v1beta1/types/error_stats_service.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,13 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
import proto # type: ignore
-
from google.cloud.errorreporting_v1beta1.types import common
-from google.protobuf import duration_pb2 as duration # type: ignore
-from google.protobuf import timestamp_pb2 as timestamp # type: ignore
+from google.protobuf import duration_pb2 # type: ignore
+from google.protobuf import timestamp_pb2 # type: ignore
__protobuf__ = proto.module(
@@ -62,7 +59,6 @@ class ErrorGroupOrder(proto.Enum):
class ListGroupStatsRequest(proto.Message):
r"""Specifies a set of ``ErrorGroupStats`` to return.
-
Attributes:
project_name (str):
Required. The resource name of the Google Cloud Platform
@@ -111,34 +107,26 @@ class ListGroupStatsRequest(proto.Message):
with the identical query parameters as the first request.
"""
- project_name = proto.Field(proto.STRING, number=1)
-
- group_id = proto.RepeatedField(proto.STRING, number=2)
-
+ project_name = proto.Field(proto.STRING, number=1,)
+ group_id = proto.RepeatedField(proto.STRING, number=2,)
service_filter = proto.Field(
proto.MESSAGE, number=3, message="ServiceContextFilter",
)
-
time_range = proto.Field(proto.MESSAGE, number=5, message="QueryTimeRange",)
-
timed_count_duration = proto.Field(
- proto.MESSAGE, number=6, message=duration.Duration,
+ proto.MESSAGE, number=6, message=duration_pb2.Duration,
)
-
alignment = proto.Field(proto.ENUM, number=7, enum="TimedCountAlignment",)
-
- alignment_time = proto.Field(proto.MESSAGE, number=8, message=timestamp.Timestamp,)
-
+ alignment_time = proto.Field(
+ proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,
+ )
order = proto.Field(proto.ENUM, number=9, enum="ErrorGroupOrder",)
-
- page_size = proto.Field(proto.INT32, number=11)
-
- page_token = proto.Field(proto.STRING, number=12)
+ page_size = proto.Field(proto.INT32, number=11,)
+ page_token = proto.Field(proto.STRING, number=12,)
class ListGroupStatsResponse(proto.Message):
r"""Contains a set of requested error group stats.
-
Attributes:
error_group_stats (Sequence[google.cloud.errorreporting_v1beta1.types.ErrorGroupStats]):
The error group stats which match the given
@@ -164,11 +152,9 @@ def raw_page(self):
error_group_stats = proto.RepeatedField(
proto.MESSAGE, number=1, message="ErrorGroupStats",
)
-
- next_page_token = proto.Field(proto.STRING, number=2)
-
+ next_page_token = proto.Field(proto.STRING, number=2,)
time_range_begin = proto.Field(
- proto.MESSAGE, number=4, message=timestamp.Timestamp,
+ proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,
)
@@ -230,23 +216,19 @@ class ErrorGroupStats(proto.Message):
"""
group = proto.Field(proto.MESSAGE, number=1, message=common.ErrorGroup,)
-
- count = proto.Field(proto.INT64, number=2)
-
- affected_users_count = proto.Field(proto.INT64, number=3)
-
+ count = proto.Field(proto.INT64, number=2,)
+ affected_users_count = proto.Field(proto.INT64, number=3,)
timed_counts = proto.RepeatedField(proto.MESSAGE, number=4, message="TimedCount",)
-
- first_seen_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,)
-
- last_seen_time = proto.Field(proto.MESSAGE, number=6, message=timestamp.Timestamp,)
-
+ first_seen_time = proto.Field(
+ proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,
+ )
+ last_seen_time = proto.Field(
+ proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,
+ )
affected_services = proto.RepeatedField(
proto.MESSAGE, number=7, message=common.ServiceContext,
)
-
- num_affected_services = proto.Field(proto.INT32, number=8)
-
+ num_affected_services = proto.Field(proto.INT32, number=8,)
representative = proto.Field(proto.MESSAGE, number=9, message=common.ErrorEvent,)
@@ -266,16 +248,13 @@ class TimedCount(proto.Message):
End of the time period to which ``count`` refers (excluded).
"""
- count = proto.Field(proto.INT64, number=1)
-
- start_time = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,)
-
- end_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,)
+ count = proto.Field(proto.INT64, number=1,)
+ start_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,)
+ end_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,)
class ListEventsRequest(proto.Message):
r"""Specifies a set of error events to return.
-
Attributes:
project_name (str):
Required. The resource name of the Google Cloud Platform
@@ -305,24 +284,18 @@ class ListEventsRequest(proto.Message):
response.
"""
- project_name = proto.Field(proto.STRING, number=1)
-
- group_id = proto.Field(proto.STRING, number=2)
-
+ project_name = proto.Field(proto.STRING, number=1,)
+ group_id = proto.Field(proto.STRING, number=2,)
service_filter = proto.Field(
proto.MESSAGE, number=3, message="ServiceContextFilter",
)
-
time_range = proto.Field(proto.MESSAGE, number=4, message="QueryTimeRange",)
-
- page_size = proto.Field(proto.INT32, number=6)
-
- page_token = proto.Field(proto.STRING, number=7)
+ page_size = proto.Field(proto.INT32, number=6,)
+ page_token = proto.Field(proto.STRING, number=7,)
class ListEventsResponse(proto.Message):
r"""Contains a set of requested error events.
-
Attributes:
error_events (Sequence[google.cloud.errorreporting_v1beta1.types.ErrorEvent]):
The error events which match the given
@@ -344,11 +317,9 @@ def raw_page(self):
error_events = proto.RepeatedField(
proto.MESSAGE, number=1, message=common.ErrorEvent,
)
-
- next_page_token = proto.Field(proto.STRING, number=2)
-
+ next_page_token = proto.Field(proto.STRING, number=2,)
time_range_begin = proto.Field(
- proto.MESSAGE, number=4, message=timestamp.Timestamp,
+ proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,
)
@@ -392,16 +363,13 @@ class ServiceContextFilter(proto.Message):
```ServiceContext.resource_type`` `__.
"""
- service = proto.Field(proto.STRING, number=2)
-
- version = proto.Field(proto.STRING, number=3)
-
- resource_type = proto.Field(proto.STRING, number=4)
+ service = proto.Field(proto.STRING, number=2,)
+ version = proto.Field(proto.STRING, number=3,)
+ resource_type = proto.Field(proto.STRING, number=4,)
class DeleteEventsRequest(proto.Message):
r"""Deletes all events in the project.
-
Attributes:
project_name (str):
Required. The resource name of the Google Cloud Platform
@@ -412,11 +380,11 @@ class DeleteEventsRequest(proto.Message):
Example: ``projects/my-project-123``.
"""
- project_name = proto.Field(proto.STRING, number=1)
+ project_name = proto.Field(proto.STRING, number=1,)
class DeleteEventsResponse(proto.Message):
- r"""Response message for deleting error events."""
+ r"""Response message for deleting error events. """
__all__ = tuple(sorted(__protobuf__.manifest))
diff --git a/google/cloud/errorreporting_v1beta1/types/report_errors_service.py b/google/cloud/errorreporting_v1beta1/types/report_errors_service.py
index bdba6ee8..82840f60 100644
--- a/google/cloud/errorreporting_v1beta1/types/report_errors_service.py
+++ b/google/cloud/errorreporting_v1beta1/types/report_errors_service.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,12 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
import proto # type: ignore
-
from google.cloud.errorreporting_v1beta1.types import common
-from google.protobuf import timestamp_pb2 as timestamp # type: ignore
+from google.protobuf import timestamp_pb2 # type: ignore
__protobuf__ = proto.module(
@@ -34,7 +31,6 @@
class ReportErrorEventRequest(proto.Message):
r"""A request for reporting an individual error event.
-
Attributes:
project_name (str):
Required. The resource name of the Google Cloud Platform
@@ -47,15 +43,14 @@ class ReportErrorEventRequest(proto.Message):
Required. The error event to be reported.
"""
- project_name = proto.Field(proto.STRING, number=1)
-
+ project_name = proto.Field(proto.STRING, number=1,)
event = proto.Field(proto.MESSAGE, number=2, message="ReportedErrorEvent",)
class ReportErrorEventResponse(proto.Message):
r"""Response for reporting an individual error event.
Data may be added to this message in the future.
- """
+ """
class ReportedErrorEvent(proto.Message):
@@ -102,14 +97,11 @@ class ReportedErrorEvent(proto.Message):
which the error occurred.
"""
- event_time = proto.Field(proto.MESSAGE, number=1, message=timestamp.Timestamp,)
-
+ event_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,)
service_context = proto.Field(
proto.MESSAGE, number=2, message=common.ServiceContext,
)
-
- message = proto.Field(proto.STRING, number=3)
-
+ message = proto.Field(proto.STRING, number=3,)
context = proto.Field(proto.MESSAGE, number=4, message=common.ErrorContext,)
diff --git a/noxfile.py b/noxfile.py
index 3f66499f..fa33394f 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -62,16 +62,9 @@ def lint(session):
session.run("flake8", "google", "tests")
-@nox.session(python="3.6")
+@nox.session(python=DEFAULT_PYTHON_VERSION)
def blacken(session):
- """Run black.
-
- Format code to uniform standard.
-
- This currently uses Python 3.6 due to the automated Kokoro run of synthtool.
- That run uses an image that doesn't have 3.6 installed. Before updating this
- check the state of the `gcp_ubuntu_config` we use for that Kokoro run.
- """
+ """Run black. Format code to uniform standard."""
session.install(BLACK_VERSION)
session.run(
"black", *BLACK_PATHS,
@@ -131,9 +124,6 @@ def system(session):
# Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true.
if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false":
session.skip("RUN_SYSTEM_TESTS is set to false, skipping")
- # 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")
@@ -191,7 +181,7 @@ def docs(session):
"""Build the docs for this library."""
session.install("-e", ".")
- session.install("sphinx", "alabaster", "recommonmark")
+ session.install("sphinx==4.0.1", "alabaster", "recommonmark")
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
session.run(
@@ -213,7 +203,9 @@ def docfx(session):
"""Build the docfx yaml files for this library."""
session.install("-e", ".")
- session.install("sphinx", "alabaster", "recommonmark", "gcp-sphinx-docfx-yaml")
+ session.install(
+ "sphinx==4.0.1", "alabaster", "recommonmark", "gcp-sphinx-docfx-yaml"
+ )
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
session.run(
diff --git a/synth.py b/owlbot.py
similarity index 73%
rename from synth.py
rename to owlbot.py
index 5fb57f34..8fd0def0 100644
--- a/synth.py
+++ b/owlbot.py
@@ -17,19 +17,14 @@
from synthtool import gcp
from synthtool.languages import python
-gapic = gcp.GAPICBazel()
common = gcp.CommonTemplates()
-# ----------------------------------------------------------------------------
-# Generate error_reporting GAPIC layer
-# ----------------------------------------------------------------------------
-library = gapic.py_library(
- service="errorreporting",
- version="v1beta1",
- bazel_target="//google/devtools/clouderrorreporting/v1beta1:devtools-clouderrorreporting-v1beta1-py",
- include_protos=True,
-)
-s.move(library, excludes=["nox.py", "setup.py", "README.rst", "docs/index.rst", "google/cloud/errorreporting/"])
+default_version = "v1beta1"
+
+for library in s.get_staging_dirs(default_version):
+ s.move(library, excludes=["nox.py", "setup.py", "README.rst", "docs/index.rst", "google/cloud/errorreporting/"])
+
+s.remove_staging_dirs()
# ----------------------------------------------------------------------------
# Add templated files
diff --git a/renovate.json b/renovate.json
index f08bc22c..c0489556 100644
--- a/renovate.json
+++ b/renovate.json
@@ -2,5 +2,8 @@
"extends": [
"config:base", ":preserveSemverRanges"
],
- "ignorePaths": [".pre-commit-config.yaml"]
+ "ignorePaths": [".pre-commit-config.yaml"],
+ "pip_requirements": {
+ "fileMatch": ["requirements-test.txt", "samples/[\\S/]*constraints.txt", "samples/[\\S/]*constraints-test.txt"]
+ }
}
diff --git a/samples/snippets/api/noxfile.py b/samples/snippets/api/noxfile.py
index 97bf7da8..5ff9e1db 100644
--- a/samples/snippets/api/noxfile.py
+++ b/samples/snippets/api/noxfile.py
@@ -50,7 +50,10 @@
# to use your own Cloud project.
'gcloud_project_env': 'GOOGLE_CLOUD_PROJECT',
# 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
-
+ # If you need to use a specific version of pip,
+ # change pip_version_override to the string representation
+ # of the version number, for example, "20.2.4"
+ "pip_version_override": None,
# A dictionary you want to inject into your test. Don't put any
# secrets here. These values will override predefined values.
'envs': {},
@@ -170,12 +173,21 @@ def blacken(session: nox.sessions.Session) -> None:
def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None:
+ if TEST_CONFIG["pip_version_override"]:
+ pip_version = TEST_CONFIG["pip_version_override"]
+ session.install(f"pip=={pip_version}")
"""Runs py.test for a particular project."""
if os.path.exists("requirements.txt"):
- session.install("-r", "requirements.txt")
+ if os.path.exists("constraints.txt"):
+ session.install("-r", "requirements.txt", "-c", "constraints.txt")
+ else:
+ session.install("-r", "requirements.txt")
if os.path.exists("requirements-test.txt"):
- session.install("-r", "requirements-test.txt")
+ if os.path.exists("constraints-test.txt"):
+ session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt")
+ else:
+ session.install("-r", "requirements-test.txt")
if INSTALL_LIBRARY_FROM_SOURCE:
session.install("-e", _get_repo_root())
diff --git a/samples/snippets/api/requirements-test.txt b/samples/snippets/api/requirements-test.txt
index 7e460c8c..95ea1e6a 100644
--- a/samples/snippets/api/requirements-test.txt
+++ b/samples/snippets/api/requirements-test.txt
@@ -1 +1 @@
-pytest==6.0.1
+pytest==6.2.4
diff --git a/samples/snippets/api/requirements.txt b/samples/snippets/api/requirements.txt
index 47f476da..562e7605 100644
--- a/samples/snippets/api/requirements.txt
+++ b/samples/snippets/api/requirements.txt
@@ -1 +1 @@
-google-cloud-error-reporting==1.1.1
+google-cloud-error-reporting==1.1.2
diff --git a/samples/snippets/fluent_on_compute/noxfile.py b/samples/snippets/fluent_on_compute/noxfile.py
index 97bf7da8..5ff9e1db 100644
--- a/samples/snippets/fluent_on_compute/noxfile.py
+++ b/samples/snippets/fluent_on_compute/noxfile.py
@@ -50,7 +50,10 @@
# to use your own Cloud project.
'gcloud_project_env': 'GOOGLE_CLOUD_PROJECT',
# 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
-
+ # If you need to use a specific version of pip,
+ # change pip_version_override to the string representation
+ # of the version number, for example, "20.2.4"
+ "pip_version_override": None,
# A dictionary you want to inject into your test. Don't put any
# secrets here. These values will override predefined values.
'envs': {},
@@ -170,12 +173,21 @@ def blacken(session: nox.sessions.Session) -> None:
def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None:
+ if TEST_CONFIG["pip_version_override"]:
+ pip_version = TEST_CONFIG["pip_version_override"]
+ session.install(f"pip=={pip_version}")
"""Runs py.test for a particular project."""
if os.path.exists("requirements.txt"):
- session.install("-r", "requirements.txt")
+ if os.path.exists("constraints.txt"):
+ session.install("-r", "requirements.txt", "-c", "constraints.txt")
+ else:
+ session.install("-r", "requirements.txt")
if os.path.exists("requirements-test.txt"):
- session.install("-r", "requirements-test.txt")
+ if os.path.exists("constraints-test.txt"):
+ session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt")
+ else:
+ session.install("-r", "requirements-test.txt")
if INSTALL_LIBRARY_FROM_SOURCE:
session.install("-e", _get_repo_root())
diff --git a/samples/snippets/fluent_on_compute/requirements-test.txt b/samples/snippets/fluent_on_compute/requirements-test.txt
index 2466e250..b0cf7672 100644
--- a/samples/snippets/fluent_on_compute/requirements-test.txt
+++ b/samples/snippets/fluent_on_compute/requirements-test.txt
@@ -1,2 +1,2 @@
-pytest==6.0.1
-mock==4.0.2
+pytest==6.2.4
+mock==4.0.3
diff --git a/scripts/fixup_errorreporting_v1beta1_keywords.py b/scripts/fixup_errorreporting_v1beta1_keywords.py
index df916be1..7d1e7d7d 100644
--- a/scripts/fixup_errorreporting_v1beta1_keywords.py
+++ b/scripts/fixup_errorreporting_v1beta1_keywords.py
@@ -1,6 +1,5 @@
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
import argparse
import os
import libcst as cst
@@ -41,13 +39,12 @@ def partition(
class errorreportingCallTransformer(cst.CSTTransformer):
CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata')
METHOD_TO_PARAMS: Dict[str, Tuple[str]] = {
- 'delete_events': ('project_name', ),
- 'get_group': ('group_name', ),
- 'list_events': ('project_name', 'group_id', 'service_filter', 'time_range', 'page_size', 'page_token', ),
- 'list_group_stats': ('project_name', 'group_id', 'service_filter', 'time_range', 'timed_count_duration', 'alignment', 'alignment_time', 'order', 'page_size', 'page_token', ),
- 'report_error_event': ('project_name', 'event', ),
- 'update_group': ('group', ),
-
+ 'delete_events': ('project_name', ),
+ 'get_group': ('group_name', ),
+ 'list_events': ('project_name', 'group_id', 'service_filter', 'time_range', 'page_size', 'page_token', ),
+ 'list_group_stats': ('project_name', 'group_id', 'service_filter', 'time_range', 'timed_count_duration', 'alignment', 'alignment_time', 'order', 'page_size', 'page_token', ),
+ 'report_error_event': ('project_name', 'event', ),
+ 'update_group': ('group', ),
}
def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode:
@@ -78,7 +75,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode:
value=cst.Dict([
cst.DictElement(
cst.SimpleString("'{}'".format(name)),
- cst.Element(value=arg.value)
+cst.Element(value=arg.value)
)
# Note: the args + kwargs looks silly, but keep in mind that
# the control parameters had to be stripped out, and that
diff --git a/setup.py b/setup.py
index 859ef21d..90e25a4d 100644
--- a/setup.py
+++ b/setup.py
@@ -22,16 +22,17 @@
name = "google-cloud-error-reporting"
description = "Error Reporting API client library"
-version = "1.1.2"
+version = "1.2.0"
# Should be one of:
# 'Development Status :: 3 - Alpha'
# 'Development Status :: 4 - Beta'
# 'Development Status :: 5 - Production/Stable'
release_status = "Development Status :: 4 - Beta"
dependencies = [
- "google-cloud-logging>=1.14.0, <2.4",
- "google-api-core[grpc] >= 1.22.2, < 2.0.0dev",
+ "google-cloud-logging>=1.14.0, <3.0.0dev",
+ "google-api-core[grpc] >= 1.26.0, <2.0.0dev",
"proto-plus >= 1.4.0",
+ "packaging >= 14.3",
]
extras = {}
diff --git a/synth.metadata b/synth.metadata
deleted file mode 100644
index bba4a1eb..00000000
--- a/synth.metadata
+++ /dev/null
@@ -1,166 +0,0 @@
-{
- "sources": [
- {
- "git": {
- "name": ".",
- "remote": "https://github.com/googleapis/python-error-reporting.git",
- "sha": "86c5c543d2b278c5b93ea26d42ab3e57281dd4f0"
- }
- },
- {
- "git": {
- "name": "googleapis",
- "remote": "https://github.com/googleapis/googleapis.git",
- "sha": "915925089600094e72e4bfa8cf586c170e6b7109",
- "internalRef": "366152684"
- }
- },
- {
- "git": {
- "name": "synthtool",
- "remote": "https://github.com/googleapis/synthtool.git",
- "sha": "6d76df2138f8f841e5a5b9ac427f81def520c15f"
- }
- },
- {
- "git": {
- "name": "synthtool",
- "remote": "https://github.com/googleapis/synthtool.git",
- "sha": "6d76df2138f8f841e5a5b9ac427f81def520c15f"
- }
- }
- ],
- "destinations": [
- {
- "client": {
- "source": "googleapis",
- "apiName": "errorreporting",
- "apiVersion": "v1beta1",
- "language": "python",
- "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-head.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-head.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-head.cfg",
- ".kokoro/samples/python3.8/periodic.cfg",
- ".kokoro/samples/python3.8/presubmit.cfg",
- ".kokoro/test-samples-against-head.sh",
- ".kokoro/test-samples-impl.sh",
- ".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/errorreporting_v1beta1/error_group_service.rst",
- "docs/errorreporting_v1beta1/error_stats_service.rst",
- "docs/errorreporting_v1beta1/report_errors_service.rst",
- "docs/errorreporting_v1beta1/services.rst",
- "docs/errorreporting_v1beta1/types.rst",
- "docs/multiprocessing.rst",
- "google/cloud/errorreporting_v1beta1/__init__.py",
- "google/cloud/errorreporting_v1beta1/proto/common.proto",
- "google/cloud/errorreporting_v1beta1/proto/error_group_service.proto",
- "google/cloud/errorreporting_v1beta1/proto/error_stats_service.proto",
- "google/cloud/errorreporting_v1beta1/proto/report_errors_service.proto",
- "google/cloud/errorreporting_v1beta1/py.typed",
- "google/cloud/errorreporting_v1beta1/services/__init__.py",
- "google/cloud/errorreporting_v1beta1/services/error_group_service/__init__.py",
- "google/cloud/errorreporting_v1beta1/services/error_group_service/async_client.py",
- "google/cloud/errorreporting_v1beta1/services/error_group_service/client.py",
- "google/cloud/errorreporting_v1beta1/services/error_group_service/transports/__init__.py",
- "google/cloud/errorreporting_v1beta1/services/error_group_service/transports/base.py",
- "google/cloud/errorreporting_v1beta1/services/error_group_service/transports/grpc.py",
- "google/cloud/errorreporting_v1beta1/services/error_group_service/transports/grpc_asyncio.py",
- "google/cloud/errorreporting_v1beta1/services/error_stats_service/__init__.py",
- "google/cloud/errorreporting_v1beta1/services/error_stats_service/async_client.py",
- "google/cloud/errorreporting_v1beta1/services/error_stats_service/client.py",
- "google/cloud/errorreporting_v1beta1/services/error_stats_service/pagers.py",
- "google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/__init__.py",
- "google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/base.py",
- "google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/grpc.py",
- "google/cloud/errorreporting_v1beta1/services/error_stats_service/transports/grpc_asyncio.py",
- "google/cloud/errorreporting_v1beta1/services/report_errors_service/__init__.py",
- "google/cloud/errorreporting_v1beta1/services/report_errors_service/async_client.py",
- "google/cloud/errorreporting_v1beta1/services/report_errors_service/client.py",
- "google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/__init__.py",
- "google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/base.py",
- "google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc.py",
- "google/cloud/errorreporting_v1beta1/services/report_errors_service/transports/grpc_asyncio.py",
- "google/cloud/errorreporting_v1beta1/types/__init__.py",
- "google/cloud/errorreporting_v1beta1/types/common.py",
- "google/cloud/errorreporting_v1beta1/types/error_group_service.py",
- "google/cloud/errorreporting_v1beta1/types/error_stats_service.py",
- "google/cloud/errorreporting_v1beta1/types/report_errors_service.py",
- "mypy.ini",
- "noxfile.py",
- "renovate.json",
- "samples/AUTHORING_GUIDE.md",
- "samples/CONTRIBUTING.md",
- "samples/snippets/api/noxfile.py",
- "samples/snippets/fluent_on_compute/noxfile.py",
- "scripts/decrypt-secrets.sh",
- "scripts/fixup_errorreporting_v1beta1_keywords.py",
- "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/errorreporting_v1beta1/__init__.py",
- "tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py",
- "tests/unit/gapic/errorreporting_v1beta1/test_error_stats_service.py",
- "tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py"
- ]
-}
\ No newline at end of file
diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt
index cf04f5fa..9e25b6db 100644
--- a/testing/constraints-3.6.txt
+++ b/testing/constraints-3.6.txt
@@ -6,5 +6,6 @@
# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev",
# Then this file should have foo==1.14.0
google-cloud-logging==1.14.0
-google-api-core==1.22.2
+google-api-core==1.26.0
proto-plus==1.4.0
+packaging==14.3
diff --git a/tests/__init__.py b/tests/__init__.py
index e69de29b..4de65971 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -0,0 +1,15 @@
+# -*- 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.
+#
diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py
index df379f1e..4de65971 100644
--- a/tests/unit/__init__.py
+++ b/tests/unit/__init__.py
@@ -1,4 +1,5 @@
-# Copyright 2016 Google LLC
+# -*- 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.
@@ -11,3 +12,4 @@
# 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.
+#
diff --git a/tests/unit/gapic/__init__.py b/tests/unit/gapic/__init__.py
new file mode 100644
index 00000000..4de65971
--- /dev/null
+++ b/tests/unit/gapic/__init__.py
@@ -0,0 +1,15 @@
+# -*- 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.
+#
diff --git a/tests/unit/gapic/errorreporting_v1beta1/__init__.py b/tests/unit/gapic/errorreporting_v1beta1/__init__.py
index 42ffdf2b..4de65971 100644
--- a/tests/unit/gapic/errorreporting_v1beta1/__init__.py
+++ b/tests/unit/gapic/errorreporting_v1beta1/__init__.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py b/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py
index 814cefe8..2ed701f9 100644
--- a/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py
+++ b/tests/unit/gapic/errorreporting_v1beta1/test_error_group_service.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,9 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
import os
import mock
+import packaging.version
import grpc
from grpc.experimental import aio
@@ -24,13 +23,13 @@
import pytest
from proto.marshal.rules.dates import DurationRule, TimestampRule
-from google import auth
+
from google.api_core import client_options
-from google.api_core import exceptions
+from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
from google.api_core import grpc_helpers
from google.api_core import grpc_helpers_async
-from google.auth import credentials
+from google.auth import credentials as ga_credentials
from google.auth.exceptions import MutualTLSChannelError
from google.cloud.errorreporting_v1beta1.services.error_group_service import (
ErrorGroupServiceAsyncClient,
@@ -39,9 +38,27 @@
ErrorGroupServiceClient,
)
from google.cloud.errorreporting_v1beta1.services.error_group_service import transports
+from google.cloud.errorreporting_v1beta1.services.error_group_service.transports.base import (
+ _GOOGLE_AUTH_VERSION,
+)
from google.cloud.errorreporting_v1beta1.types import common
from google.cloud.errorreporting_v1beta1.types import error_group_service
from google.oauth2 import service_account
+import google.auth
+
+
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
+# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
+requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
+ packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
+ reason="This test requires google-auth < 1.25.0",
+)
+requires_google_auth_gte_1_25_0 = pytest.mark.skipif(
+ packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"),
+ reason="This test requires google-auth >= 1.25.0",
+)
def client_cert_source_callback():
@@ -93,7 +110,7 @@ def test__get_default_mtls_endpoint():
"client_class", [ErrorGroupServiceClient, ErrorGroupServiceAsyncClient,]
)
def test_error_group_service_client_from_service_account_info(client_class):
- creds = credentials.AnonymousCredentials()
+ creds = ga_credentials.AnonymousCredentials()
with mock.patch.object(
service_account.Credentials, "from_service_account_info"
) as factory:
@@ -106,11 +123,41 @@ def test_error_group_service_client_from_service_account_info(client_class):
assert client.transport._host == "clouderrorreporting.googleapis.com:443"
+@pytest.mark.parametrize(
+ "client_class", [ErrorGroupServiceClient, ErrorGroupServiceAsyncClient,]
+)
+def test_error_group_service_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.ErrorGroupServiceGrpcTransport, "grpc"),
+ (transports.ErrorGroupServiceGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_error_group_service_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize(
"client_class", [ErrorGroupServiceClient, ErrorGroupServiceAsyncClient,]
)
def test_error_group_service_client_from_service_account_file(client_class):
- creds = credentials.AnonymousCredentials()
+ creds = ga_credentials.AnonymousCredentials()
with mock.patch.object(
service_account.Credentials, "from_service_account_file"
) as factory:
@@ -163,7 +210,7 @@ def test_error_group_service_client_client_options(
):
# Check that if channel is provided we won't create a new one.
with mock.patch.object(ErrorGroupServiceClient, "get_transport_class") as gtc:
- transport = transport_class(credentials=credentials.AnonymousCredentials())
+ transport = transport_class(credentials=ga_credentials.AnonymousCredentials())
client = client_class(transport=transport)
gtc.assert_not_called()
@@ -461,7 +508,7 @@ def test_get_group(
transport: str = "grpc", request_type=error_group_service.GetGroupRequest
):
client = ErrorGroupServiceClient(
- credentials=credentials.AnonymousCredentials(), transport=transport,
+ credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
@@ -476,23 +523,17 @@ def test_get_group(
group_id="group_id_value",
resolution_status=common.ResolutionStatus.OPEN,
)
-
response = client.get_group(request)
# Establish that the underlying gRPC stub method was called.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
-
assert args[0] == error_group_service.GetGroupRequest()
# Establish that the response is the type that we expect.
-
assert isinstance(response, common.ErrorGroup)
-
assert response.name == "name_value"
-
assert response.group_id == "group_id_value"
-
assert response.resolution_status == common.ResolutionStatus.OPEN
@@ -504,7 +545,7 @@ def test_get_group_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
client = ErrorGroupServiceClient(
- credentials=credentials.AnonymousCredentials(), transport="grpc",
+ credentials=ga_credentials.AnonymousCredentials(), transport="grpc",
)
# Mock the actual call within the gRPC stub, and fake the request.
@@ -512,7 +553,6 @@ def test_get_group_empty_call():
client.get_group()
call.assert_called()
_, args, _ = call.mock_calls[0]
-
assert args[0] == error_group_service.GetGroupRequest()
@@ -521,7 +561,7 @@ async def test_get_group_async(
transport: str = "grpc_asyncio", request_type=error_group_service.GetGroupRequest
):
client = ErrorGroupServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(), transport=transport,
+ credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
@@ -538,22 +578,17 @@ async def test_get_group_async(
resolution_status=common.ResolutionStatus.OPEN,
)
)
-
response = await client.get_group(request)
# Establish that the underlying gRPC stub method was called.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
-
assert args[0] == error_group_service.GetGroupRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, common.ErrorGroup)
-
assert response.name == "name_value"
-
assert response.group_id == "group_id_value"
-
assert response.resolution_status == common.ResolutionStatus.OPEN
@@ -563,17 +598,17 @@ async def test_get_group_async_from_dict():
def test_get_group_field_headers():
- client = ErrorGroupServiceClient(credentials=credentials.AnonymousCredentials(),)
+ client = ErrorGroupServiceClient(credentials=ga_credentials.AnonymousCredentials(),)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = error_group_service.GetGroupRequest()
+
request.group_name = "group_name/value"
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.get_group), "__call__") as call:
call.return_value = common.ErrorGroup()
-
client.get_group(request)
# Establish that the underlying gRPC stub method was called.
@@ -589,18 +624,18 @@ def test_get_group_field_headers():
@pytest.mark.asyncio
async def test_get_group_field_headers_async():
client = ErrorGroupServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = error_group_service.GetGroupRequest()
+
request.group_name = "group_name/value"
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.get_group), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(common.ErrorGroup())
-
await client.get_group(request)
# Establish that the underlying gRPC stub method was called.
@@ -614,13 +649,12 @@ async def test_get_group_field_headers_async():
def test_get_group_flattened():
- client = ErrorGroupServiceClient(credentials=credentials.AnonymousCredentials(),)
+ client = ErrorGroupServiceClient(credentials=ga_credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.get_group), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = common.ErrorGroup()
-
# Call the method with a truthy value for each flattened field,
# using the keyword arguments to the method.
client.get_group(group_name="group_name_value",)
@@ -629,12 +663,11 @@ def test_get_group_flattened():
# request object values.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
-
assert args[0].group_name == "group_name_value"
def test_get_group_flattened_error():
- client = ErrorGroupServiceClient(credentials=credentials.AnonymousCredentials(),)
+ client = ErrorGroupServiceClient(credentials=ga_credentials.AnonymousCredentials(),)
# Attempting to call a method with both a request object and flattened
# fields is an error.
@@ -647,7 +680,7 @@ def test_get_group_flattened_error():
@pytest.mark.asyncio
async def test_get_group_flattened_async():
client = ErrorGroupServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
@@ -664,14 +697,13 @@ async def test_get_group_flattened_async():
# request object values.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
-
assert args[0].group_name == "group_name_value"
@pytest.mark.asyncio
async def test_get_group_flattened_error_async():
client = ErrorGroupServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
@@ -686,7 +718,7 @@ def test_update_group(
transport: str = "grpc", request_type=error_group_service.UpdateGroupRequest
):
client = ErrorGroupServiceClient(
- credentials=credentials.AnonymousCredentials(), transport=transport,
+ credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
@@ -701,23 +733,17 @@ def test_update_group(
group_id="group_id_value",
resolution_status=common.ResolutionStatus.OPEN,
)
-
response = client.update_group(request)
# Establish that the underlying gRPC stub method was called.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
-
assert args[0] == error_group_service.UpdateGroupRequest()
# Establish that the response is the type that we expect.
-
assert isinstance(response, common.ErrorGroup)
-
assert response.name == "name_value"
-
assert response.group_id == "group_id_value"
-
assert response.resolution_status == common.ResolutionStatus.OPEN
@@ -729,7 +755,7 @@ def test_update_group_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
client = ErrorGroupServiceClient(
- credentials=credentials.AnonymousCredentials(), transport="grpc",
+ credentials=ga_credentials.AnonymousCredentials(), transport="grpc",
)
# Mock the actual call within the gRPC stub, and fake the request.
@@ -737,7 +763,6 @@ def test_update_group_empty_call():
client.update_group()
call.assert_called()
_, args, _ = call.mock_calls[0]
-
assert args[0] == error_group_service.UpdateGroupRequest()
@@ -746,7 +771,7 @@ async def test_update_group_async(
transport: str = "grpc_asyncio", request_type=error_group_service.UpdateGroupRequest
):
client = ErrorGroupServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(), transport=transport,
+ credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
@@ -763,22 +788,17 @@ async def test_update_group_async(
resolution_status=common.ResolutionStatus.OPEN,
)
)
-
response = await client.update_group(request)
# Establish that the underlying gRPC stub method was called.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
-
assert args[0] == error_group_service.UpdateGroupRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, common.ErrorGroup)
-
assert response.name == "name_value"
-
assert response.group_id == "group_id_value"
-
assert response.resolution_status == common.ResolutionStatus.OPEN
@@ -788,17 +808,17 @@ async def test_update_group_async_from_dict():
def test_update_group_field_headers():
- client = ErrorGroupServiceClient(credentials=credentials.AnonymousCredentials(),)
+ client = ErrorGroupServiceClient(credentials=ga_credentials.AnonymousCredentials(),)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = error_group_service.UpdateGroupRequest()
+
request.group.name = "group.name/value"
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.update_group), "__call__") as call:
call.return_value = common.ErrorGroup()
-
client.update_group(request)
# Establish that the underlying gRPC stub method was called.
@@ -814,18 +834,18 @@ def test_update_group_field_headers():
@pytest.mark.asyncio
async def test_update_group_field_headers_async():
client = ErrorGroupServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = error_group_service.UpdateGroupRequest()
+
request.group.name = "group.name/value"
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.update_group), "__call__") as call:
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(common.ErrorGroup())
-
await client.update_group(request)
# Establish that the underlying gRPC stub method was called.
@@ -839,13 +859,12 @@ async def test_update_group_field_headers_async():
def test_update_group_flattened():
- client = ErrorGroupServiceClient(credentials=credentials.AnonymousCredentials(),)
+ client = ErrorGroupServiceClient(credentials=ga_credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.update_group), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = common.ErrorGroup()
-
# Call the method with a truthy value for each flattened field,
# using the keyword arguments to the method.
client.update_group(group=common.ErrorGroup(name="name_value"),)
@@ -854,12 +873,11 @@ def test_update_group_flattened():
# request object values.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
-
assert args[0].group == common.ErrorGroup(name="name_value")
def test_update_group_flattened_error():
- client = ErrorGroupServiceClient(credentials=credentials.AnonymousCredentials(),)
+ client = ErrorGroupServiceClient(credentials=ga_credentials.AnonymousCredentials(),)
# Attempting to call a method with both a request object and flattened
# fields is an error.
@@ -873,7 +891,7 @@ def test_update_group_flattened_error():
@pytest.mark.asyncio
async def test_update_group_flattened_async():
client = ErrorGroupServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
@@ -892,14 +910,13 @@ async def test_update_group_flattened_async():
# request object values.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
-
assert args[0].group == common.ErrorGroup(name="name_value")
@pytest.mark.asyncio
async def test_update_group_flattened_error_async():
client = ErrorGroupServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
@@ -914,16 +931,16 @@ async def test_update_group_flattened_error_async():
def test_credentials_transport_error():
# It is an error to provide credentials and a transport instance.
transport = transports.ErrorGroupServiceGrpcTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
with pytest.raises(ValueError):
client = ErrorGroupServiceClient(
- credentials=credentials.AnonymousCredentials(), transport=transport,
+ credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
# It is an error to provide a credentials file and a transport instance.
transport = transports.ErrorGroupServiceGrpcTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
with pytest.raises(ValueError):
client = ErrorGroupServiceClient(
@@ -933,7 +950,7 @@ def test_credentials_transport_error():
# It is an error to provide scopes and a transport instance.
transport = transports.ErrorGroupServiceGrpcTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
with pytest.raises(ValueError):
client = ErrorGroupServiceClient(
@@ -944,7 +961,7 @@ def test_credentials_transport_error():
def test_transport_instance():
# A client may be instantiated with a custom transport instance.
transport = transports.ErrorGroupServiceGrpcTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
client = ErrorGroupServiceClient(transport=transport)
assert client.transport is transport
@@ -953,13 +970,13 @@ def test_transport_instance():
def test_transport_get_channel():
# A client may be instantiated with a custom transport instance.
transport = transports.ErrorGroupServiceGrpcTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
channel = transport.grpc_channel
assert channel
transport = transports.ErrorGroupServiceGrpcAsyncIOTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
channel = transport.grpc_channel
assert channel
@@ -974,23 +991,23 @@ def test_transport_get_channel():
)
def test_transport_adc(transport_class):
# Test default credentials are used if not provided.
- with mock.patch.object(auth, "default") as adc:
- adc.return_value = (credentials.AnonymousCredentials(), None)
+ with mock.patch.object(google.auth, "default") as adc:
+ adc.return_value = (ga_credentials.AnonymousCredentials(), None)
transport_class()
adc.assert_called_once()
def test_transport_grpc_default():
# A client should use the gRPC transport by default.
- client = ErrorGroupServiceClient(credentials=credentials.AnonymousCredentials(),)
+ client = ErrorGroupServiceClient(credentials=ga_credentials.AnonymousCredentials(),)
assert isinstance(client.transport, transports.ErrorGroupServiceGrpcTransport,)
def test_error_group_service_base_transport_error():
# Passing both a credentials object and credentials_file should raise an error
- with pytest.raises(exceptions.DuplicateCredentialArgs):
+ with pytest.raises(core_exceptions.DuplicateCredentialArgs):
transport = transports.ErrorGroupServiceTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
credentials_file="credentials.json",
)
@@ -1002,7 +1019,7 @@ def test_error_group_service_base_transport():
) as Transport:
Transport.return_value = None
transport = transports.ErrorGroupServiceTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
# Every method on the transport should just blindly
@@ -1016,15 +1033,37 @@ def test_error_group_service_base_transport():
getattr(transport, method)(request=object())
+@requires_google_auth_gte_1_25_0
def test_error_group_service_base_transport_with_credentials_file():
# Instantiate the base transport with a credentials file
with mock.patch.object(
- auth, "load_credentials_from_file"
+ google.auth, "load_credentials_from_file", autospec=True
+ ) as load_creds, mock.patch(
+ "google.cloud.errorreporting_v1beta1.services.error_group_service.transports.ErrorGroupServiceTransport._prep_wrapped_messages"
+ ) as Transport:
+ Transport.return_value = None
+ load_creds.return_value = (ga_credentials.AnonymousCredentials(), None)
+ transport = transports.ErrorGroupServiceTransport(
+ credentials_file="credentials.json", quota_project_id="octopus",
+ )
+ load_creds.assert_called_once_with(
+ "credentials.json",
+ scopes=None,
+ default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ quota_project_id="octopus",
+ )
+
+
+@requires_google_auth_lt_1_25_0
+def test_error_group_service_base_transport_with_credentials_file_old_google_auth():
+ # Instantiate the base transport with a credentials file
+ with mock.patch.object(
+ google.auth, "load_credentials_from_file", autospec=True
) as load_creds, mock.patch(
"google.cloud.errorreporting_v1beta1.services.error_group_service.transports.ErrorGroupServiceTransport._prep_wrapped_messages"
) as Transport:
Transport.return_value = None
- load_creds.return_value = (credentials.AnonymousCredentials(), None)
+ load_creds.return_value = (ga_credentials.AnonymousCredentials(), None)
transport = transports.ErrorGroupServiceTransport(
credentials_file="credentials.json", quota_project_id="octopus",
)
@@ -1037,19 +1076,33 @@ def test_error_group_service_base_transport_with_credentials_file():
def test_error_group_service_base_transport_with_adc():
# Test the default credentials are used if credentials and credentials_file are None.
- with mock.patch.object(auth, "default") as adc, mock.patch(
+ with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch(
"google.cloud.errorreporting_v1beta1.services.error_group_service.transports.ErrorGroupServiceTransport._prep_wrapped_messages"
) as Transport:
Transport.return_value = None
- adc.return_value = (credentials.AnonymousCredentials(), None)
+ adc.return_value = (ga_credentials.AnonymousCredentials(), None)
transport = transports.ErrorGroupServiceTransport()
adc.assert_called_once()
+@requires_google_auth_gte_1_25_0
def test_error_group_service_auth_adc():
# If no credentials are provided, we should use ADC credentials.
- with mock.patch.object(auth, "default") as adc:
- adc.return_value = (credentials.AnonymousCredentials(), None)
+ with mock.patch.object(google.auth, "default", autospec=True) as adc:
+ adc.return_value = (ga_credentials.AnonymousCredentials(), None)
+ ErrorGroupServiceClient()
+ adc.assert_called_once_with(
+ scopes=None,
+ default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ quota_project_id=None,
+ )
+
+
+@requires_google_auth_lt_1_25_0
+def test_error_group_service_auth_adc_old_google_auth():
+ # If no credentials are provided, we should use ADC credentials.
+ with mock.patch.object(google.auth, "default", autospec=True) as adc:
+ adc.return_value = (ga_credentials.AnonymousCredentials(), None)
ErrorGroupServiceClient()
adc.assert_called_once_with(
scopes=("https://www.googleapis.com/auth/cloud-platform",),
@@ -1057,20 +1110,82 @@ def test_error_group_service_auth_adc():
)
-def test_error_group_service_transport_auth_adc():
+@pytest.mark.parametrize(
+ "transport_class",
+ [
+ transports.ErrorGroupServiceGrpcTransport,
+ transports.ErrorGroupServiceGrpcAsyncIOTransport,
+ ],
+)
+@requires_google_auth_gte_1_25_0
+def test_error_group_service_transport_auth_adc(transport_class):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
- with mock.patch.object(auth, "default") as adc:
- adc.return_value = (credentials.AnonymousCredentials(), None)
- transports.ErrorGroupServiceGrpcTransport(
- host="squid.clam.whelk", quota_project_id="octopus"
+ with mock.patch.object(google.auth, "default", autospec=True) as adc:
+ adc.return_value = (ga_credentials.AnonymousCredentials(), None)
+ transport_class(quota_project_id="octopus", scopes=["1", "2"])
+ adc.assert_called_once_with(
+ scopes=["1", "2"],
+ default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ quota_project_id="octopus",
)
+
+
+@pytest.mark.parametrize(
+ "transport_class",
+ [
+ transports.ErrorGroupServiceGrpcTransport,
+ transports.ErrorGroupServiceGrpcAsyncIOTransport,
+ ],
+)
+@requires_google_auth_lt_1_25_0
+def test_error_group_service_transport_auth_adc_old_google_auth(transport_class):
+ # If credentials and host are not provided, the transport class should use
+ # ADC credentials.
+ with mock.patch.object(google.auth, "default", autospec=True) as adc:
+ adc.return_value = (ga_credentials.AnonymousCredentials(), None)
+ transport_class(quota_project_id="octopus")
adc.assert_called_once_with(
scopes=("https://www.googleapis.com/auth/cloud-platform",),
quota_project_id="octopus",
)
+@pytest.mark.parametrize(
+ "transport_class,grpc_helpers",
+ [
+ (transports.ErrorGroupServiceGrpcTransport, grpc_helpers),
+ (transports.ErrorGroupServiceGrpcAsyncIOTransport, grpc_helpers_async),
+ ],
+)
+def test_error_group_service_transport_create_channel(transport_class, grpc_helpers):
+ # If credentials and host are not provided, the transport class should use
+ # ADC credentials.
+ with mock.patch.object(
+ google.auth, "default", autospec=True
+ ) as adc, mock.patch.object(
+ grpc_helpers, "create_channel", autospec=True
+ ) as create_channel:
+ creds = ga_credentials.AnonymousCredentials()
+ adc.return_value = (creds, None)
+ transport_class(quota_project_id="octopus", scopes=["1", "2"])
+
+ create_channel.assert_called_with(
+ "clouderrorreporting.googleapis.com:443",
+ credentials=creds,
+ credentials_file=None,
+ quota_project_id="octopus",
+ default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ scopes=["1", "2"],
+ default_host="clouderrorreporting.googleapis.com",
+ ssl_credentials=None,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
+ )
+
+
@pytest.mark.parametrize(
"transport_class",
[
@@ -1081,7 +1196,7 @@ def test_error_group_service_transport_auth_adc():
def test_error_group_service_grpc_transport_client_cert_source_for_mtls(
transport_class,
):
- cred = credentials.AnonymousCredentials()
+ cred = ga_credentials.AnonymousCredentials()
# Check ssl_channel_credentials is used if provided.
with mock.patch.object(transport_class, "create_channel") as mock_create_channel:
@@ -1095,7 +1210,7 @@ def test_error_group_service_grpc_transport_client_cert_source_for_mtls(
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -1120,7 +1235,7 @@ def test_error_group_service_grpc_transport_client_cert_source_for_mtls(
def test_error_group_service_host_no_port():
client = ErrorGroupServiceClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
client_options=client_options.ClientOptions(
api_endpoint="clouderrorreporting.googleapis.com"
),
@@ -1130,7 +1245,7 @@ def test_error_group_service_host_no_port():
def test_error_group_service_host_with_port():
client = ErrorGroupServiceClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
client_options=client_options.ClientOptions(
api_endpoint="clouderrorreporting.googleapis.com:8000"
),
@@ -1186,9 +1301,9 @@ def test_error_group_service_transport_channel_mtls_with_client_cert_source(
mock_grpc_channel = mock.Mock()
grpc_create_channel.return_value = mock_grpc_channel
- cred = credentials.AnonymousCredentials()
+ cred = ga_credentials.AnonymousCredentials()
with pytest.warns(DeprecationWarning):
- with mock.patch.object(auth, "default") as adc:
+ with mock.patch.object(google.auth, "default") as adc:
adc.return_value = (cred, None)
transport = transport_class(
host="squid.clam.whelk",
@@ -1204,7 +1319,7 @@ def test_error_group_service_transport_channel_mtls_with_client_cert_source(
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -1251,7 +1366,7 @@ def test_error_group_service_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -1265,7 +1380,6 @@ def test_error_group_service_transport_channel_mtls_with_adc(transport_class):
def test_error_group_path():
project = "squid"
group = "clam"
-
expected = "projects/{project}/groups/{group}".format(project=project, group=group,)
actual = ErrorGroupServiceClient.error_group_path(project, group)
assert expected == actual
@@ -1285,7 +1399,6 @@ def test_parse_error_group_path():
def test_common_billing_account_path():
billing_account = "oyster"
-
expected = "billingAccounts/{billing_account}".format(
billing_account=billing_account,
)
@@ -1306,7 +1419,6 @@ def test_parse_common_billing_account_path():
def test_common_folder_path():
folder = "cuttlefish"
-
expected = "folders/{folder}".format(folder=folder,)
actual = ErrorGroupServiceClient.common_folder_path(folder)
assert expected == actual
@@ -1325,7 +1437,6 @@ def test_parse_common_folder_path():
def test_common_organization_path():
organization = "winkle"
-
expected = "organizations/{organization}".format(organization=organization,)
actual = ErrorGroupServiceClient.common_organization_path(organization)
assert expected == actual
@@ -1344,7 +1455,6 @@ def test_parse_common_organization_path():
def test_common_project_path():
project = "scallop"
-
expected = "projects/{project}".format(project=project,)
actual = ErrorGroupServiceClient.common_project_path(project)
assert expected == actual
@@ -1364,7 +1474,6 @@ def test_parse_common_project_path():
def test_common_location_path():
project = "squid"
location = "clam"
-
expected = "projects/{project}/locations/{location}".format(
project=project, location=location,
)
@@ -1391,7 +1500,7 @@ def test_client_withDEFAULT_CLIENT_INFO():
transports.ErrorGroupServiceTransport, "_prep_wrapped_messages"
) as prep:
client = ErrorGroupServiceClient(
- credentials=credentials.AnonymousCredentials(), client_info=client_info,
+ credentials=ga_credentials.AnonymousCredentials(), client_info=client_info,
)
prep.assert_called_once_with(client_info)
@@ -1400,6 +1509,6 @@ def test_client_withDEFAULT_CLIENT_INFO():
) as prep:
transport_class = ErrorGroupServiceClient.get_transport_class()
transport = transport_class(
- credentials=credentials.AnonymousCredentials(), client_info=client_info,
+ credentials=ga_credentials.AnonymousCredentials(), client_info=client_info,
)
prep.assert_called_once_with(client_info)
diff --git a/tests/unit/gapic/errorreporting_v1beta1/test_error_stats_service.py b/tests/unit/gapic/errorreporting_v1beta1/test_error_stats_service.py
index 1966becb..96acc5ba 100644
--- a/tests/unit/gapic/errorreporting_v1beta1/test_error_stats_service.py
+++ b/tests/unit/gapic/errorreporting_v1beta1/test_error_stats_service.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,9 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
import os
import mock
+import packaging.version
import grpc
from grpc.experimental import aio
@@ -24,13 +23,13 @@
import pytest
from proto.marshal.rules.dates import DurationRule, TimestampRule
-from google import auth
+
from google.api_core import client_options
-from google.api_core import exceptions
+from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
from google.api_core import grpc_helpers
from google.api_core import grpc_helpers_async
-from google.auth import credentials
+from google.auth import credentials as ga_credentials
from google.auth.exceptions import MutualTLSChannelError
from google.cloud.errorreporting_v1beta1.services.error_stats_service import (
ErrorStatsServiceAsyncClient,
@@ -40,11 +39,29 @@
)
from google.cloud.errorreporting_v1beta1.services.error_stats_service import pagers
from google.cloud.errorreporting_v1beta1.services.error_stats_service import transports
+from google.cloud.errorreporting_v1beta1.services.error_stats_service.transports.base import (
+ _GOOGLE_AUTH_VERSION,
+)
from google.cloud.errorreporting_v1beta1.types import common
from google.cloud.errorreporting_v1beta1.types import error_stats_service
from google.oauth2 import service_account
-from google.protobuf import duration_pb2 as duration # type: ignore
-from google.protobuf import timestamp_pb2 as timestamp # type: ignore
+from google.protobuf import duration_pb2 # type: ignore
+from google.protobuf import timestamp_pb2 # type: ignore
+import google.auth
+
+
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
+# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
+requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
+ packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
+ reason="This test requires google-auth < 1.25.0",
+)
+requires_google_auth_gte_1_25_0 = pytest.mark.skipif(
+ packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"),
+ reason="This test requires google-auth >= 1.25.0",
+)
def client_cert_source_callback():
@@ -96,7 +113,7 @@ def test__get_default_mtls_endpoint():
"client_class", [ErrorStatsServiceClient, ErrorStatsServiceAsyncClient,]
)
def test_error_stats_service_client_from_service_account_info(client_class):
- creds = credentials.AnonymousCredentials()
+ creds = ga_credentials.AnonymousCredentials()
with mock.patch.object(
service_account.Credentials, "from_service_account_info"
) as factory:
@@ -109,11 +126,41 @@ def test_error_stats_service_client_from_service_account_info(client_class):
assert client.transport._host == "clouderrorreporting.googleapis.com:443"
+@pytest.mark.parametrize(
+ "client_class", [ErrorStatsServiceClient, ErrorStatsServiceAsyncClient,]
+)
+def test_error_stats_service_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.ErrorStatsServiceGrpcTransport, "grpc"),
+ (transports.ErrorStatsServiceGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_error_stats_service_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize(
"client_class", [ErrorStatsServiceClient, ErrorStatsServiceAsyncClient,]
)
def test_error_stats_service_client_from_service_account_file(client_class):
- creds = credentials.AnonymousCredentials()
+ creds = ga_credentials.AnonymousCredentials()
with mock.patch.object(
service_account.Credentials, "from_service_account_file"
) as factory:
@@ -166,7 +213,7 @@ def test_error_stats_service_client_client_options(
):
# Check that if channel is provided we won't create a new one.
with mock.patch.object(ErrorStatsServiceClient, "get_transport_class") as gtc:
- transport = transport_class(credentials=credentials.AnonymousCredentials())
+ transport = transport_class(credentials=ga_credentials.AnonymousCredentials())
client = client_class(transport=transport)
gtc.assert_not_called()
@@ -464,7 +511,7 @@ def test_list_group_stats(
transport: str = "grpc", request_type=error_stats_service.ListGroupStatsRequest
):
client = ErrorStatsServiceClient(
- credentials=credentials.AnonymousCredentials(), transport=transport,
+ credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
@@ -477,19 +524,15 @@ def test_list_group_stats(
call.return_value = error_stats_service.ListGroupStatsResponse(
next_page_token="next_page_token_value",
)
-
response = client.list_group_stats(request)
# Establish that the underlying gRPC stub method was called.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
-
assert args[0] == error_stats_service.ListGroupStatsRequest()
# Establish that the response is the type that we expect.
-
assert isinstance(response, pagers.ListGroupStatsPager)
-
assert response.next_page_token == "next_page_token_value"
@@ -501,7 +544,7 @@ def test_list_group_stats_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
client = ErrorStatsServiceClient(
- credentials=credentials.AnonymousCredentials(), transport="grpc",
+ credentials=ga_credentials.AnonymousCredentials(), transport="grpc",
)
# Mock the actual call within the gRPC stub, and fake the request.
@@ -509,7 +552,6 @@ def test_list_group_stats_empty_call():
client.list_group_stats()
call.assert_called()
_, args, _ = call.mock_calls[0]
-
assert args[0] == error_stats_service.ListGroupStatsRequest()
@@ -519,7 +561,7 @@ async def test_list_group_stats_async(
request_type=error_stats_service.ListGroupStatsRequest,
):
client = ErrorStatsServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(), transport=transport,
+ credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
@@ -534,18 +576,15 @@ async def test_list_group_stats_async(
next_page_token="next_page_token_value",
)
)
-
response = await client.list_group_stats(request)
# Establish that the underlying gRPC stub method was called.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
-
assert args[0] == error_stats_service.ListGroupStatsRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, pagers.ListGroupStatsAsyncPager)
-
assert response.next_page_token == "next_page_token_value"
@@ -555,17 +594,17 @@ async def test_list_group_stats_async_from_dict():
def test_list_group_stats_field_headers():
- client = ErrorStatsServiceClient(credentials=credentials.AnonymousCredentials(),)
+ client = ErrorStatsServiceClient(credentials=ga_credentials.AnonymousCredentials(),)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = error_stats_service.ListGroupStatsRequest()
+
request.project_name = "project_name/value"
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.list_group_stats), "__call__") as call:
call.return_value = error_stats_service.ListGroupStatsResponse()
-
client.list_group_stats(request)
# Establish that the underlying gRPC stub method was called.
@@ -583,12 +622,13 @@ def test_list_group_stats_field_headers():
@pytest.mark.asyncio
async def test_list_group_stats_field_headers_async():
client = ErrorStatsServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = error_stats_service.ListGroupStatsRequest()
+
request.project_name = "project_name/value"
# Mock the actual call within the gRPC stub, and fake the request.
@@ -596,7 +636,6 @@ async def test_list_group_stats_field_headers_async():
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
error_stats_service.ListGroupStatsResponse()
)
-
await client.list_group_stats(request)
# Establish that the underlying gRPC stub method was called.
@@ -612,13 +651,12 @@ async def test_list_group_stats_field_headers_async():
def test_list_group_stats_flattened():
- client = ErrorStatsServiceClient(credentials=credentials.AnonymousCredentials(),)
+ client = ErrorStatsServiceClient(credentials=ga_credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.list_group_stats), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = error_stats_service.ListGroupStatsResponse()
-
# Call the method with a truthy value for each flattened field,
# using the keyword arguments to the method.
client.list_group_stats(
@@ -632,16 +670,14 @@ def test_list_group_stats_flattened():
# request object values.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
-
assert args[0].project_name == "project_name_value"
-
assert args[0].time_range == error_stats_service.QueryTimeRange(
period=error_stats_service.QueryTimeRange.Period.PERIOD_1_HOUR
)
def test_list_group_stats_flattened_error():
- client = ErrorStatsServiceClient(credentials=credentials.AnonymousCredentials(),)
+ client = ErrorStatsServiceClient(credentials=ga_credentials.AnonymousCredentials(),)
# Attempting to call a method with both a request object and flattened
# fields is an error.
@@ -658,7 +694,7 @@ def test_list_group_stats_flattened_error():
@pytest.mark.asyncio
async def test_list_group_stats_flattened_async():
client = ErrorStatsServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
@@ -682,9 +718,7 @@ async def test_list_group_stats_flattened_async():
# request object values.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
-
assert args[0].project_name == "project_name_value"
-
assert args[0].time_range == error_stats_service.QueryTimeRange(
period=error_stats_service.QueryTimeRange.Period.PERIOD_1_HOUR
)
@@ -693,7 +727,7 @@ async def test_list_group_stats_flattened_async():
@pytest.mark.asyncio
async def test_list_group_stats_flattened_error_async():
client = ErrorStatsServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
@@ -709,7 +743,7 @@ async def test_list_group_stats_flattened_error_async():
def test_list_group_stats_pager():
- client = ErrorStatsServiceClient(credentials=credentials.AnonymousCredentials,)
+ client = ErrorStatsServiceClient(credentials=ga_credentials.AnonymousCredentials,)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.list_group_stats), "__call__") as call:
@@ -753,7 +787,7 @@ def test_list_group_stats_pager():
def test_list_group_stats_pages():
- client = ErrorStatsServiceClient(credentials=credentials.AnonymousCredentials,)
+ client = ErrorStatsServiceClient(credentials=ga_credentials.AnonymousCredentials,)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.list_group_stats), "__call__") as call:
@@ -789,7 +823,9 @@ def test_list_group_stats_pages():
@pytest.mark.asyncio
async def test_list_group_stats_async_pager():
- client = ErrorStatsServiceAsyncClient(credentials=credentials.AnonymousCredentials,)
+ client = ErrorStatsServiceAsyncClient(
+ credentials=ga_credentials.AnonymousCredentials,
+ )
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
@@ -834,7 +870,9 @@ async def test_list_group_stats_async_pager():
@pytest.mark.asyncio
async def test_list_group_stats_async_pages():
- client = ErrorStatsServiceAsyncClient(credentials=credentials.AnonymousCredentials,)
+ client = ErrorStatsServiceAsyncClient(
+ credentials=ga_credentials.AnonymousCredentials,
+ )
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
@@ -876,7 +914,7 @@ def test_list_events(
transport: str = "grpc", request_type=error_stats_service.ListEventsRequest
):
client = ErrorStatsServiceClient(
- credentials=credentials.AnonymousCredentials(), transport=transport,
+ credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
@@ -889,19 +927,15 @@ def test_list_events(
call.return_value = error_stats_service.ListEventsResponse(
next_page_token="next_page_token_value",
)
-
response = client.list_events(request)
# Establish that the underlying gRPC stub method was called.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
-
assert args[0] == error_stats_service.ListEventsRequest()
# Establish that the response is the type that we expect.
-
assert isinstance(response, pagers.ListEventsPager)
-
assert response.next_page_token == "next_page_token_value"
@@ -913,7 +947,7 @@ def test_list_events_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
client = ErrorStatsServiceClient(
- credentials=credentials.AnonymousCredentials(), transport="grpc",
+ credentials=ga_credentials.AnonymousCredentials(), transport="grpc",
)
# Mock the actual call within the gRPC stub, and fake the request.
@@ -921,7 +955,6 @@ def test_list_events_empty_call():
client.list_events()
call.assert_called()
_, args, _ = call.mock_calls[0]
-
assert args[0] == error_stats_service.ListEventsRequest()
@@ -930,7 +963,7 @@ async def test_list_events_async(
transport: str = "grpc_asyncio", request_type=error_stats_service.ListEventsRequest
):
client = ErrorStatsServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(), transport=transport,
+ credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
@@ -945,18 +978,15 @@ async def test_list_events_async(
next_page_token="next_page_token_value",
)
)
-
response = await client.list_events(request)
# Establish that the underlying gRPC stub method was called.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
-
assert args[0] == error_stats_service.ListEventsRequest()
# Establish that the response is the type that we expect.
assert isinstance(response, pagers.ListEventsAsyncPager)
-
assert response.next_page_token == "next_page_token_value"
@@ -966,17 +996,17 @@ async def test_list_events_async_from_dict():
def test_list_events_field_headers():
- client = ErrorStatsServiceClient(credentials=credentials.AnonymousCredentials(),)
+ client = ErrorStatsServiceClient(credentials=ga_credentials.AnonymousCredentials(),)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = error_stats_service.ListEventsRequest()
+
request.project_name = "project_name/value"
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.list_events), "__call__") as call:
call.return_value = error_stats_service.ListEventsResponse()
-
client.list_events(request)
# Establish that the underlying gRPC stub method was called.
@@ -994,12 +1024,13 @@ def test_list_events_field_headers():
@pytest.mark.asyncio
async def test_list_events_field_headers_async():
client = ErrorStatsServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = error_stats_service.ListEventsRequest()
+
request.project_name = "project_name/value"
# Mock the actual call within the gRPC stub, and fake the request.
@@ -1007,7 +1038,6 @@ async def test_list_events_field_headers_async():
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
error_stats_service.ListEventsResponse()
)
-
await client.list_events(request)
# Establish that the underlying gRPC stub method was called.
@@ -1023,13 +1053,12 @@ async def test_list_events_field_headers_async():
def test_list_events_flattened():
- client = ErrorStatsServiceClient(credentials=credentials.AnonymousCredentials(),)
+ client = ErrorStatsServiceClient(credentials=ga_credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.list_events), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = error_stats_service.ListEventsResponse()
-
# Call the method with a truthy value for each flattened field,
# using the keyword arguments to the method.
client.list_events(
@@ -1040,14 +1069,12 @@ def test_list_events_flattened():
# request object values.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
-
assert args[0].project_name == "project_name_value"
-
assert args[0].group_id == "group_id_value"
def test_list_events_flattened_error():
- client = ErrorStatsServiceClient(credentials=credentials.AnonymousCredentials(),)
+ client = ErrorStatsServiceClient(credentials=ga_credentials.AnonymousCredentials(),)
# Attempting to call a method with both a request object and flattened
# fields is an error.
@@ -1062,7 +1089,7 @@ def test_list_events_flattened_error():
@pytest.mark.asyncio
async def test_list_events_flattened_async():
client = ErrorStatsServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
@@ -1083,16 +1110,14 @@ async def test_list_events_flattened_async():
# request object values.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
-
assert args[0].project_name == "project_name_value"
-
assert args[0].group_id == "group_id_value"
@pytest.mark.asyncio
async def test_list_events_flattened_error_async():
client = ErrorStatsServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
@@ -1106,7 +1131,7 @@ async def test_list_events_flattened_error_async():
def test_list_events_pager():
- client = ErrorStatsServiceClient(credentials=credentials.AnonymousCredentials,)
+ client = ErrorStatsServiceClient(credentials=ga_credentials.AnonymousCredentials,)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.list_events), "__call__") as call:
@@ -1146,7 +1171,7 @@ def test_list_events_pager():
def test_list_events_pages():
- client = ErrorStatsServiceClient(credentials=credentials.AnonymousCredentials,)
+ client = ErrorStatsServiceClient(credentials=ga_credentials.AnonymousCredentials,)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.list_events), "__call__") as call:
@@ -1178,7 +1203,9 @@ def test_list_events_pages():
@pytest.mark.asyncio
async def test_list_events_async_pager():
- client = ErrorStatsServiceAsyncClient(credentials=credentials.AnonymousCredentials,)
+ client = ErrorStatsServiceAsyncClient(
+ credentials=ga_credentials.AnonymousCredentials,
+ )
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
@@ -1217,7 +1244,9 @@ async def test_list_events_async_pager():
@pytest.mark.asyncio
async def test_list_events_async_pages():
- client = ErrorStatsServiceAsyncClient(credentials=credentials.AnonymousCredentials,)
+ client = ErrorStatsServiceAsyncClient(
+ credentials=ga_credentials.AnonymousCredentials,
+ )
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
@@ -1255,7 +1284,7 @@ def test_delete_events(
transport: str = "grpc", request_type=error_stats_service.DeleteEventsRequest
):
client = ErrorStatsServiceClient(
- credentials=credentials.AnonymousCredentials(), transport=transport,
+ credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
@@ -1266,17 +1295,14 @@ def test_delete_events(
with mock.patch.object(type(client.transport.delete_events), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = error_stats_service.DeleteEventsResponse()
-
response = client.delete_events(request)
# Establish that the underlying gRPC stub method was called.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
-
assert args[0] == error_stats_service.DeleteEventsRequest()
# Establish that the response is the type that we expect.
-
assert isinstance(response, error_stats_service.DeleteEventsResponse)
@@ -1288,7 +1314,7 @@ def test_delete_events_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
client = ErrorStatsServiceClient(
- credentials=credentials.AnonymousCredentials(), transport="grpc",
+ credentials=ga_credentials.AnonymousCredentials(), transport="grpc",
)
# Mock the actual call within the gRPC stub, and fake the request.
@@ -1296,7 +1322,6 @@ def test_delete_events_empty_call():
client.delete_events()
call.assert_called()
_, args, _ = call.mock_calls[0]
-
assert args[0] == error_stats_service.DeleteEventsRequest()
@@ -1306,7 +1331,7 @@ async def test_delete_events_async(
request_type=error_stats_service.DeleteEventsRequest,
):
client = ErrorStatsServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(), transport=transport,
+ credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
@@ -1319,13 +1344,11 @@ async def test_delete_events_async(
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
error_stats_service.DeleteEventsResponse()
)
-
response = await client.delete_events(request)
# Establish that the underlying gRPC stub method was called.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
-
assert args[0] == error_stats_service.DeleteEventsRequest()
# Establish that the response is the type that we expect.
@@ -1338,17 +1361,17 @@ async def test_delete_events_async_from_dict():
def test_delete_events_field_headers():
- client = ErrorStatsServiceClient(credentials=credentials.AnonymousCredentials(),)
+ client = ErrorStatsServiceClient(credentials=ga_credentials.AnonymousCredentials(),)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = error_stats_service.DeleteEventsRequest()
+
request.project_name = "project_name/value"
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.delete_events), "__call__") as call:
call.return_value = error_stats_service.DeleteEventsResponse()
-
client.delete_events(request)
# Establish that the underlying gRPC stub method was called.
@@ -1366,12 +1389,13 @@ def test_delete_events_field_headers():
@pytest.mark.asyncio
async def test_delete_events_field_headers_async():
client = ErrorStatsServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = error_stats_service.DeleteEventsRequest()
+
request.project_name = "project_name/value"
# Mock the actual call within the gRPC stub, and fake the request.
@@ -1379,7 +1403,6 @@ async def test_delete_events_field_headers_async():
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
error_stats_service.DeleteEventsResponse()
)
-
await client.delete_events(request)
# Establish that the underlying gRPC stub method was called.
@@ -1395,13 +1418,12 @@ async def test_delete_events_field_headers_async():
def test_delete_events_flattened():
- client = ErrorStatsServiceClient(credentials=credentials.AnonymousCredentials(),)
+ client = ErrorStatsServiceClient(credentials=ga_credentials.AnonymousCredentials(),)
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(type(client.transport.delete_events), "__call__") as call:
# Designate an appropriate return value for the call.
call.return_value = error_stats_service.DeleteEventsResponse()
-
# Call the method with a truthy value for each flattened field,
# using the keyword arguments to the method.
client.delete_events(project_name="project_name_value",)
@@ -1410,12 +1432,11 @@ def test_delete_events_flattened():
# request object values.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
-
assert args[0].project_name == "project_name_value"
def test_delete_events_flattened_error():
- client = ErrorStatsServiceClient(credentials=credentials.AnonymousCredentials(),)
+ client = ErrorStatsServiceClient(credentials=ga_credentials.AnonymousCredentials(),)
# Attempting to call a method with both a request object and flattened
# fields is an error.
@@ -1429,7 +1450,7 @@ def test_delete_events_flattened_error():
@pytest.mark.asyncio
async def test_delete_events_flattened_async():
client = ErrorStatsServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
@@ -1448,14 +1469,13 @@ async def test_delete_events_flattened_async():
# request object values.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
-
assert args[0].project_name == "project_name_value"
@pytest.mark.asyncio
async def test_delete_events_flattened_error_async():
client = ErrorStatsServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
@@ -1470,16 +1490,16 @@ async def test_delete_events_flattened_error_async():
def test_credentials_transport_error():
# It is an error to provide credentials and a transport instance.
transport = transports.ErrorStatsServiceGrpcTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
with pytest.raises(ValueError):
client = ErrorStatsServiceClient(
- credentials=credentials.AnonymousCredentials(), transport=transport,
+ credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
# It is an error to provide a credentials file and a transport instance.
transport = transports.ErrorStatsServiceGrpcTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
with pytest.raises(ValueError):
client = ErrorStatsServiceClient(
@@ -1489,7 +1509,7 @@ def test_credentials_transport_error():
# It is an error to provide scopes and a transport instance.
transport = transports.ErrorStatsServiceGrpcTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
with pytest.raises(ValueError):
client = ErrorStatsServiceClient(
@@ -1500,7 +1520,7 @@ def test_credentials_transport_error():
def test_transport_instance():
# A client may be instantiated with a custom transport instance.
transport = transports.ErrorStatsServiceGrpcTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
client = ErrorStatsServiceClient(transport=transport)
assert client.transport is transport
@@ -1509,13 +1529,13 @@ def test_transport_instance():
def test_transport_get_channel():
# A client may be instantiated with a custom transport instance.
transport = transports.ErrorStatsServiceGrpcTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
channel = transport.grpc_channel
assert channel
transport = transports.ErrorStatsServiceGrpcAsyncIOTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
channel = transport.grpc_channel
assert channel
@@ -1530,23 +1550,23 @@ def test_transport_get_channel():
)
def test_transport_adc(transport_class):
# Test default credentials are used if not provided.
- with mock.patch.object(auth, "default") as adc:
- adc.return_value = (credentials.AnonymousCredentials(), None)
+ with mock.patch.object(google.auth, "default") as adc:
+ adc.return_value = (ga_credentials.AnonymousCredentials(), None)
transport_class()
adc.assert_called_once()
def test_transport_grpc_default():
# A client should use the gRPC transport by default.
- client = ErrorStatsServiceClient(credentials=credentials.AnonymousCredentials(),)
+ client = ErrorStatsServiceClient(credentials=ga_credentials.AnonymousCredentials(),)
assert isinstance(client.transport, transports.ErrorStatsServiceGrpcTransport,)
def test_error_stats_service_base_transport_error():
# Passing both a credentials object and credentials_file should raise an error
- with pytest.raises(exceptions.DuplicateCredentialArgs):
+ with pytest.raises(core_exceptions.DuplicateCredentialArgs):
transport = transports.ErrorStatsServiceTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
credentials_file="credentials.json",
)
@@ -1558,7 +1578,7 @@ def test_error_stats_service_base_transport():
) as Transport:
Transport.return_value = None
transport = transports.ErrorStatsServiceTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
# Every method on the transport should just blindly
@@ -1573,15 +1593,37 @@ def test_error_stats_service_base_transport():
getattr(transport, method)(request=object())
+@requires_google_auth_gte_1_25_0
def test_error_stats_service_base_transport_with_credentials_file():
# Instantiate the base transport with a credentials file
with mock.patch.object(
- auth, "load_credentials_from_file"
+ google.auth, "load_credentials_from_file", autospec=True
) as load_creds, mock.patch(
"google.cloud.errorreporting_v1beta1.services.error_stats_service.transports.ErrorStatsServiceTransport._prep_wrapped_messages"
) as Transport:
Transport.return_value = None
- load_creds.return_value = (credentials.AnonymousCredentials(), None)
+ load_creds.return_value = (ga_credentials.AnonymousCredentials(), None)
+ transport = transports.ErrorStatsServiceTransport(
+ credentials_file="credentials.json", quota_project_id="octopus",
+ )
+ load_creds.assert_called_once_with(
+ "credentials.json",
+ scopes=None,
+ default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ quota_project_id="octopus",
+ )
+
+
+@requires_google_auth_lt_1_25_0
+def test_error_stats_service_base_transport_with_credentials_file_old_google_auth():
+ # Instantiate the base transport with a credentials file
+ with mock.patch.object(
+ google.auth, "load_credentials_from_file", autospec=True
+ ) as load_creds, mock.patch(
+ "google.cloud.errorreporting_v1beta1.services.error_stats_service.transports.ErrorStatsServiceTransport._prep_wrapped_messages"
+ ) as Transport:
+ Transport.return_value = None
+ load_creds.return_value = (ga_credentials.AnonymousCredentials(), None)
transport = transports.ErrorStatsServiceTransport(
credentials_file="credentials.json", quota_project_id="octopus",
)
@@ -1594,19 +1636,33 @@ def test_error_stats_service_base_transport_with_credentials_file():
def test_error_stats_service_base_transport_with_adc():
# Test the default credentials are used if credentials and credentials_file are None.
- with mock.patch.object(auth, "default") as adc, mock.patch(
+ with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch(
"google.cloud.errorreporting_v1beta1.services.error_stats_service.transports.ErrorStatsServiceTransport._prep_wrapped_messages"
) as Transport:
Transport.return_value = None
- adc.return_value = (credentials.AnonymousCredentials(), None)
+ adc.return_value = (ga_credentials.AnonymousCredentials(), None)
transport = transports.ErrorStatsServiceTransport()
adc.assert_called_once()
+@requires_google_auth_gte_1_25_0
def test_error_stats_service_auth_adc():
# If no credentials are provided, we should use ADC credentials.
- with mock.patch.object(auth, "default") as adc:
- adc.return_value = (credentials.AnonymousCredentials(), None)
+ with mock.patch.object(google.auth, "default", autospec=True) as adc:
+ adc.return_value = (ga_credentials.AnonymousCredentials(), None)
+ ErrorStatsServiceClient()
+ adc.assert_called_once_with(
+ scopes=None,
+ default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ quota_project_id=None,
+ )
+
+
+@requires_google_auth_lt_1_25_0
+def test_error_stats_service_auth_adc_old_google_auth():
+ # If no credentials are provided, we should use ADC credentials.
+ with mock.patch.object(google.auth, "default", autospec=True) as adc:
+ adc.return_value = (ga_credentials.AnonymousCredentials(), None)
ErrorStatsServiceClient()
adc.assert_called_once_with(
scopes=("https://www.googleapis.com/auth/cloud-platform",),
@@ -1614,20 +1670,82 @@ def test_error_stats_service_auth_adc():
)
-def test_error_stats_service_transport_auth_adc():
+@pytest.mark.parametrize(
+ "transport_class",
+ [
+ transports.ErrorStatsServiceGrpcTransport,
+ transports.ErrorStatsServiceGrpcAsyncIOTransport,
+ ],
+)
+@requires_google_auth_gte_1_25_0
+def test_error_stats_service_transport_auth_adc(transport_class):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
- with mock.patch.object(auth, "default") as adc:
- adc.return_value = (credentials.AnonymousCredentials(), None)
- transports.ErrorStatsServiceGrpcTransport(
- host="squid.clam.whelk", quota_project_id="octopus"
+ with mock.patch.object(google.auth, "default", autospec=True) as adc:
+ adc.return_value = (ga_credentials.AnonymousCredentials(), None)
+ transport_class(quota_project_id="octopus", scopes=["1", "2"])
+ adc.assert_called_once_with(
+ scopes=["1", "2"],
+ default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ quota_project_id="octopus",
)
+
+
+@pytest.mark.parametrize(
+ "transport_class",
+ [
+ transports.ErrorStatsServiceGrpcTransport,
+ transports.ErrorStatsServiceGrpcAsyncIOTransport,
+ ],
+)
+@requires_google_auth_lt_1_25_0
+def test_error_stats_service_transport_auth_adc_old_google_auth(transport_class):
+ # If credentials and host are not provided, the transport class should use
+ # ADC credentials.
+ with mock.patch.object(google.auth, "default", autospec=True) as adc:
+ adc.return_value = (ga_credentials.AnonymousCredentials(), None)
+ transport_class(quota_project_id="octopus")
adc.assert_called_once_with(
scopes=("https://www.googleapis.com/auth/cloud-platform",),
quota_project_id="octopus",
)
+@pytest.mark.parametrize(
+ "transport_class,grpc_helpers",
+ [
+ (transports.ErrorStatsServiceGrpcTransport, grpc_helpers),
+ (transports.ErrorStatsServiceGrpcAsyncIOTransport, grpc_helpers_async),
+ ],
+)
+def test_error_stats_service_transport_create_channel(transport_class, grpc_helpers):
+ # If credentials and host are not provided, the transport class should use
+ # ADC credentials.
+ with mock.patch.object(
+ google.auth, "default", autospec=True
+ ) as adc, mock.patch.object(
+ grpc_helpers, "create_channel", autospec=True
+ ) as create_channel:
+ creds = ga_credentials.AnonymousCredentials()
+ adc.return_value = (creds, None)
+ transport_class(quota_project_id="octopus", scopes=["1", "2"])
+
+ create_channel.assert_called_with(
+ "clouderrorreporting.googleapis.com:443",
+ credentials=creds,
+ credentials_file=None,
+ quota_project_id="octopus",
+ default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ scopes=["1", "2"],
+ default_host="clouderrorreporting.googleapis.com",
+ ssl_credentials=None,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
+ )
+
+
@pytest.mark.parametrize(
"transport_class",
[
@@ -1638,7 +1756,7 @@ def test_error_stats_service_transport_auth_adc():
def test_error_stats_service_grpc_transport_client_cert_source_for_mtls(
transport_class,
):
- cred = credentials.AnonymousCredentials()
+ cred = ga_credentials.AnonymousCredentials()
# Check ssl_channel_credentials is used if provided.
with mock.patch.object(transport_class, "create_channel") as mock_create_channel:
@@ -1652,7 +1770,7 @@ def test_error_stats_service_grpc_transport_client_cert_source_for_mtls(
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -1677,7 +1795,7 @@ def test_error_stats_service_grpc_transport_client_cert_source_for_mtls(
def test_error_stats_service_host_no_port():
client = ErrorStatsServiceClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
client_options=client_options.ClientOptions(
api_endpoint="clouderrorreporting.googleapis.com"
),
@@ -1687,7 +1805,7 @@ def test_error_stats_service_host_no_port():
def test_error_stats_service_host_with_port():
client = ErrorStatsServiceClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
client_options=client_options.ClientOptions(
api_endpoint="clouderrorreporting.googleapis.com:8000"
),
@@ -1743,9 +1861,9 @@ def test_error_stats_service_transport_channel_mtls_with_client_cert_source(
mock_grpc_channel = mock.Mock()
grpc_create_channel.return_value = mock_grpc_channel
- cred = credentials.AnonymousCredentials()
+ cred = ga_credentials.AnonymousCredentials()
with pytest.warns(DeprecationWarning):
- with mock.patch.object(auth, "default") as adc:
+ with mock.patch.object(google.auth, "default") as adc:
adc.return_value = (cred, None)
transport = transport_class(
host="squid.clam.whelk",
@@ -1761,7 +1879,7 @@ def test_error_stats_service_transport_channel_mtls_with_client_cert_source(
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -1808,7 +1926,7 @@ def test_error_stats_service_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -1822,7 +1940,6 @@ def test_error_stats_service_transport_channel_mtls_with_adc(transport_class):
def test_error_group_path():
project = "squid"
group = "clam"
-
expected = "projects/{project}/groups/{group}".format(project=project, group=group,)
actual = ErrorStatsServiceClient.error_group_path(project, group)
assert expected == actual
@@ -1842,7 +1959,6 @@ def test_parse_error_group_path():
def test_common_billing_account_path():
billing_account = "oyster"
-
expected = "billingAccounts/{billing_account}".format(
billing_account=billing_account,
)
@@ -1863,7 +1979,6 @@ def test_parse_common_billing_account_path():
def test_common_folder_path():
folder = "cuttlefish"
-
expected = "folders/{folder}".format(folder=folder,)
actual = ErrorStatsServiceClient.common_folder_path(folder)
assert expected == actual
@@ -1882,7 +1997,6 @@ def test_parse_common_folder_path():
def test_common_organization_path():
organization = "winkle"
-
expected = "organizations/{organization}".format(organization=organization,)
actual = ErrorStatsServiceClient.common_organization_path(organization)
assert expected == actual
@@ -1901,7 +2015,6 @@ def test_parse_common_organization_path():
def test_common_project_path():
project = "scallop"
-
expected = "projects/{project}".format(project=project,)
actual = ErrorStatsServiceClient.common_project_path(project)
assert expected == actual
@@ -1921,7 +2034,6 @@ def test_parse_common_project_path():
def test_common_location_path():
project = "squid"
location = "clam"
-
expected = "projects/{project}/locations/{location}".format(
project=project, location=location,
)
@@ -1948,7 +2060,7 @@ def test_client_withDEFAULT_CLIENT_INFO():
transports.ErrorStatsServiceTransport, "_prep_wrapped_messages"
) as prep:
client = ErrorStatsServiceClient(
- credentials=credentials.AnonymousCredentials(), client_info=client_info,
+ credentials=ga_credentials.AnonymousCredentials(), client_info=client_info,
)
prep.assert_called_once_with(client_info)
@@ -1957,6 +2069,6 @@ def test_client_withDEFAULT_CLIENT_INFO():
) as prep:
transport_class = ErrorStatsServiceClient.get_transport_class()
transport = transport_class(
- credentials=credentials.AnonymousCredentials(), client_info=client_info,
+ credentials=ga_credentials.AnonymousCredentials(), client_info=client_info,
)
prep.assert_called_once_with(client_info)
diff --git a/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py b/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py
index 98a83947..c9fbd13a 100644
--- a/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py
+++ b/tests/unit/gapic/errorreporting_v1beta1/test_report_errors_service.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,9 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
import os
import mock
+import packaging.version
import grpc
from grpc.experimental import aio
@@ -24,13 +23,13 @@
import pytest
from proto.marshal.rules.dates import DurationRule, TimestampRule
-from google import auth
+
from google.api_core import client_options
-from google.api_core import exceptions
+from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
from google.api_core import grpc_helpers
from google.api_core import grpc_helpers_async
-from google.auth import credentials
+from google.auth import credentials as ga_credentials
from google.auth.exceptions import MutualTLSChannelError
from google.cloud.errorreporting_v1beta1.services.report_errors_service import (
ReportErrorsServiceAsyncClient,
@@ -41,10 +40,28 @@
from google.cloud.errorreporting_v1beta1.services.report_errors_service import (
transports,
)
+from google.cloud.errorreporting_v1beta1.services.report_errors_service.transports.base import (
+ _GOOGLE_AUTH_VERSION,
+)
from google.cloud.errorreporting_v1beta1.types import common
from google.cloud.errorreporting_v1beta1.types import report_errors_service
from google.oauth2 import service_account
-from google.protobuf import timestamp_pb2 as timestamp # type: ignore
+from google.protobuf import timestamp_pb2 # type: ignore
+import google.auth
+
+
+# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively
+# through google-api-core:
+# - Delete the auth "less than" test cases
+# - Delete these pytest markers (Make the "greater than or equal to" tests the default).
+requires_google_auth_lt_1_25_0 = pytest.mark.skipif(
+ packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"),
+ reason="This test requires google-auth < 1.25.0",
+)
+requires_google_auth_gte_1_25_0 = pytest.mark.skipif(
+ packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"),
+ reason="This test requires google-auth >= 1.25.0",
+)
def client_cert_source_callback():
@@ -96,7 +113,7 @@ def test__get_default_mtls_endpoint():
"client_class", [ReportErrorsServiceClient, ReportErrorsServiceAsyncClient,]
)
def test_report_errors_service_client_from_service_account_info(client_class):
- creds = credentials.AnonymousCredentials()
+ creds = ga_credentials.AnonymousCredentials()
with mock.patch.object(
service_account.Credentials, "from_service_account_info"
) as factory:
@@ -109,11 +126,41 @@ def test_report_errors_service_client_from_service_account_info(client_class):
assert client.transport._host == "clouderrorreporting.googleapis.com:443"
+@pytest.mark.parametrize(
+ "client_class", [ReportErrorsServiceClient, ReportErrorsServiceAsyncClient,]
+)
+def test_report_errors_service_client_service_account_always_use_jwt(client_class):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ client = client_class(credentials=creds)
+ use_jwt.assert_not_called()
+
+
+@pytest.mark.parametrize(
+ "transport_class,transport_name",
+ [
+ (transports.ReportErrorsServiceGrpcTransport, "grpc"),
+ (transports.ReportErrorsServiceGrpcAsyncIOTransport, "grpc_asyncio"),
+ ],
+)
+def test_report_errors_service_client_service_account_always_use_jwt_true(
+ transport_class, transport_name
+):
+ with mock.patch.object(
+ service_account.Credentials, "with_always_use_jwt_access", create=True
+ ) as use_jwt:
+ creds = service_account.Credentials(None, None, None)
+ transport = transport_class(credentials=creds, always_use_jwt_access=True)
+ use_jwt.assert_called_once_with(True)
+
+
@pytest.mark.parametrize(
"client_class", [ReportErrorsServiceClient, ReportErrorsServiceAsyncClient,]
)
def test_report_errors_service_client_from_service_account_file(client_class):
- creds = credentials.AnonymousCredentials()
+ creds = ga_credentials.AnonymousCredentials()
with mock.patch.object(
service_account.Credentials, "from_service_account_file"
) as factory:
@@ -170,7 +217,7 @@ def test_report_errors_service_client_client_options(
):
# Check that if channel is provided we won't create a new one.
with mock.patch.object(ReportErrorsServiceClient, "get_transport_class") as gtc:
- transport = transport_class(credentials=credentials.AnonymousCredentials())
+ transport = transport_class(credentials=ga_credentials.AnonymousCredentials())
client = client_class(transport=transport)
gtc.assert_not_called()
@@ -476,7 +523,7 @@ def test_report_error_event(
transport: str = "grpc", request_type=report_errors_service.ReportErrorEventRequest
):
client = ReportErrorsServiceClient(
- credentials=credentials.AnonymousCredentials(), transport=transport,
+ credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
@@ -489,17 +536,14 @@ def test_report_error_event(
) as call:
# Designate an appropriate return value for the call.
call.return_value = report_errors_service.ReportErrorEventResponse()
-
response = client.report_error_event(request)
# Establish that the underlying gRPC stub method was called.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
-
assert args[0] == report_errors_service.ReportErrorEventRequest()
# Establish that the response is the type that we expect.
-
assert isinstance(response, report_errors_service.ReportErrorEventResponse)
@@ -511,7 +555,7 @@ def test_report_error_event_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
client = ReportErrorsServiceClient(
- credentials=credentials.AnonymousCredentials(), transport="grpc",
+ credentials=ga_credentials.AnonymousCredentials(), transport="grpc",
)
# Mock the actual call within the gRPC stub, and fake the request.
@@ -521,7 +565,6 @@ def test_report_error_event_empty_call():
client.report_error_event()
call.assert_called()
_, args, _ = call.mock_calls[0]
-
assert args[0] == report_errors_service.ReportErrorEventRequest()
@@ -531,7 +574,7 @@ async def test_report_error_event_async(
request_type=report_errors_service.ReportErrorEventRequest,
):
client = ReportErrorsServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(), transport=transport,
+ credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
# Everything is optional in proto3 as far as the runtime is concerned,
@@ -546,13 +589,11 @@ async def test_report_error_event_async(
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
report_errors_service.ReportErrorEventResponse()
)
-
response = await client.report_error_event(request)
# Establish that the underlying gRPC stub method was called.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
-
assert args[0] == report_errors_service.ReportErrorEventRequest()
# Establish that the response is the type that we expect.
@@ -565,11 +606,14 @@ async def test_report_error_event_async_from_dict():
def test_report_error_event_field_headers():
- client = ReportErrorsServiceClient(credentials=credentials.AnonymousCredentials(),)
+ client = ReportErrorsServiceClient(
+ credentials=ga_credentials.AnonymousCredentials(),
+ )
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = report_errors_service.ReportErrorEventRequest()
+
request.project_name = "project_name/value"
# Mock the actual call within the gRPC stub, and fake the request.
@@ -577,7 +621,6 @@ def test_report_error_event_field_headers():
type(client.transport.report_error_event), "__call__"
) as call:
call.return_value = report_errors_service.ReportErrorEventResponse()
-
client.report_error_event(request)
# Establish that the underlying gRPC stub method was called.
@@ -595,12 +638,13 @@ def test_report_error_event_field_headers():
@pytest.mark.asyncio
async def test_report_error_event_field_headers_async():
client = ReportErrorsServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = report_errors_service.ReportErrorEventRequest()
+
request.project_name = "project_name/value"
# Mock the actual call within the gRPC stub, and fake the request.
@@ -610,7 +654,6 @@ async def test_report_error_event_field_headers_async():
call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(
report_errors_service.ReportErrorEventResponse()
)
-
await client.report_error_event(request)
# Establish that the underlying gRPC stub method was called.
@@ -626,7 +669,9 @@ async def test_report_error_event_field_headers_async():
def test_report_error_event_flattened():
- client = ReportErrorsServiceClient(credentials=credentials.AnonymousCredentials(),)
+ client = ReportErrorsServiceClient(
+ credentials=ga_credentials.AnonymousCredentials(),
+ )
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
@@ -634,13 +679,12 @@ def test_report_error_event_flattened():
) as call:
# Designate an appropriate return value for the call.
call.return_value = report_errors_service.ReportErrorEventResponse()
-
# Call the method with a truthy value for each flattened field,
# using the keyword arguments to the method.
client.report_error_event(
project_name="project_name_value",
event=report_errors_service.ReportedErrorEvent(
- event_time=timestamp.Timestamp(seconds=751)
+ event_time=timestamp_pb2.Timestamp(seconds=751)
),
)
@@ -648,16 +692,16 @@ def test_report_error_event_flattened():
# request object values.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
-
assert args[0].project_name == "project_name_value"
-
assert args[0].event == report_errors_service.ReportedErrorEvent(
- event_time=timestamp.Timestamp(seconds=751)
+ event_time=timestamp_pb2.Timestamp(seconds=751)
)
def test_report_error_event_flattened_error():
- client = ReportErrorsServiceClient(credentials=credentials.AnonymousCredentials(),)
+ client = ReportErrorsServiceClient(
+ credentials=ga_credentials.AnonymousCredentials(),
+ )
# Attempting to call a method with both a request object and flattened
# fields is an error.
@@ -666,7 +710,7 @@ def test_report_error_event_flattened_error():
report_errors_service.ReportErrorEventRequest(),
project_name="project_name_value",
event=report_errors_service.ReportedErrorEvent(
- event_time=timestamp.Timestamp(seconds=751)
+ event_time=timestamp_pb2.Timestamp(seconds=751)
),
)
@@ -674,7 +718,7 @@ def test_report_error_event_flattened_error():
@pytest.mark.asyncio
async def test_report_error_event_flattened_async():
client = ReportErrorsServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
# Mock the actual call within the gRPC stub, and fake the request.
@@ -692,7 +736,7 @@ async def test_report_error_event_flattened_async():
response = await client.report_error_event(
project_name="project_name_value",
event=report_errors_service.ReportedErrorEvent(
- event_time=timestamp.Timestamp(seconds=751)
+ event_time=timestamp_pb2.Timestamp(seconds=751)
),
)
@@ -700,18 +744,16 @@ async def test_report_error_event_flattened_async():
# request object values.
assert len(call.mock_calls)
_, args, _ = call.mock_calls[0]
-
assert args[0].project_name == "project_name_value"
-
assert args[0].event == report_errors_service.ReportedErrorEvent(
- event_time=timestamp.Timestamp(seconds=751)
+ event_time=timestamp_pb2.Timestamp(seconds=751)
)
@pytest.mark.asyncio
async def test_report_error_event_flattened_error_async():
client = ReportErrorsServiceAsyncClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
# Attempting to call a method with both a request object and flattened
@@ -721,7 +763,7 @@ async def test_report_error_event_flattened_error_async():
report_errors_service.ReportErrorEventRequest(),
project_name="project_name_value",
event=report_errors_service.ReportedErrorEvent(
- event_time=timestamp.Timestamp(seconds=751)
+ event_time=timestamp_pb2.Timestamp(seconds=751)
),
)
@@ -729,16 +771,16 @@ async def test_report_error_event_flattened_error_async():
def test_credentials_transport_error():
# It is an error to provide credentials and a transport instance.
transport = transports.ReportErrorsServiceGrpcTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
with pytest.raises(ValueError):
client = ReportErrorsServiceClient(
- credentials=credentials.AnonymousCredentials(), transport=transport,
+ credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
# It is an error to provide a credentials file and a transport instance.
transport = transports.ReportErrorsServiceGrpcTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
with pytest.raises(ValueError):
client = ReportErrorsServiceClient(
@@ -748,7 +790,7 @@ def test_credentials_transport_error():
# It is an error to provide scopes and a transport instance.
transport = transports.ReportErrorsServiceGrpcTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
with pytest.raises(ValueError):
client = ReportErrorsServiceClient(
@@ -759,7 +801,7 @@ def test_credentials_transport_error():
def test_transport_instance():
# A client may be instantiated with a custom transport instance.
transport = transports.ReportErrorsServiceGrpcTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
client = ReportErrorsServiceClient(transport=transport)
assert client.transport is transport
@@ -768,13 +810,13 @@ def test_transport_instance():
def test_transport_get_channel():
# A client may be instantiated with a custom transport instance.
transport = transports.ReportErrorsServiceGrpcTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
channel = transport.grpc_channel
assert channel
transport = transports.ReportErrorsServiceGrpcAsyncIOTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
channel = transport.grpc_channel
assert channel
@@ -789,23 +831,25 @@ def test_transport_get_channel():
)
def test_transport_adc(transport_class):
# Test default credentials are used if not provided.
- with mock.patch.object(auth, "default") as adc:
- adc.return_value = (credentials.AnonymousCredentials(), None)
+ with mock.patch.object(google.auth, "default") as adc:
+ adc.return_value = (ga_credentials.AnonymousCredentials(), None)
transport_class()
adc.assert_called_once()
def test_transport_grpc_default():
# A client should use the gRPC transport by default.
- client = ReportErrorsServiceClient(credentials=credentials.AnonymousCredentials(),)
+ client = ReportErrorsServiceClient(
+ credentials=ga_credentials.AnonymousCredentials(),
+ )
assert isinstance(client.transport, transports.ReportErrorsServiceGrpcTransport,)
def test_report_errors_service_base_transport_error():
# Passing both a credentials object and credentials_file should raise an error
- with pytest.raises(exceptions.DuplicateCredentialArgs):
+ with pytest.raises(core_exceptions.DuplicateCredentialArgs):
transport = transports.ReportErrorsServiceTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
credentials_file="credentials.json",
)
@@ -817,7 +861,7 @@ def test_report_errors_service_base_transport():
) as Transport:
Transport.return_value = None
transport = transports.ReportErrorsServiceTransport(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
)
# Every method on the transport should just blindly
@@ -828,15 +872,37 @@ def test_report_errors_service_base_transport():
getattr(transport, method)(request=object())
+@requires_google_auth_gte_1_25_0
def test_report_errors_service_base_transport_with_credentials_file():
# Instantiate the base transport with a credentials file
with mock.patch.object(
- auth, "load_credentials_from_file"
+ google.auth, "load_credentials_from_file", autospec=True
+ ) as load_creds, mock.patch(
+ "google.cloud.errorreporting_v1beta1.services.report_errors_service.transports.ReportErrorsServiceTransport._prep_wrapped_messages"
+ ) as Transport:
+ Transport.return_value = None
+ load_creds.return_value = (ga_credentials.AnonymousCredentials(), None)
+ transport = transports.ReportErrorsServiceTransport(
+ credentials_file="credentials.json", quota_project_id="octopus",
+ )
+ load_creds.assert_called_once_with(
+ "credentials.json",
+ scopes=None,
+ default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ quota_project_id="octopus",
+ )
+
+
+@requires_google_auth_lt_1_25_0
+def test_report_errors_service_base_transport_with_credentials_file_old_google_auth():
+ # Instantiate the base transport with a credentials file
+ with mock.patch.object(
+ google.auth, "load_credentials_from_file", autospec=True
) as load_creds, mock.patch(
"google.cloud.errorreporting_v1beta1.services.report_errors_service.transports.ReportErrorsServiceTransport._prep_wrapped_messages"
) as Transport:
Transport.return_value = None
- load_creds.return_value = (credentials.AnonymousCredentials(), None)
+ load_creds.return_value = (ga_credentials.AnonymousCredentials(), None)
transport = transports.ReportErrorsServiceTransport(
credentials_file="credentials.json", quota_project_id="octopus",
)
@@ -849,19 +915,33 @@ def test_report_errors_service_base_transport_with_credentials_file():
def test_report_errors_service_base_transport_with_adc():
# Test the default credentials are used if credentials and credentials_file are None.
- with mock.patch.object(auth, "default") as adc, mock.patch(
+ with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch(
"google.cloud.errorreporting_v1beta1.services.report_errors_service.transports.ReportErrorsServiceTransport._prep_wrapped_messages"
) as Transport:
Transport.return_value = None
- adc.return_value = (credentials.AnonymousCredentials(), None)
+ adc.return_value = (ga_credentials.AnonymousCredentials(), None)
transport = transports.ReportErrorsServiceTransport()
adc.assert_called_once()
+@requires_google_auth_gte_1_25_0
def test_report_errors_service_auth_adc():
# If no credentials are provided, we should use ADC credentials.
- with mock.patch.object(auth, "default") as adc:
- adc.return_value = (credentials.AnonymousCredentials(), None)
+ with mock.patch.object(google.auth, "default", autospec=True) as adc:
+ adc.return_value = (ga_credentials.AnonymousCredentials(), None)
+ ReportErrorsServiceClient()
+ adc.assert_called_once_with(
+ scopes=None,
+ default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ quota_project_id=None,
+ )
+
+
+@requires_google_auth_lt_1_25_0
+def test_report_errors_service_auth_adc_old_google_auth():
+ # If no credentials are provided, we should use ADC credentials.
+ with mock.patch.object(google.auth, "default", autospec=True) as adc:
+ adc.return_value = (ga_credentials.AnonymousCredentials(), None)
ReportErrorsServiceClient()
adc.assert_called_once_with(
scopes=("https://www.googleapis.com/auth/cloud-platform",),
@@ -869,20 +949,82 @@ def test_report_errors_service_auth_adc():
)
-def test_report_errors_service_transport_auth_adc():
+@pytest.mark.parametrize(
+ "transport_class",
+ [
+ transports.ReportErrorsServiceGrpcTransport,
+ transports.ReportErrorsServiceGrpcAsyncIOTransport,
+ ],
+)
+@requires_google_auth_gte_1_25_0
+def test_report_errors_service_transport_auth_adc(transport_class):
# If credentials and host are not provided, the transport class should use
# ADC credentials.
- with mock.patch.object(auth, "default") as adc:
- adc.return_value = (credentials.AnonymousCredentials(), None)
- transports.ReportErrorsServiceGrpcTransport(
- host="squid.clam.whelk", quota_project_id="octopus"
+ with mock.patch.object(google.auth, "default", autospec=True) as adc:
+ adc.return_value = (ga_credentials.AnonymousCredentials(), None)
+ transport_class(quota_project_id="octopus", scopes=["1", "2"])
+ adc.assert_called_once_with(
+ scopes=["1", "2"],
+ default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ quota_project_id="octopus",
)
+
+
+@pytest.mark.parametrize(
+ "transport_class",
+ [
+ transports.ReportErrorsServiceGrpcTransport,
+ transports.ReportErrorsServiceGrpcAsyncIOTransport,
+ ],
+)
+@requires_google_auth_lt_1_25_0
+def test_report_errors_service_transport_auth_adc_old_google_auth(transport_class):
+ # If credentials and host are not provided, the transport class should use
+ # ADC credentials.
+ with mock.patch.object(google.auth, "default", autospec=True) as adc:
+ adc.return_value = (ga_credentials.AnonymousCredentials(), None)
+ transport_class(quota_project_id="octopus")
adc.assert_called_once_with(
scopes=("https://www.googleapis.com/auth/cloud-platform",),
quota_project_id="octopus",
)
+@pytest.mark.parametrize(
+ "transport_class,grpc_helpers",
+ [
+ (transports.ReportErrorsServiceGrpcTransport, grpc_helpers),
+ (transports.ReportErrorsServiceGrpcAsyncIOTransport, grpc_helpers_async),
+ ],
+)
+def test_report_errors_service_transport_create_channel(transport_class, grpc_helpers):
+ # If credentials and host are not provided, the transport class should use
+ # ADC credentials.
+ with mock.patch.object(
+ google.auth, "default", autospec=True
+ ) as adc, mock.patch.object(
+ grpc_helpers, "create_channel", autospec=True
+ ) as create_channel:
+ creds = ga_credentials.AnonymousCredentials()
+ adc.return_value = (creds, None)
+ transport_class(quota_project_id="octopus", scopes=["1", "2"])
+
+ create_channel.assert_called_with(
+ "clouderrorreporting.googleapis.com:443",
+ credentials=creds,
+ credentials_file=None,
+ quota_project_id="octopus",
+ default_scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ scopes=["1", "2"],
+ default_host="clouderrorreporting.googleapis.com",
+ ssl_credentials=None,
+ options=[
+ ("grpc.max_send_message_length", -1),
+ ("grpc.max_receive_message_length", -1),
+ ],
+ )
+
+
@pytest.mark.parametrize(
"transport_class",
[
@@ -893,7 +1035,7 @@ def test_report_errors_service_transport_auth_adc():
def test_report_errors_service_grpc_transport_client_cert_source_for_mtls(
transport_class,
):
- cred = credentials.AnonymousCredentials()
+ cred = ga_credentials.AnonymousCredentials()
# Check ssl_channel_credentials is used if provided.
with mock.patch.object(transport_class, "create_channel") as mock_create_channel:
@@ -907,7 +1049,7 @@ def test_report_errors_service_grpc_transport_client_cert_source_for_mtls(
"squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ scopes=None,
ssl_credentials=mock_ssl_channel_creds,
quota_project_id=None,
options=[
@@ -932,7 +1074,7 @@ def test_report_errors_service_grpc_transport_client_cert_source_for_mtls(
def test_report_errors_service_host_no_port():
client = ReportErrorsServiceClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
client_options=client_options.ClientOptions(
api_endpoint="clouderrorreporting.googleapis.com"
),
@@ -942,7 +1084,7 @@ def test_report_errors_service_host_no_port():
def test_report_errors_service_host_with_port():
client = ReportErrorsServiceClient(
- credentials=credentials.AnonymousCredentials(),
+ credentials=ga_credentials.AnonymousCredentials(),
client_options=client_options.ClientOptions(
api_endpoint="clouderrorreporting.googleapis.com:8000"
),
@@ -998,9 +1140,9 @@ def test_report_errors_service_transport_channel_mtls_with_client_cert_source(
mock_grpc_channel = mock.Mock()
grpc_create_channel.return_value = mock_grpc_channel
- cred = credentials.AnonymousCredentials()
+ cred = ga_credentials.AnonymousCredentials()
with pytest.warns(DeprecationWarning):
- with mock.patch.object(auth, "default") as adc:
+ with mock.patch.object(google.auth, "default") as adc:
adc.return_value = (cred, None)
transport = transport_class(
host="squid.clam.whelk",
@@ -1016,7 +1158,7 @@ def test_report_errors_service_transport_channel_mtls_with_client_cert_source(
"mtls.squid.clam.whelk:443",
credentials=cred,
credentials_file=None,
- scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -1063,7 +1205,7 @@ def test_report_errors_service_transport_channel_mtls_with_adc(transport_class):
"mtls.squid.clam.whelk:443",
credentials=mock_cred,
credentials_file=None,
- scopes=("https://www.googleapis.com/auth/cloud-platform",),
+ scopes=None,
ssl_credentials=mock_ssl_cred,
quota_project_id=None,
options=[
@@ -1076,7 +1218,6 @@ def test_report_errors_service_transport_channel_mtls_with_adc(transport_class):
def test_common_billing_account_path():
billing_account = "squid"
-
expected = "billingAccounts/{billing_account}".format(
billing_account=billing_account,
)
@@ -1097,7 +1238,6 @@ def test_parse_common_billing_account_path():
def test_common_folder_path():
folder = "whelk"
-
expected = "folders/{folder}".format(folder=folder,)
actual = ReportErrorsServiceClient.common_folder_path(folder)
assert expected == actual
@@ -1116,7 +1256,6 @@ def test_parse_common_folder_path():
def test_common_organization_path():
organization = "oyster"
-
expected = "organizations/{organization}".format(organization=organization,)
actual = ReportErrorsServiceClient.common_organization_path(organization)
assert expected == actual
@@ -1135,7 +1274,6 @@ def test_parse_common_organization_path():
def test_common_project_path():
project = "cuttlefish"
-
expected = "projects/{project}".format(project=project,)
actual = ReportErrorsServiceClient.common_project_path(project)
assert expected == actual
@@ -1155,7 +1293,6 @@ def test_parse_common_project_path():
def test_common_location_path():
project = "winkle"
location = "nautilus"
-
expected = "projects/{project}/locations/{location}".format(
project=project, location=location,
)
@@ -1182,7 +1319,7 @@ def test_client_withDEFAULT_CLIENT_INFO():
transports.ReportErrorsServiceTransport, "_prep_wrapped_messages"
) as prep:
client = ReportErrorsServiceClient(
- credentials=credentials.AnonymousCredentials(), client_info=client_info,
+ credentials=ga_credentials.AnonymousCredentials(), client_info=client_info,
)
prep.assert_called_once_with(client_info)
@@ -1191,6 +1328,6 @@ def test_client_withDEFAULT_CLIENT_INFO():
) as prep:
transport_class = ReportErrorsServiceClient.get_transport_class()
transport = transport_class(
- credentials=credentials.AnonymousCredentials(), client_info=client_info,
+ credentials=ga_credentials.AnonymousCredentials(), client_info=client_info,
)
prep.assert_called_once_with(client_info)