diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml new file mode 100644 index 0000000..864c176 --- /dev/null +++ b/.github/.OwlBot.lock.yaml @@ -0,0 +1,3 @@ +docker: + image: gcr.io/repo-automation-bots/owlbot-python:latest + digest: sha256:4c981a6b6f2b8914a448d7b3a01688365be03e3ed26dfee399a6aa77fb112eaa diff --git a/.github/.OwlBot.yaml b/.github/.OwlBot.yaml new file mode 100644 index 0000000..21c43b6 --- /dev/null +++ b/.github/.OwlBot.yaml @@ -0,0 +1,29 @@ +# 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-preserve-regex: + - /owl-bot-staging/v1beta1 + +deep-copy-regex: + - source: /google/cloud/managedidentities/(v.*)/.*-py/(.*) + dest: /owl-bot-staging/$1/$2 + +begin-after-commit-hash: 6a5da3f1274b088752f074da5bc9e30bd1beb27e + 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 9399d1d..1b33b10 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-managed-identities 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 34a9b35..9868503 100644 --- a/.kokoro/release/common.cfg +++ b/.kokoro/release/common.cfg @@ -23,18 +23,8 @@ env_vars: { value: "github/python-managed-identities/.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.6/periodic-head.cfg b/.kokoro/samples/python3.6/periodic-head.cfg new file mode 100644 index 0000000..f9cfcd3 --- /dev/null +++ b/.kokoro/samples/python3.6/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.7/periodic-head.cfg b/.kokoro/samples/python3.7/periodic-head.cfg new file mode 100644 index 0000000..f9cfcd3 --- /dev/null +++ b/.kokoro/samples/python3.7/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.8/periodic-head.cfg b/.kokoro/samples/python3.8/periodic-head.cfg new file mode 100644 index 0000000..f9cfcd3 --- /dev/null +++ b/.kokoro/samples/python3.8/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/test-samples-against-head.sh b/.kokoro/test-samples-against-head.sh new file mode 100755 index 0000000..c250547 --- /dev/null +++ b/.kokoro/test-samples-against-head.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# 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 +# +# https://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. + +# A customized test runner for samples. +# +# For periodic builds, you can specify this file for testing against head. + +# `-e` enables the script to automatically fail when a command fails +# `-o pipefail` sets the exit code to the rightmost comment to exit with a non-zero +set -eo pipefail +# Enables `**` to include files nested inside sub-folders +shopt -s globstar + +cd github/python-managed-identities + +exec .kokoro/test-samples-impl.sh diff --git a/.kokoro/test-samples-impl.sh b/.kokoro/test-samples-impl.sh new file mode 100755 index 0000000..cf5de74 --- /dev/null +++ b/.kokoro/test-samples-impl.sh @@ -0,0 +1,102 @@ +#!/bin/bash +# 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 +# +# https://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. + + +# `-e` enables the script to automatically fail when a command fails +# `-o pipefail` sets the exit code to the rightmost comment to exit with a non-zero +set -eo pipefail +# Enables `**` to include files nested inside sub-folders +shopt -s globstar + +# Exit early if samples directory doesn't exist +if [ ! -d "./samples" ]; then + echo "No tests run. `./samples` not found" + exit 0 +fi + +# Disable buffering, so that the logs stream through. +export PYTHONUNBUFFERED=1 + +# Debug: show build environment +env | grep KOKORO + +# Install nox +python3.6 -m pip install --upgrade --quiet nox + +# Use secrets acessor service account to get secrets +if [[ -f "${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" ]]; then + gcloud auth activate-service-account \ + --key-file="${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" \ + --project="cloud-devrel-kokoro-resources" +fi + +# This script will create 3 files: +# - testing/test-env.sh +# - testing/service-account.json +# - testing/client-secrets.json +./scripts/decrypt-secrets.sh + +source ./testing/test-env.sh +export GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/testing/service-account.json + +# For cloud-run session, we activate the service account for gcloud sdk. +gcloud auth activate-service-account \ + --key-file "${GOOGLE_APPLICATION_CREDENTIALS}" + +export GOOGLE_CLIENT_SECRETS=$(pwd)/testing/client-secrets.json + +echo -e "\n******************** TESTING PROJECTS ********************" + +# Switch to 'fail at end' to allow all tests to complete before exiting. +set +e +# Use RTN to return a non-zero value if the test fails. +RTN=0 +ROOT=$(pwd) +# Find all requirements.txt in the samples directory (may break on whitespace). +for file in samples/**/requirements.txt; do + cd "$ROOT" + # Navigate to the project folder. + file=$(dirname "$file") + cd "$file" + + echo "------------------------------------------------------------" + echo "- testing $file" + echo "------------------------------------------------------------" + + # Use nox to execute the tests for the project. + python3.6 -m nox -s "$RUN_TESTS_SESSION" + EXIT=$? + + # If this is a periodic build, send the test log to the FlakyBot. + # See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot. + if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then + chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot + $KOKORO_GFILE_DIR/linux_amd64/flakybot + fi + + if [[ $EXIT -ne 0 ]]; then + RTN=1 + echo -e "\n Testing failed: Nox returned a non-zero exit code. \n" + else + echo -e "\n Testing completed.\n" + fi + +done +cd "$ROOT" + +# Workaround for Kokoro permissions issue: delete secrets +rm testing/{test-env.sh,client-secrets.json,service-account.json} + +exit "$RTN" diff --git a/.kokoro/test-samples.sh b/.kokoro/test-samples.sh index f20498e..f3d5be6 100755 --- a/.kokoro/test-samples.sh +++ b/.kokoro/test-samples.sh @@ -13,6 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +# The default test runner for samples. +# +# For periodic builds, we rewinds the repo to the latest release, and +# run test-samples-impl.sh. # `-e` enables the script to automatically fail when a command fails # `-o pipefail` sets the exit code to the rightmost comment to exit with a non-zero @@ -24,87 +28,19 @@ cd github/python-managed-identities # Run periodic samples tests at latest release if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then + # preserving the test runner implementation. + cp .kokoro/test-samples-impl.sh "${TMPDIR}/test-samples-impl.sh" + echo "--- IMPORTANT IMPORTANT IMPORTANT ---" + echo "Now we rewind the repo back to the latest release..." LATEST_RELEASE=$(git describe --abbrev=0 --tags) git checkout $LATEST_RELEASE -fi - -# Exit early if samples directory doesn't exist -if [ ! -d "./samples" ]; then - echo "No tests run. `./samples` not found" - exit 0 -fi - -# Disable buffering, so that the logs stream through. -export PYTHONUNBUFFERED=1 - -# Debug: show build environment -env | grep KOKORO - -# Install nox -python3.6 -m pip install --upgrade --quiet nox - -# Use secrets acessor service account to get secrets -if [[ -f "${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" ]]; then - gcloud auth activate-service-account \ - --key-file="${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" \ - --project="cloud-devrel-kokoro-resources" -fi - -# This script will create 3 files: -# - testing/test-env.sh -# - testing/service-account.json -# - testing/client-secrets.json -./scripts/decrypt-secrets.sh - -source ./testing/test-env.sh -export GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/testing/service-account.json - -# For cloud-run session, we activate the service account for gcloud sdk. -gcloud auth activate-service-account \ - --key-file "${GOOGLE_APPLICATION_CREDENTIALS}" - -export GOOGLE_CLIENT_SECRETS=$(pwd)/testing/client-secrets.json - -echo -e "\n******************** TESTING PROJECTS ********************" - -# Switch to 'fail at end' to allow all tests to complete before exiting. -set +e -# Use RTN to return a non-zero value if the test fails. -RTN=0 -ROOT=$(pwd) -# Find all requirements.txt in the samples directory (may break on whitespace). -for file in samples/**/requirements.txt; do - cd "$ROOT" - # Navigate to the project folder. - file=$(dirname "$file") - cd "$file" - - echo "------------------------------------------------------------" - echo "- testing $file" - echo "------------------------------------------------------------" - - # Use nox to execute the tests for the project. - python3.6 -m nox -s "$RUN_TESTS_SESSION" - EXIT=$? - - # If this is a periodic build, send the test log to the FlakyBot. - # See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot. - if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then - chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot - $KOKORO_GFILE_DIR/linux_amd64/flakybot + echo "The current head is: " + echo $(git rev-parse --verify HEAD) + echo "--- IMPORTANT IMPORTANT IMPORTANT ---" + # move back the test runner implementation if there's no file. + if [ ! -f .kokoro/test-samples-impl.sh ]; then + cp "${TMPDIR}/test-samples-impl.sh" .kokoro/test-samples-impl.sh fi +fi - if [[ $EXIT -ne 0 ]]; then - RTN=1 - echo -e "\n Testing failed: Nox returned a non-zero exit code. \n" - else - echo -e "\n Testing completed.\n" - fi - -done -cd "$ROOT" - -# Workaround for Kokoro permissions issue: delete secrets -rm testing/{test-env.sh,client-secrets.json,service-account.json} - -exit "$RTN" +exec .kokoro/test-samples-impl.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 55cc59e..4f00c7c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 641eb12..6b03927 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -6,6 +6,7 @@ "issue_tracker": "", "release_level": "beta", "language": "python", + "library_type": "GAPIC_AUTO", "repo": "googleapis/python-managed-identities", "distribution_name": "google-cloud-managed-identities", "api_id": "managedidentities.googleapis.com" diff --git a/CHANGELOG.md b/CHANGELOG.md index c39a4b0..d370e9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## [0.2.0](https://www.github.com/googleapis/python-managed-identities/compare/v0.1.0...v0.2.0) (2021-05-16) + + +### Features + +* support self-signed JWT flow for service accounts ([cf6f145](https://www.github.com/googleapis/python-managed-identities/commit/cf6f1456a626433753dafff5700f182497d9b18d)) + + +### Bug Fixes + +* add async client to %name_%version/init.py ([cf6f145](https://www.github.com/googleapis/python-managed-identities/commit/cf6f1456a626433753dafff5700f182497d9b18d)) +* **deps:** add packaging requirement ([#30](https://www.github.com/googleapis/python-managed-identities/issues/30)) ([e618271](https://www.github.com/googleapis/python-managed-identities/commit/e618271758f0c9a8ed2c2ae8b057f9fc83491724)) + ## 0.1.0 (2021-03-15) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 207d6b7..ecc9656 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -160,21 +160,7 @@ Running System Tests 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 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/managedidentities_v1/managed_identities_service.rst b/docs/managedidentities_v1/managed_identities_service.rst index 7860185..d08b52d 100644 --- a/docs/managedidentities_v1/managed_identities_service.rst +++ b/docs/managedidentities_v1/managed_identities_service.rst @@ -5,7 +5,6 @@ ManagedIdentitiesService :members: :inherited-members: - .. automodule:: google.cloud.managedidentities_v1.services.managed_identities_service.pagers :members: :inherited-members: diff --git a/google/cloud/managedidentities/__init__.py b/google/cloud/managedidentities/__init__.py index 0e27a12..3dac09f 100644 --- a/google/cloud/managedidentities/__init__.py +++ b/google/cloud/managedidentities/__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.managedidentities_v1.services.managed_identities_service.async_client import ( - ManagedIdentitiesServiceAsyncClient, -) from google.cloud.managedidentities_v1.services.managed_identities_service.client import ( ManagedIdentitiesServiceClient, ) +from google.cloud.managedidentities_v1.services.managed_identities_service.async_client import ( + ManagedIdentitiesServiceAsyncClient, +) + from google.cloud.managedidentities_v1.types.managed_identities_service import ( AttachTrustRequest, ) @@ -64,21 +64,21 @@ from google.cloud.managedidentities_v1.types.resource import Trust __all__ = ( + "ManagedIdentitiesServiceClient", + "ManagedIdentitiesServiceAsyncClient", "AttachTrustRequest", "CreateMicrosoftAdDomainRequest", "DeleteDomainRequest", "DetachTrustRequest", - "Domain", "GetDomainRequest", "ListDomainsRequest", "ListDomainsResponse", - "ManagedIdentitiesServiceAsyncClient", - "ManagedIdentitiesServiceClient", "OpMetadata", "ReconfigureTrustRequest", "ResetAdminPasswordRequest", "ResetAdminPasswordResponse", - "Trust", "UpdateDomainRequest", "ValidateTrustRequest", + "Domain", + "Trust", ) diff --git a/google/cloud/managedidentities_v1/__init__.py b/google/cloud/managedidentities_v1/__init__.py index 7181a0f..096d391 100644 --- a/google/cloud/managedidentities_v1/__init__.py +++ b/google/cloud/managedidentities_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.managed_identities_service import ManagedIdentitiesServiceClient +from .services.managed_identities_service import ManagedIdentitiesServiceAsyncClient + from .types.managed_identities_service import AttachTrustRequest from .types.managed_identities_service import CreateMicrosoftAdDomainRequest from .types.managed_identities_service import DeleteDomainRequest @@ -32,8 +33,8 @@ from .types.resource import Domain from .types.resource import Trust - __all__ = ( + "ManagedIdentitiesServiceAsyncClient", "AttachTrustRequest", "CreateMicrosoftAdDomainRequest", "DeleteDomainRequest", @@ -42,6 +43,7 @@ "GetDomainRequest", "ListDomainsRequest", "ListDomainsResponse", + "ManagedIdentitiesServiceClient", "OpMetadata", "ReconfigureTrustRequest", "ResetAdminPasswordRequest", @@ -49,5 +51,4 @@ "Trust", "UpdateDomainRequest", "ValidateTrustRequest", - "ManagedIdentitiesServiceClient", ) diff --git a/google/cloud/managedidentities_v1/gapic_metadata.json b/google/cloud/managedidentities_v1/gapic_metadata.json new file mode 100644 index 0000000..8b5405a --- /dev/null +++ b/google/cloud/managedidentities_v1/gapic_metadata.json @@ -0,0 +1,123 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.managedidentities_v1", + "protoPackage": "google.cloud.managedidentities.v1", + "schema": "1.0", + "services": { + "ManagedIdentitiesService": { + "clients": { + "grpc": { + "libraryClient": "ManagedIdentitiesServiceClient", + "rpcs": { + "AttachTrust": { + "methods": [ + "attach_trust" + ] + }, + "CreateMicrosoftAdDomain": { + "methods": [ + "create_microsoft_ad_domain" + ] + }, + "DeleteDomain": { + "methods": [ + "delete_domain" + ] + }, + "DetachTrust": { + "methods": [ + "detach_trust" + ] + }, + "GetDomain": { + "methods": [ + "get_domain" + ] + }, + "ListDomains": { + "methods": [ + "list_domains" + ] + }, + "ReconfigureTrust": { + "methods": [ + "reconfigure_trust" + ] + }, + "ResetAdminPassword": { + "methods": [ + "reset_admin_password" + ] + }, + "UpdateDomain": { + "methods": [ + "update_domain" + ] + }, + "ValidateTrust": { + "methods": [ + "validate_trust" + ] + } + } + }, + "grpc-async": { + "libraryClient": "ManagedIdentitiesServiceAsyncClient", + "rpcs": { + "AttachTrust": { + "methods": [ + "attach_trust" + ] + }, + "CreateMicrosoftAdDomain": { + "methods": [ + "create_microsoft_ad_domain" + ] + }, + "DeleteDomain": { + "methods": [ + "delete_domain" + ] + }, + "DetachTrust": { + "methods": [ + "detach_trust" + ] + }, + "GetDomain": { + "methods": [ + "get_domain" + ] + }, + "ListDomains": { + "methods": [ + "list_domains" + ] + }, + "ReconfigureTrust": { + "methods": [ + "reconfigure_trust" + ] + }, + "ResetAdminPassword": { + "methods": [ + "reset_admin_password" + ] + }, + "UpdateDomain": { + "methods": [ + "update_domain" + ] + }, + "ValidateTrust": { + "methods": [ + "validate_trust" + ] + } + } + } + } + } + } +} diff --git a/google/cloud/managedidentities_v1/services/__init__.py b/google/cloud/managedidentities_v1/services/__init__.py index 42ffdf2..4de6597 100644 --- a/google/cloud/managedidentities_v1/services/__init__.py +++ b/google/cloud/managedidentities_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/managedidentities_v1/services/managed_identities_service/__init__.py b/google/cloud/managedidentities_v1/services/managed_identities_service/__init__.py index 9f17b1f..ea59d4f 100644 --- a/google/cloud/managedidentities_v1/services/managed_identities_service/__init__.py +++ b/google/cloud/managedidentities_v1/services/managed_identities_service/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import ManagedIdentitiesServiceClient from .async_client import ManagedIdentitiesServiceAsyncClient diff --git a/google/cloud/managedidentities_v1/services/managed_identities_service/async_client.py b/google/cloud/managedidentities_v1/services/managed_identities_service/async_client.py index 55c23d0..430dec6 100644 --- a/google/cloud/managedidentities_v1/services/managed_identities_service/async_client.py +++ b/google/cloud/managedidentities_v1/services/managed_identities_service/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,10 +20,10 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation # type: ignore @@ -33,18 +31,16 @@ from google.cloud.managedidentities_v1.services.managed_identities_service import pagers from google.cloud.managedidentities_v1.types import managed_identities_service from google.cloud.managedidentities_v1.types import resource -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import ManagedIdentitiesServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import ManagedIdentitiesServiceGrpcAsyncIOTransport from .client import ManagedIdentitiesServiceClient class ManagedIdentitiesServiceAsyncClient: - """ - API Overview + """API Overview The ``managedidentites.googleapis.com`` service implements the Google Cloud Managed Identites API for identity services (e.g. @@ -88,33 +84,28 @@ class ManagedIdentitiesServiceAsyncClient: domain_path = staticmethod(ManagedIdentitiesServiceClient.domain_path) parse_domain_path = staticmethod(ManagedIdentitiesServiceClient.parse_domain_path) - common_billing_account_path = staticmethod( ManagedIdentitiesServiceClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( ManagedIdentitiesServiceClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(ManagedIdentitiesServiceClient.common_folder_path) parse_common_folder_path = staticmethod( ManagedIdentitiesServiceClient.parse_common_folder_path ) - common_organization_path = staticmethod( ManagedIdentitiesServiceClient.common_organization_path ) parse_common_organization_path = staticmethod( ManagedIdentitiesServiceClient.parse_common_organization_path ) - common_project_path = staticmethod( ManagedIdentitiesServiceClient.common_project_path ) parse_common_project_path = staticmethod( ManagedIdentitiesServiceClient.parse_common_project_path ) - common_location_path = staticmethod( ManagedIdentitiesServiceClient.common_location_path ) @@ -124,7 +115,8 @@ class ManagedIdentitiesServiceAsyncClient: @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. @@ -139,7 +131,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 @@ -156,7 +148,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> ManagedIdentitiesServiceTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: ManagedIdentitiesServiceTransport: The transport used by the client instance. @@ -171,12 +163,12 @@ def transport(self) -> ManagedIdentitiesServiceTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, ManagedIdentitiesServiceTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the managed identities service client. + """Instantiates the managed identities service client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -208,7 +200,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = ManagedIdentitiesServiceClient( credentials=credentials, transport=transport, @@ -266,7 +257,6 @@ async def create_microsoft_ad_domain( This corresponds to the ``domain`` 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. @@ -296,7 +286,6 @@ async def create_microsoft_ad_domain( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if domain_name is not None: @@ -354,7 +343,6 @@ async def reset_admin_password( This corresponds to the ``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. @@ -381,7 +369,6 @@ async def reset_admin_password( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -427,7 +414,6 @@ async def list_domains( This corresponds to the ``parent`` 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. @@ -457,7 +443,6 @@ async def list_domains( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -509,7 +494,6 @@ async def get_domain( This corresponds to the ``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. @@ -536,7 +520,6 @@ async def get_domain( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -565,7 +548,7 @@ async def update_domain( request: managed_identities_service.UpdateDomainRequest = None, *, domain: resource.Domain = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -596,7 +579,6 @@ async def update_domain( This corresponds to the ``update_mask`` 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. @@ -626,7 +608,6 @@ async def update_domain( # If we have keyword arguments corresponding to fields on the # request, apply these. - if domain is not None: request.domain = domain if update_mask is not None: @@ -684,7 +665,6 @@ async def delete_domain( This corresponds to the ``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. @@ -724,7 +704,6 @@ async def delete_domain( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -749,7 +728,7 @@ async def delete_domain( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=managed_identities_service.OpMetadata, ) @@ -785,7 +764,6 @@ async def attach_trust( This corresponds to the ``trust`` 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. @@ -815,7 +793,6 @@ async def attach_trust( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if trust is not None: @@ -890,7 +867,6 @@ async def reconfigure_trust( This corresponds to the ``target_dns_ip_addresses`` 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. @@ -920,12 +896,10 @@ async def reconfigure_trust( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if target_domain_name is not None: request.target_domain_name = target_domain_name - if target_dns_ip_addresses: request.target_dns_ip_addresses.extend(target_dns_ip_addresses) @@ -988,7 +962,6 @@ async def detach_trust( This corresponds to the ``trust`` 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. @@ -1018,7 +991,6 @@ async def detach_trust( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if trust is not None: @@ -1085,7 +1057,6 @@ async def validate_trust( This corresponds to the ``trust`` 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. @@ -1115,7 +1086,6 @@ async def validate_trust( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if trust is not None: diff --git a/google/cloud/managedidentities_v1/services/managed_identities_service/client.py b/google/cloud/managedidentities_v1/services/managed_identities_service/client.py index 44d6eb6..9925e2a 100644 --- a/google/cloud/managedidentities_v1/services/managed_identities_service/client.py +++ b/google/cloud/managedidentities_v1/services/managed_identities_service/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore @@ -37,10 +35,9 @@ from google.cloud.managedidentities_v1.services.managed_identities_service import pagers from google.cloud.managedidentities_v1.types import managed_identities_service from google.cloud.managedidentities_v1.types import resource -from google.protobuf import empty_pb2 as empty # type: ignore -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import empty_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import ManagedIdentitiesServiceTransport, DEFAULT_CLIENT_INFO from .transports.grpc import ManagedIdentitiesServiceGrpcTransport from .transports.grpc_asyncio import ManagedIdentitiesServiceGrpcAsyncIOTransport @@ -63,7 +60,7 @@ class ManagedIdentitiesServiceClientMeta(type): def get_transport_class( cls, label: str = None, ) -> Type[ManagedIdentitiesServiceTransport]: - """Return an appropriate transport class. + """Returns an appropriate transport class. Args: label: The name of the desired transport. If none is @@ -82,8 +79,7 @@ def get_transport_class( class ManagedIdentitiesServiceClient(metaclass=ManagedIdentitiesServiceClientMeta): - """ - API Overview + """API Overview The ``managedidentites.googleapis.com`` service implements the Google Cloud Managed Identites API for identity services (e.g. @@ -122,7 +118,8 @@ class ManagedIdentitiesServiceClient(metaclass=ManagedIdentitiesServiceClientMet @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: @@ -156,7 +153,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. @@ -173,7 +171,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 @@ -192,23 +190,24 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> ManagedIdentitiesServiceTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: - ManagedIdentitiesServiceTransport: The transport used by the client instance. + ManagedIdentitiesServiceTransport: The transport used by the client + instance. """ return self._transport @staticmethod def domain_path(project: str, location: str, domain: str,) -> str: - """Return a fully-qualified domain string.""" + """Returns a fully-qualified domain string.""" return "projects/{project}/locations/{location}/domains/{domain}".format( project=project, location=location, domain=domain, ) @staticmethod def parse_domain_path(path: str) -> Dict[str, str]: - """Parse a domain path into its component segments.""" + """Parses a domain path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/(?P.+?)/domains/(?P.+?)$", path, @@ -217,7 +216,7 @@ def parse_domain_path(path: str) -> Dict[str, str]: @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, ) @@ -230,7 +229,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 @@ -241,7 +240,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 @@ -252,7 +251,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 @@ -263,7 +262,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, ) @@ -277,12 +276,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, ManagedIdentitiesServiceTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the managed identities service client. + """Instantiates the managed identities service client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -337,9 +336,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: @@ -351,12 +351,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. @@ -371,8 +373,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: @@ -437,7 +439,6 @@ def create_microsoft_ad_domain( This corresponds to the ``domain`` 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. @@ -471,10 +472,8 @@ def create_microsoft_ad_domain( request, managed_identities_service.CreateMicrosoftAdDomainRequest ): request = managed_identities_service.CreateMicrosoftAdDomainRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if domain_name is not None: @@ -530,7 +529,6 @@ def reset_admin_password( This corresponds to the ``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. @@ -561,10 +559,8 @@ def reset_admin_password( request, managed_identities_service.ResetAdminPasswordRequest ): request = managed_identities_service.ResetAdminPasswordRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -606,7 +602,6 @@ def list_domains( This corresponds to the ``parent`` 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. @@ -638,10 +633,8 @@ def list_domains( # there are no flattened fields. if not isinstance(request, managed_identities_service.ListDomainsRequest): request = managed_identities_service.ListDomainsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -689,7 +682,6 @@ def get_domain( This corresponds to the ``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. @@ -718,10 +710,8 @@ def get_domain( # there are no flattened fields. if not isinstance(request, managed_identities_service.GetDomainRequest): request = managed_identities_service.GetDomainRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -746,7 +736,7 @@ def update_domain( request: managed_identities_service.UpdateDomainRequest = None, *, domain: resource.Domain = None, - update_mask: field_mask.FieldMask = None, + update_mask: field_mask_pb2.FieldMask = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -777,7 +767,6 @@ def update_domain( This corresponds to the ``update_mask`` 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. @@ -809,10 +798,8 @@ def update_domain( # there are no flattened fields. if not isinstance(request, managed_identities_service.UpdateDomainRequest): request = managed_identities_service.UpdateDomainRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if domain is not None: request.domain = domain if update_mask is not None: @@ -866,7 +853,6 @@ def delete_domain( This corresponds to the ``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. @@ -908,10 +894,8 @@ def delete_domain( # there are no flattened fields. if not isinstance(request, managed_identities_service.DeleteDomainRequest): request = managed_identities_service.DeleteDomainRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -932,7 +916,7 @@ def delete_domain( response = operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=managed_identities_service.OpMetadata, ) @@ -968,7 +952,6 @@ def attach_trust( This corresponds to the ``trust`` 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. @@ -1000,10 +983,8 @@ def attach_trust( # there are no flattened fields. if not isinstance(request, managed_identities_service.AttachTrustRequest): request = managed_identities_service.AttachTrustRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if trust is not None: @@ -1074,7 +1055,6 @@ def reconfigure_trust( This corresponds to the ``target_dns_ip_addresses`` 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. @@ -1106,10 +1086,8 @@ def reconfigure_trust( # there are no flattened fields. if not isinstance(request, managed_identities_service.ReconfigureTrustRequest): request = managed_identities_service.ReconfigureTrustRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if target_domain_name is not None: @@ -1172,7 +1150,6 @@ def detach_trust( This corresponds to the ``trust`` 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. @@ -1204,10 +1181,8 @@ def detach_trust( # there are no flattened fields. if not isinstance(request, managed_identities_service.DetachTrustRequest): request = managed_identities_service.DetachTrustRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if trust is not None: @@ -1270,7 +1245,6 @@ def validate_trust( This corresponds to the ``trust`` 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. @@ -1302,10 +1276,8 @@ def validate_trust( # there are no flattened fields. if not isinstance(request, managed_identities_service.ValidateTrustRequest): request = managed_identities_service.ValidateTrustRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name if trust is not None: diff --git a/google/cloud/managedidentities_v1/services/managed_identities_service/pagers.py b/google/cloud/managedidentities_v1/services/managed_identities_service/pagers.py index 5d5035b..9107d11 100644 --- a/google/cloud/managedidentities_v1/services/managed_identities_service/pagers.py +++ b/google/cloud/managedidentities_v1/services/managed_identities_service/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, @@ -120,7 +118,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/managedidentities_v1/services/managed_identities_service/transports/__init__.py b/google/cloud/managedidentities_v1/services/managed_identities_service/transports/__init__.py index df7f634..152cae7 100644 --- a/google/cloud/managedidentities_v1/services/managed_identities_service/transports/__init__.py +++ b/google/cloud/managedidentities_v1/services/managed_identities_service/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/managedidentities_v1/services/managed_identities_service/transports/base.py b/google/cloud/managedidentities_v1/services/managed_identities_service/transports/base.py index 62bcfd1..2879286 100644 --- a/google/cloud/managedidentities_v1/services/managed_identities_service/transports/base.py +++ b/google/cloud/managedidentities_v1/services/managed_identities_service/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,22 +13,22 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.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.cloud.managedidentities_v1.types import managed_identities_service from google.cloud.managedidentities_v1.types import resource -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( @@ -40,27 +39,41 @@ 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 + +_API_CORE_VERSION = google.api_core.__version__ + class ManagedIdentitiesServiceTransport(abc.ABC): """Abstract transport class for ManagedIdentitiesService.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "managedidentities.googleapis.com" + def __init__( self, *, - host: str = "managedidentities.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, **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 @@ -69,13 +82,13 @@ 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): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + 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. """ # Save the hostname. Default to port 443 (HTTPS) if none is specified. @@ -83,28 +96,75 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + + # Save the scopes. + self._scopes = scopes or self.AUTH_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=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=scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials - # Lifted into its own function so it can be stubbed out during tests. - self._prep_wrapped_messages(client_info) + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are 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 + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. @@ -153,20 +213,20 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_microsoft_ad_domain( self, - ) -> typing.Callable[ + ) -> Callable[ [managed_identities_service.CreateMicrosoftAdDomainRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def reset_admin_password( self, - ) -> typing.Callable[ + ) -> Callable[ [managed_identities_service.ResetAdminPasswordRequest], - typing.Union[ + Union[ managed_identities_service.ResetAdminPasswordResponse, - typing.Awaitable[managed_identities_service.ResetAdminPasswordResponse], + Awaitable[managed_identities_service.ResetAdminPasswordResponse], ], ]: raise NotImplementedError() @@ -174,11 +234,11 @@ def reset_admin_password( @property def list_domains( self, - ) -> typing.Callable[ + ) -> Callable[ [managed_identities_service.ListDomainsRequest], - typing.Union[ + Union[ managed_identities_service.ListDomainsResponse, - typing.Awaitable[managed_identities_service.ListDomainsResponse], + Awaitable[managed_identities_service.ListDomainsResponse], ], ]: raise NotImplementedError() @@ -186,63 +246,63 @@ def list_domains( @property def get_domain( self, - ) -> typing.Callable[ + ) -> Callable[ [managed_identities_service.GetDomainRequest], - typing.Union[resource.Domain, typing.Awaitable[resource.Domain]], + Union[resource.Domain, Awaitable[resource.Domain]], ]: raise NotImplementedError() @property def update_domain( self, - ) -> typing.Callable[ + ) -> Callable[ [managed_identities_service.UpdateDomainRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def delete_domain( self, - ) -> typing.Callable[ + ) -> Callable[ [managed_identities_service.DeleteDomainRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def attach_trust( self, - ) -> typing.Callable[ + ) -> Callable[ [managed_identities_service.AttachTrustRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def reconfigure_trust( self, - ) -> typing.Callable[ + ) -> Callable[ [managed_identities_service.ReconfigureTrustRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def detach_trust( self, - ) -> typing.Callable[ + ) -> Callable[ [managed_identities_service.DetachTrustRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def validate_trust( self, - ) -> typing.Callable[ + ) -> Callable[ [managed_identities_service.ValidateTrustRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() diff --git a/google/cloud/managedidentities_v1/services/managed_identities_service/transports/grpc.py b/google/cloud/managedidentities_v1/services/managed_identities_service/transports/grpc.py index 40d217c..3aa47be 100644 --- a/google/cloud/managedidentities_v1/services/managed_identities_service/transports/grpc.py +++ b/google/cloud/managedidentities_v1/services/managed_identities_service/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,23 +13,21 @@ # 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.cloud.managedidentities_v1.types import managed_identities_service from google.cloud.managedidentities_v1.types import resource -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import ManagedIdentitiesServiceTransport, DEFAULT_CLIENT_INFO @@ -87,7 +84,7 @@ def __init__( self, *, host: str = "managedidentities.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -101,7 +98,8 @@ def __init__( """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 @@ -143,7 +141,10 @@ def __init__( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ + self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client = None if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) @@ -151,70 +152,50 @@ def __init__( warnings.warn("client_cert_source is deprecated", DeprecationWarning) if channel: - # Sanity check: Ensure that channel and credentials are not both - # provided. + # Ignore credentials if a channel was passed. credentials = False - # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - elif api_mtls_endpoint: - host = ( - api_mtls_endpoint - if ":" in api_mtls_endpoint - else api_mtls_endpoint + ":443" - ) - - if credentials is None: - credentials, _ = auth.default( - scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id - ) - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - ssl_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - ssl_credentials = SslCredentials().ssl_credentials - # create a new channel. The provided one is ignored. - self._grpc_channel = type(self).create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - ssl_credentials=ssl_credentials, - scopes=scopes or self.AUTH_SCOPES, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - self._ssl_channel_credentials = ssl_credentials else: - host = host if ":" in host else host + ":443" + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials - if credentials is None: - credentials, _ = auth.default( - scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id - ) + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + ) - # create a new channel. The provided one is ignored. + if not self._grpc_channel: self._grpc_channel = type(self).create_channel( - host, - credentials=credentials, + self._host, + credentials=self._credentials, credentials_file=credentials_file, + scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, - scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, options=[ ("grpc.max_send_message_length", -1), @@ -222,24 +203,14 @@ def __init__( ], ) - self._stubs = {} # type: Dict[str, Callable] - self._operations_client = None - - # Run the base constructor. - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes or self.AUTH_SCOPES, - quota_project_id=quota_project_id, - client_info=client_info, - ) + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) @classmethod def create_channel( cls, host: str = "managedidentities.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, @@ -247,7 +218,7 @@ def create_channel( ) -> grpc.Channel: """Create and return a gRPC channel object. Args: - address (Optional[str]): The host for the channel to use. + host (Optional[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If @@ -270,13 +241,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -305,7 +278,7 @@ def create_microsoft_ad_domain( self, ) -> Callable[ [managed_identities_service.CreateMicrosoftAdDomainRequest], - operations.Operation, + operations_pb2.Operation, ]: r"""Return a callable for the create microsoft ad domain method over gRPC. @@ -325,7 +298,7 @@ def create_microsoft_ad_domain( self._stubs["create_microsoft_ad_domain"] = self.grpc_channel.unary_unary( "/google.cloud.managedidentities.v1.ManagedIdentitiesService/CreateMicrosoftAdDomain", request_serializer=managed_identities_service.CreateMicrosoftAdDomainRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_microsoft_ad_domain"] @@ -417,7 +390,7 @@ def get_domain( def update_domain( self, ) -> Callable[ - [managed_identities_service.UpdateDomainRequest], operations.Operation + [managed_identities_service.UpdateDomainRequest], operations_pb2.Operation ]: r"""Return a callable for the update domain method over gRPC. @@ -437,7 +410,7 @@ def update_domain( self._stubs["update_domain"] = self.grpc_channel.unary_unary( "/google.cloud.managedidentities.v1.ManagedIdentitiesService/UpdateDomain", request_serializer=managed_identities_service.UpdateDomainRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_domain"] @@ -445,7 +418,7 @@ def update_domain( def delete_domain( self, ) -> Callable[ - [managed_identities_service.DeleteDomainRequest], operations.Operation + [managed_identities_service.DeleteDomainRequest], operations_pb2.Operation ]: r"""Return a callable for the delete domain method over gRPC. @@ -465,7 +438,7 @@ def delete_domain( self._stubs["delete_domain"] = self.grpc_channel.unary_unary( "/google.cloud.managedidentities.v1.ManagedIdentitiesService/DeleteDomain", request_serializer=managed_identities_service.DeleteDomainRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_domain"] @@ -473,7 +446,7 @@ def delete_domain( def attach_trust( self, ) -> Callable[ - [managed_identities_service.AttachTrustRequest], operations.Operation + [managed_identities_service.AttachTrustRequest], operations_pb2.Operation ]: r"""Return a callable for the attach trust method over gRPC. @@ -493,7 +466,7 @@ def attach_trust( self._stubs["attach_trust"] = self.grpc_channel.unary_unary( "/google.cloud.managedidentities.v1.ManagedIdentitiesService/AttachTrust", request_serializer=managed_identities_service.AttachTrustRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["attach_trust"] @@ -501,7 +474,7 @@ def attach_trust( def reconfigure_trust( self, ) -> Callable[ - [managed_identities_service.ReconfigureTrustRequest], operations.Operation + [managed_identities_service.ReconfigureTrustRequest], operations_pb2.Operation ]: r"""Return a callable for the reconfigure trust method over gRPC. @@ -521,7 +494,7 @@ def reconfigure_trust( self._stubs["reconfigure_trust"] = self.grpc_channel.unary_unary( "/google.cloud.managedidentities.v1.ManagedIdentitiesService/ReconfigureTrust", request_serializer=managed_identities_service.ReconfigureTrustRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["reconfigure_trust"] @@ -529,7 +502,7 @@ def reconfigure_trust( def detach_trust( self, ) -> Callable[ - [managed_identities_service.DetachTrustRequest], operations.Operation + [managed_identities_service.DetachTrustRequest], operations_pb2.Operation ]: r"""Return a callable for the detach trust method over gRPC. @@ -549,7 +522,7 @@ def detach_trust( self._stubs["detach_trust"] = self.grpc_channel.unary_unary( "/google.cloud.managedidentities.v1.ManagedIdentitiesService/DetachTrust", request_serializer=managed_identities_service.DetachTrustRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["detach_trust"] @@ -557,7 +530,7 @@ def detach_trust( def validate_trust( self, ) -> Callable[ - [managed_identities_service.ValidateTrustRequest], operations.Operation + [managed_identities_service.ValidateTrustRequest], operations_pb2.Operation ]: r"""Return a callable for the validate trust method over gRPC. @@ -579,7 +552,7 @@ def validate_trust( self._stubs["validate_trust"] = self.grpc_channel.unary_unary( "/google.cloud.managedidentities.v1.ManagedIdentitiesService/ValidateTrust", request_serializer=managed_identities_service.ValidateTrustRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["validate_trust"] diff --git a/google/cloud/managedidentities_v1/services/managed_identities_service/transports/grpc_asyncio.py b/google/cloud/managedidentities_v1/services/managed_identities_service/transports/grpc_asyncio.py index 73544ae..cf8d5d6 100644 --- a/google/cloud/managedidentities_v1/services/managed_identities_service/transports/grpc_asyncio.py +++ b/google/cloud/managedidentities_v1/services/managed_identities_service/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,24 +13,22 @@ # 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.cloud.managedidentities_v1.types import managed_identities_service from google.cloud.managedidentities_v1.types import resource -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import ManagedIdentitiesServiceTransport, DEFAULT_CLIENT_INFO from .grpc import ManagedIdentitiesServiceGrpcTransport @@ -90,7 +87,7 @@ class ManagedIdentitiesServiceGrpcAsyncIOTransport(ManagedIdentitiesServiceTrans def create_channel( cls, host: str = "managedidentities.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, @@ -98,7 +95,7 @@ def create_channel( ) -> aio.Channel: """Create and return a gRPC AsyncIO channel object. Args: - address (Optional[str]): The host for the channel to use. + host (Optional[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If @@ -117,13 +114,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -131,7 +130,7 @@ def __init__( self, *, host: str = "managedidentities.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, @@ -145,7 +144,8 @@ def __init__( """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 @@ -188,7 +188,10 @@ def __init__( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ + self._grpc_channel = None self._ssl_channel_credentials = ssl_channel_credentials + self._stubs: Dict[str, Callable] = {} + self._operations_client = None if api_mtls_endpoint: warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning) @@ -196,70 +199,49 @@ def __init__( warnings.warn("client_cert_source is deprecated", DeprecationWarning) if channel: - # Sanity check: Ensure that channel and credentials are not both - # provided. + # Ignore credentials if a channel was passed. credentials = False - # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - elif api_mtls_endpoint: - host = ( - api_mtls_endpoint - if ":" in api_mtls_endpoint - else api_mtls_endpoint + ":443" - ) - - if credentials is None: - credentials, _ = auth.default( - scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id - ) - - # Create SSL credentials with client_cert_source or application - # default SSL credentials. - if client_cert_source: - cert, key = client_cert_source() - ssl_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) - else: - ssl_credentials = SslCredentials().ssl_credentials - - # create a new channel. The provided one is ignored. - self._grpc_channel = type(self).create_channel( - host, - credentials=credentials, - credentials_file=credentials_file, - ssl_credentials=ssl_credentials, - scopes=scopes or self.AUTH_SCOPES, - quota_project_id=quota_project_id, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - self._ssl_channel_credentials = ssl_credentials else: - host = host if ":" in host else host + ":443" + if api_mtls_endpoint: + host = api_mtls_endpoint + + # Create SSL credentials with client_cert_source or application + # default SSL credentials. + if client_cert_source: + cert, key = client_cert_source() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) + else: + self._ssl_channel_credentials = SslCredentials().ssl_credentials - if credentials is None: - credentials, _ = auth.default( - scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id - ) + else: + if client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) - if client_cert_source_for_mtls and not ssl_channel_credentials: - cert, key = client_cert_source_for_mtls() - self._ssl_channel_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) + # The base transport sets the host, credentials and scopes + super().__init__( + host=host, + credentials=credentials, + credentials_file=credentials_file, + scopes=scopes, + quota_project_id=quota_project_id, + client_info=client_info, + ) - # create a new channel. The provided one is ignored. + if not self._grpc_channel: self._grpc_channel = type(self).create_channel( - host, - credentials=credentials, + self._host, + credentials=self._credentials, credentials_file=credentials_file, + scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, - scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, options=[ ("grpc.max_send_message_length", -1), @@ -267,18 +249,8 @@ def __init__( ], ) - # Run the base constructor. - super().__init__( - host=host, - credentials=credentials, - credentials_file=credentials_file, - scopes=scopes or self.AUTH_SCOPES, - quota_project_id=quota_project_id, - client_info=client_info, - ) - - self._stubs = {} - self._operations_client = None + # Wrap messages. This must be done after self._grpc_channel exists + self._prep_wrapped_messages(client_info) @property def grpc_channel(self) -> aio.Channel: @@ -311,7 +283,7 @@ def create_microsoft_ad_domain( self, ) -> Callable[ [managed_identities_service.CreateMicrosoftAdDomainRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the create microsoft ad domain method over gRPC. @@ -331,7 +303,7 @@ def create_microsoft_ad_domain( self._stubs["create_microsoft_ad_domain"] = self.grpc_channel.unary_unary( "/google.cloud.managedidentities.v1.ManagedIdentitiesService/CreateMicrosoftAdDomain", request_serializer=managed_identities_service.CreateMicrosoftAdDomainRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_microsoft_ad_domain"] @@ -426,7 +398,7 @@ def update_domain( self, ) -> Callable[ [managed_identities_service.UpdateDomainRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the update domain method over gRPC. @@ -446,7 +418,7 @@ def update_domain( self._stubs["update_domain"] = self.grpc_channel.unary_unary( "/google.cloud.managedidentities.v1.ManagedIdentitiesService/UpdateDomain", request_serializer=managed_identities_service.UpdateDomainRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_domain"] @@ -455,7 +427,7 @@ def delete_domain( self, ) -> Callable[ [managed_identities_service.DeleteDomainRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the delete domain method over gRPC. @@ -475,7 +447,7 @@ def delete_domain( self._stubs["delete_domain"] = self.grpc_channel.unary_unary( "/google.cloud.managedidentities.v1.ManagedIdentitiesService/DeleteDomain", request_serializer=managed_identities_service.DeleteDomainRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_domain"] @@ -483,7 +455,8 @@ def delete_domain( def attach_trust( self, ) -> Callable[ - [managed_identities_service.AttachTrustRequest], Awaitable[operations.Operation] + [managed_identities_service.AttachTrustRequest], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the attach trust method over gRPC. @@ -503,7 +476,7 @@ def attach_trust( self._stubs["attach_trust"] = self.grpc_channel.unary_unary( "/google.cloud.managedidentities.v1.ManagedIdentitiesService/AttachTrust", request_serializer=managed_identities_service.AttachTrustRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["attach_trust"] @@ -512,7 +485,7 @@ def reconfigure_trust( self, ) -> Callable[ [managed_identities_service.ReconfigureTrustRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the reconfigure trust method over gRPC. @@ -532,7 +505,7 @@ def reconfigure_trust( self._stubs["reconfigure_trust"] = self.grpc_channel.unary_unary( "/google.cloud.managedidentities.v1.ManagedIdentitiesService/ReconfigureTrust", request_serializer=managed_identities_service.ReconfigureTrustRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["reconfigure_trust"] @@ -540,7 +513,8 @@ def reconfigure_trust( def detach_trust( self, ) -> Callable[ - [managed_identities_service.DetachTrustRequest], Awaitable[operations.Operation] + [managed_identities_service.DetachTrustRequest], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the detach trust method over gRPC. @@ -560,7 +534,7 @@ def detach_trust( self._stubs["detach_trust"] = self.grpc_channel.unary_unary( "/google.cloud.managedidentities.v1.ManagedIdentitiesService/DetachTrust", request_serializer=managed_identities_service.DetachTrustRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["detach_trust"] @@ -569,7 +543,7 @@ def validate_trust( self, ) -> Callable[ [managed_identities_service.ValidateTrustRequest], - Awaitable[operations.Operation], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the validate trust method over gRPC. @@ -591,7 +565,7 @@ def validate_trust( self._stubs["validate_trust"] = self.grpc_channel.unary_unary( "/google.cloud.managedidentities.v1.ManagedIdentitiesService/ValidateTrust", request_serializer=managed_identities_service.ValidateTrustRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["validate_trust"] diff --git a/google/cloud/managedidentities_v1/types/__init__.py b/google/cloud/managedidentities_v1/types/__init__.py index c2a1c1d..0ebcaff 100644 --- a/google/cloud/managedidentities_v1/types/__init__.py +++ b/google/cloud/managedidentities_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 .managed_identities_service import ( AttachTrustRequest, CreateMicrosoftAdDomainRequest, diff --git a/google/cloud/managedidentities_v1/types/managed_identities_service.py b/google/cloud/managedidentities_v1/types/managed_identities_service.py index 5673f00..c79314f 100644 --- a/google/cloud/managedidentities_v1/types/managed_identities_service.py +++ b/google/cloud/managedidentities_v1/types/managed_identities_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - from google.cloud.managedidentities_v1.types import resource -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -45,7 +42,6 @@ class OpMetadata(proto.Message): r"""Represents the metadata of the long-running operation. - Attributes: create_time (google.protobuf.timestamp_pb2.Timestamp): Output only. The time the operation was @@ -70,17 +66,12 @@ class OpMetadata(proto.Message): operation. """ - create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,) - - target = proto.Field(proto.STRING, number=3) - - verb = proto.Field(proto.STRING, number=4) - - requested_cancellation = proto.Field(proto.BOOL, number=5) - - api_version = proto.Field(proto.STRING, number=6) + create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + target = proto.Field(proto.STRING, number=3,) + verb = proto.Field(proto.STRING, number=4,) + requested_cancellation = proto.Field(proto.BOOL, number=5,) + api_version = proto.Field(proto.STRING, number=6,) class CreateMicrosoftAdDomainRequest(proto.Message): @@ -110,10 +101,8 @@ class CreateMicrosoftAdDomainRequest(proto.Message): Required. A Managed Identity domain resource. """ - parent = proto.Field(proto.STRING, number=1) - - domain_name = proto.Field(proto.STRING, number=2) - + parent = proto.Field(proto.STRING, number=1,) + domain_name = proto.Field(proto.STRING, number=2,) domain = proto.Field(proto.MESSAGE, number=3, message=resource.Domain,) @@ -127,7 +116,7 @@ class ResetAdminPasswordRequest(proto.Message): ``projects/{project_id}/locations/global/domains/{domain_name}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class ResetAdminPasswordResponse(proto.Message): @@ -141,7 +130,7 @@ class ResetAdminPasswordResponse(proto.Message): more information. """ - password = proto.Field(proto.STRING, number=1) + password = proto.Field(proto.STRING, number=1,) class ListDomainsRequest(proto.Message): @@ -172,15 +161,11 @@ class ListDomainsRequest(proto.Message): for more information. """ - parent = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=4) - - order_by = proto.Field(proto.STRING, number=5) + parent = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=4,) + order_by = proto.Field(proto.STRING, number=5,) class ListDomainsResponse(proto.Message): @@ -205,10 +190,8 @@ def raw_page(self): return self domains = proto.RepeatedField(proto.MESSAGE, number=1, message=resource.Domain,) - - next_page_token = proto.Field(proto.STRING, number=2) - - unreachable = proto.RepeatedField(proto.STRING, number=3) + next_page_token = proto.Field(proto.STRING, number=2,) + unreachable = proto.RepeatedField(proto.STRING, number=3,) class GetDomainRequest(proto.Message): @@ -221,7 +204,7 @@ class GetDomainRequest(proto.Message): ``projects/{project_id}/locations/global/domains/{domain_name}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class UpdateDomainRequest(proto.Message): @@ -243,8 +226,9 @@ class UpdateDomainRequest(proto.Message): fields specified in update_mask are updated. """ - update_mask = proto.Field(proto.MESSAGE, number=1, message=field_mask.FieldMask,) - + update_mask = proto.Field( + proto.MESSAGE, number=1, message=field_mask_pb2.FieldMask, + ) domain = proto.Field(proto.MESSAGE, number=2, message=resource.Domain,) @@ -258,7 +242,7 @@ class DeleteDomainRequest(proto.Message): ``projects/{project_id}/locations/global/domains/{domain_name}`` """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class AttachTrustRequest(proto.Message): @@ -274,8 +258,7 @@ class AttachTrustRequest(proto.Message): Required. The domain trust resource. """ - name = proto.Field(proto.STRING, number=1) - + name = proto.Field(proto.STRING, number=1,) trust = proto.Field(proto.MESSAGE, number=2, message=resource.Trust,) @@ -297,11 +280,9 @@ class ReconfigureTrustRequest(proto.Message): trust. """ - name = proto.Field(proto.STRING, number=1) - - target_domain_name = proto.Field(proto.STRING, number=2) - - target_dns_ip_addresses = proto.RepeatedField(proto.STRING, number=3) + name = proto.Field(proto.STRING, number=1,) + target_domain_name = proto.Field(proto.STRING, number=2,) + target_dns_ip_addresses = proto.RepeatedField(proto.STRING, number=3,) class DetachTrustRequest(proto.Message): @@ -318,8 +299,7 @@ class DetachTrustRequest(proto.Message): removed. """ - name = proto.Field(proto.STRING, number=1) - + name = proto.Field(proto.STRING, number=1,) trust = proto.Field(proto.MESSAGE, number=2, message=resource.Trust,) @@ -337,8 +317,7 @@ class ValidateTrustRequest(proto.Message): state for. """ - name = proto.Field(proto.STRING, number=1) - + name = proto.Field(proto.STRING, number=1,) trust = proto.Field(proto.MESSAGE, number=2, message=resource.Trust,) diff --git a/google/cloud/managedidentities_v1/types/resource.py b/google/cloud/managedidentities_v1/types/resource.py index 250f9db..338fe7c 100644 --- a/google/cloud/managedidentities_v1/types/resource.py +++ b/google/cloud/managedidentities_v1/types/resource.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -28,7 +25,6 @@ class Domain(proto.Message): r"""Represents a managed Microsoft Active Directory domain. - Attributes: name (str): Required. The unique name of the domain using the form: @@ -90,28 +86,21 @@ class State(proto.Enum): PERFORMING_MAINTENANCE = 6 UNAVAILABLE = 7 - name = proto.Field(proto.STRING, number=1) - - labels = proto.MapField(proto.STRING, proto.STRING, number=2) - - authorized_networks = proto.RepeatedField(proto.STRING, number=3) - - reserved_ip_range = proto.Field(proto.STRING, number=4) - - locations = proto.RepeatedField(proto.STRING, number=5) - - admin = proto.Field(proto.STRING, number=6) - - fqdn = proto.Field(proto.STRING, number=10) - - create_time = proto.Field(proto.MESSAGE, number=11, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=12, message=timestamp.Timestamp,) - + name = proto.Field(proto.STRING, number=1,) + labels = proto.MapField(proto.STRING, proto.STRING, number=2,) + authorized_networks = proto.RepeatedField(proto.STRING, number=3,) + reserved_ip_range = proto.Field(proto.STRING, number=4,) + locations = proto.RepeatedField(proto.STRING, number=5,) + admin = proto.Field(proto.STRING, number=6,) + fqdn = proto.Field(proto.STRING, number=10,) + create_time = proto.Field( + proto.MESSAGE, number=11, message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, number=12, message=timestamp_pb2.Timestamp, + ) state = proto.Field(proto.ENUM, number=13, enum=State,) - - status_message = proto.Field(proto.STRING, number=14) - + status_message = proto.Field(proto.STRING, number=14,) trusts = proto.RepeatedField(proto.MESSAGE, number=15, message="Trust",) @@ -185,28 +174,18 @@ class TrustDirection(proto.Enum): OUTBOUND = 2 BIDIRECTIONAL = 3 - target_domain_name = proto.Field(proto.STRING, number=1) - + target_domain_name = proto.Field(proto.STRING, number=1,) trust_type = proto.Field(proto.ENUM, number=2, enum=TrustType,) - trust_direction = proto.Field(proto.ENUM, number=3, enum=TrustDirection,) - - selective_authentication = proto.Field(proto.BOOL, number=4) - - target_dns_ip_addresses = proto.RepeatedField(proto.STRING, number=5) - - trust_handshake_secret = proto.Field(proto.STRING, number=6) - - create_time = proto.Field(proto.MESSAGE, number=7, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=8, message=timestamp.Timestamp,) - + selective_authentication = proto.Field(proto.BOOL, number=4,) + target_dns_ip_addresses = proto.RepeatedField(proto.STRING, number=5,) + trust_handshake_secret = proto.Field(proto.STRING, number=6,) + create_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) + update_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) state = proto.Field(proto.ENUM, number=9, enum=State,) - - state_description = proto.Field(proto.STRING, number=11) - + state_description = proto.Field(proto.STRING, number=11,) last_trust_heartbeat_time = proto.Field( - proto.MESSAGE, number=12, message=timestamp.Timestamp, + proto.MESSAGE, number=12, message=timestamp_pb2.Timestamp, ) diff --git a/noxfile.py b/noxfile.py index fe377cd..1d45cad 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", @@ -41,6 +44,9 @@ "docs", ] +# Error if a python version is missing +nox.options.error_on_missing_interpreters = True + @nox.session(python=DEFAULT_PYTHON_VERSION) def lint(session): @@ -56,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, @@ -81,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( @@ -114,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") @@ -138,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: @@ -170,7 +169,7 @@ def cover(session): test runs (not system test runs), and then erases coverage data. """ session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=86") + session.run("coverage", "report", "--show-missing", "--fail-under=99") session.run("coverage", "erase") @@ -202,9 +201,7 @@ 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", "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 afa05e5..fd0c14c 100644 --- a/synth.py +++ b/owlbot.py @@ -20,26 +20,15 @@ import synthtool.gcp as gcp from synthtool.languages import python -gapic = gcp.GAPICBazel() common = gcp.CommonTemplates() -versions = [ - "v1", - -] # Add new versions at the end of the list - -# ---------------------------------------------------------------------------- -# Generate managedidentities GAPIC layer -# ---------------------------------------------------------------------------- -for version in versions: - library = gapic.py_library( - service="managedidentities", - version=version, - bazel_target=f"//google/cloud/managedidentities/{version}:managedidentities-{version}-py", - ) +default_version = "v1" +for library in s.get_staging_dirs(default_version): 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 4fa9493..c048955 100644 --- a/renovate.json +++ b/renovate.json @@ -1,5 +1,9 @@ { "extends": [ "config:base", ":preserveSemverRanges" - ] + ], + "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_managedidentities_v1_keywords.py b/scripts/fixup_managedidentities_v1_keywords.py index 288b8fc..bfd6122 100644 --- a/scripts/fixup_managedidentities_v1_keywords.py +++ b/scripts/fixup_managedidentities_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,17 +39,16 @@ def partition( class managedidentitiesCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'attach_trust': ('name', 'trust', ), - 'create_microsoft_ad_domain': ('parent', 'domain_name', 'domain', ), - 'delete_domain': ('name', ), - 'detach_trust': ('name', 'trust', ), - 'get_domain': ('name', ), - 'list_domains': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), - 'reconfigure_trust': ('name', 'target_domain_name', 'target_dns_ip_addresses', ), - 'reset_admin_password': ('name', ), - 'update_domain': ('update_mask', 'domain', ), - 'validate_trust': ('name', 'trust', ), - + 'attach_trust': ('name', 'trust', ), + 'create_microsoft_ad_domain': ('parent', 'domain_name', 'domain', ), + 'delete_domain': ('name', ), + 'detach_trust': ('name', 'trust', ), + 'get_domain': ('name', ), + 'list_domains': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'reconfigure_trust': ('name', 'target_domain_name', 'target_dns_ip_addresses', ), + 'reset_admin_password': ('name', ), + 'update_domain': ('update_mask', 'domain', ), + 'validate_trust': ('name', 'trust', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: @@ -82,7 +79,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 0d9040f..2ae4f33 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ import setuptools # type: ignore name = "google-cloud-managed-identities" -version = "0.1.0" +version = "0.2.0" description = "Managed Service for Microsoft Active Directory API client library" release_status = "Development Status :: 4 - Beta" url = "https://github.com/googleapis/python-managed-identities" @@ -28,6 +28,7 @@ "google-api-core[grpc] >= 1.22.2, < 2.0.0dev", "libcst >= 0.2.5", "proto-plus >= 1.4.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..04a7850 --- /dev/null +++ b/testing/constraints-3.6.txt @@ -0,0 +1,25 @@ +# 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.22.2 +libcst==0.2.5 +proto-plus==1.4.0 +packaging==14.3 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/managedidentities_v1/__init__.py b/tests/unit/gapic/managedidentities_v1/__init__.py index 42ffdf2..4de6597 100644 --- a/tests/unit/gapic/managedidentities_v1/__init__.py +++ b/tests/unit/gapic/managedidentities_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/managedidentities_v1/test_managed_identities_service.py b/tests/unit/gapic/managedidentities_v1/test_managed_identities_service.py index 7572e1a..5547a95 100644 --- a/tests/unit/gapic/managedidentities_v1/test_managed_identities_service.py +++ b/tests/unit/gapic/managedidentities_v1/test_managed_identities_service.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,16 +23,16 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth + from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import 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.managedidentities_v1.services.managed_identities_service import ( ManagedIdentitiesServiceAsyncClient, @@ -45,12 +44,42 @@ from google.cloud.managedidentities_v1.services.managed_identities_service import ( transports, ) +from google.cloud.managedidentities_v1.services.managed_identities_service.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.managedidentities_v1.services.managed_identities_service.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.managedidentities_v1.types import managed_identities_service from google.cloud.managedidentities_v1.types import resource from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import field_mask_pb2 as field_mask # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and 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", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -103,7 +132,7 @@ def test__get_default_mtls_endpoint(): [ManagedIdentitiesServiceClient, ManagedIdentitiesServiceAsyncClient,], ) def test_managed_identities_service_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -121,7 +150,7 @@ def test_managed_identities_service_client_from_service_account_info(client_clas [ManagedIdentitiesServiceClient, ManagedIdentitiesServiceAsyncClient,], ) def test_managed_identities_service_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -180,7 +209,7 @@ def test_managed_identities_service_client_client_options( with mock.patch.object( ManagedIdentitiesServiceClient, "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() @@ -489,7 +518,7 @@ def test_create_microsoft_ad_domain( request_type=managed_identities_service.CreateMicrosoftAdDomainRequest, ): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -502,13 +531,11 @@ def test_create_microsoft_ad_domain( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_microsoft_ad_domain(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.CreateMicrosoftAdDomainRequest() # Establish that the response is the type that we expect. @@ -523,7 +550,7 @@ def test_create_microsoft_ad_domain_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 = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -533,7 +560,6 @@ def test_create_microsoft_ad_domain_empty_call(): client.create_microsoft_ad_domain() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.CreateMicrosoftAdDomainRequest() @@ -543,7 +569,7 @@ async def test_create_microsoft_ad_domain_async( request_type=managed_identities_service.CreateMicrosoftAdDomainRequest, ): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -558,13 +584,11 @@ async def test_create_microsoft_ad_domain_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_microsoft_ad_domain(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.CreateMicrosoftAdDomainRequest() # Establish that the response is the type that we expect. @@ -578,12 +602,13 @@ async def test_create_microsoft_ad_domain_async_from_dict(): def test_create_microsoft_ad_domain_field_headers(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = managed_identities_service.CreateMicrosoftAdDomainRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -591,7 +616,6 @@ def test_create_microsoft_ad_domain_field_headers(): type(client.transport.create_microsoft_ad_domain), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.create_microsoft_ad_domain(request) # Establish that the underlying gRPC stub method was called. @@ -607,12 +631,13 @@ def test_create_microsoft_ad_domain_field_headers(): @pytest.mark.asyncio async def test_create_microsoft_ad_domain_field_headers_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = managed_identities_service.CreateMicrosoftAdDomainRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -622,7 +647,6 @@ async def test_create_microsoft_ad_domain_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.create_microsoft_ad_domain(request) # Establish that the underlying gRPC stub method was called. @@ -637,7 +661,7 @@ async def test_create_microsoft_ad_domain_field_headers_async(): def test_create_microsoft_ad_domain_flattened(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -646,7 +670,6 @@ def test_create_microsoft_ad_domain_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_microsoft_ad_domain( @@ -659,17 +682,14 @@ def test_create_microsoft_ad_domain_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].domain_name == "domain_name_value" - assert args[0].domain == resource.Domain(name="name_value") def test_create_microsoft_ad_domain_flattened_error(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -686,7 +706,7 @@ def test_create_microsoft_ad_domain_flattened_error(): @pytest.mark.asyncio async def test_create_microsoft_ad_domain_flattened_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -711,18 +731,15 @@ async def test_create_microsoft_ad_domain_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].domain_name == "domain_name_value" - assert args[0].domain == resource.Domain(name="name_value") @pytest.mark.asyncio async def test_create_microsoft_ad_domain_flattened_error_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -741,7 +758,7 @@ def test_reset_admin_password( request_type=managed_identities_service.ResetAdminPasswordRequest, ): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -756,19 +773,15 @@ def test_reset_admin_password( call.return_value = managed_identities_service.ResetAdminPasswordResponse( password="password_value", ) - response = client.reset_admin_password(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.ResetAdminPasswordRequest() # Establish that the response is the type that we expect. - assert isinstance(response, managed_identities_service.ResetAdminPasswordResponse) - assert response.password == "password_value" @@ -780,7 +793,7 @@ def test_reset_admin_password_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 = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -790,7 +803,6 @@ def test_reset_admin_password_empty_call(): client.reset_admin_password() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.ResetAdminPasswordRequest() @@ -800,7 +812,7 @@ async def test_reset_admin_password_async( request_type=managed_identities_service.ResetAdminPasswordRequest, ): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -817,18 +829,15 @@ async def test_reset_admin_password_async( password="password_value", ) ) - response = await client.reset_admin_password(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.ResetAdminPasswordRequest() # Establish that the response is the type that we expect. assert isinstance(response, managed_identities_service.ResetAdminPasswordResponse) - assert response.password == "password_value" @@ -839,12 +848,13 @@ async def test_reset_admin_password_async_from_dict(): def test_reset_admin_password_field_headers(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = managed_identities_service.ResetAdminPasswordRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -852,7 +862,6 @@ def test_reset_admin_password_field_headers(): type(client.transport.reset_admin_password), "__call__" ) as call: call.return_value = managed_identities_service.ResetAdminPasswordResponse() - client.reset_admin_password(request) # Establish that the underlying gRPC stub method was called. @@ -868,12 +877,13 @@ def test_reset_admin_password_field_headers(): @pytest.mark.asyncio async def test_reset_admin_password_field_headers_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = managed_identities_service.ResetAdminPasswordRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -883,7 +893,6 @@ async def test_reset_admin_password_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( managed_identities_service.ResetAdminPasswordResponse() ) - await client.reset_admin_password(request) # Establish that the underlying gRPC stub method was called. @@ -898,7 +907,7 @@ async def test_reset_admin_password_field_headers_async(): def test_reset_admin_password_flattened(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -907,7 +916,6 @@ def test_reset_admin_password_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = managed_identities_service.ResetAdminPasswordResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.reset_admin_password(name="name_value",) @@ -916,13 +924,12 @@ def test_reset_admin_password_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_reset_admin_password_flattened_error(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -936,7 +943,7 @@ def test_reset_admin_password_flattened_error(): @pytest.mark.asyncio async def test_reset_admin_password_flattened_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -957,14 +964,13 @@ async def test_reset_admin_password_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_reset_admin_password_flattened_error_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -979,7 +985,7 @@ def test_list_domains( transport: str = "grpc", request_type=managed_identities_service.ListDomainsRequest ): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -992,21 +998,16 @@ def test_list_domains( call.return_value = managed_identities_service.ListDomainsResponse( next_page_token="next_page_token_value", unreachable=["unreachable_value"], ) - response = client.list_domains(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.ListDomainsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListDomainsPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] @@ -1018,7 +1019,7 @@ def test_list_domains_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 = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1026,7 +1027,6 @@ def test_list_domains_empty_call(): client.list_domains() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.ListDomainsRequest() @@ -1036,7 +1036,7 @@ async def test_list_domains_async( request_type=managed_identities_service.ListDomainsRequest, ): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1052,20 +1052,16 @@ async def test_list_domains_async( unreachable=["unreachable_value"], ) ) - response = await client.list_domains(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.ListDomainsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListDomainsAsyncPager) - assert response.next_page_token == "next_page_token_value" - assert response.unreachable == ["unreachable_value"] @@ -1076,18 +1072,18 @@ async def test_list_domains_async_from_dict(): def test_list_domains_field_headers(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = managed_identities_service.ListDomainsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_domains), "__call__") as call: call.return_value = managed_identities_service.ListDomainsResponse() - client.list_domains(request) # Establish that the underlying gRPC stub method was called. @@ -1103,12 +1099,13 @@ def test_list_domains_field_headers(): @pytest.mark.asyncio async def test_list_domains_field_headers_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = managed_identities_service.ListDomainsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1116,7 +1113,6 @@ async def test_list_domains_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( managed_identities_service.ListDomainsResponse() ) - await client.list_domains(request) # Establish that the underlying gRPC stub method was called. @@ -1131,14 +1127,13 @@ async def test_list_domains_field_headers_async(): def test_list_domains_flattened(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_domains), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = managed_identities_service.ListDomainsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_domains(parent="parent_value",) @@ -1147,13 +1142,12 @@ def test_list_domains_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_domains_flattened_error(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1167,7 +1161,7 @@ def test_list_domains_flattened_error(): @pytest.mark.asyncio async def test_list_domains_flattened_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1186,14 +1180,13 @@ async def test_list_domains_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" @pytest.mark.asyncio async def test_list_domains_flattened_error_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1206,7 +1199,7 @@ async def test_list_domains_flattened_error_async(): def test_list_domains_pager(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1244,7 +1237,7 @@ def test_list_domains_pager(): def test_list_domains_pages(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1274,7 +1267,7 @@ def test_list_domains_pages(): @pytest.mark.asyncio async def test_list_domains_async_pager(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1311,7 +1304,7 @@ async def test_list_domains_async_pager(): @pytest.mark.asyncio async def test_list_domains_async_pages(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1346,7 +1339,7 @@ def test_get_domain( transport: str = "grpc", request_type=managed_identities_service.GetDomainRequest ): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1366,33 +1359,22 @@ def test_get_domain( state=resource.Domain.State.CREATING, status_message="status_message_value", ) - response = client.get_domain(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.GetDomainRequest() # Establish that the response is the type that we expect. - assert isinstance(response, resource.Domain) - assert response.name == "name_value" - assert response.authorized_networks == ["authorized_networks_value"] - assert response.reserved_ip_range == "reserved_ip_range_value" - assert response.locations == ["locations_value"] - assert response.admin == "admin_value" - assert response.fqdn == "fqdn_value" - assert response.state == resource.Domain.State.CREATING - assert response.status_message == "status_message_value" @@ -1404,7 +1386,7 @@ def test_get_domain_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 = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1412,7 +1394,6 @@ def test_get_domain_empty_call(): client.get_domain() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.GetDomainRequest() @@ -1422,7 +1403,7 @@ async def test_get_domain_async( request_type=managed_identities_service.GetDomainRequest, ): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1444,32 +1425,22 @@ async def test_get_domain_async( status_message="status_message_value", ) ) - response = await client.get_domain(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.GetDomainRequest() # Establish that the response is the type that we expect. assert isinstance(response, resource.Domain) - assert response.name == "name_value" - assert response.authorized_networks == ["authorized_networks_value"] - assert response.reserved_ip_range == "reserved_ip_range_value" - assert response.locations == ["locations_value"] - assert response.admin == "admin_value" - assert response.fqdn == "fqdn_value" - assert response.state == resource.Domain.State.CREATING - assert response.status_message == "status_message_value" @@ -1480,18 +1451,18 @@ async def test_get_domain_async_from_dict(): def test_get_domain_field_headers(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = managed_identities_service.GetDomainRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_domain), "__call__") as call: call.return_value = resource.Domain() - client.get_domain(request) # Establish that the underlying gRPC stub method was called. @@ -1507,18 +1478,18 @@ def test_get_domain_field_headers(): @pytest.mark.asyncio async def test_get_domain_field_headers_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = managed_identities_service.GetDomainRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_domain), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resource.Domain()) - await client.get_domain(request) # Establish that the underlying gRPC stub method was called. @@ -1533,14 +1504,13 @@ async def test_get_domain_field_headers_async(): def test_get_domain_flattened(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_domain), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resource.Domain() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_domain(name="name_value",) @@ -1549,13 +1519,12 @@ def test_get_domain_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_domain_flattened_error(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1569,7 +1538,7 @@ def test_get_domain_flattened_error(): @pytest.mark.asyncio async def test_get_domain_flattened_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1586,14 +1555,13 @@ async def test_get_domain_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_get_domain_flattened_error_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1608,7 +1576,7 @@ def test_update_domain( transport: str = "grpc", request_type=managed_identities_service.UpdateDomainRequest ): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1619,13 +1587,11 @@ def test_update_domain( with mock.patch.object(type(client.transport.update_domain), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_domain(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.UpdateDomainRequest() # Establish that the response is the type that we expect. @@ -1640,7 +1606,7 @@ def test_update_domain_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 = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1648,7 +1614,6 @@ def test_update_domain_empty_call(): client.update_domain() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.UpdateDomainRequest() @@ -1658,7 +1623,7 @@ async def test_update_domain_async( request_type=managed_identities_service.UpdateDomainRequest, ): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1671,13 +1636,11 @@ async def test_update_domain_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.update_domain(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.UpdateDomainRequest() # Establish that the response is the type that we expect. @@ -1691,18 +1654,18 @@ async def test_update_domain_async_from_dict(): def test_update_domain_field_headers(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = managed_identities_service.UpdateDomainRequest() + request.domain.name = "domain.name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_domain), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.update_domain(request) # Establish that the underlying gRPC stub method was called. @@ -1718,12 +1681,13 @@ def test_update_domain_field_headers(): @pytest.mark.asyncio async def test_update_domain_field_headers_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = managed_identities_service.UpdateDomainRequest() + request.domain.name = "domain.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1731,7 +1695,6 @@ async def test_update_domain_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.update_domain(request) # Establish that the underlying gRPC stub method was called. @@ -1746,34 +1709,31 @@ async def test_update_domain_field_headers_async(): def test_update_domain_flattened(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_domain), "__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.update_domain( domain=resource.Domain(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_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].domain == resource.Domain(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) def test_update_domain_flattened_error(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1782,14 +1742,14 @@ def test_update_domain_flattened_error(): client.update_domain( managed_identities_service.UpdateDomainRequest(), domain=resource.Domain(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_update_domain_flattened_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1804,23 +1764,21 @@ async def test_update_domain_flattened_async(): # using the keyword arguments to the method. response = await client.update_domain( domain=resource.Domain(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_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].domain == resource.Domain(name="name_value") - - assert args[0].update_mask == field_mask.FieldMask(paths=["paths_value"]) + assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) @pytest.mark.asyncio async def test_update_domain_flattened_error_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -1829,7 +1787,7 @@ async def test_update_domain_flattened_error_async(): await client.update_domain( managed_identities_service.UpdateDomainRequest(), domain=resource.Domain(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -1837,7 +1795,7 @@ def test_delete_domain( transport: str = "grpc", request_type=managed_identities_service.DeleteDomainRequest ): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1848,13 +1806,11 @@ def test_delete_domain( with mock.patch.object(type(client.transport.delete_domain), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_domain(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.DeleteDomainRequest() # Establish that the response is the type that we expect. @@ -1869,7 +1825,7 @@ def test_delete_domain_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 = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1877,7 +1833,6 @@ def test_delete_domain_empty_call(): client.delete_domain() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.DeleteDomainRequest() @@ -1887,7 +1842,7 @@ async def test_delete_domain_async( request_type=managed_identities_service.DeleteDomainRequest, ): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1900,13 +1855,11 @@ async def test_delete_domain_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_domain(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.DeleteDomainRequest() # Establish that the response is the type that we expect. @@ -1920,18 +1873,18 @@ async def test_delete_domain_async_from_dict(): def test_delete_domain_field_headers(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = managed_identities_service.DeleteDomainRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_domain), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_domain(request) # Establish that the underlying gRPC stub method was called. @@ -1947,12 +1900,13 @@ def test_delete_domain_field_headers(): @pytest.mark.asyncio async def test_delete_domain_field_headers_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = managed_identities_service.DeleteDomainRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1960,7 +1914,6 @@ async def test_delete_domain_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_domain(request) # Establish that the underlying gRPC stub method was called. @@ -1975,14 +1928,13 @@ async def test_delete_domain_field_headers_async(): def test_delete_domain_flattened(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_domain), "__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_domain(name="name_value",) @@ -1991,13 +1943,12 @@ def test_delete_domain_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_domain_flattened_error(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2011,7 +1962,7 @@ def test_delete_domain_flattened_error(): @pytest.mark.asyncio async def test_delete_domain_flattened_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2030,14 +1981,13 @@ async def test_delete_domain_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" @pytest.mark.asyncio async def test_delete_domain_flattened_error_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2052,7 +2002,7 @@ def test_attach_trust( transport: str = "grpc", request_type=managed_identities_service.AttachTrustRequest ): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2063,13 +2013,11 @@ def test_attach_trust( with mock.patch.object(type(client.transport.attach_trust), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.attach_trust(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.AttachTrustRequest() # Establish that the response is the type that we expect. @@ -2084,7 +2032,7 @@ def test_attach_trust_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 = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2092,7 +2040,6 @@ def test_attach_trust_empty_call(): client.attach_trust() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.AttachTrustRequest() @@ -2102,7 +2049,7 @@ async def test_attach_trust_async( request_type=managed_identities_service.AttachTrustRequest, ): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2115,13 +2062,11 @@ async def test_attach_trust_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.attach_trust(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.AttachTrustRequest() # Establish that the response is the type that we expect. @@ -2135,18 +2080,18 @@ async def test_attach_trust_async_from_dict(): def test_attach_trust_field_headers(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = managed_identities_service.AttachTrustRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.attach_trust), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.attach_trust(request) # Establish that the underlying gRPC stub method was called. @@ -2162,12 +2107,13 @@ def test_attach_trust_field_headers(): @pytest.mark.asyncio async def test_attach_trust_field_headers_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = managed_identities_service.AttachTrustRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2175,7 +2121,6 @@ async def test_attach_trust_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.attach_trust(request) # Establish that the underlying gRPC stub method was called. @@ -2190,14 +2135,13 @@ async def test_attach_trust_field_headers_async(): def test_attach_trust_flattened(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.attach_trust), "__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.attach_trust( @@ -2209,9 +2153,7 @@ def test_attach_trust_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].trust == resource.Trust( target_domain_name="target_domain_name_value" ) @@ -2219,7 +2161,7 @@ def test_attach_trust_flattened(): def test_attach_trust_flattened_error(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2235,7 +2177,7 @@ def test_attach_trust_flattened_error(): @pytest.mark.asyncio async def test_attach_trust_flattened_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2257,9 +2199,7 @@ async def test_attach_trust_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].trust == resource.Trust( target_domain_name="target_domain_name_value" ) @@ -2268,7 +2208,7 @@ async def test_attach_trust_flattened_async(): @pytest.mark.asyncio async def test_attach_trust_flattened_error_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2286,7 +2226,7 @@ def test_reconfigure_trust( request_type=managed_identities_service.ReconfigureTrustRequest, ): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2299,13 +2239,11 @@ def test_reconfigure_trust( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.reconfigure_trust(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.ReconfigureTrustRequest() # Establish that the response is the type that we expect. @@ -2320,7 +2258,7 @@ def test_reconfigure_trust_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 = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2330,7 +2268,6 @@ def test_reconfigure_trust_empty_call(): client.reconfigure_trust() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.ReconfigureTrustRequest() @@ -2340,7 +2277,7 @@ async def test_reconfigure_trust_async( request_type=managed_identities_service.ReconfigureTrustRequest, ): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2355,13 +2292,11 @@ async def test_reconfigure_trust_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.reconfigure_trust(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.ReconfigureTrustRequest() # Establish that the response is the type that we expect. @@ -2375,12 +2310,13 @@ async def test_reconfigure_trust_async_from_dict(): def test_reconfigure_trust_field_headers(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = managed_identities_service.ReconfigureTrustRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2388,7 +2324,6 @@ def test_reconfigure_trust_field_headers(): type(client.transport.reconfigure_trust), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.reconfigure_trust(request) # Establish that the underlying gRPC stub method was called. @@ -2404,12 +2339,13 @@ def test_reconfigure_trust_field_headers(): @pytest.mark.asyncio async def test_reconfigure_trust_field_headers_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = managed_identities_service.ReconfigureTrustRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2419,7 +2355,6 @@ async def test_reconfigure_trust_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.reconfigure_trust(request) # Establish that the underlying gRPC stub method was called. @@ -2434,7 +2369,7 @@ async def test_reconfigure_trust_field_headers_async(): def test_reconfigure_trust_flattened(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2443,7 +2378,6 @@ def test_reconfigure_trust_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.reconfigure_trust( @@ -2456,17 +2390,14 @@ def test_reconfigure_trust_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].target_domain_name == "target_domain_name_value" - assert args[0].target_dns_ip_addresses == ["target_dns_ip_addresses_value"] def test_reconfigure_trust_flattened_error(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2483,7 +2414,7 @@ def test_reconfigure_trust_flattened_error(): @pytest.mark.asyncio async def test_reconfigure_trust_flattened_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2508,18 +2439,15 @@ async def test_reconfigure_trust_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].target_domain_name == "target_domain_name_value" - assert args[0].target_dns_ip_addresses == ["target_dns_ip_addresses_value"] @pytest.mark.asyncio async def test_reconfigure_trust_flattened_error_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2537,7 +2465,7 @@ def test_detach_trust( transport: str = "grpc", request_type=managed_identities_service.DetachTrustRequest ): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2548,13 +2476,11 @@ def test_detach_trust( with mock.patch.object(type(client.transport.detach_trust), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.detach_trust(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.DetachTrustRequest() # Establish that the response is the type that we expect. @@ -2569,7 +2495,7 @@ def test_detach_trust_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 = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2577,7 +2503,6 @@ def test_detach_trust_empty_call(): client.detach_trust() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.DetachTrustRequest() @@ -2587,7 +2512,7 @@ async def test_detach_trust_async( request_type=managed_identities_service.DetachTrustRequest, ): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2600,13 +2525,11 @@ async def test_detach_trust_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.detach_trust(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.DetachTrustRequest() # Establish that the response is the type that we expect. @@ -2620,18 +2543,18 @@ async def test_detach_trust_async_from_dict(): def test_detach_trust_field_headers(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = managed_identities_service.DetachTrustRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.detach_trust), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.detach_trust(request) # Establish that the underlying gRPC stub method was called. @@ -2647,12 +2570,13 @@ def test_detach_trust_field_headers(): @pytest.mark.asyncio async def test_detach_trust_field_headers_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = managed_identities_service.DetachTrustRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2660,7 +2584,6 @@ async def test_detach_trust_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.detach_trust(request) # Establish that the underlying gRPC stub method was called. @@ -2675,14 +2598,13 @@ async def test_detach_trust_field_headers_async(): def test_detach_trust_flattened(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.detach_trust), "__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.detach_trust( @@ -2694,9 +2616,7 @@ def test_detach_trust_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].trust == resource.Trust( target_domain_name="target_domain_name_value" ) @@ -2704,7 +2624,7 @@ def test_detach_trust_flattened(): def test_detach_trust_flattened_error(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2720,7 +2640,7 @@ def test_detach_trust_flattened_error(): @pytest.mark.asyncio async def test_detach_trust_flattened_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2742,9 +2662,7 @@ async def test_detach_trust_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].trust == resource.Trust( target_domain_name="target_domain_name_value" ) @@ -2753,7 +2671,7 @@ async def test_detach_trust_flattened_async(): @pytest.mark.asyncio async def test_detach_trust_flattened_error_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2771,7 +2689,7 @@ def test_validate_trust( request_type=managed_identities_service.ValidateTrustRequest, ): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2782,13 +2700,11 @@ def test_validate_trust( with mock.patch.object(type(client.transport.validate_trust), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.validate_trust(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.ValidateTrustRequest() # Establish that the response is the type that we expect. @@ -2803,7 +2719,7 @@ def test_validate_trust_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 = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2811,7 +2727,6 @@ def test_validate_trust_empty_call(): client.validate_trust() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.ValidateTrustRequest() @@ -2821,7 +2736,7 @@ async def test_validate_trust_async( request_type=managed_identities_service.ValidateTrustRequest, ): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2834,13 +2749,11 @@ async def test_validate_trust_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.validate_trust(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == managed_identities_service.ValidateTrustRequest() # Establish that the response is the type that we expect. @@ -2854,18 +2767,18 @@ async def test_validate_trust_async_from_dict(): def test_validate_trust_field_headers(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = managed_identities_service.ValidateTrustRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.validate_trust), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.validate_trust(request) # Establish that the underlying gRPC stub method was called. @@ -2881,12 +2794,13 @@ def test_validate_trust_field_headers(): @pytest.mark.asyncio async def test_validate_trust_field_headers_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = managed_identities_service.ValidateTrustRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2894,7 +2808,6 @@ async def test_validate_trust_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.validate_trust(request) # Establish that the underlying gRPC stub method was called. @@ -2909,14 +2822,13 @@ async def test_validate_trust_field_headers_async(): def test_validate_trust_flattened(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.validate_trust), "__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.validate_trust( @@ -2928,9 +2840,7 @@ def test_validate_trust_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].trust == resource.Trust( target_domain_name="target_domain_name_value" ) @@ -2938,7 +2848,7 @@ def test_validate_trust_flattened(): def test_validate_trust_flattened_error(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -2954,7 +2864,7 @@ def test_validate_trust_flattened_error(): @pytest.mark.asyncio async def test_validate_trust_flattened_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2976,9 +2886,7 @@ async def test_validate_trust_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].trust == resource.Trust( target_domain_name="target_domain_name_value" ) @@ -2987,7 +2895,7 @@ async def test_validate_trust_flattened_async(): @pytest.mark.asyncio async def test_validate_trust_flattened_error_async(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Attempting to call a method with both a request object and flattened @@ -3003,16 +2911,16 @@ async def test_validate_trust_flattened_error_async(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.ManagedIdentitiesServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = ManagedIdentitiesServiceClient( - 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.ManagedIdentitiesServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = ManagedIdentitiesServiceClient( @@ -3022,7 +2930,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.ManagedIdentitiesServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = ManagedIdentitiesServiceClient( @@ -3033,7 +2941,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.ManagedIdentitiesServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = ManagedIdentitiesServiceClient(transport=transport) assert client.transport is transport @@ -3042,13 +2950,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.ManagedIdentitiesServiceGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.ManagedIdentitiesServiceGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -3063,8 +2971,8 @@ 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() @@ -3072,7 +2980,7 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) assert isinstance( client.transport, transports.ManagedIdentitiesServiceGrpcTransport, @@ -3081,9 +2989,9 @@ def test_transport_grpc_default(): def test_managed_identities_service_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.ManagedIdentitiesServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -3095,7 +3003,7 @@ def test_managed_identities_service_base_transport(): ) as Transport: Transport.return_value = None transport = transports.ManagedIdentitiesServiceTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -3122,15 +3030,37 @@ def test_managed_identities_service_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_managed_identities_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.managedidentities_v1.services.managed_identities_service.transports.ManagedIdentitiesServiceTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.ManagedIdentitiesServiceTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_managed_identities_service_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.managedidentities_v1.services.managed_identities_service.transports.ManagedIdentitiesServiceTransport._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.ManagedIdentitiesServiceTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -3143,19 +3073,33 @@ def test_managed_identities_service_base_transport_with_credentials_file(): def test_managed_identities_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.managedidentities_v1.services.managed_identities_service.transports.ManagedIdentitiesServiceTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.ManagedIdentitiesServiceTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_managed_identities_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + ManagedIdentitiesServiceClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_managed_identities_service_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) ManagedIdentitiesServiceClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -3163,20 +3107,158 @@ def test_managed_identities_service_auth_adc(): ) -def test_managed_identities_service_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [ + transports.ManagedIdentitiesServiceGrpcTransport, + transports.ManagedIdentitiesServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_gte_1_25_0 +def test_managed_identities_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.ManagedIdentitiesServiceGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [ + transports.ManagedIdentitiesServiceGrpcTransport, + transports.ManagedIdentitiesServiceGrpcAsyncIOTransport, + ], +) +@requires_google_auth_lt_1_25_0 +def test_managed_identities_service_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.ManagedIdentitiesServiceGrpcTransport, grpc_helpers), + (transports.ManagedIdentitiesServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_managed_identities_service_transport_create_channel( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "managedidentities.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="managedidentities.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.ManagedIdentitiesServiceGrpcTransport, grpc_helpers), + (transports.ManagedIdentitiesServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_managed_identities_service_transport_create_channel_old_api_core( + 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") + + create_channel.assert_called_with( + "managedidentities.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.ManagedIdentitiesServiceGrpcTransport, grpc_helpers), + (transports.ManagedIdentitiesServiceGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_managed_identities_service_transport_create_channel_user_scopes( + 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( + "managedidentities.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [ @@ -3187,7 +3269,7 @@ def test_managed_identities_service_transport_auth_adc(): def test_managed_identities_service_grpc_transport_client_cert_source_for_mtls( transport_class, ): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -3226,7 +3308,7 @@ def test_managed_identities_service_grpc_transport_client_cert_source_for_mtls( def test_managed_identities_service_host_no_port(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="managedidentities.googleapis.com" ), @@ -3236,7 +3318,7 @@ def test_managed_identities_service_host_no_port(): def test_managed_identities_service_host_with_port(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="managedidentities.googleapis.com:8000" ), @@ -3292,9 +3374,9 @@ def test_managed_identities_service_transport_channel_mtls_with_client_cert_sour 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", @@ -3370,7 +3452,7 @@ def test_managed_identities_service_transport_channel_mtls_with_adc(transport_cl def test_managed_identities_service_grpc_lro_client(): client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -3383,7 +3465,7 @@ def test_managed_identities_service_grpc_lro_client(): def test_managed_identities_service_grpc_lro_async_client(): client = ManagedIdentitiesServiceAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -3398,7 +3480,6 @@ def test_domain_path(): project = "squid" location = "clam" domain = "whelk" - expected = "projects/{project}/locations/{location}/domains/{domain}".format( project=project, location=location, domain=domain, ) @@ -3421,7 +3502,6 @@ def test_parse_domain_path(): def test_common_billing_account_path(): billing_account = "cuttlefish" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -3442,7 +3522,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "winkle" - expected = "folders/{folder}".format(folder=folder,) actual = ManagedIdentitiesServiceClient.common_folder_path(folder) assert expected == actual @@ -3461,7 +3540,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "scallop" - expected = "organizations/{organization}".format(organization=organization,) actual = ManagedIdentitiesServiceClient.common_organization_path(organization) assert expected == actual @@ -3480,7 +3558,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "squid" - expected = "projects/{project}".format(project=project,) actual = ManagedIdentitiesServiceClient.common_project_path(project) assert expected == actual @@ -3500,7 +3577,6 @@ def test_parse_common_project_path(): def test_common_location_path(): project = "whelk" location = "octopus" - expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -3527,7 +3603,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.ManagedIdentitiesServiceTransport, "_prep_wrapped_messages" ) as prep: client = ManagedIdentitiesServiceClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -3536,6 +3612,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = ManagedIdentitiesServiceClient.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)