diff --git a/.coveragerc b/.coveragerc index be6eccb..00ae33c 100644 --- a/.coveragerc +++ b/.coveragerc @@ -2,7 +2,6 @@ branch = True [report] -fail_under = 100 show_missing = True omit = google/cloud/servicemanagement/__init__.py diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml new file mode 100644 index 0000000..e2b39f9 --- /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 0000000..07cf1b4 --- /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/api/servicemanagement/(v.*)/.*-py/(.*) + dest: /owl-bot-staging/$1/$2 + +begin-after-commit-hash: 6acf4a0a797f1082027985c55c4b14b60f673dd7 + diff --git a/.github/header-checker-lint.yml b/.github/header-checker-lint.yml index fc281c0..6fe78aa 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 0470d4a..a97a73e 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-service-management 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 8dc31aa..836cd86 100644 --- a/.kokoro/release/common.cfg +++ b/.kokoro/release/common.cfg @@ -23,18 +23,8 @@ env_vars: { value: "github/python-service-management/.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 0000000..a6afe33 --- /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-service-management/.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-service-management/.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 0000000..a1c8d97 --- /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 0000000..f9cfcd3 --- /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 0000000..50fec96 --- /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 0000000..a1c8d97 --- /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 55cc59e..62eb5a7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ # 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 @@ -26,6 +26,6 @@ repos: hooks: - id: black - repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.4 + rev: 3.9.2 hooks: - id: flake8 diff --git a/.repo-metadata.json b/.repo-metadata.json index 21ba691..3fe6759 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -4,8 +4,9 @@ "product_documentation": "https://cloud.google.com/service-infrastructure/docs/overview/", "client_documentation": "https://googleapis.dev/python/servicemanagement/latest", "issue_tracker": "", - "release_level": "beta", + "release_level": "ga", "language": "python", + "library_type": "GAPIC_AUTO", "repo": "googleapis/python-service-management", "distribution_name": "google-cloud-service-management", "api_id": "servicemanagement.googleapis.com" diff --git a/CHANGELOG.md b/CHANGELOG.md index a7da22d..5881cd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,30 @@ # Changelog +## [1.0.0](https://www.github.com/googleapis/python-service-management/compare/v0.1.0...v1.0.0) (2021-07-10) + + +### Features + +* add always_use_jwt_access ([#31](https://www.github.com/googleapis/python-service-management/issues/31)) ([8d76ae3](https://www.github.com/googleapis/python-service-management/commit/8d76ae37bb3186e8aa0991fa89a4852dd0798280)) +* bump release level to production/stable ([#17](https://www.github.com/googleapis/python-service-management/issues/17)) ([f521883](https://www.github.com/googleapis/python-service-management/commit/f52188344dea468736855dd357570d6a428b2f62)) +* support self-signed JWT flow for service accounts ([cb785b5](https://www.github.com/googleapis/python-service-management/commit/cb785b5b6885a7063f49de76ab2ff0145a83e4fe)) + + +### Bug Fixes + +* add async client ([cb785b5](https://www.github.com/googleapis/python-service-management/commit/cb785b5b6885a7063f49de76ab2ff0145a83e4fe)) +* **deps:** add packaging requirement ([#18](https://www.github.com/googleapis/python-service-management/issues/18)) ([d7084d9](https://www.github.com/googleapis/python-service-management/commit/d7084d9a4d019d54d2a7e5ded04d9d3996f0cc4c)) + + +### Documentation + +* omit mention of Python 2.7 in 'CONTRIBUTING.rst' ([#1127](https://www.github.com/googleapis/python-service-management/issues/1127)) ([#25](https://www.github.com/googleapis/python-service-management/issues/25)) ([78f33d1](https://www.github.com/googleapis/python-service-management/commit/78f33d18edec8caa2c014258307289c9aef3d609)) + + +### Miscellaneous Chores + +* release as 1.0.0 ([#22](https://www.github.com/googleapis/python-service-management/issues/22)) ([028b5a1](https://www.github.com/googleapis/python-service-management/commit/028b5a15fd80dfd62ae708a53cdef6de95ecbe92)) + ## 0.1.0 (2021-03-24) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 70cf52f..2829903 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-service-management/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/README.rst b/README.rst index 9a74068..f7709e8 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,7 @@ Python Client for Service Management API ======================================== -|beta| |pypi| |versions| +|GA| |pypi| |versions| `Service Management API`_: Service Infrastructure is a foundational platform for creating, managing, securing, and consuming APIs and services across @@ -14,8 +14,8 @@ monitoring. - `Client Library Documentation`_ - `Product Documentation`_ -.. |beta| image:: https://img.shields.io/badge/support-beta-orange.svg - :target: https://github.com/googleapis/google-cloud-python/blob/master/README.rst#beta-support +.. |GA| image:: https://img.shields.io/badge/support-ga-gold.svg + :target: https://github.com/googleapis/google-cloud-python/blob/master/README.rst#general-availability .. |pypi| image:: https://img.shields.io/pypi/v/google-cloud-service-management.svg :target: https://pypi.org/project/google-cloud-service-management/ .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-service-management.svg diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..8b58ae9 --- /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 bcd37bb..b0a2954 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 5549821..95788ea 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -80,9 +80,9 @@ master_doc = "index" # General information about the project. -project = u"google-cloud-service-management" -copyright = u"2019, Google" -author = u"Google APIs" +project = "google-cloud-service-management" +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 @@ -281,7 +281,7 @@ ( master_doc, "google-cloud-service-management.tex", - u"google-cloud-service-management Documentation", + "google-cloud-service-management Documentation", author, "manual", ) @@ -316,7 +316,7 @@ ( master_doc, "google-cloud-service-management", - u"google-cloud-service-management Documentation", + "google-cloud-service-management Documentation", [author], 1, ) @@ -335,7 +335,7 @@ ( master_doc, "google-cloud-service-management", - u"google-cloud-service-management Documentation", + "google-cloud-service-management Documentation", author, "google-cloud-service-management", "google-cloud-service-management Library", @@ -363,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/multiprocessing.rst b/docs/multiprocessing.rst index 1cb29d4..536d17b 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/docs/servicemanagement_v1/service_manager.rst b/docs/servicemanagement_v1/service_manager.rst index c83380b..54acafe 100644 --- a/docs/servicemanagement_v1/service_manager.rst +++ b/docs/servicemanagement_v1/service_manager.rst @@ -5,7 +5,6 @@ ServiceManager :members: :inherited-members: - .. automodule:: google.cloud.servicemanagement_v1.services.service_manager.pagers :members: :inherited-members: diff --git a/google/cloud/servicemanagement/__init__.py b/google/cloud/servicemanagement/__init__.py index 47f1e1f..e980da0 100644 --- a/google/cloud/servicemanagement/__init__.py +++ b/google/cloud/servicemanagement/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,12 +14,13 @@ # limitations under the License. # -from google.cloud.servicemanagement_v1.services.service_manager.async_client import ( - ServiceManagerAsyncClient, -) from google.cloud.servicemanagement_v1.services.service_manager.client import ( ServiceManagerClient, ) +from google.cloud.servicemanagement_v1.services.service_manager.async_client import ( + ServiceManagerAsyncClient, +) + from google.cloud.servicemanagement_v1.types.resources import ChangeReport from google.cloud.servicemanagement_v1.types.resources import ConfigFile from google.cloud.servicemanagement_v1.types.resources import ConfigRef @@ -84,15 +84,20 @@ ) __all__ = ( + "ServiceManagerClient", + "ServiceManagerAsyncClient", "ChangeReport", "ConfigFile", "ConfigRef", "ConfigSource", + "Diagnostic", + "ManagedService", + "OperationMetadata", + "Rollout", "CreateServiceConfigRequest", "CreateServiceRequest", "CreateServiceRolloutRequest", "DeleteServiceRequest", - "Diagnostic", "DisableServiceRequest", "DisableServiceResponse", "EnableServiceRequest", @@ -108,11 +113,6 @@ "ListServiceRolloutsResponse", "ListServicesRequest", "ListServicesResponse", - "ManagedService", - "OperationMetadata", - "Rollout", - "ServiceManagerAsyncClient", - "ServiceManagerClient", "SubmitConfigSourceRequest", "SubmitConfigSourceResponse", "UndeleteServiceRequest", diff --git a/google/cloud/servicemanagement_v1/__init__.py b/google/cloud/servicemanagement_v1/__init__.py index 132b70f..c980a83 100644 --- a/google/cloud/servicemanagement_v1/__init__.py +++ b/google/cloud/servicemanagement_v1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,6 +15,8 @@ # from .services.service_manager import ServiceManagerClient +from .services.service_manager import ServiceManagerAsyncClient + from .types.resources import ChangeReport from .types.resources import ConfigFile from .types.resources import ConfigRef @@ -48,8 +49,8 @@ from .types.servicemanager import UndeleteServiceRequest from .types.servicemanager import UndeleteServiceResponse - __all__ = ( + "ServiceManagerAsyncClient", "ChangeReport", "ConfigFile", "ConfigRef", @@ -77,9 +78,9 @@ "ManagedService", "OperationMetadata", "Rollout", + "ServiceManagerClient", "SubmitConfigSourceRequest", "SubmitConfigSourceResponse", "UndeleteServiceRequest", "UndeleteServiceResponse", - "ServiceManagerClient", ) diff --git a/google/cloud/servicemanagement_v1/gapic_metadata.json b/google/cloud/servicemanagement_v1/gapic_metadata.json new file mode 100644 index 0000000..56131c0 --- /dev/null +++ b/google/cloud/servicemanagement_v1/gapic_metadata.json @@ -0,0 +1,173 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.servicemanagement_v1", + "protoPackage": "google.api.servicemanagement.v1", + "schema": "1.0", + "services": { + "ServiceManager": { + "clients": { + "grpc": { + "libraryClient": "ServiceManagerClient", + "rpcs": { + "CreateService": { + "methods": [ + "create_service" + ] + }, + "CreateServiceConfig": { + "methods": [ + "create_service_config" + ] + }, + "CreateServiceRollout": { + "methods": [ + "create_service_rollout" + ] + }, + "DeleteService": { + "methods": [ + "delete_service" + ] + }, + "DisableService": { + "methods": [ + "disable_service" + ] + }, + "EnableService": { + "methods": [ + "enable_service" + ] + }, + "GenerateConfigReport": { + "methods": [ + "generate_config_report" + ] + }, + "GetService": { + "methods": [ + "get_service" + ] + }, + "GetServiceConfig": { + "methods": [ + "get_service_config" + ] + }, + "GetServiceRollout": { + "methods": [ + "get_service_rollout" + ] + }, + "ListServiceConfigs": { + "methods": [ + "list_service_configs" + ] + }, + "ListServiceRollouts": { + "methods": [ + "list_service_rollouts" + ] + }, + "ListServices": { + "methods": [ + "list_services" + ] + }, + "SubmitConfigSource": { + "methods": [ + "submit_config_source" + ] + }, + "UndeleteService": { + "methods": [ + "undelete_service" + ] + } + } + }, + "grpc-async": { + "libraryClient": "ServiceManagerAsyncClient", + "rpcs": { + "CreateService": { + "methods": [ + "create_service" + ] + }, + "CreateServiceConfig": { + "methods": [ + "create_service_config" + ] + }, + "CreateServiceRollout": { + "methods": [ + "create_service_rollout" + ] + }, + "DeleteService": { + "methods": [ + "delete_service" + ] + }, + "DisableService": { + "methods": [ + "disable_service" + ] + }, + "EnableService": { + "methods": [ + "enable_service" + ] + }, + "GenerateConfigReport": { + "methods": [ + "generate_config_report" + ] + }, + "GetService": { + "methods": [ + "get_service" + ] + }, + "GetServiceConfig": { + "methods": [ + "get_service_config" + ] + }, + "GetServiceRollout": { + "methods": [ + "get_service_rollout" + ] + }, + "ListServiceConfigs": { + "methods": [ + "list_service_configs" + ] + }, + "ListServiceRollouts": { + "methods": [ + "list_service_rollouts" + ] + }, + "ListServices": { + "methods": [ + "list_services" + ] + }, + "SubmitConfigSource": { + "methods": [ + "submit_config_source" + ] + }, + "UndeleteService": { + "methods": [ + "undelete_service" + ] + } + } + } + } + } + } +} diff --git a/google/cloud/servicemanagement_v1/services/__init__.py b/google/cloud/servicemanagement_v1/services/__init__.py index 42ffdf2..4de6597 100644 --- a/google/cloud/servicemanagement_v1/services/__init__.py +++ b/google/cloud/servicemanagement_v1/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/servicemanagement_v1/services/service_manager/__init__.py b/google/cloud/servicemanagement_v1/services/service_manager/__init__.py index 929bddd..a1fbec7 100644 --- a/google/cloud/servicemanagement_v1/services/service_manager/__init__.py +++ b/google/cloud/servicemanagement_v1/services/service_manager/__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 ServiceManagerClient from .async_client import ServiceManagerAsyncClient diff --git a/google/cloud/servicemanagement_v1/services/service_manager/async_client.py b/google/cloud/servicemanagement_v1/services/service_manager/async_client.py index fa001c2..c431535 100644 --- a/google/cloud/servicemanagement_v1/services/service_manager/async_client.py +++ b/google/cloud/servicemanagement_v1/services/service_manager/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,57 +13,58 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources +import warnings 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.api import auth_pb2 as auth # type: ignore -from google.api import backend_pb2 as backend # type: ignore -from google.api import billing_pb2 as billing # type: ignore -from google.api import context_pb2 as context # type: ignore -from google.api import control_pb2 as control # type: ignore -from google.api import documentation_pb2 as documentation # type: ignore -from google.api import endpoint_pb2 as endpoint # type: ignore -from google.api import http_pb2 as http # type: ignore -from google.api import log_pb2 as log # type: ignore -from google.api import logging_pb2 as logging # type: ignore -from google.api import metric_pb2 as metric # type: ignore -from google.api import monitored_resource_pb2 as monitored_resource # type: ignore -from google.api import monitoring_pb2 as monitoring # type: ignore -from google.api import quota_pb2 as quota # type: ignore -from google.api import service_pb2 as service # type: ignore -from google.api import source_info_pb2 as source_info # type: ignore -from google.api import system_parameter_pb2 as system_parameter # type: ignore -from google.api import usage_pb2 as usage # type: ignore +from google.api import auth_pb2 # type: ignore +from google.api import backend_pb2 # type: ignore +from google.api import billing_pb2 # type: ignore +from google.api import context_pb2 # type: ignore +from google.api import control_pb2 # type: ignore +from google.api import documentation_pb2 # type: ignore +from google.api import endpoint_pb2 # type: ignore +from google.api import http_pb2 # type: ignore +from google.api import log_pb2 # type: ignore +from google.api import logging_pb2 # type: ignore +from google.api import metric_pb2 # type: ignore +from google.api import monitored_resource_pb2 # type: ignore +from google.api import monitoring_pb2 # type: ignore +from google.api import quota_pb2 # type: ignore +from google.api import service_pb2 # type: ignore +from google.api import source_info_pb2 # type: ignore +from google.api import system_parameter_pb2 # type: ignore +from google.api import usage_pb2 # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.servicemanagement_v1.services.service_manager import pagers from google.cloud.servicemanagement_v1.types import resources from google.cloud.servicemanagement_v1.types import servicemanager -from google.protobuf import any_pb2 as gp_any # type: ignore -from google.protobuf import api_pb2 as api # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.protobuf import type_pb2 as gp_type # type: ignore -from google.protobuf import wrappers_pb2 as wrappers # type: ignore - +from google.protobuf import any_pb2 # type: ignore +from google.protobuf import api_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.protobuf import type_pb2 # type: ignore +from google.protobuf import wrappers_pb2 # type: ignore from .transports.base import ServiceManagerTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import ServiceManagerGrpcAsyncIOTransport from .client import ServiceManagerClient class ServiceManagerAsyncClient: - """`Google Service Management API `__""" + """`Google Service Management + API `__ + """ _client: ServiceManagerClient @@ -77,24 +77,20 @@ class ServiceManagerAsyncClient: parse_common_billing_account_path = staticmethod( ServiceManagerClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(ServiceManagerClient.common_folder_path) parse_common_folder_path = staticmethod( ServiceManagerClient.parse_common_folder_path ) - common_organization_path = staticmethod( ServiceManagerClient.common_organization_path ) parse_common_organization_path = staticmethod( ServiceManagerClient.parse_common_organization_path ) - common_project_path = staticmethod(ServiceManagerClient.common_project_path) parse_common_project_path = staticmethod( ServiceManagerClient.parse_common_project_path ) - common_location_path = staticmethod(ServiceManagerClient.common_location_path) parse_common_location_path = staticmethod( ServiceManagerClient.parse_common_location_path @@ -102,7 +98,8 @@ class ServiceManagerAsyncClient: @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. @@ -117,7 +114,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 @@ -134,7 +131,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> ServiceManagerTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: ServiceManagerTransport: The transport used by the client instance. @@ -148,12 +145,12 @@ def transport(self) -> ServiceManagerTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, ServiceManagerTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the service manager client. + """Instantiates the service manager client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -185,7 +182,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = ServiceManagerClient( credentials=credentials, transport=transport, @@ -235,7 +231,6 @@ async def list_services( This corresponds to the ``consumer_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. @@ -264,7 +259,6 @@ async def list_services( # If we have keyword arguments corresponding to fields on the # request, apply these. - if producer_project_id is not None: request.producer_project_id = producer_project_id if consumer_id is not None: @@ -314,7 +308,6 @@ async def get_service( This corresponds to the ``service_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. @@ -342,7 +335,6 @@ async def get_service( # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name @@ -385,7 +377,6 @@ async def create_service( This corresponds to the ``service`` 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. @@ -414,7 +405,6 @@ async def create_service( # If we have keyword arguments corresponding to fields on the # request, apply these. - if service is not None: request.service = service @@ -464,13 +454,13 @@ async def delete_service( method. service_name (:class:`str`): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. This corresponds to the ``service_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. @@ -510,7 +500,6 @@ async def delete_service( # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name @@ -529,7 +518,7 @@ async def delete_service( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=resources.OperationMetadata, ) @@ -559,13 +548,13 @@ async def undelete_service( method. service_name (:class:`str`): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. This corresponds to the ``service_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. @@ -595,7 +584,6 @@ async def undelete_service( # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name @@ -639,13 +627,13 @@ async def list_service_configs( ListServiceConfigs method. service_name (:class:`str`): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. This corresponds to the ``service_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. @@ -675,7 +663,6 @@ async def list_service_configs( # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name @@ -709,7 +696,7 @@ async def get_service_config( retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> service.Service: + ) -> service_pb2.Service: r"""Gets a service configuration (version) for a managed service. @@ -719,8 +706,9 @@ async def get_service_config( method. service_name (:class:`str`): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. This corresponds to the ``service_name`` field on the ``request`` instance; if ``request`` is provided, this @@ -742,7 +730,6 @@ async def get_service_config( This corresponds to the ``view`` 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. @@ -761,7 +748,7 @@ async def get_service_config( Example: - type: google.api.Service config_version: 3 name: + type: google.api.Service name: calendar.googleapis.com title: Google Calendar API apis: - name: google.calendar.v3.Calendar authentication: providers: - id: @@ -786,7 +773,6 @@ async def get_service_config( # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name if config_id is not None: @@ -813,11 +799,11 @@ async def create_service_config( request: servicemanager.CreateServiceConfigRequest = None, *, service_name: str = None, - service_config: service.Service = None, + service_config: service_pb2.Service = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> service.Service: + ) -> service_pb2.Service: r"""Creates a new service configuration (version) for a managed service. This method only stores the service configuration. To roll out the service configuration to backend systems please @@ -834,8 +820,9 @@ async def create_service_config( CreateServiceConfig method. service_name (:class:`str`): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. This corresponds to the ``service_name`` field on the ``request`` instance; if ``request`` is provided, this @@ -847,7 +834,6 @@ async def create_service_config( This corresponds to the ``service_config`` 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. @@ -866,7 +852,7 @@ async def create_service_config( Example: - type: google.api.Service config_version: 3 name: + type: google.api.Service name: calendar.googleapis.com title: Google Calendar API apis: - name: google.calendar.v3.Calendar authentication: providers: - id: @@ -891,7 +877,6 @@ async def create_service_config( # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name if service_config is not None: @@ -942,8 +927,9 @@ async def submit_config_source( SubmitConfigSource method. service_name (:class:`str`): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. This corresponds to the ``service_name`` field on the ``request`` instance; if ``request`` is provided, this @@ -964,7 +950,6 @@ async def submit_config_source( This corresponds to the ``validate_only`` 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. @@ -994,7 +979,6 @@ async def submit_config_source( # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name if config_source is not None: @@ -1044,8 +1028,9 @@ async def list_service_rollouts( 'ListServiceRollouts' service_name (:class:`str`): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. This corresponds to the ``service_name`` field on the ``request`` instance; if ``request`` is provided, this @@ -1053,18 +1038,17 @@ async def list_service_rollouts( filter (:class:`str`): Required. Use ``filter`` to return subset of rollouts. The following filters are supported: -- To limit the - results to only those in - `status `__ + results to only those in status + (google.api.servicemanagement.v1.RolloutStatus) 'SUCCESS', use filter='status=SUCCESS' -- To limit the - results to those in - `status `__ + results to those in status + (google.api.servicemanagement.v1.RolloutStatus) 'CANCELLED' or 'FAILED', use filter='status=CANCELLED OR status=FAILED' This corresponds to the ``filter`` 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. @@ -1094,7 +1078,6 @@ async def list_service_rollouts( # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name if filter is not None: @@ -1139,8 +1122,9 @@ async def get_service_rollout( GetServiceRollout method. service_name (:class:`str`): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. This corresponds to the ``service_name`` field on the ``request`` instance; if ``request`` is provided, this @@ -1152,7 +1136,6 @@ async def get_service_rollout( This corresponds to the ``rollout_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. @@ -1183,7 +1166,6 @@ async def get_service_rollout( # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name if rollout_id is not None: @@ -1237,8 +1219,9 @@ async def create_service_rollout( 'CreateServiceRollout' service_name (:class:`str`): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. This corresponds to the ``service_name`` field on the ``request`` instance; if ``request`` is provided, this @@ -1250,7 +1233,6 @@ async def create_service_rollout( This corresponds to the ``rollout`` 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. @@ -1281,7 +1263,6 @@ async def create_service_rollout( # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name if rollout is not None: @@ -1313,8 +1294,8 @@ async def generate_config_report( self, request: servicemanager.GenerateConfigReportRequest = None, *, - new_config: gp_any.Any = None, - old_config: gp_any.Any = None, + new_config: any_pb2.Any = None, + old_config: any_pb2.Any = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1358,7 +1339,6 @@ async def generate_config_report( This corresponds to the ``old_config`` 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. @@ -1385,7 +1365,6 @@ async def generate_config_report( # If we have keyword arguments corresponding to fields on the # request, apply these. - if new_config is not None: request.new_config = new_config if old_config is not None: @@ -1450,7 +1429,6 @@ async def enable_service( This corresponds to the ``consumer_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. @@ -1466,6 +1444,10 @@ async def enable_service( Operation payload for EnableService method. """ + warnings.warn( + "ServiceManagerAsyncClient.enable_service is deprecated", DeprecationWarning + ) + # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. @@ -1480,7 +1462,6 @@ async def enable_service( # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name if consumer_id is not None: @@ -1553,7 +1534,6 @@ async def disable_service( This corresponds to the ``consumer_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. @@ -1569,6 +1549,11 @@ async def disable_service( Operation payload for DisableService method. """ + warnings.warn( + "ServiceManagerAsyncClient.disable_service is deprecated", + DeprecationWarning, + ) + # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. @@ -1583,7 +1568,6 @@ async def disable_service( # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name if consumer_id is not None: diff --git a/google/cloud/servicemanagement_v1/services/service_manager/client.py b/google/cloud/servicemanagement_v1/services/service_manager/client.py index 29f75e9..d5c4777 100644 --- a/google/cloud/servicemanagement_v1/services/service_manager/client.py +++ b/google/cloud/servicemanagement_v1/services/service_manager/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,54 +13,53 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os import re from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources +import warnings 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.api import auth_pb2 as auth # type: ignore -from google.api import backend_pb2 as backend # type: ignore -from google.api import billing_pb2 as billing # type: ignore -from google.api import context_pb2 as context # type: ignore -from google.api import control_pb2 as control # type: ignore -from google.api import documentation_pb2 as documentation # type: ignore -from google.api import endpoint_pb2 as endpoint # type: ignore -from google.api import http_pb2 as http # type: ignore -from google.api import log_pb2 as log # type: ignore -from google.api import logging_pb2 as logging # type: ignore -from google.api import metric_pb2 as metric # type: ignore -from google.api import monitored_resource_pb2 as monitored_resource # type: ignore -from google.api import monitoring_pb2 as monitoring # type: ignore -from google.api import quota_pb2 as quota # type: ignore -from google.api import service_pb2 as service # type: ignore -from google.api import source_info_pb2 as source_info # type: ignore -from google.api import system_parameter_pb2 as system_parameter # type: ignore -from google.api import usage_pb2 as usage # type: ignore +from google.api import auth_pb2 # type: ignore +from google.api import backend_pb2 # type: ignore +from google.api import billing_pb2 # type: ignore +from google.api import context_pb2 # type: ignore +from google.api import control_pb2 # type: ignore +from google.api import documentation_pb2 # type: ignore +from google.api import endpoint_pb2 # type: ignore +from google.api import http_pb2 # type: ignore +from google.api import log_pb2 # type: ignore +from google.api import logging_pb2 # type: ignore +from google.api import metric_pb2 # type: ignore +from google.api import monitored_resource_pb2 # type: ignore +from google.api import monitoring_pb2 # type: ignore +from google.api import quota_pb2 # type: ignore +from google.api import service_pb2 # type: ignore +from google.api import source_info_pb2 # type: ignore +from google.api import system_parameter_pb2 # type: ignore +from google.api import usage_pb2 # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.servicemanagement_v1.services.service_manager import pagers from google.cloud.servicemanagement_v1.types import resources from google.cloud.servicemanagement_v1.types import servicemanager -from google.protobuf import any_pb2 as gp_any # type: ignore -from google.protobuf import api_pb2 as api # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.protobuf import type_pb2 as gp_type # type: ignore -from google.protobuf import wrappers_pb2 as wrappers # type: ignore - +from google.protobuf import any_pb2 # type: ignore +from google.protobuf import api_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.protobuf import type_pb2 # type: ignore +from google.protobuf import wrappers_pb2 # type: ignore from .transports.base import ServiceManagerTransport, DEFAULT_CLIENT_INFO from .transports.grpc import ServiceManagerGrpcTransport from .transports.grpc_asyncio import ServiceManagerGrpcAsyncIOTransport @@ -82,7 +80,7 @@ class ServiceManagerClientMeta(type): _transport_registry["grpc_asyncio"] = ServiceManagerGrpcAsyncIOTransport def get_transport_class(cls, label: str = None,) -> Type[ServiceManagerTransport]: - """Return an appropriate transport class. + """Returns an appropriate transport class. Args: label: The name of the desired transport. If none is @@ -101,11 +99,14 @@ def get_transport_class(cls, label: str = None,) -> Type[ServiceManagerTransport class ServiceManagerClient(metaclass=ServiceManagerClientMeta): - """`Google Service Management API `__""" + """`Google Service Management + API `__ + """ @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: @@ -139,7 +140,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. @@ -156,7 +158,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 @@ -175,16 +177,17 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> ServiceManagerTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: - ServiceManagerTransport: The transport used by the client instance. + ServiceManagerTransport: 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, ) @@ -197,7 +200,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 @@ -208,7 +211,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 @@ -219,7 +222,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 @@ -230,7 +233,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, ) @@ -244,12 +247,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, ServiceManagerTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the service manager client. + """Instantiates the service manager client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -304,9 +307,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: @@ -318,12 +322,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. @@ -338,8 +344,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: @@ -396,7 +402,6 @@ def list_services( This corresponds to the ``consumer_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. @@ -427,10 +432,8 @@ def list_services( # there are no flattened fields. if not isinstance(request, servicemanager.ListServicesRequest): request = servicemanager.ListServicesRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if producer_project_id is not None: request.producer_project_id = producer_project_id if consumer_id is not None: @@ -476,7 +479,6 @@ def get_service( This corresponds to the ``service_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. @@ -506,10 +508,8 @@ def get_service( # there are no flattened fields. if not isinstance(request, servicemanager.GetServiceRequest): request = servicemanager.GetServiceRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name @@ -548,7 +548,6 @@ def create_service( This corresponds to the ``service`` 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. @@ -579,10 +578,8 @@ def create_service( # there are no flattened fields. if not isinstance(request, servicemanager.CreateServiceRequest): request = servicemanager.CreateServiceRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if service is not None: request.service = service @@ -628,13 +625,13 @@ def delete_service( method. service_name (str): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. This corresponds to the ``service_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. @@ -676,10 +673,8 @@ def delete_service( # there are no flattened fields. if not isinstance(request, servicemanager.DeleteServiceRequest): request = servicemanager.DeleteServiceRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name @@ -694,7 +689,7 @@ def delete_service( response = operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=resources.OperationMetadata, ) @@ -724,13 +719,13 @@ def undelete_service( method. service_name (str): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. This corresponds to the ``service_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. @@ -762,10 +757,8 @@ def undelete_service( # there are no flattened fields. if not isinstance(request, servicemanager.UndeleteServiceRequest): request = servicemanager.UndeleteServiceRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name @@ -805,13 +798,13 @@ def list_service_configs( ListServiceConfigs method. service_name (str): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. This corresponds to the ``service_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. @@ -843,10 +836,8 @@ def list_service_configs( # there are no flattened fields. if not isinstance(request, servicemanager.ListServiceConfigsRequest): request = servicemanager.ListServiceConfigsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name @@ -876,7 +867,7 @@ def get_service_config( retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> service.Service: + ) -> service_pb2.Service: r"""Gets a service configuration (version) for a managed service. @@ -886,8 +877,9 @@ def get_service_config( method. service_name (str): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. This corresponds to the ``service_name`` field on the ``request`` instance; if ``request`` is provided, this @@ -909,7 +901,6 @@ def get_service_config( This corresponds to the ``view`` 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. @@ -928,7 +919,7 @@ def get_service_config( Example: - type: google.api.Service config_version: 3 name: + type: google.api.Service name: calendar.googleapis.com title: Google Calendar API apis: - name: google.calendar.v3.Calendar authentication: providers: - id: @@ -955,10 +946,8 @@ def get_service_config( # there are no flattened fields. if not isinstance(request, servicemanager.GetServiceConfigRequest): request = servicemanager.GetServiceConfigRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name if config_id is not None: @@ -981,11 +970,11 @@ def create_service_config( request: servicemanager.CreateServiceConfigRequest = None, *, service_name: str = None, - service_config: service.Service = None, + service_config: service_pb2.Service = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), - ) -> service.Service: + ) -> service_pb2.Service: r"""Creates a new service configuration (version) for a managed service. This method only stores the service configuration. To roll out the service configuration to backend systems please @@ -1002,8 +991,9 @@ def create_service_config( CreateServiceConfig method. service_name (str): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. This corresponds to the ``service_name`` field on the ``request`` instance; if ``request`` is provided, this @@ -1015,7 +1005,6 @@ def create_service_config( This corresponds to the ``service_config`` 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. @@ -1034,7 +1023,7 @@ def create_service_config( Example: - type: google.api.Service config_version: 3 name: + type: google.api.Service name: calendar.googleapis.com title: Google Calendar API apis: - name: google.calendar.v3.Calendar authentication: providers: - id: @@ -1061,10 +1050,8 @@ def create_service_config( # there are no flattened fields. if not isinstance(request, servicemanager.CreateServiceConfigRequest): request = servicemanager.CreateServiceConfigRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name if service_config is not None: @@ -1111,8 +1098,9 @@ def submit_config_source( SubmitConfigSource method. service_name (str): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. This corresponds to the ``service_name`` field on the ``request`` instance; if ``request`` is provided, this @@ -1133,7 +1121,6 @@ def submit_config_source( This corresponds to the ``validate_only`` 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. @@ -1165,10 +1152,8 @@ def submit_config_source( # there are no flattened fields. if not isinstance(request, servicemanager.SubmitConfigSourceRequest): request = servicemanager.SubmitConfigSourceRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name if config_source is not None: @@ -1214,8 +1199,9 @@ def list_service_rollouts( 'ListServiceRollouts' service_name (str): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. This corresponds to the ``service_name`` field on the ``request`` instance; if ``request`` is provided, this @@ -1223,18 +1209,17 @@ def list_service_rollouts( filter (str): Required. Use ``filter`` to return subset of rollouts. The following filters are supported: -- To limit the - results to only those in - `status `__ + results to only those in status + (google.api.servicemanagement.v1.RolloutStatus) 'SUCCESS', use filter='status=SUCCESS' -- To limit the - results to those in - `status `__ + results to those in status + (google.api.servicemanagement.v1.RolloutStatus) 'CANCELLED' or 'FAILED', use filter='status=CANCELLED OR status=FAILED' This corresponds to the ``filter`` 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. @@ -1266,10 +1251,8 @@ def list_service_rollouts( # there are no flattened fields. if not isinstance(request, servicemanager.ListServiceRolloutsRequest): request = servicemanager.ListServiceRolloutsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name if filter is not None: @@ -1310,8 +1293,9 @@ def get_service_rollout( GetServiceRollout method. service_name (str): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. This corresponds to the ``service_name`` field on the ``request`` instance; if ``request`` is provided, this @@ -1323,7 +1307,6 @@ def get_service_rollout( This corresponds to the ``rollout_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. @@ -1356,10 +1339,8 @@ def get_service_rollout( # there are no flattened fields. if not isinstance(request, servicemanager.GetServiceRolloutRequest): request = servicemanager.GetServiceRolloutRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name if rollout_id is not None: @@ -1409,8 +1390,9 @@ def create_service_rollout( 'CreateServiceRollout' service_name (str): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. This corresponds to the ``service_name`` field on the ``request`` instance; if ``request`` is provided, this @@ -1422,7 +1404,6 @@ def create_service_rollout( This corresponds to the ``rollout`` 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. @@ -1455,10 +1436,8 @@ def create_service_rollout( # there are no flattened fields. if not isinstance(request, servicemanager.CreateServiceRolloutRequest): request = servicemanager.CreateServiceRolloutRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name if rollout is not None: @@ -1486,8 +1465,8 @@ def generate_config_report( self, request: servicemanager.GenerateConfigReportRequest = None, *, - new_config: gp_any.Any = None, - old_config: gp_any.Any = None, + new_config: any_pb2.Any = None, + old_config: any_pb2.Any = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -1531,7 +1510,6 @@ def generate_config_report( This corresponds to the ``old_config`` 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. @@ -1560,10 +1538,8 @@ def generate_config_report( # there are no flattened fields. if not isinstance(request, servicemanager.GenerateConfigReportRequest): request = servicemanager.GenerateConfigReportRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if new_config is not None: request.new_config = new_config if old_config is not None: @@ -1624,7 +1600,6 @@ def enable_service( This corresponds to the ``consumer_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. @@ -1640,6 +1615,10 @@ def enable_service( Operation payload for EnableService method. """ + warnings.warn( + "ServiceManagerClient.enable_service is deprecated", DeprecationWarning + ) + # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. @@ -1656,10 +1635,8 @@ def enable_service( # there are no flattened fields. if not isinstance(request, servicemanager.EnableServiceRequest): request = servicemanager.EnableServiceRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name if consumer_id is not None: @@ -1728,7 +1705,6 @@ def disable_service( This corresponds to the ``consumer_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. @@ -1744,6 +1720,10 @@ def disable_service( Operation payload for DisableService method. """ + warnings.warn( + "ServiceManagerClient.disable_service is deprecated", DeprecationWarning + ) + # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. @@ -1760,10 +1740,8 @@ def disable_service( # there are no flattened fields. if not isinstance(request, servicemanager.DisableServiceRequest): request = servicemanager.DisableServiceRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if service_name is not None: request.service_name = service_name if consumer_id is not None: diff --git a/google/cloud/servicemanagement_v1/services/service_manager/pagers.py b/google/cloud/servicemanagement_v1/services/service_manager/pagers.py index 50c8118..17baaeb 100644 --- a/google/cloud/servicemanagement_v1/services/service_manager/pagers.py +++ b/google/cloud/servicemanagement_v1/services/service_manager/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, @@ -26,7 +24,7 @@ Optional, ) -from google.api import service_pb2 as service # type: ignore +from google.api import service_pb2 # type: ignore from google.cloud.servicemanagement_v1.types import resources from google.cloud.servicemanagement_v1.types import servicemanager @@ -119,7 +117,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -213,7 +211,7 @@ def pages(self) -> Iterable[servicemanager.ListServiceConfigsResponse]: self._response = self._method(self._request, metadata=self._metadata) yield self._response - def __iter__(self) -> Iterable[service.Service]: + def __iter__(self) -> Iterable[service_pb2.Service]: for page in self.pages: yield from page.service_configs @@ -247,7 +245,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -275,7 +273,7 @@ async def pages(self) -> AsyncIterable[servicemanager.ListServiceConfigsResponse self._response = await self._method(self._request, metadata=self._metadata) yield self._response - def __aiter__(self) -> AsyncIterable[service.Service]: + def __aiter__(self) -> AsyncIterable[service_pb2.Service]: async def async_generator(): async for page in self.pages: for response in page.service_configs: @@ -375,7 +373,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/servicemanagement_v1/services/service_manager/transports/__init__.py b/google/cloud/servicemanagement_v1/services/service_manager/transports/__init__.py index fccec92..a7e0a1a 100644 --- a/google/cloud/servicemanagement_v1/services/service_manager/transports/__init__.py +++ b/google/cloud/servicemanagement_v1/services/service_manager/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/servicemanagement_v1/services/service_manager/transports/base.py b/google/cloud/servicemanagement_v1/services/service_manager/transports/base.py index 33fe533..e2b007e 100644 --- a/google/cloud/servicemanagement_v1/services/service_manager/transports/base.py +++ b/google/cloud/servicemanagement_v1/services/service_manager/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,23 +13,24 @@ # 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.api_core import operations_v1 # 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.api import service_pb2 as service # type: ignore +from google.api import service_pb2 # type: ignore from google.cloud.servicemanagement_v1.types import resources from google.cloud.servicemanagement_v1.types import servicemanager -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -41,6 +41,15 @@ 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 ServiceManagerTransport(abc.ABC): """Abstract transport class for ServiceManager.""" @@ -52,21 +61,25 @@ class ServiceManagerTransport(abc.ABC): "https://www.googleapis.com/auth/service.management.readonly", ) + DEFAULT_HOST: str = "servicemanagement.googleapis.com" + def __init__( self, *, - host: str = "servicemanagement.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 @@ -75,7 +88,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): @@ -83,35 +96,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 = { @@ -182,11 +230,11 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def list_services( self, - ) -> typing.Callable[ + ) -> Callable[ [servicemanager.ListServicesRequest], - typing.Union[ + Union[ servicemanager.ListServicesResponse, - typing.Awaitable[servicemanager.ListServicesResponse], + Awaitable[servicemanager.ListServicesResponse], ], ]: raise NotImplementedError() @@ -194,49 +242,47 @@ def list_services( @property def get_service( self, - ) -> typing.Callable[ + ) -> Callable[ [servicemanager.GetServiceRequest], - typing.Union[ - resources.ManagedService, typing.Awaitable[resources.ManagedService] - ], + Union[resources.ManagedService, Awaitable[resources.ManagedService]], ]: raise NotImplementedError() @property def create_service( self, - ) -> typing.Callable[ + ) -> Callable[ [servicemanager.CreateServiceRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def delete_service( self, - ) -> typing.Callable[ + ) -> Callable[ [servicemanager.DeleteServiceRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def undelete_service( self, - ) -> typing.Callable[ + ) -> Callable[ [servicemanager.UndeleteServiceRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def list_service_configs( self, - ) -> typing.Callable[ + ) -> Callable[ [servicemanager.ListServiceConfigsRequest], - typing.Union[ + Union[ servicemanager.ListServiceConfigsResponse, - typing.Awaitable[servicemanager.ListServiceConfigsResponse], + Awaitable[servicemanager.ListServiceConfigsResponse], ], ]: raise NotImplementedError() @@ -244,38 +290,38 @@ def list_service_configs( @property def get_service_config( self, - ) -> typing.Callable[ + ) -> Callable[ [servicemanager.GetServiceConfigRequest], - typing.Union[service.Service, typing.Awaitable[service.Service]], + Union[service_pb2.Service, Awaitable[service_pb2.Service]], ]: raise NotImplementedError() @property def create_service_config( self, - ) -> typing.Callable[ + ) -> Callable[ [servicemanager.CreateServiceConfigRequest], - typing.Union[service.Service, typing.Awaitable[service.Service]], + Union[service_pb2.Service, Awaitable[service_pb2.Service]], ]: raise NotImplementedError() @property def submit_config_source( self, - ) -> typing.Callable[ + ) -> Callable[ [servicemanager.SubmitConfigSourceRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def list_service_rollouts( self, - ) -> typing.Callable[ + ) -> Callable[ [servicemanager.ListServiceRolloutsRequest], - typing.Union[ + Union[ servicemanager.ListServiceRolloutsResponse, - typing.Awaitable[servicemanager.ListServiceRolloutsResponse], + Awaitable[servicemanager.ListServiceRolloutsResponse], ], ]: raise NotImplementedError() @@ -283,29 +329,29 @@ def list_service_rollouts( @property def get_service_rollout( self, - ) -> typing.Callable[ + ) -> Callable[ [servicemanager.GetServiceRolloutRequest], - typing.Union[resources.Rollout, typing.Awaitable[resources.Rollout]], + Union[resources.Rollout, Awaitable[resources.Rollout]], ]: raise NotImplementedError() @property def create_service_rollout( self, - ) -> typing.Callable[ + ) -> Callable[ [servicemanager.CreateServiceRolloutRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def generate_config_report( self, - ) -> typing.Callable[ + ) -> Callable[ [servicemanager.GenerateConfigReportRequest], - typing.Union[ + Union[ servicemanager.GenerateConfigReportResponse, - typing.Awaitable[servicemanager.GenerateConfigReportResponse], + Awaitable[servicemanager.GenerateConfigReportResponse], ], ]: raise NotImplementedError() @@ -313,18 +359,18 @@ def generate_config_report( @property def enable_service( self, - ) -> typing.Callable[ + ) -> Callable[ [servicemanager.EnableServiceRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def disable_service( self, - ) -> typing.Callable[ + ) -> Callable[ [servicemanager.DisableServiceRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() diff --git a/google/cloud/servicemanagement_v1/services/service_manager/transports/grpc.py b/google/cloud/servicemanagement_v1/services/service_manager/transports/grpc.py index 0cab753..66f10bd 100644 --- a/google/cloud/servicemanagement_v1/services/service_manager/transports/grpc.py +++ b/google/cloud/servicemanagement_v1/services/service_manager/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,31 +13,30 @@ # 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 operations_v1 # 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.api import service_pb2 as service # type: ignore +from google.api import service_pb2 # type: ignore from google.cloud.servicemanagement_v1.types import resources from google.cloud.servicemanagement_v1.types import servicemanager -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import ServiceManagerTransport, DEFAULT_CLIENT_INFO class ServiceManagerGrpcTransport(ServiceManagerTransport): """gRPC backend transport for ServiceManager. - `Google Service Management API `__ + `Google Service Management + API `__ This class defines the same methods as the primary client, so the primary client can load the underlying transport implementation @@ -54,7 +52,7 @@ def __init__( self, *, host: str = "servicemanagement.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -64,11 +62,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 @@ -103,6 +103,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 @@ -156,6 +158,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: @@ -179,7 +182,7 @@ def __init__( def create_channel( cls, host: str = "servicemanagement.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, @@ -210,13 +213,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, ) @@ -306,7 +311,7 @@ def get_service( @property def create_service( self, - ) -> Callable[[servicemanager.CreateServiceRequest], operations.Operation]: + ) -> Callable[[servicemanager.CreateServiceRequest], operations_pb2.Operation]: r"""Return a callable for the create service method over gRPC. Creates a new managed service. @@ -328,14 +333,14 @@ def create_service( self._stubs["create_service"] = self.grpc_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/CreateService", request_serializer=servicemanager.CreateServiceRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_service"] @property def delete_service( self, - ) -> Callable[[servicemanager.DeleteServiceRequest], operations.Operation]: + ) -> Callable[[servicemanager.DeleteServiceRequest], operations_pb2.Operation]: r"""Return a callable for the delete service method over gRPC. Deletes a managed service. This method will change the service @@ -361,14 +366,14 @@ def delete_service( self._stubs["delete_service"] = self.grpc_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/DeleteService", request_serializer=servicemanager.DeleteServiceRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_service"] @property def undelete_service( self, - ) -> Callable[[servicemanager.UndeleteServiceRequest], operations.Operation]: + ) -> Callable[[servicemanager.UndeleteServiceRequest], operations_pb2.Operation]: r"""Return a callable for the undelete service method over gRPC. Revives a previously deleted managed service. The @@ -393,7 +398,7 @@ def undelete_service( self._stubs["undelete_service"] = self.grpc_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/UndeleteService", request_serializer=servicemanager.UndeleteServiceRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["undelete_service"] @@ -430,7 +435,7 @@ def list_service_configs( @property def get_service_config( self, - ) -> Callable[[servicemanager.GetServiceConfigRequest], service.Service]: + ) -> Callable[[servicemanager.GetServiceConfigRequest], service_pb2.Service]: r"""Return a callable for the get service config method over gRPC. Gets a service configuration (version) for a managed @@ -450,14 +455,14 @@ def get_service_config( self._stubs["get_service_config"] = self.grpc_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/GetServiceConfig", request_serializer=servicemanager.GetServiceConfigRequest.serialize, - response_deserializer=service.Service.FromString, + response_deserializer=service_pb2.Service.FromString, ) return self._stubs["get_service_config"] @property def create_service_config( self, - ) -> Callable[[servicemanager.CreateServiceConfigRequest], service.Service]: + ) -> Callable[[servicemanager.CreateServiceConfigRequest], service_pb2.Service]: r"""Return a callable for the create service config method over gRPC. Creates a new service configuration (version) for a managed @@ -484,14 +489,14 @@ def create_service_config( self._stubs["create_service_config"] = self.grpc_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/CreateServiceConfig", request_serializer=servicemanager.CreateServiceConfigRequest.serialize, - response_deserializer=service.Service.FromString, + response_deserializer=service_pb2.Service.FromString, ) return self._stubs["create_service_config"] @property def submit_config_source( self, - ) -> Callable[[servicemanager.SubmitConfigSourceRequest], operations.Operation]: + ) -> Callable[[servicemanager.SubmitConfigSourceRequest], operations_pb2.Operation]: r"""Return a callable for the submit config source method over gRPC. Creates a new service configuration (version) for a managed @@ -522,7 +527,7 @@ def submit_config_source( self._stubs["submit_config_source"] = self.grpc_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/SubmitConfigSource", request_serializer=servicemanager.SubmitConfigSourceRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["submit_config_source"] @@ -587,7 +592,9 @@ def get_service_rollout( @property def create_service_rollout( self, - ) -> Callable[[servicemanager.CreateServiceRolloutRequest], operations.Operation]: + ) -> Callable[ + [servicemanager.CreateServiceRolloutRequest], operations_pb2.Operation + ]: r"""Return a callable for the create service rollout method over gRPC. Creates a new service configuration rollout. Based on @@ -622,7 +629,7 @@ def create_service_rollout( self._stubs["create_service_rollout"] = self.grpc_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/CreateServiceRollout", request_serializer=servicemanager.CreateServiceRolloutRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_service_rollout"] @@ -669,7 +676,7 @@ def generate_config_report( @property def enable_service( self, - ) -> Callable[[servicemanager.EnableServiceRequest], operations.Operation]: + ) -> Callable[[servicemanager.EnableServiceRequest], operations_pb2.Operation]: r"""Return a callable for the enable service method over gRPC. Enables a @@ -694,14 +701,14 @@ def enable_service( self._stubs["enable_service"] = self.grpc_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/EnableService", request_serializer=servicemanager.EnableServiceRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["enable_service"] @property def disable_service( self, - ) -> Callable[[servicemanager.DisableServiceRequest], operations.Operation]: + ) -> Callable[[servicemanager.DisableServiceRequest], operations_pb2.Operation]: r"""Return a callable for the disable service method over gRPC. Disables a @@ -726,7 +733,7 @@ def disable_service( self._stubs["disable_service"] = self.grpc_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/DisableService", request_serializer=servicemanager.DisableServiceRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["disable_service"] diff --git a/google/cloud/servicemanagement_v1/services/service_manager/transports/grpc_asyncio.py b/google/cloud/servicemanagement_v1/services/service_manager/transports/grpc_asyncio.py index 7b3ae3e..29b2258 100644 --- a/google/cloud/servicemanagement_v1/services/service_manager/transports/grpc_asyncio.py +++ b/google/cloud/servicemanagement_v1/services/service_manager/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,25 +13,23 @@ # 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.api_core import operations_v1 # 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.api import service_pb2 as service # type: ignore +from google.api import service_pb2 # type: ignore from google.cloud.servicemanagement_v1.types import resources from google.cloud.servicemanagement_v1.types import servicemanager -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import ServiceManagerTransport, DEFAULT_CLIENT_INFO from .grpc import ServiceManagerGrpcTransport @@ -40,7 +37,8 @@ class ServiceManagerGrpcAsyncIOTransport(ServiceManagerTransport): """gRPC AsyncIO backend transport for ServiceManager. - `Google Service Management API `__ + `Google Service Management + API `__ This class defines the same methods as the primary client, so the primary client can load the underlying transport implementation @@ -57,7 +55,7 @@ class ServiceManagerGrpcAsyncIOTransport(ServiceManagerTransport): def create_channel( cls, host: str = "servicemanagement.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, @@ -84,13 +82,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, ) @@ -98,7 +98,7 @@ def __init__( self, *, host: str = "servicemanagement.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, @@ -108,11 +108,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 @@ -148,6 +150,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 @@ -171,7 +175,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 @@ -201,6 +204,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: @@ -316,7 +320,7 @@ def get_service( def create_service( self, ) -> Callable[ - [servicemanager.CreateServiceRequest], Awaitable[operations.Operation] + [servicemanager.CreateServiceRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the create service method over gRPC. @@ -339,7 +343,7 @@ def create_service( self._stubs["create_service"] = self.grpc_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/CreateService", request_serializer=servicemanager.CreateServiceRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_service"] @@ -347,7 +351,7 @@ def create_service( def delete_service( self, ) -> Callable[ - [servicemanager.DeleteServiceRequest], Awaitable[operations.Operation] + [servicemanager.DeleteServiceRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the delete service method over gRPC. @@ -374,7 +378,7 @@ def delete_service( self._stubs["delete_service"] = self.grpc_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/DeleteService", request_serializer=servicemanager.DeleteServiceRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_service"] @@ -382,7 +386,7 @@ def delete_service( def undelete_service( self, ) -> Callable[ - [servicemanager.UndeleteServiceRequest], Awaitable[operations.Operation] + [servicemanager.UndeleteServiceRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the undelete service method over gRPC. @@ -408,7 +412,7 @@ def undelete_service( self._stubs["undelete_service"] = self.grpc_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/UndeleteService", request_serializer=servicemanager.UndeleteServiceRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["undelete_service"] @@ -445,7 +449,9 @@ def list_service_configs( @property def get_service_config( self, - ) -> Callable[[servicemanager.GetServiceConfigRequest], Awaitable[service.Service]]: + ) -> Callable[ + [servicemanager.GetServiceConfigRequest], Awaitable[service_pb2.Service] + ]: r"""Return a callable for the get service config method over gRPC. Gets a service configuration (version) for a managed @@ -465,7 +471,7 @@ def get_service_config( self._stubs["get_service_config"] = self.grpc_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/GetServiceConfig", request_serializer=servicemanager.GetServiceConfigRequest.serialize, - response_deserializer=service.Service.FromString, + response_deserializer=service_pb2.Service.FromString, ) return self._stubs["get_service_config"] @@ -473,7 +479,7 @@ def get_service_config( def create_service_config( self, ) -> Callable[ - [servicemanager.CreateServiceConfigRequest], Awaitable[service.Service] + [servicemanager.CreateServiceConfigRequest], Awaitable[service_pb2.Service] ]: r"""Return a callable for the create service config method over gRPC. @@ -501,7 +507,7 @@ def create_service_config( self._stubs["create_service_config"] = self.grpc_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/CreateServiceConfig", request_serializer=servicemanager.CreateServiceConfigRequest.serialize, - response_deserializer=service.Service.FromString, + response_deserializer=service_pb2.Service.FromString, ) return self._stubs["create_service_config"] @@ -509,7 +515,7 @@ def create_service_config( def submit_config_source( self, ) -> Callable[ - [servicemanager.SubmitConfigSourceRequest], Awaitable[operations.Operation] + [servicemanager.SubmitConfigSourceRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the submit config source method over gRPC. @@ -541,7 +547,7 @@ def submit_config_source( self._stubs["submit_config_source"] = self.grpc_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/SubmitConfigSource", request_serializer=servicemanager.SubmitConfigSourceRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["submit_config_source"] @@ -609,7 +615,8 @@ def get_service_rollout( def create_service_rollout( self, ) -> Callable[ - [servicemanager.CreateServiceRolloutRequest], Awaitable[operations.Operation] + [servicemanager.CreateServiceRolloutRequest], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the create service rollout method over gRPC. @@ -645,7 +652,7 @@ def create_service_rollout( self._stubs["create_service_rollout"] = self.grpc_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/CreateServiceRollout", request_serializer=servicemanager.CreateServiceRolloutRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_service_rollout"] @@ -693,7 +700,7 @@ def generate_config_report( def enable_service( self, ) -> Callable[ - [servicemanager.EnableServiceRequest], Awaitable[operations.Operation] + [servicemanager.EnableServiceRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the enable service method over gRPC. @@ -719,7 +726,7 @@ def enable_service( self._stubs["enable_service"] = self.grpc_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/EnableService", request_serializer=servicemanager.EnableServiceRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["enable_service"] @@ -727,7 +734,7 @@ def enable_service( def disable_service( self, ) -> Callable[ - [servicemanager.DisableServiceRequest], Awaitable[operations.Operation] + [servicemanager.DisableServiceRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the disable service method over gRPC. @@ -753,7 +760,7 @@ def disable_service( self._stubs["disable_service"] = self.grpc_channel.unary_unary( "/google.api.servicemanagement.v1.ServiceManager/DisableService", request_serializer=servicemanager.DisableServiceRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["disable_service"] diff --git a/google/cloud/servicemanagement_v1/types/__init__.py b/google/cloud/servicemanagement_v1/types/__init__.py index c7734db..d73013e 100644 --- a/google/cloud/servicemanagement_v1/types/__init__.py +++ b/google/cloud/servicemanagement_v1/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 .resources import ( ChangeReport, ConfigFile, diff --git a/google/cloud/servicemanagement_v1/types/resources.py b/google/cloud/servicemanagement_v1/types/resources.py index 785979a..1cfe21d 100644 --- a/google/cloud/servicemanagement_v1/types/resources.py +++ b/google/cloud/servicemanagement_v1/types/resources.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.api import config_change_pb2 as config_change # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.api import config_change_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -44,16 +41,15 @@ class ManagedService(proto.Message): Attributes: service_name (str): The name of the service. See the - `overview `__ for naming - requirements. + `overview `__ + for naming requirements. producer_project_id (str): ID of the project that produces and owns this service. """ - service_name = proto.Field(proto.STRING, number=2) - - producer_project_id = proto.Field(proto.STRING, number=3) + service_name = proto.Field(proto.STRING, number=2,) + producer_project_id = proto.Field(proto.STRING, number=3,) class OperationMetadata(proto.Message): @@ -87,7 +83,6 @@ class Status(proto.Enum): class Step(proto.Message): r"""Represents the status of one operation step. - Attributes: description (str): The short description of the step. @@ -95,22 +90,17 @@ class Step(proto.Message): The status code. """ - description = proto.Field(proto.STRING, number=2) - + description = proto.Field(proto.STRING, number=2,) status = proto.Field(proto.ENUM, number=4, enum="OperationMetadata.Status",) - resource_names = proto.RepeatedField(proto.STRING, number=1) - + resource_names = proto.RepeatedField(proto.STRING, number=1,) steps = proto.RepeatedField(proto.MESSAGE, number=2, message=Step,) - - progress_percentage = proto.Field(proto.INT32, number=3) - - start_time = proto.Field(proto.MESSAGE, number=4, message=timestamp.Timestamp,) + progress_percentage = proto.Field(proto.INT32, number=3,) + start_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) class Diagnostic(proto.Message): r"""Represents a diagnostic message (error or warning) - Attributes: location (str): File name and line number of the error or @@ -126,11 +116,9 @@ class Kind(proto.Enum): WARNING = 0 ERROR = 1 - location = proto.Field(proto.STRING, number=1) - + location = proto.Field(proto.STRING, number=1,) kind = proto.Field(proto.ENUM, number=2, enum=Kind,) - - message = proto.Field(proto.STRING, number=3) + message = proto.Field(proto.STRING, number=3,) class ConfigSource(proto.Message): @@ -148,14 +136,12 @@ class ConfigSource(proto.Message): a service configuration (``google.api.Service``). """ - id = proto.Field(proto.STRING, number=5) - + id = proto.Field(proto.STRING, number=5,) files = proto.RepeatedField(proto.MESSAGE, number=2, message="ConfigFile",) class ConfigFile(proto.Message): r"""Generic specification of a source configuration file - Attributes: file_path (str): The file name of the configuration file (full @@ -176,16 +162,13 @@ class FileType(proto.Enum): FILE_DESCRIPTOR_SET_PROTO = 4 PROTO_FILE = 6 - file_path = proto.Field(proto.STRING, number=1) - - file_contents = proto.Field(proto.BYTES, number=3) - + file_path = proto.Field(proto.STRING, number=1,) + file_contents = proto.Field(proto.BYTES, number=3,) file_type = proto.Field(proto.ENUM, number=4, enum=FileType,) class ConfigRef(proto.Message): r"""Represents a service configuration with its name and id. - Attributes: name (str): Resource name of a service config. It must @@ -193,7 +176,7 @@ class ConfigRef(proto.Message): name}/configs/{config id}". """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ChangeReport(proto.Message): @@ -212,7 +195,7 @@ class ChangeReport(proto.Message): """ config_changes = proto.RepeatedField( - proto.MESSAGE, number=1, message=config_change.ConfigChange, + proto.MESSAGE, number=1, message=config_change_pb2.ConfigChange, ) @@ -307,31 +290,25 @@ class TrafficPercentStrategy(proto.Message): the sum must equal to 100.0. """ - percentages = proto.MapField(proto.STRING, proto.DOUBLE, number=1) + percentages = proto.MapField(proto.STRING, proto.DOUBLE, number=1,) class DeleteServiceStrategy(proto.Message): r"""Strategy used to delete a service. This strategy is a placeholder only used by the system generated rollout to delete a service. - """ - - rollout_id = proto.Field(proto.STRING, number=1) - - create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,) - - created_by = proto.Field(proto.STRING, number=3) + """ + rollout_id = proto.Field(proto.STRING, number=1,) + create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + created_by = proto.Field(proto.STRING, number=3,) status = proto.Field(proto.ENUM, number=4, enum=RolloutStatus,) - traffic_percent_strategy = proto.Field( proto.MESSAGE, number=5, oneof="strategy", message=TrafficPercentStrategy, ) - delete_service_strategy = proto.Field( proto.MESSAGE, number=200, oneof="strategy", message=DeleteServiceStrategy, ) - - service_name = proto.Field(proto.STRING, number=8) + service_name = proto.Field(proto.STRING, number=8,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/servicemanagement_v1/types/servicemanager.py b/google/cloud/servicemanagement_v1/types/servicemanager.py index 1162e10..3cbd9ed 100644 --- a/google/cloud/servicemanagement_v1/types/servicemanager.py +++ b/google/cloud/servicemanagement_v1/types/servicemanager.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.api import service_pb2 as ga_service # type: ignore +from google.api import service_pb2 # type: ignore from google.cloud.servicemanagement_v1.types import resources -from google.protobuf import any_pb2 as gp_any # type: ignore +from google.protobuf import any_pb2 # type: ignore __protobuf__ = proto.module( @@ -55,7 +52,6 @@ class ListServicesRequest(proto.Message): r"""Request message for ``ListServices`` method. - Attributes: producer_project_id (str): Include services produced by the specified @@ -76,18 +72,14 @@ class ListServicesRequest(proto.Message): - project: """ - producer_project_id = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=5) - - page_token = proto.Field(proto.STRING, number=6) - - consumer_id = proto.Field(proto.STRING, number=7) + producer_project_id = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=5,) + page_token = proto.Field(proto.STRING, number=6,) + consumer_id = proto.Field(proto.STRING, number=7,) class ListServicesResponse(proto.Message): r"""Response message for ``ListServices`` method. - Attributes: services (Sequence[google.cloud.servicemanagement_v1.types.ManagedService]): The returned services will only have the name @@ -104,13 +96,11 @@ def raw_page(self): services = proto.RepeatedField( proto.MESSAGE, number=1, message=resources.ManagedService, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class GetServiceRequest(proto.Message): r"""Request message for ``GetService`` method. - Attributes: service_name (str): Required. The name of the service. See the @@ -118,12 +108,11 @@ class GetServiceRequest(proto.Message): example: ``example.googleapis.com``. """ - service_name = proto.Field(proto.STRING, number=1) + service_name = proto.Field(proto.STRING, number=1,) class CreateServiceRequest(proto.Message): r"""Request message for CreateService method. - Attributes: service (google.cloud.servicemanagement_v1.types.ManagedService): Required. Initial values for the service @@ -135,33 +124,32 @@ class CreateServiceRequest(proto.Message): class DeleteServiceRequest(proto.Message): r"""Request message for DeleteService method. - Attributes: service_name (str): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. """ - service_name = proto.Field(proto.STRING, number=1) + service_name = proto.Field(proto.STRING, number=1,) class UndeleteServiceRequest(proto.Message): r"""Request message for UndeleteService method. - Attributes: service_name (str): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. """ - service_name = proto.Field(proto.STRING, number=1) + service_name = proto.Field(proto.STRING, number=1,) class UndeleteServiceResponse(proto.Message): r"""Response message for UndeleteService method. - Attributes: service (google.cloud.servicemanagement_v1.types.ManagedService): Revived service resource. @@ -172,12 +160,12 @@ class UndeleteServiceResponse(proto.Message): class GetServiceConfigRequest(proto.Message): r"""Request message for GetServiceConfig method. - Attributes: service_name (str): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. config_id (str): Required. The id of the service configuration resource. @@ -193,21 +181,19 @@ class ConfigView(proto.Enum): BASIC = 0 FULL = 1 - service_name = proto.Field(proto.STRING, number=1) - - config_id = proto.Field(proto.STRING, number=2) - + service_name = proto.Field(proto.STRING, number=1,) + config_id = proto.Field(proto.STRING, number=2,) view = proto.Field(proto.ENUM, number=3, enum=ConfigView,) class ListServiceConfigsRequest(proto.Message): r"""Request message for ListServiceConfigs method. - Attributes: service_name (str): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. page_token (str): The token of the page to retrieve. page_size (int): @@ -216,16 +202,13 @@ class ListServiceConfigsRequest(proto.Message): Maximum value is 100. """ - service_name = proto.Field(proto.STRING, number=1) - - page_token = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) + service_name = proto.Field(proto.STRING, number=1,) + page_token = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) class ListServiceConfigsResponse(proto.Message): r"""Response message for ListServiceConfigs method. - Attributes: service_configs (Sequence[google.api.service_pb2.Service]): The list of service configuration resources. @@ -238,37 +221,35 @@ def raw_page(self): return self service_configs = proto.RepeatedField( - proto.MESSAGE, number=1, message=ga_service.Service, + proto.MESSAGE, number=1, message=service_pb2.Service, ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class CreateServiceConfigRequest(proto.Message): r"""Request message for CreateServiceConfig method. - Attributes: service_name (str): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. service_config (google.api.service_pb2.Service): Required. The service configuration resource. """ - service_name = proto.Field(proto.STRING, number=1) - - service_config = proto.Field(proto.MESSAGE, number=2, message=ga_service.Service,) + service_name = proto.Field(proto.STRING, number=1,) + service_config = proto.Field(proto.MESSAGE, number=2, message=service_pb2.Service,) class SubmitConfigSourceRequest(proto.Message): r"""Request message for SubmitConfigSource method. - Attributes: service_name (str): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. config_source (google.cloud.servicemanagement_v1.types.ConfigSource): Required. The source configuration for the service. @@ -279,52 +260,48 @@ class SubmitConfigSourceRequest(proto.Message): sources will NOT be persisted. """ - service_name = proto.Field(proto.STRING, number=1) - + service_name = proto.Field(proto.STRING, number=1,) config_source = proto.Field( proto.MESSAGE, number=2, message=resources.ConfigSource, ) - - validate_only = proto.Field(proto.BOOL, number=3) + validate_only = proto.Field(proto.BOOL, number=3,) class SubmitConfigSourceResponse(proto.Message): r"""Response message for SubmitConfigSource method. - Attributes: service_config (google.api.service_pb2.Service): The generated service configuration. """ - service_config = proto.Field(proto.MESSAGE, number=1, message=ga_service.Service,) + service_config = proto.Field(proto.MESSAGE, number=1, message=service_pb2.Service,) class CreateServiceRolloutRequest(proto.Message): r"""Request message for 'CreateServiceRollout' - Attributes: service_name (str): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. rollout (google.cloud.servicemanagement_v1.types.Rollout): Required. The rollout resource. The ``service_name`` field is output only. """ - service_name = proto.Field(proto.STRING, number=1) - + service_name = proto.Field(proto.STRING, number=1,) rollout = proto.Field(proto.MESSAGE, number=2, message=resources.Rollout,) class ListServiceRolloutsRequest(proto.Message): r"""Request message for 'ListServiceRollouts' - Attributes: service_name (str): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. page_token (str): The token of the page to retrieve. page_size (int): @@ -334,27 +311,22 @@ class ListServiceRolloutsRequest(proto.Message): filter (str): Required. Use ``filter`` to return subset of rollouts. The following filters are supported: -- To limit the results to - only those in - `status `__ - 'SUCCESS', use filter='status=SUCCESS' -- To limit the - results to those in - `status `__ + only those in status + (google.api.servicemanagement.v1.RolloutStatus) 'SUCCESS', + use filter='status=SUCCESS' -- To limit the results to those + in status (google.api.servicemanagement.v1.RolloutStatus) 'CANCELLED' or 'FAILED', use filter='status=CANCELLED OR status=FAILED' """ - service_name = proto.Field(proto.STRING, number=1) - - page_token = proto.Field(proto.STRING, number=2) - - page_size = proto.Field(proto.INT32, number=3) - - filter = proto.Field(proto.STRING, number=4) + service_name = proto.Field(proto.STRING, number=1,) + page_token = proto.Field(proto.STRING, number=2,) + page_size = proto.Field(proto.INT32, number=3,) + filter = proto.Field(proto.STRING, number=4,) class ListServiceRolloutsResponse(proto.Message): r"""Response message for ListServiceRollouts method. - Attributes: rollouts (Sequence[google.cloud.servicemanagement_v1.types.Rollout]): The list of rollout resources. @@ -367,30 +339,27 @@ def raw_page(self): return self rollouts = proto.RepeatedField(proto.MESSAGE, number=1, message=resources.Rollout,) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class GetServiceRolloutRequest(proto.Message): r"""Request message for GetServiceRollout method. - Attributes: service_name (str): Required. The name of the service. See the - `overview `__ for naming - requirements. For example: ``example.googleapis.com``. + `overview `__ + for naming requirements. For example: + ``example.googleapis.com``. rollout_id (str): Required. The id of the rollout resource. """ - service_name = proto.Field(proto.STRING, number=1) - - rollout_id = proto.Field(proto.STRING, number=2) + service_name = proto.Field(proto.STRING, number=1,) + rollout_id = proto.Field(proto.STRING, number=2,) class EnableServiceRequest(proto.Message): r"""Request message for EnableService method. - Attributes: service_name (str): Required. Name of the service to enable. @@ -409,18 +378,16 @@ class EnableServiceRequest(proto.Message): google.api.servicecontrol.v1.Operation.consumer_id. """ - service_name = proto.Field(proto.STRING, number=1) - - consumer_id = proto.Field(proto.STRING, number=2) + service_name = proto.Field(proto.STRING, number=1,) + consumer_id = proto.Field(proto.STRING, number=2,) class EnableServiceResponse(proto.Message): - r"""Operation payload for EnableService method.""" + r"""Operation payload for EnableService method. """ class DisableServiceRequest(proto.Message): r"""Request message for DisableService method. - Attributes: service_name (str): Required. Name of the service to disable. @@ -439,18 +406,16 @@ class DisableServiceRequest(proto.Message): google.api.servicecontrol.v1.Operation.consumer_id. """ - service_name = proto.Field(proto.STRING, number=1) - - consumer_id = proto.Field(proto.STRING, number=2) + service_name = proto.Field(proto.STRING, number=1,) + consumer_id = proto.Field(proto.STRING, number=2,) class DisableServiceResponse(proto.Message): - r"""Operation payload for DisableService method.""" + r"""Operation payload for DisableService method. """ class GenerateConfigReportRequest(proto.Message): r"""Request message for GenerateConfigReport method. - Attributes: new_config (google.protobuf.any_pb2.Any): Required. Service configuration for which we want to @@ -468,14 +433,12 @@ class GenerateConfigReportRequest(proto.Message): and [google.api.Service][google.api.Service] """ - new_config = proto.Field(proto.MESSAGE, number=1, message=gp_any.Any,) - - old_config = proto.Field(proto.MESSAGE, number=2, message=gp_any.Any,) + new_config = proto.Field(proto.MESSAGE, number=1, message=any_pb2.Any,) + old_config = proto.Field(proto.MESSAGE, number=2, message=any_pb2.Any,) class GenerateConfigReportResponse(proto.Message): r"""Response message for GenerateConfigReport method. - Attributes: service_name (str): Name of the service this report belongs to. @@ -491,14 +454,11 @@ class GenerateConfigReportResponse(proto.Message): belongs to. """ - service_name = proto.Field(proto.STRING, number=1) - - id = proto.Field(proto.STRING, number=2) - + service_name = proto.Field(proto.STRING, number=1,) + id = proto.Field(proto.STRING, number=2,) change_reports = proto.RepeatedField( proto.MESSAGE, number=3, message=resources.ChangeReport, ) - diagnostics = proto.RepeatedField( proto.MESSAGE, number=4, message=resources.Diagnostic, ) diff --git a/noxfile.py b/noxfile.py index d6d974c..94ee6a8 100644 --- a/noxfile.py +++ b/noxfile.py @@ -18,6 +18,7 @@ from __future__ import absolute_import import os +import pathlib import shutil import nox @@ -30,6 +31,8 @@ SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"] +CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() + # 'docfx' is excluded since it only needs to run in 'docs-presubmit' nox.options.sessions = [ "unit", @@ -59,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, @@ -84,13 +80,15 @@ def lint_setup_py(session): def default(session): # Install all test dependencies, then install this package in-place. - session.install("asyncmock", "pytest-asyncio") - session.install( - "mock", "pytest", "pytest-cov", + constraints_path = str( + CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) + session.install("asyncmock", "pytest-asyncio", "-c", constraints_path) - session.install("-e", ".") + session.install("mock", "pytest", "pytest-cov", "-c", constraints_path) + + session.install("-e", ".", "-c", constraints_path) # Run py.test against the unit tests. session.run( @@ -117,15 +115,15 @@ def unit(session): @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) def system(session): """Run the system test suite.""" + constraints_path = str( + CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" + ) system_test_path = os.path.join("tests", "system.py") system_test_folder_path = os.path.join("tests", "system") # 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") @@ -141,10 +139,8 @@ def system(session): # Install all test dependencies, then install this package into the # virtualenv's dist-packages. - session.install( - "mock", "pytest", "google-cloud-testutils", - ) - session.install("-e", ".") + session.install("mock", "pytest", "google-cloud-testutils", "-c", constraints_path) + session.install("-e", ".", "-c", constraints_path) # Run py.test against the system tests. if system_test_exists: @@ -183,7 +179,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( @@ -205,9 +201,9 @@ def docfx(session): """Build the docfx yaml files for this library.""" session.install("-e", ".") - # sphinx-docfx-yaml supports up to sphinx version 1.5.5. - # https://github.com/docascode/sphinx-docfx-yaml/issues/97 - session.install("sphinx==1.5.5", "alabaster", "recommonmark", "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 71% rename from synth.py rename to owlbot.py index b9dfb72..a273821 100644 --- a/synth.py +++ b/owlbot.py @@ -20,25 +20,23 @@ import synthtool.gcp as gcp from synthtool.languages import python -gapic = gcp.GAPICBazel() common = gcp.CommonTemplates() -versions = [ - "v1", +default_version = "v1" -] # add new versions at the end of the list +for library in s.get_staging_dirs(default_version): + s.move(library, excludes=["setup.py", "README.rst", "docs/index.rst"]) -# ---------------------------------------------------------------------------- -# Generate servicemanagement GAPIC layer -# ---------------------------------------------------------------------------- -for version in versions: - library = gapic.py_library( - service="servicemanagement", - version=version, - bazel_target=f"//google/api/servicemanagement/{version}:google-cloud-servicemanagement-{version}-py", + # Fix DeprecationWarning + # Fix incorrect DeprecationWarning + # Fixed in https://github.com/googleapis/gapic-generator-python/pull/943 + s.replace( + "google/**/*client.py", + "warnings\.DeprecationWarning", + "DeprecationWarning" ) - s.move(library, excludes=["setup.py", "README.rst", "docs/index.rst"]) +s.remove_staging_dirs() # ---------------------------------------------------------------------------- # Add templated files diff --git a/renovate.json b/renovate.json index f08bc22..c048955 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/scripts/fixup_servicemanagement_v1_keywords.py b/scripts/fixup_servicemanagement_v1_keywords.py index 6f515e7..1ac6d2a 100644 --- a/scripts/fixup_servicemanagement_v1_keywords.py +++ b/scripts/fixup_servicemanagement_v1_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,22 +39,21 @@ def partition( class servicemanagementCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'create_service': ('service', ), - 'create_service_config': ('service_name', 'service_config', ), - 'create_service_rollout': ('service_name', 'rollout', ), - 'delete_service': ('service_name', ), - 'disable_service': ('service_name', 'consumer_id', ), - 'enable_service': ('service_name', 'consumer_id', ), - 'generate_config_report': ('new_config', 'old_config', ), - 'get_service': ('service_name', ), - 'get_service_config': ('service_name', 'config_id', 'view', ), - 'get_service_rollout': ('service_name', 'rollout_id', ), - 'list_service_configs': ('service_name', 'page_token', 'page_size', ), - 'list_service_rollouts': ('service_name', 'filter', 'page_token', 'page_size', ), - 'list_services': ('producer_project_id', 'page_size', 'page_token', 'consumer_id', ), - 'submit_config_source': ('service_name', 'config_source', 'validate_only', ), - 'undelete_service': ('service_name', ), - + 'create_service': ('service', ), + 'create_service_config': ('service_name', 'service_config', ), + 'create_service_rollout': ('service_name', 'rollout', ), + 'delete_service': ('service_name', ), + 'disable_service': ('service_name', 'consumer_id', ), + 'enable_service': ('service_name', 'consumer_id', ), + 'generate_config_report': ('new_config', 'old_config', ), + 'get_service': ('service_name', ), + 'get_service_config': ('service_name', 'config_id', 'view', ), + 'get_service_rollout': ('service_name', 'rollout_id', ), + 'list_service_configs': ('service_name', 'page_token', 'page_size', ), + 'list_service_rollouts': ('service_name', 'filter', 'page_token', 'page_size', ), + 'list_services': ('producer_project_id', 'page_size', 'page_token', 'consumer_id', ), + 'submit_config_source': ('service_name', 'config_source', 'validate_only', ), + 'undelete_service': ('service_name', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: @@ -87,7 +84,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 f1bcfb0..9374556 100644 --- a/setup.py +++ b/setup.py @@ -20,14 +20,15 @@ import setuptools # type: ignore name = "google-cloud-service-management" -version = "0.1.0" +version = "1.0.0" description = "Service Management API" -release_status = "Development Status :: 4 - Beta" +release_status = "Development Status :: 5 - Production/Stable" url = "https://github.com/googleapis/python-service-management" dependencies = [ - "google-api-core[grpc] >= 1.22.2, < 2.0.0dev", + "google-api-core[grpc] >= 1.26.0, <2.0.0dev", "libcst >= 0.2.5", "proto-plus >= 1.15.0", + "packaging >= 14.3", ] package_root = os.path.abspath(os.path.dirname(__file__)) diff --git a/testing/constraints-3.10.txt b/testing/constraints-3.10.txt new file mode 100644 index 0000000..e69de29 diff --git a/testing/constraints-3.11.txt b/testing/constraints-3.11.txt new file mode 100644 index 0000000..e69de29 diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt new file mode 100644 index 0000000..ce8cfca --- /dev/null +++ b/testing/constraints-3.6.txt @@ -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. +# +# This constraints file is used to check that lower bounds +# are correct in setup.py +# List *all* library dependencies and extras in this file. +# Pin the version to the lower bound. +# +# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", +# Then this file should have foo==1.14.0 +google-api-core==1.26.0 +libcst==0.2.5 +proto-plus==1.15.0 +packaging==14.3 +google-auth==1.24.0 # TODO: remove when google-auth>=1.25.0 si transitively required through google-api-core diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt new file mode 100644 index 0000000..e69de29 diff --git a/testing/constraints-3.8.txt b/testing/constraints-3.8.txt new file mode 100644 index 0000000..e69de29 diff --git a/testing/constraints-3.9.txt b/testing/constraints-3.9.txt new file mode 100644 index 0000000..e69de29 diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..4de6597 --- /dev/null +++ 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 new file mode 100644 index 0000000..4de6597 --- /dev/null +++ b/tests/unit/__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/__init__.py b/tests/unit/gapic/__init__.py new file mode 100644 index 0000000..4de6597 --- /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/servicemanagement_v1/__init__.py b/tests/unit/gapic/servicemanagement_v1/__init__.py index 42ffdf2..4de6597 100644 --- a/tests/unit/gapic/servicemanagement_v1/__init__.py +++ b/tests/unit/gapic/servicemanagement_v1/__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/servicemanagement_v1/test_service_manager.py b/tests/unit/gapic/servicemanagement_v1/test_service_manager.py index 3e01b6f..72e6ed7 100644 --- a/tests/unit/gapic/servicemanagement_v1/test_service_manager.py +++ b/tests/unit/gapic/servicemanagement_v1/test_service_manager.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,36 +23,36 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth -from google.api import auth_pb2 as ga_auth # type: ignore -from google.api import backend_pb2 as backend # type: ignore -from google.api import billing_pb2 as billing # type: ignore -from google.api import context_pb2 as context # type: ignore -from google.api import control_pb2 as control # type: ignore -from google.api import documentation_pb2 as documentation # type: ignore -from google.api import endpoint_pb2 as endpoint # type: ignore -from google.api import http_pb2 as http # type: ignore -from google.api import label_pb2 as label # type: ignore -from google.api import launch_stage_pb2 as launch_stage # type: ignore -from google.api import log_pb2 as log # type: ignore -from google.api import logging_pb2 as logging # type: ignore -from google.api import metric_pb2 as metric # type: ignore -from google.api import monitored_resource_pb2 as monitored_resource # type: ignore -from google.api import monitoring_pb2 as monitoring # type: ignore -from google.api import quota_pb2 as quota # type: ignore -from google.api import service_pb2 as service # type: ignore -from google.api import source_info_pb2 as source_info # type: ignore -from google.api import system_parameter_pb2 as system_parameter # type: ignore -from google.api import usage_pb2 as usage # type: ignore + +from google.api import auth_pb2 # type: ignore +from google.api import backend_pb2 # type: ignore +from google.api import billing_pb2 # type: ignore +from google.api import context_pb2 # type: ignore +from google.api import control_pb2 # type: ignore +from google.api import documentation_pb2 # type: ignore +from google.api import endpoint_pb2 # type: ignore +from google.api import http_pb2 # type: ignore +from google.api import label_pb2 # type: ignore +from google.api import launch_stage_pb2 # type: ignore +from google.api import log_pb2 # type: ignore +from google.api import logging_pb2 # type: ignore +from google.api import metric_pb2 # type: ignore +from google.api import monitored_resource_pb2 # type: ignore +from google.api import monitoring_pb2 # type: ignore +from google.api import quota_pb2 # type: ignore +from google.api import service_pb2 # type: ignore +from google.api import source_info_pb2 # type: ignore +from google.api import system_parameter_pb2 # type: ignore +from google.api import usage_pb2 # type: ignore 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 future from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 -from google.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.servicemanagement_v1.services.service_manager import ( ServiceManagerAsyncClient, @@ -63,17 +62,35 @@ ) from google.cloud.servicemanagement_v1.services.service_manager import pagers from google.cloud.servicemanagement_v1.services.service_manager import transports +from google.cloud.servicemanagement_v1.services.service_manager.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.servicemanagement_v1.types import resources from google.cloud.servicemanagement_v1.types import servicemanager from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import any_pb2 as gp_any # type: ignore -from google.protobuf import api_pb2 as api # type: ignore -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import source_context_pb2 as source_context # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore -from google.protobuf import type_pb2 as gp_type # type: ignore -from google.protobuf import wrappers_pb2 as wrappers # type: ignore +from google.protobuf import any_pb2 # type: ignore +from google.protobuf import api_pb2 # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import source_context_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.protobuf import type_pb2 # type: ignore +from google.protobuf import wrappers_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(): @@ -124,7 +141,7 @@ def test__get_default_mtls_endpoint(): "client_class", [ServiceManagerClient, ServiceManagerAsyncClient,] ) def test_service_manager_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: @@ -137,11 +154,41 @@ def test_service_manager_client_from_service_account_info(client_class): assert client.transport._host == "servicemanagement.googleapis.com:443" +@pytest.mark.parametrize( + "client_class", [ServiceManagerClient, ServiceManagerAsyncClient,] +) +def test_service_manager_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.ServiceManagerGrpcTransport, "grpc"), + (transports.ServiceManagerGrpcAsyncIOTransport, "grpc_asyncio"), + ], +) +def test_service_manager_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", [ServiceManagerClient, ServiceManagerAsyncClient,] ) def test_service_manager_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: @@ -194,7 +241,7 @@ def test_service_manager_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(ServiceManagerClient, "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() @@ -482,7 +529,7 @@ def test_list_services( transport: str = "grpc", request_type=servicemanager.ListServicesRequest ): client = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -495,19 +542,15 @@ def test_list_services( call.return_value = servicemanager.ListServicesResponse( next_page_token="next_page_token_value", ) - response = client.list_services(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.ListServicesRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListServicesPager) - assert response.next_page_token == "next_page_token_value" @@ -519,7 +562,7 @@ def test_list_services_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 = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -527,7 +570,6 @@ def test_list_services_empty_call(): client.list_services() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.ListServicesRequest() @@ -536,7 +578,7 @@ async def test_list_services_async( transport: str = "grpc_asyncio", request_type=servicemanager.ListServicesRequest ): client = ServiceManagerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -551,18 +593,15 @@ async def test_list_services_async( next_page_token="next_page_token_value", ) ) - response = await client.list_services(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.ListServicesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListServicesAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -572,13 +611,12 @@ async def test_list_services_async_from_dict(): def test_list_services_flattened(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_services), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = servicemanager.ListServicesResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_services( @@ -590,14 +628,12 @@ def test_list_services_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].producer_project_id == "producer_project_id_value" - assert args[0].consumer_id == "consumer_id_value" def test_list_services_flattened_error(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -611,7 +647,9 @@ def test_list_services_flattened_error(): @pytest.mark.asyncio async def test_list_services_flattened_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_services), "__call__") as call: @@ -632,15 +670,15 @@ async def test_list_services_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].producer_project_id == "producer_project_id_value" - assert args[0].consumer_id == "consumer_id_value" @pytest.mark.asyncio async def test_list_services_flattened_error_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -653,7 +691,7 @@ async def test_list_services_flattened_error_async(): def test_list_services_pager(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials,) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_services), "__call__") as call: @@ -688,7 +726,7 @@ def test_list_services_pager(): def test_list_services_pages(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials,) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_services), "__call__") as call: @@ -718,7 +756,7 @@ def test_list_services_pages(): @pytest.mark.asyncio async def test_list_services_async_pager(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ServiceManagerAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -755,7 +793,7 @@ async def test_list_services_async_pager(): @pytest.mark.asyncio async def test_list_services_async_pages(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ServiceManagerAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -791,7 +829,7 @@ def test_get_service( transport: str = "grpc", request_type=servicemanager.GetServiceRequest ): client = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -805,21 +843,16 @@ def test_get_service( service_name="service_name_value", producer_project_id="producer_project_id_value", ) - response = client.get_service(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.GetServiceRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.ManagedService) - assert response.service_name == "service_name_value" - assert response.producer_project_id == "producer_project_id_value" @@ -831,7 +864,7 @@ def test_get_service_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 = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -839,7 +872,6 @@ def test_get_service_empty_call(): client.get_service() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.GetServiceRequest() @@ -848,7 +880,7 @@ async def test_get_service_async( transport: str = "grpc_asyncio", request_type=servicemanager.GetServiceRequest ): client = ServiceManagerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -864,20 +896,16 @@ async def test_get_service_async( producer_project_id="producer_project_id_value", ) ) - response = await client.get_service(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.GetServiceRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.ManagedService) - assert response.service_name == "service_name_value" - assert response.producer_project_id == "producer_project_id_value" @@ -887,13 +915,12 @@ async def test_get_service_async_from_dict(): def test_get_service_flattened(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_service), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.ManagedService() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_service(service_name="service_name_value",) @@ -902,12 +929,11 @@ def test_get_service_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" def test_get_service_flattened_error(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -919,7 +945,9 @@ def test_get_service_flattened_error(): @pytest.mark.asyncio async def test_get_service_flattened_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_service), "__call__") as call: @@ -937,13 +965,14 @@ async def test_get_service_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" @pytest.mark.asyncio async def test_get_service_flattened_error_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -957,7 +986,7 @@ def test_create_service( transport: str = "grpc", request_type=servicemanager.CreateServiceRequest ): client = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -968,13 +997,11 @@ def test_create_service( with mock.patch.object(type(client.transport.create_service), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_service(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.CreateServiceRequest() # Establish that the response is the type that we expect. @@ -989,7 +1016,7 @@ def test_create_service_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 = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -997,7 +1024,6 @@ def test_create_service_empty_call(): client.create_service() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.CreateServiceRequest() @@ -1006,7 +1032,7 @@ async def test_create_service_async( transport: str = "grpc_asyncio", request_type=servicemanager.CreateServiceRequest ): client = ServiceManagerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1019,13 +1045,11 @@ async def test_create_service_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_service(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.CreateServiceRequest() # Establish that the response is the type that we expect. @@ -1038,13 +1062,12 @@ async def test_create_service_async_from_dict(): def test_create_service_flattened(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_service), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_service( @@ -1055,14 +1078,13 @@ def test_create_service_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].service == resources.ManagedService( service_name="service_name_value" ) def test_create_service_flattened_error(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1075,7 +1097,9 @@ def test_create_service_flattened_error(): @pytest.mark.asyncio async def test_create_service_flattened_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_service), "__call__") as call: @@ -1095,7 +1119,6 @@ async def test_create_service_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].service == resources.ManagedService( service_name="service_name_value" ) @@ -1103,7 +1126,9 @@ async def test_create_service_flattened_async(): @pytest.mark.asyncio async def test_create_service_flattened_error_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1118,7 +1143,7 @@ def test_delete_service( transport: str = "grpc", request_type=servicemanager.DeleteServiceRequest ): client = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1129,13 +1154,11 @@ def test_delete_service( with mock.patch.object(type(client.transport.delete_service), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_service(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.DeleteServiceRequest() # Establish that the response is the type that we expect. @@ -1150,7 +1173,7 @@ def test_delete_service_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 = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1158,7 +1181,6 @@ def test_delete_service_empty_call(): client.delete_service() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.DeleteServiceRequest() @@ -1167,7 +1189,7 @@ async def test_delete_service_async( transport: str = "grpc_asyncio", request_type=servicemanager.DeleteServiceRequest ): client = ServiceManagerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1180,13 +1202,11 @@ async def test_delete_service_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_service(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.DeleteServiceRequest() # Establish that the response is the type that we expect. @@ -1199,13 +1219,12 @@ async def test_delete_service_async_from_dict(): def test_delete_service_flattened(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_service), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_service(service_name="service_name_value",) @@ -1214,12 +1233,11 @@ def test_delete_service_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" def test_delete_service_flattened_error(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1231,7 +1249,9 @@ def test_delete_service_flattened_error(): @pytest.mark.asyncio async def test_delete_service_flattened_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_service), "__call__") as call: @@ -1249,13 +1269,14 @@ async def test_delete_service_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" @pytest.mark.asyncio async def test_delete_service_flattened_error_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1269,7 +1290,7 @@ def test_undelete_service( transport: str = "grpc", request_type=servicemanager.UndeleteServiceRequest ): client = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1280,13 +1301,11 @@ def test_undelete_service( with mock.patch.object(type(client.transport.undelete_service), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.undelete_service(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.UndeleteServiceRequest() # Establish that the response is the type that we expect. @@ -1301,7 +1320,7 @@ def test_undelete_service_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 = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1309,7 +1328,6 @@ def test_undelete_service_empty_call(): client.undelete_service() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.UndeleteServiceRequest() @@ -1318,7 +1336,7 @@ async def test_undelete_service_async( transport: str = "grpc_asyncio", request_type=servicemanager.UndeleteServiceRequest ): client = ServiceManagerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1331,13 +1349,11 @@ async def test_undelete_service_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.undelete_service(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.UndeleteServiceRequest() # Establish that the response is the type that we expect. @@ -1350,13 +1366,12 @@ async def test_undelete_service_async_from_dict(): def test_undelete_service_flattened(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.undelete_service), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.undelete_service(service_name="service_name_value",) @@ -1365,12 +1380,11 @@ def test_undelete_service_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" def test_undelete_service_flattened_error(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1382,7 +1396,9 @@ def test_undelete_service_flattened_error(): @pytest.mark.asyncio async def test_undelete_service_flattened_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.undelete_service), "__call__") as call: @@ -1400,13 +1416,14 @@ async def test_undelete_service_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" @pytest.mark.asyncio async def test_undelete_service_flattened_error_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1420,7 +1437,7 @@ def test_list_service_configs( transport: str = "grpc", request_type=servicemanager.ListServiceConfigsRequest ): client = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1435,19 +1452,15 @@ def test_list_service_configs( call.return_value = servicemanager.ListServiceConfigsResponse( next_page_token="next_page_token_value", ) - response = client.list_service_configs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.ListServiceConfigsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListServiceConfigsPager) - assert response.next_page_token == "next_page_token_value" @@ -1459,7 +1472,7 @@ def test_list_service_configs_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 = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1469,7 +1482,6 @@ def test_list_service_configs_empty_call(): client.list_service_configs() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.ListServiceConfigsRequest() @@ -1479,7 +1491,7 @@ async def test_list_service_configs_async( request_type=servicemanager.ListServiceConfigsRequest, ): client = ServiceManagerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1496,18 +1508,15 @@ async def test_list_service_configs_async( next_page_token="next_page_token_value", ) ) - response = await client.list_service_configs(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.ListServiceConfigsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListServiceConfigsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1517,7 +1526,7 @@ async def test_list_service_configs_async_from_dict(): def test_list_service_configs_flattened(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1525,7 +1534,6 @@ def test_list_service_configs_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = servicemanager.ListServiceConfigsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_service_configs(service_name="service_name_value",) @@ -1534,12 +1542,11 @@ def test_list_service_configs_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" def test_list_service_configs_flattened_error(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1552,7 +1559,9 @@ def test_list_service_configs_flattened_error(): @pytest.mark.asyncio async def test_list_service_configs_flattened_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1572,13 +1581,14 @@ async def test_list_service_configs_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" @pytest.mark.asyncio async def test_list_service_configs_flattened_error_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1590,7 +1600,7 @@ async def test_list_service_configs_flattened_error_async(): def test_list_service_configs_pager(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials,) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1600,9 +1610,9 @@ def test_list_service_configs_pager(): call.side_effect = ( servicemanager.ListServiceConfigsResponse( service_configs=[ - service.Service(), - service.Service(), - service.Service(), + service_pb2.Service(), + service_pb2.Service(), + service_pb2.Service(), ], next_page_token="abc", ), @@ -1610,10 +1620,10 @@ def test_list_service_configs_pager(): service_configs=[], next_page_token="def", ), servicemanager.ListServiceConfigsResponse( - service_configs=[service.Service(),], next_page_token="ghi", + service_configs=[service_pb2.Service(),], next_page_token="ghi", ), servicemanager.ListServiceConfigsResponse( - service_configs=[service.Service(), service.Service(),], + service_configs=[service_pb2.Service(), service_pb2.Service(),], ), RuntimeError, ) @@ -1625,11 +1635,11 @@ def test_list_service_configs_pager(): results = [i for i in pager] assert len(results) == 6 - assert all(isinstance(i, service.Service) for i in results) + assert all(isinstance(i, service_pb2.Service) for i in results) def test_list_service_configs_pages(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials,) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1639,9 +1649,9 @@ def test_list_service_configs_pages(): call.side_effect = ( servicemanager.ListServiceConfigsResponse( service_configs=[ - service.Service(), - service.Service(), - service.Service(), + service_pb2.Service(), + service_pb2.Service(), + service_pb2.Service(), ], next_page_token="abc", ), @@ -1649,10 +1659,10 @@ def test_list_service_configs_pages(): service_configs=[], next_page_token="def", ), servicemanager.ListServiceConfigsResponse( - service_configs=[service.Service(),], next_page_token="ghi", + service_configs=[service_pb2.Service(),], next_page_token="ghi", ), servicemanager.ListServiceConfigsResponse( - service_configs=[service.Service(), service.Service(),], + service_configs=[service_pb2.Service(), service_pb2.Service(),], ), RuntimeError, ) @@ -1663,7 +1673,7 @@ def test_list_service_configs_pages(): @pytest.mark.asyncio async def test_list_service_configs_async_pager(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ServiceManagerAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1675,9 +1685,9 @@ async def test_list_service_configs_async_pager(): call.side_effect = ( servicemanager.ListServiceConfigsResponse( service_configs=[ - service.Service(), - service.Service(), - service.Service(), + service_pb2.Service(), + service_pb2.Service(), + service_pb2.Service(), ], next_page_token="abc", ), @@ -1685,10 +1695,10 @@ async def test_list_service_configs_async_pager(): service_configs=[], next_page_token="def", ), servicemanager.ListServiceConfigsResponse( - service_configs=[service.Service(),], next_page_token="ghi", + service_configs=[service_pb2.Service(),], next_page_token="ghi", ), servicemanager.ListServiceConfigsResponse( - service_configs=[service.Service(), service.Service(),], + service_configs=[service_pb2.Service(), service_pb2.Service(),], ), RuntimeError, ) @@ -1699,12 +1709,12 @@ async def test_list_service_configs_async_pager(): responses.append(response) assert len(responses) == 6 - assert all(isinstance(i, service.Service) for i in responses) + assert all(isinstance(i, service_pb2.Service) for i in responses) @pytest.mark.asyncio async def test_list_service_configs_async_pages(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ServiceManagerAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1716,9 +1726,9 @@ async def test_list_service_configs_async_pages(): call.side_effect = ( servicemanager.ListServiceConfigsResponse( service_configs=[ - service.Service(), - service.Service(), - service.Service(), + service_pb2.Service(), + service_pb2.Service(), + service_pb2.Service(), ], next_page_token="abc", ), @@ -1726,10 +1736,10 @@ async def test_list_service_configs_async_pages(): service_configs=[], next_page_token="def", ), servicemanager.ListServiceConfigsResponse( - service_configs=[service.Service(),], next_page_token="ghi", + service_configs=[service_pb2.Service(),], next_page_token="ghi", ), servicemanager.ListServiceConfigsResponse( - service_configs=[service.Service(), service.Service(),], + service_configs=[service_pb2.Service(), service_pb2.Service(),], ), RuntimeError, ) @@ -1744,7 +1754,7 @@ def test_get_service_config( transport: str = "grpc", request_type=servicemanager.GetServiceConfigRequest ): client = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1756,31 +1766,24 @@ def test_get_service_config( type(client.transport.get_service_config), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = service.Service( + call.return_value = service_pb2.Service( name="name_value", title="title_value", producer_project_id="producer_project_id_value", id="id_value", ) - response = client.get_service_config(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.GetServiceConfigRequest() # Establish that the response is the type that we expect. - - assert isinstance(response, service.Service) - + assert isinstance(response, service_pb2.Service) assert response.name == "name_value" - assert response.title == "title_value" - assert response.producer_project_id == "producer_project_id_value" - assert response.id == "id_value" @@ -1792,7 +1795,7 @@ def test_get_service_config_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 = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1802,7 +1805,6 @@ def test_get_service_config_empty_call(): client.get_service_config() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.GetServiceConfigRequest() @@ -1811,7 +1813,7 @@ async def test_get_service_config_async( transport: str = "grpc_asyncio", request_type=servicemanager.GetServiceConfigRequest ): client = ServiceManagerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1824,31 +1826,25 @@ async def test_get_service_config_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - service.Service( + service_pb2.Service( name="name_value", title="title_value", producer_project_id="producer_project_id_value", id="id_value", ) ) - response = await client.get_service_config(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.GetServiceConfigRequest() # Establish that the response is the type that we expect. - assert isinstance(response, service.Service) - + assert isinstance(response, service_pb2.Service) assert response.name == "name_value" - assert response.title == "title_value" - assert response.producer_project_id == "producer_project_id_value" - assert response.id == "id_value" @@ -1858,15 +1854,14 @@ async def test_get_service_config_async_from_dict(): def test_get_service_config_flattened(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.get_service_config), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = service.Service() - + call.return_value = service_pb2.Service() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_service_config( @@ -1879,16 +1874,13 @@ def test_get_service_config_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" - assert args[0].config_id == "config_id_value" - assert args[0].view == servicemanager.GetServiceConfigRequest.ConfigView.FULL def test_get_service_config_flattened_error(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1903,16 +1895,18 @@ def test_get_service_config_flattened_error(): @pytest.mark.asyncio async def test_get_service_config_flattened_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.get_service_config), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = service.Service() + call.return_value = service_pb2.Service() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.Service()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service_pb2.Service()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.get_service_config( @@ -1925,17 +1919,16 @@ async def test_get_service_config_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" - assert args[0].config_id == "config_id_value" - assert args[0].view == servicemanager.GetServiceConfigRequest.ConfigView.FULL @pytest.mark.asyncio async def test_get_service_config_flattened_error_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1952,7 +1945,7 @@ def test_create_service_config( transport: str = "grpc", request_type=servicemanager.CreateServiceConfigRequest ): client = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1964,31 +1957,24 @@ def test_create_service_config( type(client.transport.create_service_config), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = service.Service( + call.return_value = service_pb2.Service( name="name_value", title="title_value", producer_project_id="producer_project_id_value", id="id_value", ) - response = client.create_service_config(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.CreateServiceConfigRequest() # Establish that the response is the type that we expect. - - assert isinstance(response, service.Service) - + assert isinstance(response, service_pb2.Service) assert response.name == "name_value" - assert response.title == "title_value" - assert response.producer_project_id == "producer_project_id_value" - assert response.id == "id_value" @@ -2000,7 +1986,7 @@ def test_create_service_config_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 = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2010,7 +1996,6 @@ def test_create_service_config_empty_call(): client.create_service_config() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.CreateServiceConfigRequest() @@ -2020,7 +2005,7 @@ async def test_create_service_config_async( request_type=servicemanager.CreateServiceConfigRequest, ): client = ServiceManagerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2033,31 +2018,25 @@ async def test_create_service_config_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - service.Service( + service_pb2.Service( name="name_value", title="title_value", producer_project_id="producer_project_id_value", id="id_value", ) ) - response = await client.create_service_config(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.CreateServiceConfigRequest() # Establish that the response is the type that we expect. - assert isinstance(response, service.Service) - + assert isinstance(response, service_pb2.Service) assert response.name == "name_value" - assert response.title == "title_value" - assert response.producer_project_id == "producer_project_id_value" - assert response.id == "id_value" @@ -2067,34 +2046,31 @@ async def test_create_service_config_async_from_dict(): def test_create_service_config_flattened(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.create_service_config), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = service.Service() - + call.return_value = service_pb2.Service() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_service_config( service_name="service_name_value", - service_config=service.Service(name="name_value"), + service_config=service_pb2.Service(name="name_value"), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" - - assert args[0].service_config == service.Service(name="name_value") + assert args[0].service_config == service_pb2.Service(name="name_value") def test_create_service_config_flattened_error(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2102,42 +2078,44 @@ def test_create_service_config_flattened_error(): client.create_service_config( servicemanager.CreateServiceConfigRequest(), service_name="service_name_value", - service_config=service.Service(name="name_value"), + service_config=service_pb2.Service(name="name_value"), ) @pytest.mark.asyncio async def test_create_service_config_flattened_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.create_service_config), "__call__" ) as call: # Designate an appropriate return value for the call. - call.return_value = service.Service() + call.return_value = service_pb2.Service() - call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service.Service()) + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(service_pb2.Service()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_service_config( service_name="service_name_value", - service_config=service.Service(name="name_value"), + service_config=service_pb2.Service(name="name_value"), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" - - assert args[0].service_config == service.Service(name="name_value") + assert args[0].service_config == service_pb2.Service(name="name_value") @pytest.mark.asyncio async def test_create_service_config_flattened_error_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2145,7 +2123,7 @@ async def test_create_service_config_flattened_error_async(): await client.create_service_config( servicemanager.CreateServiceConfigRequest(), service_name="service_name_value", - service_config=service.Service(name="name_value"), + service_config=service_pb2.Service(name="name_value"), ) @@ -2153,7 +2131,7 @@ def test_submit_config_source( transport: str = "grpc", request_type=servicemanager.SubmitConfigSourceRequest ): client = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2166,13 +2144,11 @@ def test_submit_config_source( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.submit_config_source(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.SubmitConfigSourceRequest() # Establish that the response is the type that we expect. @@ -2187,7 +2163,7 @@ def test_submit_config_source_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 = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2197,7 +2173,6 @@ def test_submit_config_source_empty_call(): client.submit_config_source() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.SubmitConfigSourceRequest() @@ -2207,7 +2182,7 @@ async def test_submit_config_source_async( request_type=servicemanager.SubmitConfigSourceRequest, ): client = ServiceManagerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2222,13 +2197,11 @@ async def test_submit_config_source_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.submit_config_source(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.SubmitConfigSourceRequest() # Establish that the response is the type that we expect. @@ -2241,7 +2214,7 @@ async def test_submit_config_source_async_from_dict(): def test_submit_config_source_flattened(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2249,7 +2222,6 @@ def test_submit_config_source_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.submit_config_source( @@ -2262,16 +2234,13 @@ def test_submit_config_source_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" - assert args[0].config_source == resources.ConfigSource(id="id_value") - assert args[0].validate_only == True def test_submit_config_source_flattened_error(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2286,7 +2255,9 @@ def test_submit_config_source_flattened_error(): @pytest.mark.asyncio async def test_submit_config_source_flattened_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2310,17 +2281,16 @@ async def test_submit_config_source_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" - assert args[0].config_source == resources.ConfigSource(id="id_value") - assert args[0].validate_only == True @pytest.mark.asyncio async def test_submit_config_source_flattened_error_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2337,7 +2307,7 @@ def test_list_service_rollouts( transport: str = "grpc", request_type=servicemanager.ListServiceRolloutsRequest ): client = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2352,19 +2322,15 @@ def test_list_service_rollouts( call.return_value = servicemanager.ListServiceRolloutsResponse( next_page_token="next_page_token_value", ) - response = client.list_service_rollouts(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.ListServiceRolloutsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListServiceRolloutsPager) - assert response.next_page_token == "next_page_token_value" @@ -2376,7 +2342,7 @@ def test_list_service_rollouts_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 = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2386,7 +2352,6 @@ def test_list_service_rollouts_empty_call(): client.list_service_rollouts() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.ListServiceRolloutsRequest() @@ -2396,7 +2361,7 @@ async def test_list_service_rollouts_async( request_type=servicemanager.ListServiceRolloutsRequest, ): client = ServiceManagerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2413,18 +2378,15 @@ async def test_list_service_rollouts_async( next_page_token="next_page_token_value", ) ) - response = await client.list_service_rollouts(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.ListServiceRolloutsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListServiceRolloutsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -2434,7 +2396,7 @@ async def test_list_service_rollouts_async_from_dict(): def test_list_service_rollouts_flattened(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2442,7 +2404,6 @@ def test_list_service_rollouts_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = servicemanager.ListServiceRolloutsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_service_rollouts( @@ -2453,14 +2414,12 @@ def test_list_service_rollouts_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" - assert args[0].filter == "filter_value" def test_list_service_rollouts_flattened_error(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2474,7 +2433,9 @@ def test_list_service_rollouts_flattened_error(): @pytest.mark.asyncio async def test_list_service_rollouts_flattened_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2496,15 +2457,15 @@ async def test_list_service_rollouts_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" - assert args[0].filter == "filter_value" @pytest.mark.asyncio async def test_list_service_rollouts_flattened_error_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2517,7 +2478,7 @@ async def test_list_service_rollouts_flattened_error_async(): def test_list_service_rollouts_pager(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials,) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2556,7 +2517,7 @@ def test_list_service_rollouts_pager(): def test_list_service_rollouts_pages(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials,) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2590,7 +2551,7 @@ def test_list_service_rollouts_pages(): @pytest.mark.asyncio async def test_list_service_rollouts_async_pager(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ServiceManagerAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2631,7 +2592,7 @@ async def test_list_service_rollouts_async_pager(): @pytest.mark.asyncio async def test_list_service_rollouts_async_pages(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials,) + client = ServiceManagerAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2671,7 +2632,7 @@ def test_get_service_rollout( transport: str = "grpc", request_type=servicemanager.GetServiceRolloutRequest ): client = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2692,25 +2653,18 @@ def test_get_service_rollout( percentages={"key_value": 0.541} ), ) - response = client.get_service_rollout(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.GetServiceRolloutRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resources.Rollout) - assert response.rollout_id == "rollout_id_value" - assert response.created_by == "created_by_value" - assert response.status == resources.Rollout.RolloutStatus.IN_PROGRESS - assert response.service_name == "service_name_value" @@ -2722,7 +2676,7 @@ def test_get_service_rollout_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 = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2732,7 +2686,6 @@ def test_get_service_rollout_empty_call(): client.get_service_rollout() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.GetServiceRolloutRequest() @@ -2742,7 +2695,7 @@ async def test_get_service_rollout_async( request_type=servicemanager.GetServiceRolloutRequest, ): client = ServiceManagerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2762,24 +2715,18 @@ async def test_get_service_rollout_async( service_name="service_name_value", ) ) - response = await client.get_service_rollout(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.GetServiceRolloutRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Rollout) - assert response.rollout_id == "rollout_id_value" - assert response.created_by == "created_by_value" - assert response.status == resources.Rollout.RolloutStatus.IN_PROGRESS - assert response.service_name == "service_name_value" @@ -2789,7 +2736,7 @@ async def test_get_service_rollout_async_from_dict(): def test_get_service_rollout_flattened(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2797,7 +2744,6 @@ def test_get_service_rollout_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = resources.Rollout() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_service_rollout( @@ -2808,14 +2754,12 @@ def test_get_service_rollout_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" - assert args[0].rollout_id == "rollout_id_value" def test_get_service_rollout_flattened_error(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2829,7 +2773,9 @@ def test_get_service_rollout_flattened_error(): @pytest.mark.asyncio async def test_get_service_rollout_flattened_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2849,15 +2795,15 @@ async def test_get_service_rollout_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" - assert args[0].rollout_id == "rollout_id_value" @pytest.mark.asyncio async def test_get_service_rollout_flattened_error_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2873,7 +2819,7 @@ def test_create_service_rollout( transport: str = "grpc", request_type=servicemanager.CreateServiceRolloutRequest ): client = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2886,13 +2832,11 @@ def test_create_service_rollout( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_service_rollout(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.CreateServiceRolloutRequest() # Establish that the response is the type that we expect. @@ -2907,7 +2851,7 @@ def test_create_service_rollout_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 = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2917,7 +2861,6 @@ def test_create_service_rollout_empty_call(): client.create_service_rollout() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.CreateServiceRolloutRequest() @@ -2927,7 +2870,7 @@ async def test_create_service_rollout_async( request_type=servicemanager.CreateServiceRolloutRequest, ): client = ServiceManagerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2942,13 +2885,11 @@ async def test_create_service_rollout_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_service_rollout(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.CreateServiceRolloutRequest() # Establish that the response is the type that we expect. @@ -2961,7 +2902,7 @@ async def test_create_service_rollout_async_from_dict(): def test_create_service_rollout_flattened(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2969,7 +2910,6 @@ def test_create_service_rollout_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_service_rollout( @@ -2981,14 +2921,12 @@ def test_create_service_rollout_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" - assert args[0].rollout == resources.Rollout(rollout_id="rollout_id_value") def test_create_service_rollout_flattened_error(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3002,7 +2940,9 @@ def test_create_service_rollout_flattened_error(): @pytest.mark.asyncio async def test_create_service_rollout_flattened_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3025,15 +2965,15 @@ async def test_create_service_rollout_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" - assert args[0].rollout == resources.Rollout(rollout_id="rollout_id_value") @pytest.mark.asyncio async def test_create_service_rollout_flattened_error_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3049,7 +2989,7 @@ def test_generate_config_report( transport: str = "grpc", request_type=servicemanager.GenerateConfigReportRequest ): client = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3064,21 +3004,16 @@ def test_generate_config_report( call.return_value = servicemanager.GenerateConfigReportResponse( service_name="service_name_value", id="id_value", ) - response = client.generate_config_report(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.GenerateConfigReportRequest() # Establish that the response is the type that we expect. - assert isinstance(response, servicemanager.GenerateConfigReportResponse) - assert response.service_name == "service_name_value" - assert response.id == "id_value" @@ -3090,7 +3025,7 @@ def test_generate_config_report_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 = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3100,7 +3035,6 @@ def test_generate_config_report_empty_call(): client.generate_config_report() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.GenerateConfigReportRequest() @@ -3110,7 +3044,7 @@ async def test_generate_config_report_async( request_type=servicemanager.GenerateConfigReportRequest, ): client = ServiceManagerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3127,20 +3061,16 @@ async def test_generate_config_report_async( service_name="service_name_value", id="id_value", ) ) - response = await client.generate_config_report(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.GenerateConfigReportRequest() # Establish that the response is the type that we expect. assert isinstance(response, servicemanager.GenerateConfigReportResponse) - assert response.service_name == "service_name_value" - assert response.id == "id_value" @@ -3150,7 +3080,7 @@ async def test_generate_config_report_async_from_dict(): def test_generate_config_report_flattened(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3158,40 +3088,39 @@ def test_generate_config_report_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = servicemanager.GenerateConfigReportResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.generate_config_report( - new_config=gp_any.Any(type_url="type_url_value"), - old_config=gp_any.Any(type_url="type_url_value"), + new_config=any_pb2.Any(type_url="type_url_value"), + old_config=any_pb2.Any(type_url="type_url_value"), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - - assert args[0].new_config == gp_any.Any(type_url="type_url_value") - - assert args[0].old_config == gp_any.Any(type_url="type_url_value") + assert args[0].new_config == any_pb2.Any(type_url="type_url_value") + assert args[0].old_config == any_pb2.Any(type_url="type_url_value") def test_generate_config_report_flattened_error(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.generate_config_report( servicemanager.GenerateConfigReportRequest(), - new_config=gp_any.Any(type_url="type_url_value"), - old_config=gp_any.Any(type_url="type_url_value"), + new_config=any_pb2.Any(type_url="type_url_value"), + old_config=any_pb2.Any(type_url="type_url_value"), ) @pytest.mark.asyncio async def test_generate_config_report_flattened_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3206,31 +3135,31 @@ async def test_generate_config_report_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.generate_config_report( - new_config=gp_any.Any(type_url="type_url_value"), - old_config=gp_any.Any(type_url="type_url_value"), + new_config=any_pb2.Any(type_url="type_url_value"), + old_config=any_pb2.Any(type_url="type_url_value"), ) # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - - assert args[0].new_config == gp_any.Any(type_url="type_url_value") - - assert args[0].old_config == gp_any.Any(type_url="type_url_value") + assert args[0].new_config == any_pb2.Any(type_url="type_url_value") + assert args[0].old_config == any_pb2.Any(type_url="type_url_value") @pytest.mark.asyncio async def test_generate_config_report_flattened_error_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.generate_config_report( servicemanager.GenerateConfigReportRequest(), - new_config=gp_any.Any(type_url="type_url_value"), - old_config=gp_any.Any(type_url="type_url_value"), + new_config=any_pb2.Any(type_url="type_url_value"), + old_config=any_pb2.Any(type_url="type_url_value"), ) @@ -3238,7 +3167,7 @@ def test_enable_service( transport: str = "grpc", request_type=servicemanager.EnableServiceRequest ): client = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3249,13 +3178,11 @@ def test_enable_service( with mock.patch.object(type(client.transport.enable_service), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.enable_service(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.EnableServiceRequest() # Establish that the response is the type that we expect. @@ -3270,7 +3197,7 @@ def test_enable_service_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 = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3278,7 +3205,6 @@ def test_enable_service_empty_call(): client.enable_service() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.EnableServiceRequest() @@ -3287,7 +3213,7 @@ async def test_enable_service_async( transport: str = "grpc_asyncio", request_type=servicemanager.EnableServiceRequest ): client = ServiceManagerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3300,13 +3226,11 @@ async def test_enable_service_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.enable_service(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.EnableServiceRequest() # Establish that the response is the type that we expect. @@ -3319,13 +3243,12 @@ async def test_enable_service_async_from_dict(): def test_enable_service_flattened(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.enable_service), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.enable_service( @@ -3336,14 +3259,12 @@ def test_enable_service_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" - assert args[0].consumer_id == "consumer_id_value" def test_enable_service_flattened_error(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3357,7 +3278,9 @@ def test_enable_service_flattened_error(): @pytest.mark.asyncio async def test_enable_service_flattened_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.enable_service), "__call__") as call: @@ -3377,15 +3300,15 @@ async def test_enable_service_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" - assert args[0].consumer_id == "consumer_id_value" @pytest.mark.asyncio async def test_enable_service_flattened_error_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3401,7 +3324,7 @@ def test_disable_service( transport: str = "grpc", request_type=servicemanager.DisableServiceRequest ): client = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3412,13 +3335,11 @@ def test_disable_service( with mock.patch.object(type(client.transport.disable_service), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.disable_service(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.DisableServiceRequest() # Establish that the response is the type that we expect. @@ -3433,7 +3354,7 @@ def test_disable_service_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 = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3441,7 +3362,6 @@ def test_disable_service_empty_call(): client.disable_service() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.DisableServiceRequest() @@ -3450,7 +3370,7 @@ async def test_disable_service_async( transport: str = "grpc_asyncio", request_type=servicemanager.DisableServiceRequest ): client = ServiceManagerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3463,13 +3383,11 @@ async def test_disable_service_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.disable_service(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == servicemanager.DisableServiceRequest() # Establish that the response is the type that we expect. @@ -3482,13 +3400,12 @@ async def test_disable_service_async_from_dict(): def test_disable_service_flattened(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.disable_service), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.disable_service( @@ -3499,14 +3416,12 @@ def test_disable_service_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" - assert args[0].consumer_id == "consumer_id_value" def test_disable_service_flattened_error(): - client = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3520,7 +3435,9 @@ def test_disable_service_flattened_error(): @pytest.mark.asyncio async def test_disable_service_flattened_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.disable_service), "__call__") as call: @@ -3540,15 +3457,15 @@ async def test_disable_service_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].service_name == "service_name_value" - assert args[0].consumer_id == "consumer_id_value" @pytest.mark.asyncio async def test_disable_service_flattened_error_async(): - client = ServiceManagerAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3563,16 +3480,16 @@ async def test_disable_service_flattened_error_async(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.ServiceManagerGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = ServiceManagerClient( - 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.ServiceManagerGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = ServiceManagerClient( @@ -3582,7 +3499,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.ServiceManagerGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = ServiceManagerClient( @@ -3593,7 +3510,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.ServiceManagerGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = ServiceManagerClient(transport=transport) assert client.transport is transport @@ -3602,13 +3519,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.ServiceManagerGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.ServiceManagerGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -3623,23 +3540,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 = ServiceManagerClient(credentials=credentials.AnonymousCredentials(),) + client = ServiceManagerClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.ServiceManagerGrpcTransport,) def test_service_manager_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.ServiceManagerTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -3651,7 +3568,7 @@ def test_service_manager_base_transport(): ) as Transport: Transport.return_value = None transport = transports.ServiceManagerTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -3683,15 +3600,42 @@ def test_service_manager_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_service_manager_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.servicemanagement_v1.services.service_manager.transports.ServiceManagerTransport._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.ServiceManagerTransport( + 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", + "https://www.googleapis.com/auth/cloud-platform.read-only", + "https://www.googleapis.com/auth/service.management", + "https://www.googleapis.com/auth/service.management.readonly", + ), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_service_manager_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.servicemanagement_v1.services.service_manager.transports.ServiceManagerTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.ServiceManagerTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -3709,19 +3653,38 @@ def test_service_manager_base_transport_with_credentials_file(): def test_service_manager_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.servicemanagement_v1.services.service_manager.transports.ServiceManagerTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.ServiceManagerTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_service_manager_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) + ServiceManagerClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/cloud-platform.read-only", + "https://www.googleapis.com/auth/service.management", + "https://www.googleapis.com/auth/service.management.readonly", + ), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_service_manager_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) ServiceManagerClient() adc.assert_called_once_with( scopes=( @@ -3734,14 +3697,46 @@ def test_service_manager_auth_adc(): ) -def test_service_manager_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.ServiceManagerGrpcTransport, + transports.ServiceManagerGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_service_manager_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.ServiceManagerGrpcTransport( - 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", + "https://www.googleapis.com/auth/cloud-platform.read-only", + "https://www.googleapis.com/auth/service.management", + "https://www.googleapis.com/auth/service.management.readonly", + ), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.ServiceManagerGrpcTransport, + transports.ServiceManagerGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_service_manager_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", @@ -3753,6 +3748,46 @@ def test_service_manager_transport_auth_adc(): ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.ServiceManagerGrpcTransport, grpc_helpers), + (transports.ServiceManagerGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +def test_service_manager_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( + "servicemanagement.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/cloud-platform.read-only", + "https://www.googleapis.com/auth/service.management", + "https://www.googleapis.com/auth/service.management.readonly", + ), + scopes=["1", "2"], + default_host="servicemanagement.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -3761,7 +3796,7 @@ def test_service_manager_transport_auth_adc(): ], ) def test_service_manager_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: @@ -3775,12 +3810,7 @@ def test_service_manager_grpc_transport_client_cert_source_for_mtls(transport_cl "squid.clam.whelk:443", credentials=cred, credentials_file=None, - scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloud-platform.read-only", - "https://www.googleapis.com/auth/service.management", - "https://www.googleapis.com/auth/service.management.readonly", - ), + scopes=None, ssl_credentials=mock_ssl_channel_creds, quota_project_id=None, options=[ @@ -3805,7 +3835,7 @@ def test_service_manager_grpc_transport_client_cert_source_for_mtls(transport_cl def test_service_manager_host_no_port(): client = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="servicemanagement.googleapis.com" ), @@ -3815,7 +3845,7 @@ def test_service_manager_host_no_port(): def test_service_manager_host_with_port(): client = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="servicemanagement.googleapis.com:8000" ), @@ -3871,9 +3901,9 @@ def test_service_manager_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", @@ -3889,12 +3919,7 @@ def test_service_manager_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", - "https://www.googleapis.com/auth/cloud-platform.read-only", - "https://www.googleapis.com/auth/service.management", - "https://www.googleapis.com/auth/service.management.readonly", - ), + scopes=None, ssl_credentials=mock_ssl_cred, quota_project_id=None, options=[ @@ -3941,12 +3966,7 @@ def test_service_manager_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", - "https://www.googleapis.com/auth/cloud-platform.read-only", - "https://www.googleapis.com/auth/service.management", - "https://www.googleapis.com/auth/service.management.readonly", - ), + scopes=None, ssl_credentials=mock_ssl_cred, quota_project_id=None, options=[ @@ -3959,7 +3979,7 @@ def test_service_manager_transport_channel_mtls_with_adc(transport_class): def test_service_manager_grpc_lro_client(): client = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -3972,7 +3992,7 @@ def test_service_manager_grpc_lro_client(): def test_service_manager_grpc_lro_async_client(): client = ServiceManagerAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -3985,7 +4005,6 @@ def test_service_manager_grpc_lro_async_client(): def test_common_billing_account_path(): billing_account = "squid" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -4006,7 +4025,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) actual = ServiceManagerClient.common_folder_path(folder) assert expected == actual @@ -4025,7 +4043,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) actual = ServiceManagerClient.common_organization_path(organization) assert expected == actual @@ -4044,7 +4061,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) actual = ServiceManagerClient.common_project_path(project) assert expected == actual @@ -4064,7 +4080,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, ) @@ -4091,7 +4106,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.ServiceManagerTransport, "_prep_wrapped_messages" ) as prep: client = ServiceManagerClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -4100,6 +4115,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = ServiceManagerClient.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)