From 22f25d029657cd6171ba29c2c5a1b815074cdc4c Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 23 Mar 2021 12:43:18 -0700 Subject: [PATCH 01/27] build: migrate to flakybot (#6) Source-Author: Justin Beckwith Source-Date: Thu Jan 28 22:22:38 2021 -0800 Source-Repo: googleapis/synthtool Source-Sha: d1bb9173100f62c0cfc8f3138b62241e7f47ca6a Source-Link: https://github.com/googleapis/synthtool/commit/d1bb9173100f62c0cfc8f3138b62241e7f47ca6a --- .kokoro/test-samples.sh | 8 ++++---- .kokoro/trampoline_v2.sh | 2 +- synth.metadata | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.kokoro/test-samples.sh b/.kokoro/test-samples.sh index ba72656..41671b4 100755 --- a/.kokoro/test-samples.sh +++ b/.kokoro/test-samples.sh @@ -87,11 +87,11 @@ for file in samples/**/requirements.txt; do python3.6 -m nox -s "$RUN_TESTS_SESSION" EXIT=$? - # If this is a periodic build, send the test log to the Build Cop Bot. - # See https://github.com/googleapis/repo-automation-bots/tree/master/packages/buildcop. + # 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/buildcop - $KOKORO_GFILE_DIR/linux_amd64/buildcop + chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot + $KOKORO_GFILE_DIR/linux_amd64/flakybot fi if [[ $EXIT -ne 0 ]]; then diff --git a/.kokoro/trampoline_v2.sh b/.kokoro/trampoline_v2.sh index 719bcd5..4af6cdc 100755 --- a/.kokoro/trampoline_v2.sh +++ b/.kokoro/trampoline_v2.sh @@ -159,7 +159,7 @@ if [[ -n "${KOKORO_BUILD_ID:-}" ]]; then "KOKORO_GITHUB_COMMIT" "KOKORO_GITHUB_PULL_REQUEST_NUMBER" "KOKORO_GITHUB_PULL_REQUEST_COMMIT" - # For Build Cop Bot + # For FlakyBot "KOKORO_GITHUB_COMMIT_URL" "KOKORO_GITHUB_PULL_REQUEST_URL" ) diff --git a/synth.metadata b/synth.metadata index 62df648..abe432f 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/python-domains.git", - "sha": "dfa1750c955be72fdae1ae209ce37929e7558626" + "sha": "66354c7c458c5089b70d088a2f874da091477439" } }, { @@ -19,14 +19,14 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "778d8beae28d6d87eb01fdc839a4b4d966ed2ebe" + "sha": "d1bb9173100f62c0cfc8f3138b62241e7f47ca6a" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "778d8beae28d6d87eb01fdc839a4b4d966ed2ebe" + "sha": "d1bb9173100f62c0cfc8f3138b62241e7f47ca6a" } } ], From 302f15704bdaf4334e6b70762c59a34bd4618dbe Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 30 Mar 2021 14:18:09 -0400 Subject: [PATCH 02/27] chore: add constraints file (#10) Add constraints file to test lower bounds. See googleapis/synthtool#869. --- testing/constraints-3.10.txt | 0 testing/constraints-3.11.txt | 0 testing/constraints-3.6.txt | 23 +++++++++++++++++++++++ testing/constraints-3.7.txt | 0 testing/constraints-3.8.txt | 0 testing/constraints-3.9.txt | 0 6 files changed, 23 insertions(+) create mode 100644 testing/constraints-3.10.txt create mode 100644 testing/constraints-3.11.txt create mode 100644 testing/constraints-3.6.txt create mode 100644 testing/constraints-3.7.txt create mode 100644 testing/constraints-3.8.txt create mode 100644 testing/constraints-3.9.txt 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..650f2c5 --- /dev/null +++ b/testing/constraints-3.6.txt @@ -0,0 +1,23 @@ +# 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 +proto-plus==1.4.0 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 From df21208ba711c3841401b9bdcbbd951d0c90788f Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Thu, 1 Apr 2021 14:55:11 -0700 Subject: [PATCH 03/27] test: use constraints files to test lower bounds (#9) --- .gitignore | 4 +- .kokoro/build.sh | 10 + .kokoro/samples/python3.6/periodic-head.cfg | 11 + .kokoro/samples/python3.7/periodic-head.cfg | 11 + .kokoro/samples/python3.8/periodic-head.cfg | 11 + .kokoro/test-samples-against-head.sh | 28 ++ .kokoro/test-samples-impl.sh | 102 +++++ .kokoro/test-samples.sh | 96 +--- .pre-commit-config.yaml | 2 +- CONTRIBUTING.rst | 22 +- MANIFEST.in | 4 +- domains-v1beta1-py.tar.gz | 0 .../services/domains/async_client.py | 32 +- .../services/domains/client.py | 18 +- .../services/domains/pagers.py | 11 +- .../services/domains/transports/base.py | 18 +- .../services/domains/transports/grpc.py | 114 +++-- .../domains/transports/grpc_asyncio.py | 122 +++-- .../cloud/domains_v1beta1/types/__init__.py | 80 ++-- noxfile.py | 51 ++- renovate.json | 3 +- synth.metadata | 102 +---- synth.py | 4 +- tests/unit/gapic/domains_v1beta1/__init__.py | 15 + .../gapic/domains_v1beta1/test_domains.py | 415 ++++++++++++++---- 25 files changed, 811 insertions(+), 475 deletions(-) create mode 100644 .kokoro/samples/python3.6/periodic-head.cfg create mode 100644 .kokoro/samples/python3.7/periodic-head.cfg create mode 100644 .kokoro/samples/python3.8/periodic-head.cfg create mode 100755 .kokoro/test-samples-against-head.sh create mode 100755 .kokoro/test-samples-impl.sh create mode 100644 domains-v1beta1-py.tar.gz diff --git a/.gitignore b/.gitignore index b9daa52..b4243ce 100644 --- a/.gitignore +++ b/.gitignore @@ -50,8 +50,10 @@ docs.metadata # Virtual environment env/ + +# Test logs coverage.xml -sponge_log.xml +*sponge_log.xml # System test environment variables. system_tests/local_test_setup diff --git a/.kokoro/build.sh b/.kokoro/build.sh index e51fdf2..9138623 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -40,6 +40,16 @@ python3 -m pip uninstall --yes --quiet nox-automation python3 -m pip install --upgrade --quiet nox python3 -m nox --version +# If this is a continuous 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 = *"continuous"* ]]; then + cleanup() { + chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot + $KOKORO_GFILE_DIR/linux_amd64/flakybot + } + trap cleanup EXIT HUP +fi + # If NOX_SESSION is set, it only runs the specified session, # otherwise run all the sessions. if [[ -n "${NOX_SESSION:-}" ]]; then 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..cc301e7 --- /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-domains + +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 41671b4..cfadc47 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-domains # 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 a9024b1..32302e4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,6 +12,6 @@ repos: hooks: - id: black - repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.4 + rev: 3.9.0 hooks: - id: flake8 diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 4e73905..78eee3d 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -70,9 +70,14 @@ We use `nox `__ to instrument our tests. - To test your changes, run unit tests with ``nox``:: $ nox -s unit-2.7 - $ nox -s unit-3.7 + $ nox -s unit-3.8 $ ... +- Args to pytest can be passed through the nox command separated by a `--`. For + example, to run a single test:: + + $ nox -s unit-3.8 -- -k + .. note:: The unit tests and system tests are described in the @@ -93,8 +98,12 @@ On Debian/Ubuntu:: ************ Coding Style ************ +- We use the automatic code formatter ``black``. You can run it using + the nox session ``blacken``. This will eliminate many lint errors. Run via:: + + $ nox -s blacken -- PEP8 compliance, with exceptions defined in the linter configuration. +- PEP8 compliance is required, with exceptions defined in the linter configuration. If you have ``nox`` installed, you can test that you have not introduced any non-compliant code via:: @@ -133,13 +142,18 @@ Running System Tests - To run system tests, you can execute:: - $ nox -s system-3.7 + # Run all system tests + $ nox -s system-3.8 $ nox -s system-2.7 + # Run a single system test + $ nox -s system-3.8 -- -k + + .. note:: System tests are only configured to run under Python 2.7 and - Python 3.7. For expediency, we do not run them in older versions + Python 3.8. For expediency, we do not run them in older versions of Python 3. This alone will not run the tests. You'll need to change some local diff --git a/MANIFEST.in b/MANIFEST.in index e9e29d1..e783f4c 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -16,10 +16,10 @@ # Generated by synthtool. DO NOT EDIT! include README.rst LICENSE -recursive-include google *.json *.proto +recursive-include google *.json *.proto py.typed recursive-include tests * global-exclude *.py[co] global-exclude __pycache__ # Exclude scripts for samples readmegen -prune scripts/readme-gen \ No newline at end of file +prune scripts/readme-gen diff --git a/domains-v1beta1-py.tar.gz b/domains-v1beta1-py.tar.gz new file mode 100644 index 0000000..e69de29 diff --git a/google/cloud/domains_v1beta1/services/domains/async_client.py b/google/cloud/domains_v1beta1/services/domains/async_client.py index 779ec73..3c95c9b 100644 --- a/google/cloud/domains_v1beta1/services/domains/async_client.py +++ b/google/cloud/domains_v1beta1/services/domains/async_client.py @@ -76,8 +76,36 @@ class DomainsAsyncClient: common_location_path = staticmethod(DomainsClient.common_location_path) parse_common_location_path = staticmethod(DomainsClient.parse_common_location_path) - from_service_account_info = DomainsClient.from_service_account_info - from_service_account_file = DomainsClient.from_service_account_file + @classmethod + def from_service_account_info(cls, info: dict, *args, **kwargs): + """Creates an instance of this client using the provided credentials info. + + Args: + info (dict): The service account private key info. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + DomainsAsyncClient: The constructed client. + """ + return DomainsClient.from_service_account_info.__func__(DomainsAsyncClient, info, *args, **kwargs) # type: ignore + + @classmethod + def from_service_account_file(cls, filename: str, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + DomainsAsyncClient: The constructed client. + """ + return DomainsClient.from_service_account_file.__func__(DomainsAsyncClient, filename, *args, **kwargs) # type: ignore + from_service_account_json = from_service_account_file @property diff --git a/google/cloud/domains_v1beta1/services/domains/client.py b/google/cloud/domains_v1beta1/services/domains/client.py index 15dae56..efc3176 100644 --- a/google/cloud/domains_v1beta1/services/domains/client.py +++ b/google/cloud/domains_v1beta1/services/domains/client.py @@ -291,21 +291,17 @@ def __init__( util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) ) - ssl_credentials = None + client_cert_source_func = None is_mtls = False if use_client_cert: if client_options.client_cert_source: - import grpc # type: ignore - - cert, key = client_options.client_cert_source() - ssl_credentials = grpc.ssl_channel_credentials( - certificate_chain=cert, private_key=key - ) is_mtls = True + client_cert_source_func = client_options.client_cert_source else: - creds = SslCredentials() - is_mtls = creds.is_mtls - ssl_credentials = creds.ssl_credentials if is_mtls else None + is_mtls = mtls.has_default_client_cert_source() + client_cert_source_func = ( + mtls.default_client_cert_source() if is_mtls else None + ) # Figure out which api endpoint to use. if client_options.api_endpoint is not None: @@ -348,7 +344,7 @@ def __init__( credentials_file=client_options.credentials_file, host=api_endpoint, scopes=client_options.scopes, - ssl_channel_credentials=ssl_credentials, + client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, ) diff --git a/google/cloud/domains_v1beta1/services/domains/pagers.py b/google/cloud/domains_v1beta1/services/domains/pagers.py index 632f000..801200a 100644 --- a/google/cloud/domains_v1beta1/services/domains/pagers.py +++ b/google/cloud/domains_v1beta1/services/domains/pagers.py @@ -15,7 +15,16 @@ # limitations under the License. # -from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple +from typing import ( + Any, + AsyncIterable, + Awaitable, + Callable, + Iterable, + Sequence, + Tuple, + Optional, +) from google.cloud.domains_v1beta1.types import domains diff --git a/google/cloud/domains_v1beta1/services/domains/transports/base.py b/google/cloud/domains_v1beta1/services/domains/transports/base.py index b7e5453..3d94805 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/base.py +++ b/google/cloud/domains_v1beta1/services/domains/transports/base.py @@ -69,10 +69,10 @@ def __init__( scope (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. @@ -80,6 +80,9 @@ def __init__( host += ":443" self._host = host + # 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: @@ -89,20 +92,17 @@ def __init__( if credentials_file is not None: credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=scopes, quota_project_id=quota_project_id + credentials_file, scopes=self._scopes, quota_project_id=quota_project_id ) elif credentials is None: credentials, _ = auth.default( - scopes=scopes, quota_project_id=quota_project_id + scopes=self._scopes, 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) - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/domains_v1beta1/services/domains/transports/grpc.py b/google/cloud/domains_v1beta1/services/domains/transports/grpc.py index 2b8e2d1..260bb60 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/grpc.py +++ b/google/cloud/domains_v1beta1/services/domains/transports/grpc.py @@ -60,6 +60,7 @@ def __init__( api_mtls_endpoint: str = None, client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: @@ -90,6 +91,10 @@ def __init__( ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials for grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -104,72 +109,61 @@ 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) + if client_cert_source: + 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: - warnings.warn( - "api_mtls_endpoint and client_cert_source are deprecated", - DeprecationWarning, - ) - host = ( - api_mtls_endpoint - if ":" in api_mtls_endpoint - else api_mtls_endpoint + ":443" - ) + else: + 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 - ) - - # 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 + 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 + ) - # 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 credentials is None: - credentials, _ = auth.default( - scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id - ) + # 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, - ssl_credentials=ssl_channel_credentials, - scopes=scopes or self.AUTH_SCOPES, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, options=[ ("grpc.max_send_message_length", -1), @@ -177,18 +171,8 @@ 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( @@ -202,7 +186,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 diff --git a/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py b/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py index 72d61b7..7ef2167 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py +++ b/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py @@ -64,7 +64,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 @@ -104,6 +104,7 @@ def __init__( api_mtls_endpoint: str = None, client_cert_source: Callable[[], Tuple[bytes, bytes]] = None, ssl_channel_credentials: grpc.ChannelCredentials = None, + client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, quota_project_id=None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: @@ -135,12 +136,16 @@ def __init__( ``api_mtls_endpoint`` is None. ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials for grpc channel. It is ignored if ``channel`` is provided. + client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]): + A callback to provide client certificate bytes and private key bytes, + both in PEM format. It is used to configure mutual TLS channel. It is + ignored if ``channel`` or ``ssl_channel_credentials`` is provided. 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. Raises: @@ -149,72 +154,61 @@ 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) + if client_cert_source: + 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: - warnings.warn( - "api_mtls_endpoint and client_cert_source are deprecated", - DeprecationWarning, - ) - host = ( - api_mtls_endpoint - if ":" in api_mtls_endpoint - else api_mtls_endpoint + ":443" - ) + else: + 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 - ) - - # 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 + 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 + ) - # 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 credentials is None: - credentials, _ = auth.default( - scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id - ) + # 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, - ssl_credentials=ssl_channel_credentials, - scopes=scopes or self.AUTH_SCOPES, + scopes=self._scopes, + ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, options=[ ("grpc.max_send_message_length", -1), @@ -222,18 +216,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: diff --git a/google/cloud/domains_v1beta1/types/__init__.py b/google/cloud/domains_v1beta1/types/__init__.py index 9783007..c92ebe3 100644 --- a/google/cloud/domains_v1beta1/types/__init__.py +++ b/google/cloud/domains_v1beta1/types/__init__.py @@ -16,61 +16,61 @@ # from .domains import ( - Registration, - ManagementSettings, - DnsSettings, + AuthorizationCode, + ConfigureContactSettingsRequest, + ConfigureDnsSettingsRequest, + ConfigureManagementSettingsRequest, ContactSettings, - SearchDomainsRequest, - SearchDomainsResponse, - RetrieveRegisterParametersRequest, - RetrieveRegisterParametersResponse, - RegisterDomainRequest, + DeleteRegistrationRequest, + DnsSettings, + ExportRegistrationRequest, + GetRegistrationRequest, ListRegistrationsRequest, ListRegistrationsResponse, - GetRegistrationRequest, - UpdateRegistrationRequest, - ConfigureManagementSettingsRequest, - ConfigureDnsSettingsRequest, - ConfigureContactSettingsRequest, - ExportRegistrationRequest, - DeleteRegistrationRequest, - RetrieveAuthorizationCodeRequest, - ResetAuthorizationCodeRequest, - RegisterParameters, - AuthorizationCode, + ManagementSettings, OperationMetadata, + RegisterDomainRequest, + RegisterParameters, + Registration, + ResetAuthorizationCodeRequest, + RetrieveAuthorizationCodeRequest, + RetrieveRegisterParametersRequest, + RetrieveRegisterParametersResponse, + SearchDomainsRequest, + SearchDomainsResponse, + UpdateRegistrationRequest, + ContactNotice, ContactPrivacy, DomainNotice, - ContactNotice, TransferLockState, ) __all__ = ( - "Registration", - "ManagementSettings", - "DnsSettings", + "AuthorizationCode", + "ConfigureContactSettingsRequest", + "ConfigureDnsSettingsRequest", + "ConfigureManagementSettingsRequest", "ContactSettings", - "SearchDomainsRequest", - "SearchDomainsResponse", - "RetrieveRegisterParametersRequest", - "RetrieveRegisterParametersResponse", - "RegisterDomainRequest", + "DeleteRegistrationRequest", + "DnsSettings", + "ExportRegistrationRequest", + "GetRegistrationRequest", "ListRegistrationsRequest", "ListRegistrationsResponse", - "GetRegistrationRequest", - "UpdateRegistrationRequest", - "ConfigureManagementSettingsRequest", - "ConfigureDnsSettingsRequest", - "ConfigureContactSettingsRequest", - "ExportRegistrationRequest", - "DeleteRegistrationRequest", - "RetrieveAuthorizationCodeRequest", - "ResetAuthorizationCodeRequest", - "RegisterParameters", - "AuthorizationCode", + "ManagementSettings", "OperationMetadata", + "RegisterDomainRequest", + "RegisterParameters", + "Registration", + "ResetAuthorizationCodeRequest", + "RetrieveAuthorizationCodeRequest", + "RetrieveRegisterParametersRequest", + "RetrieveRegisterParametersResponse", + "SearchDomainsRequest", + "SearchDomainsResponse", + "UpdateRegistrationRequest", + "ContactNotice", "ContactPrivacy", "DomainNotice", - "ContactNotice", "TransferLockState", ) diff --git a/noxfile.py b/noxfile.py index 9e90799..af50a60 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): @@ -81,18 +87,21 @@ 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( "py.test", "--quiet", + f"--junitxml=unit_{session.python}_sponge_log.xml", "--cov=google/cloud", "--cov=tests/unit", "--cov-append", @@ -113,6 +122,9 @@ 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") @@ -122,6 +134,9 @@ def system(session): # Sanity check: Only run tests if the environment variable is set. if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""): session.skip("Credentials must be set via environment variable") + # Install pyopenssl for mTLS testing. + if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true": + session.install("pyopenssl") system_test_exists = os.path.exists(system_test_path) system_test_folder_exists = os.path.exists(system_test_folder_path) @@ -134,16 +149,26 @@ 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: - session.run("py.test", "--quiet", system_test_path, *session.posargs) + session.run( + "py.test", + "--quiet", + f"--junitxml=system_{session.python}_sponge_log.xml", + system_test_path, + *session.posargs, + ) if system_test_folder_exists: - session.run("py.test", "--quiet", system_test_folder_path, *session.posargs) + session.run( + "py.test", + "--quiet", + f"--junitxml=system_{session.python}_sponge_log.xml", + system_test_folder_path, + *session.posargs, + ) @nox.session(python=DEFAULT_PYTHON_VERSION) @@ -154,7 +179,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=100") + session.run("coverage", "report", "--show-missing", "--fail-under=99") session.run("coverage", "erase") @@ -186,9 +211,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/renovate.json b/renovate.json index 4fa9493..f08bc22 100644 --- a/renovate.json +++ b/renovate.json @@ -1,5 +1,6 @@ { "extends": [ "config:base", ":preserveSemverRanges" - ] + ], + "ignorePaths": [".pre-commit-config.yaml"] } diff --git a/synth.metadata b/synth.metadata index abe432f..f7e0416 100644 --- a/synth.metadata +++ b/synth.metadata @@ -3,30 +3,30 @@ { "git": { "name": ".", - "remote": "https://github.com/googleapis/python-domains.git", - "sha": "66354c7c458c5089b70d088a2f874da091477439" + "remote": "git@github.com:googleapis/python-domains", + "sha": "a895ea662de3896360f995dcb93916bfd43380d7" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "9e209af3c49d23b4169a16948165c3307abeb43a", - "internalRef": "351886920" + "sha": "915925089600094e72e4bfa8cf586c170e6b7109", + "internalRef": "366152684" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "d1bb9173100f62c0cfc8f3138b62241e7f47ca6a" + "sha": "6d76df2138f8f841e5a5b9ac427f81def520c15f" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "d1bb9173100f62c0cfc8f3138b62241e7f47ca6a" + "sha": "6d76df2138f8f841e5a5b9ac427f81def520c15f" } } ], @@ -40,95 +40,5 @@ "generator": "bazel" } } - ], - "generatedFiles": [ - ".coveragerc", - ".flake8", - ".github/CONTRIBUTING.md", - ".github/ISSUE_TEMPLATE/bug_report.md", - ".github/ISSUE_TEMPLATE/feature_request.md", - ".github/ISSUE_TEMPLATE/support_request.md", - ".github/PULL_REQUEST_TEMPLATE.md", - ".github/header-checker-lint.yml", - ".github/release-please.yml", - ".github/snippet-bot.yml", - ".gitignore", - ".kokoro/build.sh", - ".kokoro/continuous/common.cfg", - ".kokoro/continuous/continuous.cfg", - ".kokoro/docker/docs/Dockerfile", - ".kokoro/docker/docs/fetch_gpg_keys.sh", - ".kokoro/docs/common.cfg", - ".kokoro/docs/docs-presubmit.cfg", - ".kokoro/docs/docs.cfg", - ".kokoro/populate-secrets.sh", - ".kokoro/presubmit/common.cfg", - ".kokoro/presubmit/presubmit.cfg", - ".kokoro/publish-docs.sh", - ".kokoro/release.sh", - ".kokoro/release/common.cfg", - ".kokoro/release/release.cfg", - ".kokoro/samples/lint/common.cfg", - ".kokoro/samples/lint/continuous.cfg", - ".kokoro/samples/lint/periodic.cfg", - ".kokoro/samples/lint/presubmit.cfg", - ".kokoro/samples/python3.6/common.cfg", - ".kokoro/samples/python3.6/continuous.cfg", - ".kokoro/samples/python3.6/periodic.cfg", - ".kokoro/samples/python3.6/presubmit.cfg", - ".kokoro/samples/python3.7/common.cfg", - ".kokoro/samples/python3.7/continuous.cfg", - ".kokoro/samples/python3.7/periodic.cfg", - ".kokoro/samples/python3.7/presubmit.cfg", - ".kokoro/samples/python3.8/common.cfg", - ".kokoro/samples/python3.8/continuous.cfg", - ".kokoro/samples/python3.8/periodic.cfg", - ".kokoro/samples/python3.8/presubmit.cfg", - ".kokoro/test-samples.sh", - ".kokoro/trampoline.sh", - ".kokoro/trampoline_v2.sh", - ".pre-commit-config.yaml", - ".trampolinerc", - "CODE_OF_CONDUCT.md", - "CONTRIBUTING.rst", - "LICENSE", - "MANIFEST.in", - "docs/_static/custom.css", - "docs/_templates/layout.html", - "docs/conf.py", - "docs/domains_v1beta1/domains.rst", - "docs/domains_v1beta1/services.rst", - "docs/domains_v1beta1/types.rst", - "docs/multiprocessing.rst", - "google/cloud/domains/__init__.py", - "google/cloud/domains/py.typed", - "google/cloud/domains_v1beta1/__init__.py", - "google/cloud/domains_v1beta1/py.typed", - "google/cloud/domains_v1beta1/services/__init__.py", - "google/cloud/domains_v1beta1/services/domains/__init__.py", - "google/cloud/domains_v1beta1/services/domains/async_client.py", - "google/cloud/domains_v1beta1/services/domains/client.py", - "google/cloud/domains_v1beta1/services/domains/pagers.py", - "google/cloud/domains_v1beta1/services/domains/transports/__init__.py", - "google/cloud/domains_v1beta1/services/domains/transports/base.py", - "google/cloud/domains_v1beta1/services/domains/transports/grpc.py", - "google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py", - "google/cloud/domains_v1beta1/types/__init__.py", - "google/cloud/domains_v1beta1/types/domains.py", - "mypy.ini", - "noxfile.py", - "renovate.json", - "scripts/decrypt-secrets.sh", - "scripts/fixup_domains_v1beta1_keywords.py", - "scripts/readme-gen/readme_gen.py", - "scripts/readme-gen/templates/README.tmpl.rst", - "scripts/readme-gen/templates/auth.tmpl.rst", - "scripts/readme-gen/templates/auth_api_key.tmpl.rst", - "scripts/readme-gen/templates/install_deps.tmpl.rst", - "scripts/readme-gen/templates/install_portaudio.tmpl.rst", - "setup.cfg", - "testing/.gitignore", - "tests/unit/gapic/domains_v1beta1/__init__.py", - "tests/unit/gapic/domains_v1beta1/test_domains.py" ] } \ No newline at end of file diff --git a/synth.py b/synth.py index f65263a..6ffafa9 100644 --- a/synth.py +++ b/synth.py @@ -40,7 +40,7 @@ # Add templated files # ---------------------------------------------------------------------------- -templated_files = common.py_library(microgenerator=True) +templated_files = common.py_library(microgenerator=True, cov_level=99) # the microgenerator has a good coveragerc file excludes = [".coveragerc"] @@ -48,4 +48,4 @@ templated_files, excludes=excludes ) -s.shell.run(["nox", "-s", "blacken"], hide_output=False) \ No newline at end of file +s.shell.run(["nox", "-s", "blacken"], hide_output=False) diff --git a/tests/unit/gapic/domains_v1beta1/__init__.py b/tests/unit/gapic/domains_v1beta1/__init__.py index 8b13789..42ffdf2 100644 --- a/tests/unit/gapic/domains_v1beta1/__init__.py +++ b/tests/unit/gapic/domains_v1beta1/__init__.py @@ -1 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/unit/gapic/domains_v1beta1/test_domains.py b/tests/unit/gapic/domains_v1beta1/test_domains.py index 0356660..d8e036f 100644 --- a/tests/unit/gapic/domains_v1beta1/test_domains.py +++ b/tests/unit/gapic/domains_v1beta1/test_domains.py @@ -86,15 +86,17 @@ def test__get_default_mtls_endpoint(): assert DomainsClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -def test_domains_client_from_service_account_info(): +@pytest.mark.parametrize("client_class", [DomainsClient, DomainsAsyncClient,]) +def test_domains_client_from_service_account_info(client_class): creds = credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = DomainsClient.from_service_account_info(info) + client = client_class.from_service_account_info(info) assert client.transport._credentials == creds + assert isinstance(client, client_class) assert client.transport._host == "domains.googleapis.com:443" @@ -108,9 +110,11 @@ def test_domains_client_from_service_account_file(client_class): factory.return_value = creds client = client_class.from_service_account_file("dummy/file/path.json") assert client.transport._credentials == creds + assert isinstance(client, client_class) client = client_class.from_service_account_json("dummy/file/path.json") assert client.transport._credentials == creds + assert isinstance(client, client_class) assert client.transport._host == "domains.googleapis.com:443" @@ -161,7 +165,7 @@ def test_domains_client_client_options(client_class, transport_class, transport_ credentials_file=None, host="squid.clam.whelk", scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -177,7 +181,7 @@ def test_domains_client_client_options(client_class, transport_class, transport_ credentials_file=None, host=client.DEFAULT_ENDPOINT, scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -193,7 +197,7 @@ def test_domains_client_client_options(client_class, transport_class, transport_ credentials_file=None, host=client.DEFAULT_MTLS_ENDPOINT, scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -221,7 +225,7 @@ def test_domains_client_client_options(client_class, transport_class, transport_ credentials_file=None, host=client.DEFAULT_ENDPOINT, scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id="octopus", client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -268,29 +272,25 @@ def test_domains_client_mtls_env_auto( client_cert_source=client_cert_source_callback ) with mock.patch.object(transport_class, "__init__") as patched: - ssl_channel_creds = mock.Mock() - with mock.patch( - "grpc.ssl_channel_credentials", return_value=ssl_channel_creds - ): - patched.return_value = None - client = client_class(client_options=options) + patched.return_value = None + client = client_class(client_options=options) - if use_client_cert_env == "false": - expected_ssl_channel_creds = None - expected_host = client.DEFAULT_ENDPOINT - else: - expected_ssl_channel_creds = ssl_channel_creds - expected_host = client.DEFAULT_MTLS_ENDPOINT + if use_client_cert_env == "false": + expected_client_cert_source = None + expected_host = client.DEFAULT_ENDPOINT + else: + expected_client_cert_source = client_cert_source_callback + expected_host = client.DEFAULT_MTLS_ENDPOINT - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - ssl_channel_credentials=expected_ssl_channel_creds, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=expected_host, + scopes=None, + client_cert_source_for_mtls=expected_client_cert_source, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) # Check the case ADC client cert is provided. Whether client cert is used depends on # GOOGLE_API_USE_CLIENT_CERTIFICATE value. @@ -299,66 +299,53 @@ def test_domains_client_mtls_env_auto( ): with mock.patch.object(transport_class, "__init__") as patched: with mock.patch( - "google.auth.transport.grpc.SslCredentials.__init__", return_value=None + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, ): with mock.patch( - "google.auth.transport.grpc.SslCredentials.is_mtls", - new_callable=mock.PropertyMock, - ) as is_mtls_mock: - with mock.patch( - "google.auth.transport.grpc.SslCredentials.ssl_credentials", - new_callable=mock.PropertyMock, - ) as ssl_credentials_mock: - if use_client_cert_env == "false": - is_mtls_mock.return_value = False - ssl_credentials_mock.return_value = None - expected_host = client.DEFAULT_ENDPOINT - expected_ssl_channel_creds = None - else: - is_mtls_mock.return_value = True - ssl_credentials_mock.return_value = mock.Mock() - expected_host = client.DEFAULT_MTLS_ENDPOINT - expected_ssl_channel_creds = ( - ssl_credentials_mock.return_value - ) - - patched.return_value = None - client = client_class() - patched.assert_called_once_with( - credentials=None, - credentials_file=None, - host=expected_host, - scopes=None, - ssl_channel_credentials=expected_ssl_channel_creds, - quota_project_id=None, - client_info=transports.base.DEFAULT_CLIENT_INFO, - ) + "google.auth.transport.mtls.default_client_cert_source", + return_value=client_cert_source_callback, + ): + if use_client_cert_env == "false": + expected_host = client.DEFAULT_ENDPOINT + expected_client_cert_source = None + else: + expected_host = client.DEFAULT_MTLS_ENDPOINT + expected_client_cert_source = client_cert_source_callback - # Check the case client_cert_source and ADC client cert are not provided. - with mock.patch.dict( - os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} - ): - with mock.patch.object(transport_class, "__init__") as patched: - with mock.patch( - "google.auth.transport.grpc.SslCredentials.__init__", return_value=None - ): - with mock.patch( - "google.auth.transport.grpc.SslCredentials.is_mtls", - new_callable=mock.PropertyMock, - ) as is_mtls_mock: - is_mtls_mock.return_value = False patched.return_value = None client = client_class() patched.assert_called_once_with( credentials=None, credentials_file=None, - host=client.DEFAULT_ENDPOINT, + host=expected_host, scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=expected_client_cert_source, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) + # Check the case client_cert_source and ADC client cert are not provided. + with mock.patch.dict( + os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": use_client_cert_env} + ): + with mock.patch.object(transport_class, "__init__") as patched: + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + patched.return_value = None + client = client_class() + patched.assert_called_once_with( + credentials=None, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + ) + @pytest.mark.parametrize( "client_class,transport_class,transport_name", @@ -380,7 +367,7 @@ def test_domains_client_client_options_scopes( credentials_file=None, host=client.DEFAULT_ENDPOINT, scopes=["1", "2"], - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -406,7 +393,7 @@ def test_domains_client_client_options_credentials_file( credentials_file="credentials.json", host=client.DEFAULT_ENDPOINT, scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -423,7 +410,7 @@ def test_domains_client_client_options_from_dict(): credentials_file=None, host="squid.clam.whelk", scopes=None, - ssl_channel_credentials=None, + client_cert_source_for_mtls=None, quota_project_id=None, client_info=transports.base.DEFAULT_CLIENT_INFO, ) @@ -462,6 +449,22 @@ def test_search_domains_from_dict(): test_search_domains(request_type=dict) +def test_search_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 = DomainsClient( + credentials=credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.search_domains), "__call__") as call: + client.search_domains() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == domains.SearchDomainsRequest() + + @pytest.mark.asyncio async def test_search_domains_async( transport: str = "grpc_asyncio", request_type=domains.SearchDomainsRequest @@ -663,6 +666,24 @@ def test_retrieve_register_parameters_from_dict(): test_retrieve_register_parameters(request_type=dict) +def test_retrieve_register_parameters_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 = DomainsClient( + credentials=credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.retrieve_register_parameters), "__call__" + ) as call: + client.retrieve_register_parameters() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == domains.RetrieveRegisterParametersRequest() + + @pytest.mark.asyncio async def test_retrieve_register_parameters_async( transport: str = "grpc_asyncio", @@ -872,6 +893,22 @@ def test_register_domain_from_dict(): test_register_domain(request_type=dict) +def test_register_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 = DomainsClient( + credentials=credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.register_domain), "__call__") as call: + client.register_domain() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == domains.RegisterDomainRequest() + + @pytest.mark.asyncio async def test_register_domain_async( transport: str = "grpc_asyncio", request_type=domains.RegisterDomainRequest @@ -1087,6 +1124,24 @@ def test_list_registrations_from_dict(): test_list_registrations(request_type=dict) +def test_list_registrations_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 = DomainsClient( + credentials=credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_registrations), "__call__" + ) as call: + client.list_registrations() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == domains.ListRegistrationsRequest() + + @pytest.mark.asyncio async def test_list_registrations_async( transport: str = "grpc_asyncio", request_type=domains.ListRegistrationsRequest @@ -1448,6 +1503,22 @@ def test_get_registration_from_dict(): test_get_registration(request_type=dict) +def test_get_registration_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 = DomainsClient( + credentials=credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_registration), "__call__") as call: + client.get_registration() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == domains.GetRegistrationRequest() + + @pytest.mark.asyncio async def test_get_registration_async( transport: str = "grpc_asyncio", request_type=domains.GetRegistrationRequest @@ -1652,6 +1723,24 @@ def test_update_registration_from_dict(): test_update_registration(request_type=dict) +def test_update_registration_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 = DomainsClient( + credentials=credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_registration), "__call__" + ) as call: + client.update_registration() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == domains.UpdateRegistrationRequest() + + @pytest.mark.asyncio async def test_update_registration_async( transport: str = "grpc_asyncio", request_type=domains.UpdateRegistrationRequest @@ -1870,6 +1959,24 @@ def test_configure_management_settings_from_dict(): test_configure_management_settings(request_type=dict) +def test_configure_management_settings_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 = DomainsClient( + credentials=credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.configure_management_settings), "__call__" + ) as call: + client.configure_management_settings() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == domains.ConfigureManagementSettingsRequest() + + @pytest.mark.asyncio async def test_configure_management_settings_async( transport: str = "grpc_asyncio", @@ -2107,6 +2214,24 @@ def test_configure_dns_settings_from_dict(): test_configure_dns_settings(request_type=dict) +def test_configure_dns_settings_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 = DomainsClient( + credentials=credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.configure_dns_settings), "__call__" + ) as call: + client.configure_dns_settings() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == domains.ConfigureDnsSettingsRequest() + + @pytest.mark.asyncio async def test_configure_dns_settings_async( transport: str = "grpc_asyncio", request_type=domains.ConfigureDnsSettingsRequest @@ -2355,6 +2480,24 @@ def test_configure_contact_settings_from_dict(): test_configure_contact_settings(request_type=dict) +def test_configure_contact_settings_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 = DomainsClient( + credentials=credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.configure_contact_settings), "__call__" + ) as call: + client.configure_contact_settings() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == domains.ConfigureContactSettingsRequest() + + @pytest.mark.asyncio async def test_configure_contact_settings_async( transport: str = "grpc_asyncio", @@ -2592,6 +2735,24 @@ def test_export_registration_from_dict(): test_export_registration(request_type=dict) +def test_export_registration_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 = DomainsClient( + credentials=credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.export_registration), "__call__" + ) as call: + client.export_registration() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == domains.ExportRegistrationRequest() + + @pytest.mark.asyncio async def test_export_registration_async( transport: str = "grpc_asyncio", request_type=domains.ExportRegistrationRequest @@ -2790,6 +2951,24 @@ def test_delete_registration_from_dict(): test_delete_registration(request_type=dict) +def test_delete_registration_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 = DomainsClient( + credentials=credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_registration), "__call__" + ) as call: + client.delete_registration() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == domains.DeleteRegistrationRequest() + + @pytest.mark.asyncio async def test_delete_registration_async( transport: str = "grpc_asyncio", request_type=domains.DeleteRegistrationRequest @@ -2991,6 +3170,24 @@ def test_retrieve_authorization_code_from_dict(): test_retrieve_authorization_code(request_type=dict) +def test_retrieve_authorization_code_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 = DomainsClient( + credentials=credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.retrieve_authorization_code), "__call__" + ) as call: + client.retrieve_authorization_code() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == domains.RetrieveAuthorizationCodeRequest() + + @pytest.mark.asyncio async def test_retrieve_authorization_code_async( transport: str = "grpc_asyncio", @@ -3203,6 +3400,24 @@ def test_reset_authorization_code_from_dict(): test_reset_authorization_code(request_type=dict) +def test_reset_authorization_code_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 = DomainsClient( + credentials=credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.reset_authorization_code), "__call__" + ) as call: + client.reset_authorization_code() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == domains.ResetAuthorizationCodeRequest() + + @pytest.mark.asyncio async def test_reset_authorization_code_async( transport: str = "grpc_asyncio", request_type=domains.ResetAuthorizationCodeRequest @@ -3548,6 +3763,48 @@ def test_domains_transport_auth_adc(): ) +@pytest.mark.parametrize( + "transport_class", + [transports.DomainsGrpcTransport, transports.DomainsGrpcAsyncIOTransport], +) +def test_domains_grpc_transport_client_cert_source_for_mtls(transport_class): + cred = credentials.AnonymousCredentials() + + # Check ssl_channel_credentials is used if provided. + with mock.patch.object(transport_class, "create_channel") as mock_create_channel: + mock_ssl_channel_creds = mock.Mock() + transport_class( + host="squid.clam.whelk", + credentials=cred, + ssl_channel_credentials=mock_ssl_channel_creds, + ) + mock_create_channel.assert_called_once_with( + "squid.clam.whelk:443", + credentials=cred, + credentials_file=None, + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=mock_ssl_channel_creds, + quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + # Check if ssl_channel_credentials is not provided, then client_cert_source_for_mtls + # is used. + with mock.patch.object(transport_class, "create_channel", return_value=mock.Mock()): + with mock.patch("grpc.ssl_channel_credentials") as mock_ssl_cred: + transport_class( + credentials=cred, + client_cert_source_for_mtls=client_cert_source_callback, + ) + expected_cert, expected_key = client_cert_source_callback() + mock_ssl_cred.assert_called_once_with( + certificate_chain=expected_cert, private_key=expected_key + ) + + def test_domains_host_no_port(): client = DomainsClient( credentials=credentials.AnonymousCredentials(), @@ -3592,6 +3849,8 @@ def test_domains_grpc_asyncio_transport_channel(): assert transport._ssl_channel_credentials == None +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. @pytest.mark.parametrize( "transport_class", [transports.DomainsGrpcTransport, transports.DomainsGrpcAsyncIOTransport], @@ -3639,6 +3898,8 @@ def test_domains_transport_channel_mtls_with_client_cert_source(transport_class) assert transport._ssl_channel_credentials == mock_ssl_cred +# Remove this test when deprecated arguments (api_mtls_endpoint, client_cert_source) are +# removed from grpc/grpc_asyncio transport constructor. @pytest.mark.parametrize( "transport_class", [transports.DomainsGrpcTransport, transports.DomainsGrpcAsyncIOTransport], From dfff7b13db58790a96126e4738f27a461ef9162d Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 2 Apr 2021 07:59:10 -0700 Subject: [PATCH 04/27] chore: start tracking obsolete files (#11) --- synth.metadata | 107 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 101 insertions(+), 6 deletions(-) diff --git a/synth.metadata b/synth.metadata index f7e0416..64246e0 100644 --- a/synth.metadata +++ b/synth.metadata @@ -3,30 +3,30 @@ { "git": { "name": ".", - "remote": "git@github.com:googleapis/python-domains", - "sha": "a895ea662de3896360f995dcb93916bfd43380d7" + "remote": "https://github.com/googleapis/python-domains.git", + "sha": "df21208ba711c3841401b9bdcbbd951d0c90788f" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "915925089600094e72e4bfa8cf586c170e6b7109", - "internalRef": "366152684" + "sha": "56fc6d43fed71188d7e18f3ca003544646c4ab35", + "internalRef": "366346972" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "6d76df2138f8f841e5a5b9ac427f81def520c15f" + "sha": "ff39353f34a36e7643b86e97724e4027ab466dc6" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "6d76df2138f8f841e5a5b9ac427f81def520c15f" + "sha": "ff39353f34a36e7643b86e97724e4027ab466dc6" } } ], @@ -40,5 +40,100 @@ "generator": "bazel" } } + ], + "generatedFiles": [ + ".coveragerc", + ".flake8", + ".github/CONTRIBUTING.md", + ".github/ISSUE_TEMPLATE/bug_report.md", + ".github/ISSUE_TEMPLATE/feature_request.md", + ".github/ISSUE_TEMPLATE/support_request.md", + ".github/PULL_REQUEST_TEMPLATE.md", + ".github/header-checker-lint.yml", + ".github/release-please.yml", + ".github/snippet-bot.yml", + ".gitignore", + ".kokoro/build.sh", + ".kokoro/continuous/common.cfg", + ".kokoro/continuous/continuous.cfg", + ".kokoro/docker/docs/Dockerfile", + ".kokoro/docker/docs/fetch_gpg_keys.sh", + ".kokoro/docs/common.cfg", + ".kokoro/docs/docs-presubmit.cfg", + ".kokoro/docs/docs.cfg", + ".kokoro/populate-secrets.sh", + ".kokoro/presubmit/common.cfg", + ".kokoro/presubmit/presubmit.cfg", + ".kokoro/publish-docs.sh", + ".kokoro/release.sh", + ".kokoro/release/common.cfg", + ".kokoro/release/release.cfg", + ".kokoro/samples/lint/common.cfg", + ".kokoro/samples/lint/continuous.cfg", + ".kokoro/samples/lint/periodic.cfg", + ".kokoro/samples/lint/presubmit.cfg", + ".kokoro/samples/python3.6/common.cfg", + ".kokoro/samples/python3.6/continuous.cfg", + ".kokoro/samples/python3.6/periodic-head.cfg", + ".kokoro/samples/python3.6/periodic.cfg", + ".kokoro/samples/python3.6/presubmit.cfg", + ".kokoro/samples/python3.7/common.cfg", + ".kokoro/samples/python3.7/continuous.cfg", + ".kokoro/samples/python3.7/periodic-head.cfg", + ".kokoro/samples/python3.7/periodic.cfg", + ".kokoro/samples/python3.7/presubmit.cfg", + ".kokoro/samples/python3.8/common.cfg", + ".kokoro/samples/python3.8/continuous.cfg", + ".kokoro/samples/python3.8/periodic-head.cfg", + ".kokoro/samples/python3.8/periodic.cfg", + ".kokoro/samples/python3.8/presubmit.cfg", + ".kokoro/test-samples-against-head.sh", + ".kokoro/test-samples-impl.sh", + ".kokoro/test-samples.sh", + ".kokoro/trampoline.sh", + ".kokoro/trampoline_v2.sh", + ".pre-commit-config.yaml", + ".trampolinerc", + "CODE_OF_CONDUCT.md", + "CONTRIBUTING.rst", + "LICENSE", + "MANIFEST.in", + "docs/_static/custom.css", + "docs/_templates/layout.html", + "docs/conf.py", + "docs/domains_v1beta1/domains.rst", + "docs/domains_v1beta1/services.rst", + "docs/domains_v1beta1/types.rst", + "docs/multiprocessing.rst", + "google/cloud/domains/__init__.py", + "google/cloud/domains/py.typed", + "google/cloud/domains_v1beta1/__init__.py", + "google/cloud/domains_v1beta1/py.typed", + "google/cloud/domains_v1beta1/services/__init__.py", + "google/cloud/domains_v1beta1/services/domains/__init__.py", + "google/cloud/domains_v1beta1/services/domains/async_client.py", + "google/cloud/domains_v1beta1/services/domains/client.py", + "google/cloud/domains_v1beta1/services/domains/pagers.py", + "google/cloud/domains_v1beta1/services/domains/transports/__init__.py", + "google/cloud/domains_v1beta1/services/domains/transports/base.py", + "google/cloud/domains_v1beta1/services/domains/transports/grpc.py", + "google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py", + "google/cloud/domains_v1beta1/types/__init__.py", + "google/cloud/domains_v1beta1/types/domains.py", + "mypy.ini", + "noxfile.py", + "renovate.json", + "scripts/decrypt-secrets.sh", + "scripts/fixup_domains_v1beta1_keywords.py", + "scripts/readme-gen/readme_gen.py", + "scripts/readme-gen/templates/README.tmpl.rst", + "scripts/readme-gen/templates/auth.tmpl.rst", + "scripts/readme-gen/templates/auth_api_key.tmpl.rst", + "scripts/readme-gen/templates/install_deps.tmpl.rst", + "scripts/readme-gen/templates/install_portaudio.tmpl.rst", + "setup.cfg", + "testing/.gitignore", + "tests/unit/gapic/domains_v1beta1/__init__.py", + "tests/unit/gapic/domains_v1beta1/test_domains.py" ] } \ No newline at end of file From c3a9cdb0cf1c5337145051e6bdcc937a16f3c3ec Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 7 Apr 2021 08:59:45 -0700 Subject: [PATCH 05/27] chore: Add license headers for python config files (#12) Source-Author: Anthonios Partheniou Source-Date: Tue Apr 6 11:32:03 2021 -0400 Source-Repo: googleapis/synthtool Source-Sha: 5b5bf6d519b2d658d9f2e483d9f6f3d0ba8ee6bc Source-Link: https://github.com/googleapis/synthtool/commit/5b5bf6d519b2d658d9f2e483d9f6f3d0ba8ee6bc --- .pre-commit-config.yaml | 14 ++++++++++++++ docs/conf.py | 13 +++++++++++++ synth.metadata | 6 +++--- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 32302e4..8912e9b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,17 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks repos: diff --git a/docs/conf.py b/docs/conf.py index 3bffd97..5c31a89 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,17 @@ # -*- coding: utf-8 -*- +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # # google-cloud-domains documentation build configuration file # diff --git a/synth.metadata b/synth.metadata index 64246e0..fffcd59 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/python-domains.git", - "sha": "df21208ba711c3841401b9bdcbbd951d0c90788f" + "sha": "dfff7b13db58790a96126e4738f27a461ef9162d" } }, { @@ -19,14 +19,14 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "ff39353f34a36e7643b86e97724e4027ab466dc6" + "sha": "5b5bf6d519b2d658d9f2e483d9f6f3d0ba8ee6bc" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "ff39353f34a36e7643b86e97724e4027ab466dc6" + "sha": "5b5bf6d519b2d658d9f2e483d9f6f3d0ba8ee6bc" } } ], From fbb632ce56f70f3a88d2bca451a1882e48466f96 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Sun, 11 Apr 2021 05:34:31 -0700 Subject: [PATCH 06/27] chore: add constraints file check for python samples (#13) This is the sibling PR to https://github.com/GoogleCloudPlatform/python-docs-samples/pull/5611 and this is the issue opened for it https://github.com/GoogleCloudPlatform/python-docs-samples/issues/5549 --- .github/header-checker-lint.yml | 2 +- renovate.json | 5 ++++- synth.metadata | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) 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/renovate.json b/renovate.json index f08bc22..c048955 100644 --- a/renovate.json +++ b/renovate.json @@ -2,5 +2,8 @@ "extends": [ "config:base", ":preserveSemverRanges" ], - "ignorePaths": [".pre-commit-config.yaml"] + "ignorePaths": [".pre-commit-config.yaml"], + "pip_requirements": { + "fileMatch": ["requirements-test.txt", "samples/[\\S/]*constraints.txt", "samples/[\\S/]*constraints-test.txt"] + } } diff --git a/synth.metadata b/synth.metadata index fffcd59..5d83b5e 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/python-domains.git", - "sha": "dfff7b13db58790a96126e4738f27a461ef9162d" + "sha": "c3a9cdb0cf1c5337145051e6bdcc937a16f3c3ec" } }, { @@ -19,14 +19,14 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "5b5bf6d519b2d658d9f2e483d9f6f3d0ba8ee6bc" + "sha": "0a071b3460344886297a304253bf924aa68ddb7e" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "5b5bf6d519b2d658d9f2e483d9f6f3d0ba8ee6bc" + "sha": "0a071b3460344886297a304253bf924aa68ddb7e" } } ], From d54436ad1f5781a44acbc59d4fec1fa3913c43f9 Mon Sep 17 00:00:00 2001 From: Dan Lee <71398022+dandhlee@users.noreply.github.com> Date: Fri, 16 Apr 2021 19:11:50 -0400 Subject: [PATCH 07/27] chore: prevent normalization of semver versioning (#15) * chore: prevent normalization of semver versioning * chore: update workaround to make sic work --- setup.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d9144a6..6077637 100644 --- a/setup.py +++ b/setup.py @@ -19,6 +19,21 @@ import os import setuptools # type: ignore +# Disable version normalization performed by setuptools.setup() +try: + # Try the approach of using sic(), added in setuptools 46.1.0 + from setuptools import sic +except ImportError: + # Try the approach of replacing packaging.version.Version + sic = lambda v: v + try: + # setuptools >=39.0.0 uses packaging from setuptools.extern + from setuptools.extern import packaging + except ImportError: + # setuptools <39.0.0 uses packaging from pkg_resources.extern + from pkg_resources.extern import packaging + packaging.version.Version = packaging.version.LegacyVersion + version = "0.1.0" package_root = os.path.abspath(os.path.dirname(__file__)) @@ -30,7 +45,7 @@ setuptools.setup( name="google-cloud-domains", - version=version, + version=sic(version), long_description=readme, author="Google LLC", author_email="googleapis-packages@google.com", From 37e1f0c7a96926b896b4fd4033943195b3055c81 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 16 Apr 2021 16:26:05 -0700 Subject: [PATCH 08/27] chore: update templates (#14) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/1bcc7a13-7747-4631-a508-b8f27b121a16/targets - [ ] To automatically regenerate this PR, check this box. (May take up to 24 hours.) Source-Link: https://github.com/googleapis/synthtool/commit/043cc620d6a6111816d9e09f2a97208565fde958 Source-Link: https://github.com/googleapis/synthtool/commit/721339ab60a6eb63b889978b3d9b295dcb3be370 --- .kokoro/release.sh | 4 ++-- .kokoro/release/common.cfg | 14 ++------------ docs/_static/custom.css | 13 ++++++++++++- synth.metadata | 6 +++--- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.kokoro/release.sh b/.kokoro/release.sh index 58438bc..eba1dd4 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-domains 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 da0937b..5b7ea2b 100644 --- a/.kokoro/release/common.cfg +++ b/.kokoro/release/common.cfg @@ -23,18 +23,8 @@ env_vars: { value: "github/python-domains/.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/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/synth.metadata b/synth.metadata index 5d83b5e..817eada 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/python-domains.git", - "sha": "c3a9cdb0cf1c5337145051e6bdcc937a16f3c3ec" + "sha": "fbb632ce56f70f3a88d2bca451a1882e48466f96" } }, { @@ -19,14 +19,14 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "0a071b3460344886297a304253bf924aa68ddb7e" + "sha": "043cc620d6a6111816d9e09f2a97208565fde958" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "0a071b3460344886297a304253bf924aa68ddb7e" + "sha": "043cc620d6a6111816d9e09f2a97208565fde958" } } ], From 19a8b1dec4b44e066c760f4f4b1f45bde27e8fb4 Mon Sep 17 00:00:00 2001 From: Dan Lee <71398022+dandhlee@users.noreply.github.com> Date: Mon, 26 Apr 2021 21:00:32 -0400 Subject: [PATCH 09/27] chore(revert): revert preventing normalization (#16) reverts previous commit for preventing normalization of versioning --- setup.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/setup.py b/setup.py index 6077637..d9144a6 100644 --- a/setup.py +++ b/setup.py @@ -19,21 +19,6 @@ import os import setuptools # type: ignore -# Disable version normalization performed by setuptools.setup() -try: - # Try the approach of using sic(), added in setuptools 46.1.0 - from setuptools import sic -except ImportError: - # Try the approach of replacing packaging.version.Version - sic = lambda v: v - try: - # setuptools >=39.0.0 uses packaging from setuptools.extern - from setuptools.extern import packaging - except ImportError: - # setuptools <39.0.0 uses packaging from pkg_resources.extern - from pkg_resources.extern import packaging - packaging.version.Version = packaging.version.LegacyVersion - version = "0.1.0" package_root = os.path.abspath(os.path.dirname(__file__)) @@ -45,7 +30,7 @@ setuptools.setup( name="google-cloud-domains", - version=sic(version), + version=version, long_description=readme, author="Google LLC", author_email="googleapis-packages@google.com", From f7d8105db77f48ebdd55762b6408a23e391f1f76 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Wed, 12 May 2021 11:49:43 -0400 Subject: [PATCH 10/27] chore: migrate to owl bot (#22) * chore: migrate to owl bot * chore: copy files from googleapis-gen 6a5da3f1274b088752f074da5bc9e30bd1beb27e * chore: run the post processor --- .github/.OwlBot.lock.yaml | 4 ++ .github/.OwlBot.yaml | 29 ++++++++ .pre-commit-config.yaml | 2 +- CONTRIBUTING.rst | 16 +---- noxfile.py | 14 +--- synth.py => owlbot.py | 15 ++-- synth.metadata | 139 -------------------------------------- 7 files changed, 41 insertions(+), 178 deletions(-) create mode 100644 .github/.OwlBot.lock.yaml create mode 100644 .github/.OwlBot.yaml rename synth.py => owlbot.py (74%) delete mode 100644 synth.metadata diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml new file mode 100644 index 0000000..d49860b --- /dev/null +++ b/.github/.OwlBot.lock.yaml @@ -0,0 +1,4 @@ +docker: + digest: sha256:457583330eec64daa02aeb7a72a04d33e7be2428f646671ce4045dcbc0191b1e + image: gcr.io/repo-automation-bots/owlbot-python:latest + diff --git a/.github/.OwlBot.yaml b/.github/.OwlBot.yaml new file mode 100644 index 0000000..a06f900 --- /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/v1alpha2 + +deep-copy-regex: + - source: /google/cloud/domains/(v.*)/.*-py/(.*) + dest: /owl-bot-staging/$1/$2 + +begin-after-commit-hash: 6a5da3f1274b088752f074da5bc9e30bd1beb27e + diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8912e9b..1bbd787 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.9.0 + rev: 3.9.1 hooks: - id: flake8 diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 78eee3d..5047131 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/noxfile.py b/noxfile.py index af50a60..1d45cad 100644 --- a/noxfile.py +++ b/noxfile.py @@ -62,16 +62,9 @@ def lint(session): session.run("flake8", "google", "tests") -@nox.session(python="3.6") +@nox.session(python=DEFAULT_PYTHON_VERSION) def blacken(session): - """Run black. - - Format code to uniform standard. - - This currently uses Python 3.6 due to the automated Kokoro run of synthtool. - That run uses an image that doesn't have 3.6 installed. Before updating this - check the state of the `gcp_ubuntu_config` we use for that Kokoro run. - """ + """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) session.run( "black", *BLACK_PATHS, @@ -131,9 +124,6 @@ def system(session): # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true. if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false": session.skip("RUN_SYSTEM_TESTS is set to false, skipping") - # Sanity check: Only run tests if the environment variable is set. - if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""): - session.skip("Credentials must be set via environment variable") # Install pyopenssl for mTLS testing. if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true": session.install("pyopenssl") diff --git a/synth.py b/owlbot.py similarity index 74% rename from synth.py rename to owlbot.py index 6ffafa9..950db31 100644 --- a/synth.py +++ b/owlbot.py @@ -20,22 +20,15 @@ import synthtool.gcp as gcp from synthtool.languages import python -gapic = gcp.GAPICBazel() common = gcp.CommonTemplates() -# ---------------------------------------------------------------------------- -# Generate domains GAPIC layer -# ---------------------------------------------------------------------------- -versions = ["v1beta1"] -for version in versions: - library = gapic.py_library( - service="domains", - version=version, - bazel_target=f"//google/cloud/domains/{version}:domains-{version}-py", - ) +default_version = "v1beta1" +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/synth.metadata b/synth.metadata deleted file mode 100644 index 817eada..0000000 --- a/synth.metadata +++ /dev/null @@ -1,139 +0,0 @@ -{ - "sources": [ - { - "git": { - "name": ".", - "remote": "https://github.com/googleapis/python-domains.git", - "sha": "fbb632ce56f70f3a88d2bca451a1882e48466f96" - } - }, - { - "git": { - "name": "googleapis", - "remote": "https://github.com/googleapis/googleapis.git", - "sha": "56fc6d43fed71188d7e18f3ca003544646c4ab35", - "internalRef": "366346972" - } - }, - { - "git": { - "name": "synthtool", - "remote": "https://github.com/googleapis/synthtool.git", - "sha": "043cc620d6a6111816d9e09f2a97208565fde958" - } - }, - { - "git": { - "name": "synthtool", - "remote": "https://github.com/googleapis/synthtool.git", - "sha": "043cc620d6a6111816d9e09f2a97208565fde958" - } - } - ], - "destinations": [ - { - "client": { - "source": "googleapis", - "apiName": "domains", - "apiVersion": "v1beta1", - "language": "python", - "generator": "bazel" - } - } - ], - "generatedFiles": [ - ".coveragerc", - ".flake8", - ".github/CONTRIBUTING.md", - ".github/ISSUE_TEMPLATE/bug_report.md", - ".github/ISSUE_TEMPLATE/feature_request.md", - ".github/ISSUE_TEMPLATE/support_request.md", - ".github/PULL_REQUEST_TEMPLATE.md", - ".github/header-checker-lint.yml", - ".github/release-please.yml", - ".github/snippet-bot.yml", - ".gitignore", - ".kokoro/build.sh", - ".kokoro/continuous/common.cfg", - ".kokoro/continuous/continuous.cfg", - ".kokoro/docker/docs/Dockerfile", - ".kokoro/docker/docs/fetch_gpg_keys.sh", - ".kokoro/docs/common.cfg", - ".kokoro/docs/docs-presubmit.cfg", - ".kokoro/docs/docs.cfg", - ".kokoro/populate-secrets.sh", - ".kokoro/presubmit/common.cfg", - ".kokoro/presubmit/presubmit.cfg", - ".kokoro/publish-docs.sh", - ".kokoro/release.sh", - ".kokoro/release/common.cfg", - ".kokoro/release/release.cfg", - ".kokoro/samples/lint/common.cfg", - ".kokoro/samples/lint/continuous.cfg", - ".kokoro/samples/lint/periodic.cfg", - ".kokoro/samples/lint/presubmit.cfg", - ".kokoro/samples/python3.6/common.cfg", - ".kokoro/samples/python3.6/continuous.cfg", - ".kokoro/samples/python3.6/periodic-head.cfg", - ".kokoro/samples/python3.6/periodic.cfg", - ".kokoro/samples/python3.6/presubmit.cfg", - ".kokoro/samples/python3.7/common.cfg", - ".kokoro/samples/python3.7/continuous.cfg", - ".kokoro/samples/python3.7/periodic-head.cfg", - ".kokoro/samples/python3.7/periodic.cfg", - ".kokoro/samples/python3.7/presubmit.cfg", - ".kokoro/samples/python3.8/common.cfg", - ".kokoro/samples/python3.8/continuous.cfg", - ".kokoro/samples/python3.8/periodic-head.cfg", - ".kokoro/samples/python3.8/periodic.cfg", - ".kokoro/samples/python3.8/presubmit.cfg", - ".kokoro/test-samples-against-head.sh", - ".kokoro/test-samples-impl.sh", - ".kokoro/test-samples.sh", - ".kokoro/trampoline.sh", - ".kokoro/trampoline_v2.sh", - ".pre-commit-config.yaml", - ".trampolinerc", - "CODE_OF_CONDUCT.md", - "CONTRIBUTING.rst", - "LICENSE", - "MANIFEST.in", - "docs/_static/custom.css", - "docs/_templates/layout.html", - "docs/conf.py", - "docs/domains_v1beta1/domains.rst", - "docs/domains_v1beta1/services.rst", - "docs/domains_v1beta1/types.rst", - "docs/multiprocessing.rst", - "google/cloud/domains/__init__.py", - "google/cloud/domains/py.typed", - "google/cloud/domains_v1beta1/__init__.py", - "google/cloud/domains_v1beta1/py.typed", - "google/cloud/domains_v1beta1/services/__init__.py", - "google/cloud/domains_v1beta1/services/domains/__init__.py", - "google/cloud/domains_v1beta1/services/domains/async_client.py", - "google/cloud/domains_v1beta1/services/domains/client.py", - "google/cloud/domains_v1beta1/services/domains/pagers.py", - "google/cloud/domains_v1beta1/services/domains/transports/__init__.py", - "google/cloud/domains_v1beta1/services/domains/transports/base.py", - "google/cloud/domains_v1beta1/services/domains/transports/grpc.py", - "google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py", - "google/cloud/domains_v1beta1/types/__init__.py", - "google/cloud/domains_v1beta1/types/domains.py", - "mypy.ini", - "noxfile.py", - "renovate.json", - "scripts/decrypt-secrets.sh", - "scripts/fixup_domains_v1beta1_keywords.py", - "scripts/readme-gen/readme_gen.py", - "scripts/readme-gen/templates/README.tmpl.rst", - "scripts/readme-gen/templates/auth.tmpl.rst", - "scripts/readme-gen/templates/auth_api_key.tmpl.rst", - "scripts/readme-gen/templates/install_deps.tmpl.rst", - "scripts/readme-gen/templates/install_portaudio.tmpl.rst", - "setup.cfg", - "testing/.gitignore", - "tests/unit/gapic/domains_v1beta1/__init__.py", - "tests/unit/gapic/domains_v1beta1/test_domains.py" - ] -} \ No newline at end of file From 7896690d1eeffa9d038e35415cb3b6644baf2ec7 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Wed, 12 May 2021 12:50:03 -0400 Subject: [PATCH 11/27] chore: add library type to .repo-metadata.json (#21) --- .repo-metadata.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.repo-metadata.json b/.repo-metadata.json index af470cf..2153687 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-domains", "distribution_name": "google-cloud-domains", "api_id": "domains.googleapis.com" From 4b246112d770cd4d4409b8a84a72f13713a59881 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sun, 16 May 2021 10:40:02 +0000 Subject: [PATCH 12/27] chore: upgrade gapic-generator-python to 0.46.3 (#24) PiperOrigin-RevId: 373649163 Source-Link: https://github.com/googleapis/googleapis/commit/7e1b14e6c7a9ab96d2db7e4a131981f162446d34 Source-Link: https://github.com/googleapis/googleapis-gen/commit/0a3c7d272d697796db75857bac73905c68e498c3 fix: add async client to %name_%version/init.py chore: add autogenerated snippets chore: remove auth, policy, and options from the reserved names list feat: support self-signed JWT flow for service accounts chore: enable GAPIC metadata generation chore: sort subpackages in %namespace/%name/init.py --- docs/domains_v1beta1/domains.rst | 1 - google/cloud/domains/__init__.py | 24 +- google/cloud/domains_v1beta1/__init__.py | 15 +- .../cloud/domains_v1beta1/gapic_metadata.json | 153 ++++ .../domains_v1beta1/services/__init__.py | 1 - .../services/domains/__init__.py | 2 - .../services/domains/async_client.py | 70 +- .../services/domains/client.py | 120 +-- .../services/domains/pagers.py | 4 +- .../services/domains/transports/__init__.py | 2 - .../services/domains/transports/base.py | 163 ++-- .../services/domains/transports/grpc.py | 54 +- .../domains/transports/grpc_asyncio.py | 60 +- .../cloud/domains_v1beta1/types/__init__.py | 2 - google/cloud/domains_v1beta1/types/domains.py | 199 ++--- scripts/fixup_domains_v1beta1_keywords.py | 31 +- tests/__init__.py | 15 + tests/unit/__init__.py | 15 + tests/unit/gapic/__init__.py | 15 + tests/unit/gapic/domains_v1beta1/__init__.py | 1 - .../gapic/domains_v1beta1/test_domains.py | 793 +++++++++--------- 21 files changed, 942 insertions(+), 798 deletions(-) create mode 100644 google/cloud/domains_v1beta1/gapic_metadata.json create mode 100644 tests/__init__.py create mode 100644 tests/unit/__init__.py create mode 100644 tests/unit/gapic/__init__.py diff --git a/docs/domains_v1beta1/domains.rst b/docs/domains_v1beta1/domains.rst index 0a8924a..13d490a 100644 --- a/docs/domains_v1beta1/domains.rst +++ b/docs/domains_v1beta1/domains.rst @@ -5,7 +5,6 @@ Domains :members: :inherited-members: - .. automodule:: google.cloud.domains_v1beta1.services.domains.pagers :members: :inherited-members: diff --git a/google/cloud/domains/__init__.py b/google/cloud/domains/__init__.py index 37e149b..c65bbe7 100644 --- a/google/cloud/domains/__init__.py +++ b/google/cloud/domains/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,22 +14,20 @@ # limitations under the License. # +from google.cloud.domains_v1beta1.services.domains.client import DomainsClient from google.cloud.domains_v1beta1.services.domains.async_client import ( DomainsAsyncClient, ) -from google.cloud.domains_v1beta1.services.domains.client import DomainsClient + from google.cloud.domains_v1beta1.types.domains import AuthorizationCode from google.cloud.domains_v1beta1.types.domains import ConfigureContactSettingsRequest from google.cloud.domains_v1beta1.types.domains import ConfigureDnsSettingsRequest from google.cloud.domains_v1beta1.types.domains import ( ConfigureManagementSettingsRequest, ) -from google.cloud.domains_v1beta1.types.domains import ContactNotice -from google.cloud.domains_v1beta1.types.domains import ContactPrivacy from google.cloud.domains_v1beta1.types.domains import ContactSettings from google.cloud.domains_v1beta1.types.domains import DeleteRegistrationRequest from google.cloud.domains_v1beta1.types.domains import DnsSettings -from google.cloud.domains_v1beta1.types.domains import DomainNotice from google.cloud.domains_v1beta1.types.domains import ExportRegistrationRequest from google.cloud.domains_v1beta1.types.domains import GetRegistrationRequest from google.cloud.domains_v1beta1.types.domains import ListRegistrationsRequest @@ -48,22 +45,22 @@ ) from google.cloud.domains_v1beta1.types.domains import SearchDomainsRequest from google.cloud.domains_v1beta1.types.domains import SearchDomainsResponse -from google.cloud.domains_v1beta1.types.domains import TransferLockState from google.cloud.domains_v1beta1.types.domains import UpdateRegistrationRequest +from google.cloud.domains_v1beta1.types.domains import ContactNotice +from google.cloud.domains_v1beta1.types.domains import ContactPrivacy +from google.cloud.domains_v1beta1.types.domains import DomainNotice +from google.cloud.domains_v1beta1.types.domains import TransferLockState __all__ = ( + "DomainsClient", + "DomainsAsyncClient", "AuthorizationCode", "ConfigureContactSettingsRequest", "ConfigureDnsSettingsRequest", "ConfigureManagementSettingsRequest", - "ContactNotice", - "ContactPrivacy", "ContactSettings", "DeleteRegistrationRequest", "DnsSettings", - "DomainNotice", - "DomainsAsyncClient", - "DomainsClient", "ExportRegistrationRequest", "GetRegistrationRequest", "ListRegistrationsRequest", @@ -79,6 +76,9 @@ "RetrieveRegisterParametersResponse", "SearchDomainsRequest", "SearchDomainsResponse", - "TransferLockState", "UpdateRegistrationRequest", + "ContactNotice", + "ContactPrivacy", + "DomainNotice", + "TransferLockState", ) diff --git a/google/cloud/domains_v1beta1/__init__.py b/google/cloud/domains_v1beta1/__init__.py index ad37849..7e9ede1 100644 --- a/google/cloud/domains_v1beta1/__init__.py +++ b/google/cloud/domains_v1beta1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,16 +15,15 @@ # from .services.domains import DomainsClient +from .services.domains import DomainsAsyncClient + from .types.domains import AuthorizationCode from .types.domains import ConfigureContactSettingsRequest from .types.domains import ConfigureDnsSettingsRequest from .types.domains import ConfigureManagementSettingsRequest -from .types.domains import ContactNotice -from .types.domains import ContactPrivacy from .types.domains import ContactSettings from .types.domains import DeleteRegistrationRequest from .types.domains import DnsSettings -from .types.domains import DomainNotice from .types.domains import ExportRegistrationRequest from .types.domains import GetRegistrationRequest from .types.domains import ListRegistrationsRequest @@ -41,11 +39,14 @@ from .types.domains import RetrieveRegisterParametersResponse from .types.domains import SearchDomainsRequest from .types.domains import SearchDomainsResponse -from .types.domains import TransferLockState from .types.domains import UpdateRegistrationRequest - +from .types.domains import ContactNotice +from .types.domains import ContactPrivacy +from .types.domains import DomainNotice +from .types.domains import TransferLockState __all__ = ( + "DomainsAsyncClient", "AuthorizationCode", "ConfigureContactSettingsRequest", "ConfigureDnsSettingsRequest", @@ -56,6 +57,7 @@ "DeleteRegistrationRequest", "DnsSettings", "DomainNotice", + "DomainsClient", "ExportRegistrationRequest", "GetRegistrationRequest", "ListRegistrationsRequest", @@ -73,5 +75,4 @@ "SearchDomainsResponse", "TransferLockState", "UpdateRegistrationRequest", - "DomainsClient", ) diff --git a/google/cloud/domains_v1beta1/gapic_metadata.json b/google/cloud/domains_v1beta1/gapic_metadata.json new file mode 100644 index 0000000..dd05252 --- /dev/null +++ b/google/cloud/domains_v1beta1/gapic_metadata.json @@ -0,0 +1,153 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.cloud.domains_v1beta1", + "protoPackage": "google.cloud.domains.v1beta1", + "schema": "1.0", + "services": { + "Domains": { + "clients": { + "grpc": { + "libraryClient": "DomainsClient", + "rpcs": { + "ConfigureContactSettings": { + "methods": [ + "configure_contact_settings" + ] + }, + "ConfigureDnsSettings": { + "methods": [ + "configure_dns_settings" + ] + }, + "ConfigureManagementSettings": { + "methods": [ + "configure_management_settings" + ] + }, + "DeleteRegistration": { + "methods": [ + "delete_registration" + ] + }, + "ExportRegistration": { + "methods": [ + "export_registration" + ] + }, + "GetRegistration": { + "methods": [ + "get_registration" + ] + }, + "ListRegistrations": { + "methods": [ + "list_registrations" + ] + }, + "RegisterDomain": { + "methods": [ + "register_domain" + ] + }, + "ResetAuthorizationCode": { + "methods": [ + "reset_authorization_code" + ] + }, + "RetrieveAuthorizationCode": { + "methods": [ + "retrieve_authorization_code" + ] + }, + "RetrieveRegisterParameters": { + "methods": [ + "retrieve_register_parameters" + ] + }, + "SearchDomains": { + "methods": [ + "search_domains" + ] + }, + "UpdateRegistration": { + "methods": [ + "update_registration" + ] + } + } + }, + "grpc-async": { + "libraryClient": "DomainsAsyncClient", + "rpcs": { + "ConfigureContactSettings": { + "methods": [ + "configure_contact_settings" + ] + }, + "ConfigureDnsSettings": { + "methods": [ + "configure_dns_settings" + ] + }, + "ConfigureManagementSettings": { + "methods": [ + "configure_management_settings" + ] + }, + "DeleteRegistration": { + "methods": [ + "delete_registration" + ] + }, + "ExportRegistration": { + "methods": [ + "export_registration" + ] + }, + "GetRegistration": { + "methods": [ + "get_registration" + ] + }, + "ListRegistrations": { + "methods": [ + "list_registrations" + ] + }, + "RegisterDomain": { + "methods": [ + "register_domain" + ] + }, + "ResetAuthorizationCode": { + "methods": [ + "reset_authorization_code" + ] + }, + "RetrieveAuthorizationCode": { + "methods": [ + "retrieve_authorization_code" + ] + }, + "RetrieveRegisterParameters": { + "methods": [ + "retrieve_register_parameters" + ] + }, + "SearchDomains": { + "methods": [ + "search_domains" + ] + }, + "UpdateRegistration": { + "methods": [ + "update_registration" + ] + } + } + } + } + } + } +} diff --git a/google/cloud/domains_v1beta1/services/__init__.py b/google/cloud/domains_v1beta1/services/__init__.py index 42ffdf2..4de6597 100644 --- a/google/cloud/domains_v1beta1/services/__init__.py +++ b/google/cloud/domains_v1beta1/services/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/google/cloud/domains_v1beta1/services/domains/__init__.py b/google/cloud/domains_v1beta1/services/domains/__init__.py index 9a3fe5a..cd7bb44 100644 --- a/google/cloud/domains_v1beta1/services/domains/__init__.py +++ b/google/cloud/domains_v1beta1/services/domains/__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 DomainsClient from .async_client import DomainsAsyncClient diff --git a/google/cloud/domains_v1beta1/services/domains/async_client.py b/google/cloud/domains_v1beta1/services/domains/async_client.py index 3c95c9b..c92d177 100644 --- a/google/cloud/domains_v1beta1/services/domains/async_client.py +++ b/google/cloud/domains_v1beta1/services/domains/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,21 +20,20 @@ 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 from google.api_core import operation_async # type: ignore from google.cloud.domains_v1beta1.services.domains import pagers from google.cloud.domains_v1beta1.types import domains -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.type import money_pb2 as money # 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 google.type import money_pb2 # type: ignore from .transports.base import DomainsTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import DomainsGrpcAsyncIOTransport from .client import DomainsClient @@ -54,31 +51,27 @@ class DomainsAsyncClient: registration_path = staticmethod(DomainsClient.registration_path) parse_registration_path = staticmethod(DomainsClient.parse_registration_path) - common_billing_account_path = staticmethod( DomainsClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( DomainsClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(DomainsClient.common_folder_path) parse_common_folder_path = staticmethod(DomainsClient.parse_common_folder_path) - common_organization_path = staticmethod(DomainsClient.common_organization_path) parse_common_organization_path = staticmethod( DomainsClient.parse_common_organization_path ) - common_project_path = staticmethod(DomainsClient.common_project_path) parse_common_project_path = staticmethod(DomainsClient.parse_common_project_path) - common_location_path = staticmethod(DomainsClient.common_location_path) parse_common_location_path = staticmethod(DomainsClient.parse_common_location_path) @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. @@ -93,7 +86,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 @@ -110,7 +103,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> DomainsTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: DomainsTransport: The transport used by the client instance. @@ -124,12 +117,12 @@ def transport(self) -> DomainsTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, DomainsTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the domains client. + """Instantiates the domains client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -161,7 +154,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = DomainsClient( credentials=credentials, transport=transport, @@ -204,7 +196,6 @@ async def search_domains( This corresponds to the ``query`` 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. @@ -229,7 +220,6 @@ async def search_domains( # If we have keyword arguments corresponding to fields on the # request, apply these. - if location is not None: request.location = location if query is not None: @@ -288,7 +278,6 @@ async def retrieve_register_parameters( This corresponds to the ``domain_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. @@ -313,7 +302,6 @@ async def retrieve_register_parameters( # If we have keyword arguments corresponding to fields on the # request, apply these. - if location is not None: request.location = location if domain_name is not None: @@ -345,7 +333,7 @@ async def register_domain( *, parent: str = None, registration: domains.Registration = None, - yearly_price: money.Money = None, + yearly_price: money_pb2.Money = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -393,7 +381,6 @@ async def register_domain( This corresponds to the ``yearly_price`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -430,7 +417,6 @@ async def register_domain( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if registration is not None: @@ -489,7 +475,6 @@ async def list_registrations( 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. @@ -518,7 +503,6 @@ async def list_registrations( # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -570,7 +554,6 @@ async def get_registration( 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. @@ -605,7 +588,6 @@ async def get_registration( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -634,7 +616,7 @@ async def update_registration( request: domains.UpdateRegistrationRequest = None, *, registration: domains.Registration = 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]] = (), @@ -667,7 +649,6 @@ async def update_registration( 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. @@ -704,7 +685,6 @@ async def update_registration( # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration if update_mask is not None: @@ -746,7 +726,7 @@ async def configure_management_settings( *, registration: str = None, management_settings: domains.ManagementSettings = 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]] = (), @@ -779,7 +759,6 @@ async def configure_management_settings( 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. @@ -816,7 +795,6 @@ async def configure_management_settings( # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration if management_settings is not None: @@ -860,7 +838,7 @@ async def configure_dns_settings( *, registration: str = None, dns_settings: domains.DnsSettings = 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]] = (), @@ -900,7 +878,6 @@ async def configure_dns_settings( 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. @@ -937,7 +914,6 @@ async def configure_dns_settings( # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration if dns_settings is not None: @@ -981,7 +957,7 @@ async def configure_contact_settings( *, registration: str = None, contact_settings: domains.ContactSettings = 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]] = (), @@ -1015,7 +991,6 @@ async def configure_contact_settings( 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. @@ -1052,7 +1027,6 @@ async def configure_contact_settings( # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration if contact_settings is not None: @@ -1125,7 +1099,6 @@ async def export_registration( 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. @@ -1162,7 +1135,6 @@ async def export_registration( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1222,7 +1194,6 @@ async def delete_registration( 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. @@ -1262,7 +1233,6 @@ async def delete_registration( # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1287,7 +1257,7 @@ async def delete_registration( response = operation_async.from_gapic( response, self._client._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=domains.OperationMetadata, ) @@ -1321,7 +1291,6 @@ async def retrieve_authorization_code( This corresponds to the ``registration`` 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. @@ -1346,7 +1315,6 @@ async def retrieve_authorization_code( # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration @@ -1399,7 +1367,6 @@ async def reset_authorization_code( This corresponds to the ``registration`` 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. @@ -1424,7 +1391,6 @@ async def reset_authorization_code( # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration diff --git a/google/cloud/domains_v1beta1/services/domains/client.py b/google/cloud/domains_v1beta1/services/domains/client.py index efc3176..d543f42 100644 --- a/google/cloud/domains_v1beta1/services/domains/client.py +++ b/google/cloud/domains_v1beta1/services/domains/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 @@ -36,11 +34,10 @@ from google.api_core import operation_async # type: ignore from google.cloud.domains_v1beta1.services.domains import pagers from google.cloud.domains_v1beta1.types import domains -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.type import money_pb2 as money # 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 google.type import money_pb2 # type: ignore from .transports.base import DomainsTransport, DEFAULT_CLIENT_INFO from .transports.grpc import DomainsGrpcTransport from .transports.grpc_asyncio import DomainsGrpcAsyncIOTransport @@ -59,7 +56,7 @@ class DomainsClientMeta(type): _transport_registry["grpc_asyncio"] = DomainsGrpcAsyncIOTransport def get_transport_class(cls, label: str = None,) -> Type[DomainsTransport]: - """Return an appropriate transport class. + """Returns an appropriate transport class. Args: label: The name of the desired transport. If none is @@ -84,7 +81,8 @@ class DomainsClient(metaclass=DomainsClientMeta): @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: @@ -118,7 +116,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. @@ -135,7 +134,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 @@ -154,23 +153,24 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> DomainsTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: - DomainsTransport: The transport used by the client instance. + DomainsTransport: The transport used by the client + instance. """ return self._transport @staticmethod def registration_path(project: str, location: str, registration: str,) -> str: - """Return a fully-qualified registration string.""" + """Returns a fully-qualified registration string.""" return "projects/{project}/locations/{location}/registrations/{registration}".format( project=project, location=location, registration=registration, ) @staticmethod def parse_registration_path(path: str) -> Dict[str, str]: - """Parse a registration path into its component segments.""" + """Parses a registration path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/(?P.+?)/registrations/(?P.+?)$", path, @@ -179,7 +179,7 @@ def parse_registration_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, ) @@ -192,7 +192,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 @@ -203,7 +203,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 @@ -214,7 +214,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 @@ -225,7 +225,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, ) @@ -239,12 +239,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, DomainsTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the domains client. + """Instantiates the domains client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -299,9 +299,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: @@ -313,12 +314,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. @@ -333,8 +336,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: @@ -384,7 +387,6 @@ def search_domains( This corresponds to the ``query`` 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. @@ -411,10 +413,8 @@ def search_domains( # there are no flattened fields. if not isinstance(request, domains.SearchDomainsRequest): request = domains.SearchDomainsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if location is not None: request.location = location if query is not None: @@ -469,7 +469,6 @@ def retrieve_register_parameters( This corresponds to the ``domain_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. @@ -496,10 +495,8 @@ def retrieve_register_parameters( # there are no flattened fields. if not isinstance(request, domains.RetrieveRegisterParametersRequest): request = domains.RetrieveRegisterParametersRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if location is not None: request.location = location if domain_name is not None: @@ -529,7 +526,7 @@ def register_domain( *, parent: str = None, registration: domains.Registration = None, - yearly_price: money.Money = None, + yearly_price: money_pb2.Money = None, retry: retries.Retry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), @@ -577,7 +574,6 @@ def register_domain( This corresponds to the ``yearly_price`` 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. @@ -616,10 +612,8 @@ def register_domain( # there are no flattened fields. if not isinstance(request, domains.RegisterDomainRequest): request = domains.RegisterDomainRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent if registration is not None: @@ -674,7 +668,6 @@ def list_registrations( 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. @@ -705,10 +698,8 @@ def list_registrations( # there are no flattened fields. if not isinstance(request, domains.ListRegistrationsRequest): request = domains.ListRegistrationsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if parent is not None: request.parent = parent @@ -756,7 +747,6 @@ def get_registration( 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. @@ -793,10 +783,8 @@ def get_registration( # there are no flattened fields. if not isinstance(request, domains.GetRegistrationRequest): request = domains.GetRegistrationRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -821,7 +809,7 @@ def update_registration( request: domains.UpdateRegistrationRequest = None, *, registration: domains.Registration = 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]] = (), @@ -854,7 +842,6 @@ def update_registration( 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. @@ -893,10 +880,8 @@ def update_registration( # there are no flattened fields. if not isinstance(request, domains.UpdateRegistrationRequest): request = domains.UpdateRegistrationRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration if update_mask is not None: @@ -934,7 +919,7 @@ def configure_management_settings( *, registration: str = None, management_settings: domains.ManagementSettings = 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]] = (), @@ -967,7 +952,6 @@ def configure_management_settings( 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. @@ -1006,10 +990,8 @@ def configure_management_settings( # there are no flattened fields. if not isinstance(request, domains.ConfigureManagementSettingsRequest): request = domains.ConfigureManagementSettingsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration if management_settings is not None: @@ -1051,7 +1033,7 @@ def configure_dns_settings( *, registration: str = None, dns_settings: domains.DnsSettings = 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]] = (), @@ -1091,7 +1073,6 @@ def configure_dns_settings( 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. @@ -1130,10 +1111,8 @@ def configure_dns_settings( # there are no flattened fields. if not isinstance(request, domains.ConfigureDnsSettingsRequest): request = domains.ConfigureDnsSettingsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration if dns_settings is not None: @@ -1173,7 +1152,7 @@ def configure_contact_settings( *, registration: str = None, contact_settings: domains.ContactSettings = 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]] = (), @@ -1207,7 +1186,6 @@ def configure_contact_settings( 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. @@ -1246,10 +1224,8 @@ def configure_contact_settings( # there are no flattened fields. if not isinstance(request, domains.ConfigureContactSettingsRequest): request = domains.ConfigureContactSettingsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration if contact_settings is not None: @@ -1320,7 +1296,6 @@ def export_registration( 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. @@ -1359,10 +1334,8 @@ def export_registration( # there are no flattened fields. if not isinstance(request, domains.ExportRegistrationRequest): request = domains.ExportRegistrationRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1418,7 +1391,6 @@ def delete_registration( 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. @@ -1460,10 +1432,8 @@ def delete_registration( # there are no flattened fields. if not isinstance(request, domains.DeleteRegistrationRequest): request = domains.DeleteRegistrationRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if name is not None: request.name = name @@ -1484,7 +1454,7 @@ def delete_registration( response = operation.from_gapic( response, self._transport.operations_client, - empty.Empty, + empty_pb2.Empty, metadata_type=domains.OperationMetadata, ) @@ -1518,7 +1488,6 @@ def retrieve_authorization_code( This corresponds to the ``registration`` 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. @@ -1545,10 +1514,8 @@ def retrieve_authorization_code( # there are no flattened fields. if not isinstance(request, domains.RetrieveAuthorizationCodeRequest): request = domains.RetrieveAuthorizationCodeRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration @@ -1599,7 +1566,6 @@ def reset_authorization_code( This corresponds to the ``registration`` 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. @@ -1626,10 +1592,8 @@ def reset_authorization_code( # there are no flattened fields. if not isinstance(request, domains.ResetAuthorizationCodeRequest): request = domains.ResetAuthorizationCodeRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if registration is not None: request.registration = registration diff --git a/google/cloud/domains_v1beta1/services/domains/pagers.py b/google/cloud/domains_v1beta1/services/domains/pagers.py index 801200a..946e27a 100644 --- a/google/cloud/domains_v1beta1/services/domains/pagers.py +++ b/google/cloud/domains_v1beta1/services/domains/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, @@ -117,7 +115,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/domains_v1beta1/services/domains/transports/__init__.py b/google/cloud/domains_v1beta1/services/domains/transports/__init__.py index be552f4..d1eb105 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/__init__.py +++ b/google/cloud/domains_v1beta1/services/domains/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/domains_v1beta1/services/domains/transports/base.py b/google/cloud/domains_v1beta1/services/domains/transports/base.py index 3d94805..11e66a5 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/base.py +++ b/google/cloud/domains_v1beta1/services/domains/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,21 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +import google.auth # type: ignore +import google.api_core # type: ignore +from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.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.domains_v1beta1.types import domains -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( @@ -37,27 +36,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 DomainsTransport(abc.ABC): """Abstract transport class for Domains.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "domains.googleapis.com" + def __init__( self, *, - host: str = "domains.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 @@ -66,7 +79,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -80,29 +93,76 @@ 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=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # 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. self._wrapped_methods = { @@ -167,23 +227,20 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def search_domains( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.SearchDomainsRequest], - typing.Union[ - domains.SearchDomainsResponse, - typing.Awaitable[domains.SearchDomainsResponse], - ], + Union[domains.SearchDomainsResponse, Awaitable[domains.SearchDomainsResponse]], ]: raise NotImplementedError() @property def retrieve_register_parameters( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.RetrieveRegisterParametersRequest], - typing.Union[ + Union[ domains.RetrieveRegisterParametersResponse, - typing.Awaitable[domains.RetrieveRegisterParametersResponse], + Awaitable[domains.RetrieveRegisterParametersResponse], ], ]: raise NotImplementedError() @@ -191,20 +248,20 @@ def retrieve_register_parameters( @property def register_domain( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.RegisterDomainRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def list_registrations( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.ListRegistrationsRequest], - typing.Union[ + Union[ domains.ListRegistrationsResponse, - typing.Awaitable[domains.ListRegistrationsResponse], + Awaitable[domains.ListRegistrationsResponse], ], ]: raise NotImplementedError() @@ -212,85 +269,81 @@ def list_registrations( @property def get_registration( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.GetRegistrationRequest], - typing.Union[domains.Registration, typing.Awaitable[domains.Registration]], + Union[domains.Registration, Awaitable[domains.Registration]], ]: raise NotImplementedError() @property def update_registration( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.UpdateRegistrationRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def configure_management_settings( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.ConfigureManagementSettingsRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def configure_dns_settings( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.ConfigureDnsSettingsRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def configure_contact_settings( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.ConfigureContactSettingsRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def export_registration( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.ExportRegistrationRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def delete_registration( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.DeleteRegistrationRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def retrieve_authorization_code( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.RetrieveAuthorizationCodeRequest], - typing.Union[ - domains.AuthorizationCode, typing.Awaitable[domains.AuthorizationCode] - ], + Union[domains.AuthorizationCode, Awaitable[domains.AuthorizationCode]], ]: raise NotImplementedError() @property def reset_authorization_code( self, - ) -> typing.Callable[ + ) -> Callable[ [domains.ResetAuthorizationCodeRequest], - typing.Union[ - domains.AuthorizationCode, typing.Awaitable[domains.AuthorizationCode] - ], + Union[domains.AuthorizationCode, Awaitable[domains.AuthorizationCode]], ]: raise NotImplementedError() diff --git a/google/cloud/domains_v1beta1/services/domains/transports/grpc.py b/google/cloud/domains_v1beta1/services/domains/transports/grpc.py index 260bb60..f6700ca 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/grpc.py +++ b/google/cloud/domains_v1beta1/services/domains/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,22 +13,20 @@ # 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.domains_v1beta1.types import domains -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import DomainsTransport, DEFAULT_CLIENT_INFO @@ -53,7 +50,7 @@ def __init__( self, *, host: str = "domains.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -67,7 +64,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 @@ -178,7 +176,7 @@ def __init__( def create_channel( cls, host: str = "domains.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, @@ -209,13 +207,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + 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, ) @@ -304,7 +304,7 @@ def retrieve_register_parameters( @property def register_domain( self, - ) -> Callable[[domains.RegisterDomainRequest], operations.Operation]: + ) -> Callable[[domains.RegisterDomainRequest], operations_pb2.Operation]: r"""Return a callable for the register domain method over gRPC. Registers a new domain name and creates a corresponding @@ -336,7 +336,7 @@ def register_domain( self._stubs["register_domain"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/RegisterDomain", request_serializer=domains.RegisterDomainRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["register_domain"] @@ -397,7 +397,7 @@ def get_registration( @property def update_registration( self, - ) -> Callable[[domains.UpdateRegistrationRequest], operations.Operation]: + ) -> Callable[[domains.UpdateRegistrationRequest], operations_pb2.Operation]: r"""Return a callable for the update registration method over gRPC. Updates select fields of a ``Registration`` resource, notably @@ -424,14 +424,16 @@ def update_registration( self._stubs["update_registration"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/UpdateRegistration", request_serializer=domains.UpdateRegistrationRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_registration"] @property def configure_management_settings( self, - ) -> Callable[[domains.ConfigureManagementSettingsRequest], operations.Operation]: + ) -> Callable[ + [domains.ConfigureManagementSettingsRequest], operations_pb2.Operation + ]: r"""Return a callable for the configure management settings method over gRPC. Updates a ``Registration``'s management settings. @@ -452,14 +454,14 @@ def configure_management_settings( ] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/ConfigureManagementSettings", request_serializer=domains.ConfigureManagementSettingsRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["configure_management_settings"] @property def configure_dns_settings( self, - ) -> Callable[[domains.ConfigureDnsSettingsRequest], operations.Operation]: + ) -> Callable[[domains.ConfigureDnsSettingsRequest], operations_pb2.Operation]: r"""Return a callable for the configure dns settings method over gRPC. Updates a ``Registration``'s DNS settings. @@ -478,14 +480,14 @@ def configure_dns_settings( self._stubs["configure_dns_settings"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/ConfigureDnsSettings", request_serializer=domains.ConfigureDnsSettingsRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["configure_dns_settings"] @property def configure_contact_settings( self, - ) -> Callable[[domains.ConfigureContactSettingsRequest], operations.Operation]: + ) -> Callable[[domains.ConfigureContactSettingsRequest], operations_pb2.Operation]: r"""Return a callable for the configure contact settings method over gRPC. Updates a ``Registration``'s contact settings. Some changes @@ -505,14 +507,14 @@ def configure_contact_settings( self._stubs["configure_contact_settings"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/ConfigureContactSettings", request_serializer=domains.ConfigureContactSettingsRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["configure_contact_settings"] @property def export_registration( self, - ) -> Callable[[domains.ExportRegistrationRequest], operations.Operation]: + ) -> Callable[[domains.ExportRegistrationRequest], operations_pb2.Operation]: r"""Return a callable for the export registration method over gRPC. Exports a ``Registration`` that you no longer want to use with @@ -544,14 +546,14 @@ def export_registration( self._stubs["export_registration"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/ExportRegistration", request_serializer=domains.ExportRegistrationRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["export_registration"] @property def delete_registration( self, - ) -> Callable[[domains.DeleteRegistrationRequest], operations.Operation]: + ) -> Callable[[domains.DeleteRegistrationRequest], operations_pb2.Operation]: r"""Return a callable for the delete registration method over gRPC. Deletes a ``Registration`` resource. @@ -576,7 +578,7 @@ def delete_registration( self._stubs["delete_registration"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/DeleteRegistration", request_serializer=domains.DeleteRegistrationRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_registration"] diff --git a/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py b/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py index 7ef2167..8ef4a15 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py +++ b/google/cloud/domains_v1beta1/services/domains/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,23 +13,21 @@ # 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.domains_v1beta1.types import domains -from google.longrunning import operations_pb2 as operations # type: ignore - +from google.longrunning import operations_pb2 # type: ignore from .base import DomainsTransport, DEFAULT_CLIENT_INFO from .grpc import DomainsGrpcTransport @@ -56,7 +53,7 @@ class DomainsGrpcAsyncIOTransport(DomainsTransport): def create_channel( cls, host: str = "domains.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, @@ -83,13 +80,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, ) @@ -97,7 +96,7 @@ def __init__( self, *, host: str = "domains.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, @@ -111,7 +110,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 @@ -170,7 +170,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -312,7 +311,7 @@ def retrieve_register_parameters( @property def register_domain( self, - ) -> Callable[[domains.RegisterDomainRequest], Awaitable[operations.Operation]]: + ) -> Callable[[domains.RegisterDomainRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the register domain method over gRPC. Registers a new domain name and creates a corresponding @@ -344,7 +343,7 @@ def register_domain( self._stubs["register_domain"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/RegisterDomain", request_serializer=domains.RegisterDomainRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["register_domain"] @@ -405,7 +404,9 @@ def get_registration( @property def update_registration( self, - ) -> Callable[[domains.UpdateRegistrationRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [domains.UpdateRegistrationRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the update registration method over gRPC. Updates select fields of a ``Registration`` resource, notably @@ -432,7 +433,7 @@ def update_registration( self._stubs["update_registration"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/UpdateRegistration", request_serializer=domains.UpdateRegistrationRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["update_registration"] @@ -440,7 +441,8 @@ def update_registration( def configure_management_settings( self, ) -> Callable[ - [domains.ConfigureManagementSettingsRequest], Awaitable[operations.Operation] + [domains.ConfigureManagementSettingsRequest], + Awaitable[operations_pb2.Operation], ]: r"""Return a callable for the configure management settings method over gRPC. @@ -462,7 +464,7 @@ def configure_management_settings( ] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/ConfigureManagementSettings", request_serializer=domains.ConfigureManagementSettingsRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["configure_management_settings"] @@ -470,7 +472,7 @@ def configure_management_settings( def configure_dns_settings( self, ) -> Callable[ - [domains.ConfigureDnsSettingsRequest], Awaitable[operations.Operation] + [domains.ConfigureDnsSettingsRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the configure dns settings method over gRPC. @@ -490,7 +492,7 @@ def configure_dns_settings( self._stubs["configure_dns_settings"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/ConfigureDnsSettings", request_serializer=domains.ConfigureDnsSettingsRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["configure_dns_settings"] @@ -498,7 +500,7 @@ def configure_dns_settings( def configure_contact_settings( self, ) -> Callable[ - [domains.ConfigureContactSettingsRequest], Awaitable[operations.Operation] + [domains.ConfigureContactSettingsRequest], Awaitable[operations_pb2.Operation] ]: r"""Return a callable for the configure contact settings method over gRPC. @@ -519,14 +521,16 @@ def configure_contact_settings( self._stubs["configure_contact_settings"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/ConfigureContactSettings", request_serializer=domains.ConfigureContactSettingsRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["configure_contact_settings"] @property def export_registration( self, - ) -> Callable[[domains.ExportRegistrationRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [domains.ExportRegistrationRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the export registration method over gRPC. Exports a ``Registration`` that you no longer want to use with @@ -558,14 +562,16 @@ def export_registration( self._stubs["export_registration"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/ExportRegistration", request_serializer=domains.ExportRegistrationRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["export_registration"] @property def delete_registration( self, - ) -> Callable[[domains.DeleteRegistrationRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [domains.DeleteRegistrationRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the delete registration method over gRPC. Deletes a ``Registration`` resource. @@ -590,7 +596,7 @@ def delete_registration( self._stubs["delete_registration"] = self.grpc_channel.unary_unary( "/google.cloud.domains.v1beta1.Domains/DeleteRegistration", request_serializer=domains.DeleteRegistrationRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["delete_registration"] diff --git a/google/cloud/domains_v1beta1/types/__init__.py b/google/cloud/domains_v1beta1/types/__init__.py index c92ebe3..73c9baa1 100644 --- a/google/cloud/domains_v1beta1/types/__init__.py +++ b/google/cloud/domains_v1beta1/types/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .domains import ( AuthorizationCode, ConfigureContactSettingsRequest, diff --git a/google/cloud/domains_v1beta1/types/domains.py b/google/cloud/domains_v1beta1/types/domains.py index 43374bb..f18a31b 100644 --- a/google/cloud/domains_v1beta1/types/domains.py +++ b/google/cloud/domains_v1beta1/types/domains.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,14 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # 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.type import money_pb2 as money # type: ignore -from google.type import postal_address_pb2 as gt_postal_address # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.type import money_pb2 # type: ignore +from google.type import postal_address_pb2 # type: ignore __protobuf__ = proto.module( @@ -172,32 +169,21 @@ class Issue(proto.Enum): CONTACT_SUPPORT = 1 UNVERIFIED_EMAIL = 2 - name = proto.Field(proto.STRING, number=1) - - domain_name = proto.Field(proto.STRING, number=2) - - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp.Timestamp,) - - expire_time = proto.Field(proto.MESSAGE, number=6, message=timestamp.Timestamp,) - + name = proto.Field(proto.STRING, number=1,) + domain_name = proto.Field(proto.STRING, number=2,) + create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) + expire_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) state = proto.Field(proto.ENUM, number=7, enum=State,) - issues = proto.RepeatedField(proto.ENUM, number=8, enum=Issue,) - - labels = proto.MapField(proto.STRING, proto.STRING, number=9) - + labels = proto.MapField(proto.STRING, proto.STRING, number=9,) management_settings = proto.Field( proto.MESSAGE, number=10, message="ManagementSettings", ) - dns_settings = proto.Field(proto.MESSAGE, number=11, message="DnsSettings",) - contact_settings = proto.Field(proto.MESSAGE, number=12, message="ContactSettings",) - pending_contact_settings = proto.Field( proto.MESSAGE, number=13, message="ContactSettings", ) - supported_privacy = proto.RepeatedField( proto.ENUM, number=14, enum="ContactPrivacy", ) @@ -222,7 +208,6 @@ class RenewalMethod(proto.Enum): MANUAL_RENEWAL = 2 renewal_method = proto.Field(proto.ENUM, number=3, enum=RenewalMethod,) - transfer_lock_state = proto.Field(proto.ENUM, number=4, enum="TransferLockState",) @@ -250,7 +235,6 @@ class DsState(proto.Enum): class CustomDns(proto.Message): r"""Configuration for an arbitrary DNS provider. - Attributes: name_servers (Sequence[str]): Required. A list of name servers that store @@ -264,8 +248,7 @@ class CustomDns(proto.Message): this field is empty, DNSSEC is disabled. """ - name_servers = proto.RepeatedField(proto.STRING, number=1) - + name_servers = proto.RepeatedField(proto.STRING, number=1,) ds_records = proto.RepeatedField( proto.MESSAGE, number=2, message="DnsSettings.DsRecord", ) @@ -295,10 +278,8 @@ class GoogleDomainsDns(proto.Message): remains empty. """ - name_servers = proto.RepeatedField(proto.STRING, number=1) - + name_servers = proto.RepeatedField(proto.STRING, number=1,) ds_state = proto.Field(proto.ENUM, number=2, enum="DnsSettings.DsState",) - ds_records = proto.RepeatedField( proto.MESSAGE, number=3, message="DnsSettings.DsRecord", ) @@ -351,17 +332,14 @@ class DigestType(proto.Enum): GOST3411 = 3 SHA384 = 4 - key_tag = proto.Field(proto.INT32, number=1) - + key_tag = proto.Field(proto.INT32, number=1,) algorithm = proto.Field( proto.ENUM, number=2, enum="DnsSettings.DsRecord.Algorithm", ) - digest_type = proto.Field( proto.ENUM, number=3, enum="DnsSettings.DsRecord.DigestType", ) - - digest = proto.Field(proto.STRING, number=4) + digest = proto.Field(proto.STRING, number=4,) class GlueRecord(proto.Message): r"""Defines a host on your domain that is a DNS name server for your @@ -385,20 +363,16 @@ class GlueRecord(proto.Message): one of ``ipv4_address`` and ``ipv6_address`` must be set. """ - host_name = proto.Field(proto.STRING, number=1) - - ipv4_addresses = proto.RepeatedField(proto.STRING, number=2) - - ipv6_addresses = proto.RepeatedField(proto.STRING, number=3) + host_name = proto.Field(proto.STRING, number=1,) + ipv4_addresses = proto.RepeatedField(proto.STRING, number=2,) + ipv6_addresses = proto.RepeatedField(proto.STRING, number=3,) custom_dns = proto.Field( proto.MESSAGE, number=1, oneof="dns_provider", message=CustomDns, ) - google_domains_dns = proto.Field( proto.MESSAGE, number=2, oneof="dns_provider", message=GoogleDomainsDns, ) - glue_records = proto.RepeatedField(proto.MESSAGE, number=4, message=GlueRecord,) @@ -433,7 +407,6 @@ class ContactSettings(proto.Message): class Contact(proto.Message): r"""Details required for a contact associated with a ``Registration``. - Attributes: postal_address (google.type.postal_address_pb2.PostalAddress): Required. Postal address of the contact. @@ -448,27 +421,20 @@ class Contact(proto.Message): """ postal_address = proto.Field( - proto.MESSAGE, number=1, message=gt_postal_address.PostalAddress, + proto.MESSAGE, number=1, message=postal_address_pb2.PostalAddress, ) - - email = proto.Field(proto.STRING, number=2) - - phone_number = proto.Field(proto.STRING, number=3) - - fax_number = proto.Field(proto.STRING, number=4) + email = proto.Field(proto.STRING, number=2,) + phone_number = proto.Field(proto.STRING, number=3,) + fax_number = proto.Field(proto.STRING, number=4,) privacy = proto.Field(proto.ENUM, number=1, enum="ContactPrivacy",) - registrant_contact = proto.Field(proto.MESSAGE, number=2, message=Contact,) - admin_contact = proto.Field(proto.MESSAGE, number=3, message=Contact,) - technical_contact = proto.Field(proto.MESSAGE, number=4, message=Contact,) class SearchDomainsRequest(proto.Message): r"""Request for the ``SearchDomains`` method. - Attributes: query (str): Required. String used to search for available @@ -478,14 +444,12 @@ class SearchDomainsRequest(proto.Message): ``projects/*/locations/*``. """ - query = proto.Field(proto.STRING, number=1) - - location = proto.Field(proto.STRING, number=2) + query = proto.Field(proto.STRING, number=1,) + location = proto.Field(proto.STRING, number=2,) class SearchDomainsResponse(proto.Message): r"""Response for the ``SearchDomains`` method. - Attributes: register_parameters (Sequence[google.cloud.domains_v1beta1.types.RegisterParameters]): Results of the domain name search. @@ -498,7 +462,6 @@ class SearchDomainsResponse(proto.Message): class RetrieveRegisterParametersRequest(proto.Message): r"""Request for the ``RetrieveRegisterParameters`` method. - Attributes: domain_name (str): Required. The domain name. Unicode domain @@ -508,14 +471,12 @@ class RetrieveRegisterParametersRequest(proto.Message): ``projects/*/locations/*``. """ - domain_name = proto.Field(proto.STRING, number=1) - - location = proto.Field(proto.STRING, number=2) + domain_name = proto.Field(proto.STRING, number=1,) + location = proto.Field(proto.STRING, number=2,) class RetrieveRegisterParametersResponse(proto.Message): r"""Response for the ``RetrieveRegisterParameters`` method. - Attributes: register_parameters (google.cloud.domains_v1beta1.types.RegisterParameters): Parameters to use when calling the ``RegisterDomain`` @@ -529,7 +490,6 @@ class RetrieveRegisterParametersResponse(proto.Message): class RegisterDomainRequest(proto.Message): r"""Request for the ``RegisterDomain`` method. - Attributes: parent (str): Required. The parent resource of the ``Registration``. Must @@ -556,22 +516,16 @@ class RegisterDomainRequest(proto.Message): https://cloud.google.com/apis/design/design_patterns#request_validation """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) registration = proto.Field(proto.MESSAGE, number=2, message="Registration",) - domain_notices = proto.RepeatedField(proto.ENUM, number=3, enum="DomainNotice",) - contact_notices = proto.RepeatedField(proto.ENUM, number=4, enum="ContactNotice",) - - yearly_price = proto.Field(proto.MESSAGE, number=5, message=money.Money,) - - validate_only = proto.Field(proto.BOOL, number=6) + yearly_price = proto.Field(proto.MESSAGE, number=5, message=money_pb2.Money,) + validate_only = proto.Field(proto.BOOL, number=6,) class ListRegistrationsRequest(proto.Message): r"""Request for the ``ListRegistrations`` method. - Attributes: parent (str): Required. The project and location from which to list @@ -605,18 +559,14 @@ class ListRegistrationsRequest(proto.Message): ``(state=SUSPENDED) OR (issue:*)``. """ - 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) + 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,) class ListRegistrationsResponse(proto.Message): r"""Response for the ``ListRegistrations`` method. - Attributes: registrations (Sequence[google.cloud.domains_v1beta1.types.Registration]): A list of ``Registration``\ s. @@ -633,25 +583,22 @@ def raw_page(self): registrations = proto.RepeatedField( proto.MESSAGE, number=1, message="Registration", ) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class GetRegistrationRequest(proto.Message): r"""Request for the ``GetRegistration`` method. - Attributes: name (str): Required. The name of the ``Registration`` to get, in the format ``projects/*/locations/*/registrations/*``. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class UpdateRegistrationRequest(proto.Message): r"""Request for the ``UpdateRegistration`` method. - Attributes: registration (google.cloud.domains_v1beta1.types.Registration): Fields of the ``Registration`` to update. @@ -663,13 +610,13 @@ class UpdateRegistrationRequest(proto.Message): """ registration = proto.Field(proto.MESSAGE, number=1, message="Registration",) - - update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + ) class ConfigureManagementSettingsRequest(proto.Message): r"""Request for the ``ConfigureManagementSettings`` method. - Attributes: registration (str): Required. The name of the ``Registration`` whose management @@ -684,18 +631,17 @@ class ConfigureManagementSettingsRequest(proto.Message): ``"transfer_lock_state"``. """ - registration = proto.Field(proto.STRING, number=1) - + registration = proto.Field(proto.STRING, number=1,) management_settings = proto.Field( proto.MESSAGE, number=2, message="ManagementSettings", ) - - update_mask = proto.Field(proto.MESSAGE, number=3, message=field_mask.FieldMask,) + update_mask = proto.Field( + proto.MESSAGE, number=3, message=field_mask_pb2.FieldMask, + ) class ConfigureDnsSettingsRequest(proto.Message): r"""Request for the ``ConfigureDnsSettings`` method. - Attributes: registration (str): Required. The name of the ``Registration`` whose DNS @@ -720,18 +666,16 @@ class ConfigureDnsSettingsRequest(proto.Message): updating the DNS settings. """ - registration = proto.Field(proto.STRING, number=1) - + registration = proto.Field(proto.STRING, number=1,) dns_settings = proto.Field(proto.MESSAGE, number=2, message="DnsSettings",) - - update_mask = proto.Field(proto.MESSAGE, number=3, message=field_mask.FieldMask,) - - validate_only = proto.Field(proto.BOOL, number=4) + update_mask = proto.Field( + proto.MESSAGE, number=3, message=field_mask_pb2.FieldMask, + ) + validate_only = proto.Field(proto.BOOL, number=4,) class ConfigureContactSettingsRequest(proto.Message): r"""Request for the ``ConfigureContactSettings`` method. - Attributes: registration (str): Required. The name of the ``Registration`` whose contact @@ -753,44 +697,39 @@ class ConfigureContactSettingsRequest(proto.Message): updating the contact settings. """ - registration = proto.Field(proto.STRING, number=1) - + registration = proto.Field(proto.STRING, number=1,) contact_settings = proto.Field(proto.MESSAGE, number=2, message="ContactSettings",) - - update_mask = proto.Field(proto.MESSAGE, number=3, message=field_mask.FieldMask,) - + update_mask = proto.Field( + proto.MESSAGE, number=3, message=field_mask_pb2.FieldMask, + ) contact_notices = proto.RepeatedField(proto.ENUM, number=4, enum="ContactNotice",) - - validate_only = proto.Field(proto.BOOL, number=5) + validate_only = proto.Field(proto.BOOL, number=5,) class ExportRegistrationRequest(proto.Message): r"""Request for the ``ExportRegistration`` method. - Attributes: name (str): Required. The name of the ``Registration`` to export, in the format ``projects/*/locations/*/registrations/*``. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class DeleteRegistrationRequest(proto.Message): r"""Request for the ``DeleteRegistration`` method. - Attributes: name (str): Required. The name of the ``Registration`` to delete, in the format ``projects/*/locations/*/registrations/*``. """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class RetrieveAuthorizationCodeRequest(proto.Message): r"""Request for the ``RetrieveAuthorizationCode`` method. - Attributes: registration (str): Required. The name of the ``Registration`` whose @@ -798,12 +737,11 @@ class RetrieveAuthorizationCodeRequest(proto.Message): ``projects/*/locations/*/registrations/*``. """ - registration = proto.Field(proto.STRING, number=1) + registration = proto.Field(proto.STRING, number=1,) class ResetAuthorizationCodeRequest(proto.Message): r"""Request for the ``ResetAuthorizationCode`` method. - Attributes: registration (str): Required. The name of the ``Registration`` whose @@ -811,12 +749,11 @@ class ResetAuthorizationCodeRequest(proto.Message): ``projects/*/locations/*/registrations/*``. """ - registration = proto.Field(proto.STRING, number=1) + registration = proto.Field(proto.STRING, number=1,) class RegisterParameters(proto.Message): r"""Parameters required to register a new domain. - Attributes: domain_name (str): The domain name. Unicode domain names are @@ -845,22 +782,17 @@ class Availability(proto.Enum): UNSUPPORTED = 3 UNKNOWN = 4 - domain_name = proto.Field(proto.STRING, number=1) - + domain_name = proto.Field(proto.STRING, number=1,) availability = proto.Field(proto.ENUM, number=2, enum=Availability,) - supported_privacy = proto.RepeatedField( proto.ENUM, number=3, enum="ContactPrivacy", ) - domain_notices = proto.RepeatedField(proto.ENUM, number=4, enum="DomainNotice",) - - yearly_price = proto.Field(proto.MESSAGE, number=5, message=money.Money,) + yearly_price = proto.Field(proto.MESSAGE, number=5, message=money_pb2.Money,) class AuthorizationCode(proto.Message): r"""Defines an authorization code. - Attributes: code (str): The Authorization Code in ASCII. It can be @@ -868,7 +800,7 @@ class AuthorizationCode(proto.Message): registrar. """ - code = proto.Field(proto.STRING, number=1) + code = proto.Field(proto.STRING, number=1,) class OperationMetadata(proto.Message): @@ -892,17 +824,12 @@ class OperationMetadata(proto.Message): API version used to start the 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) - - status_detail = proto.Field(proto.STRING, 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,) + status_detail = proto.Field(proto.STRING, number=5,) + api_version = proto.Field(proto.STRING, number=6,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/scripts/fixup_domains_v1beta1_keywords.py b/scripts/fixup_domains_v1beta1_keywords.py index 84e801c..d1ade46 100644 --- a/scripts/fixup_domains_v1beta1_keywords.py +++ b/scripts/fixup_domains_v1beta1_keywords.py @@ -1,6 +1,5 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import argparse import os import libcst as cst @@ -41,20 +39,19 @@ def partition( class domainsCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'configure_contact_settings': ('registration', 'update_mask', 'contact_settings', 'contact_notices', 'validate_only', ), - 'configure_dns_settings': ('registration', 'update_mask', 'dns_settings', 'validate_only', ), - 'configure_management_settings': ('registration', 'update_mask', 'management_settings', ), - 'delete_registration': ('name', ), - 'export_registration': ('name', ), - 'get_registration': ('name', ), - 'list_registrations': ('parent', 'page_size', 'page_token', 'filter', ), - 'register_domain': ('parent', 'registration', 'yearly_price', 'domain_notices', 'contact_notices', 'validate_only', ), - 'reset_authorization_code': ('registration', ), - 'retrieve_authorization_code': ('registration', ), - 'retrieve_register_parameters': ('domain_name', 'location', ), - 'search_domains': ('query', 'location', ), - 'update_registration': ('update_mask', 'registration', ), - + 'configure_contact_settings': ('registration', 'update_mask', 'contact_settings', 'contact_notices', 'validate_only', ), + 'configure_dns_settings': ('registration', 'update_mask', 'dns_settings', 'validate_only', ), + 'configure_management_settings': ('registration', 'update_mask', 'management_settings', ), + 'delete_registration': ('name', ), + 'export_registration': ('name', ), + 'get_registration': ('name', ), + 'list_registrations': ('parent', 'page_size', 'page_token', 'filter', ), + 'register_domain': ('parent', 'registration', 'yearly_price', 'domain_notices', 'contact_notices', 'validate_only', ), + 'reset_authorization_code': ('registration', ), + 'retrieve_authorization_code': ('registration', ), + 'retrieve_register_parameters': ('domain_name', 'location', ), + 'search_domains': ('query', 'location', ), + 'update_registration': ('update_mask', 'registration', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: @@ -85,7 +82,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/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/domains_v1beta1/__init__.py b/tests/unit/gapic/domains_v1beta1/__init__.py index 42ffdf2..4de6597 100644 --- a/tests/unit/gapic/domains_v1beta1/__init__.py +++ b/tests/unit/gapic/domains_v1beta1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/tests/unit/gapic/domains_v1beta1/test_domains.py b/tests/unit/gapic/domains_v1beta1/test_domains.py index d8e036f..7e1092f 100644 --- a/tests/unit/gapic/domains_v1beta1/test_domains.py +++ b/tests/unit/gapic/domains_v1beta1/test_domains.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,28 +23,58 @@ 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.domains_v1beta1.services.domains import DomainsAsyncClient from google.cloud.domains_v1beta1.services.domains import DomainsClient from google.cloud.domains_v1beta1.services.domains import pagers from google.cloud.domains_v1beta1.services.domains import transports +from google.cloud.domains_v1beta1.services.domains.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.domains_v1beta1.services.domains.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.domains_v1beta1.types import domains 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.type import money_pb2 as money # type: ignore -from google.type import postal_address_pb2 as postal_address # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +from google.type import money_pb2 # type: ignore +from google.type import postal_address_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(): @@ -88,7 +117,7 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize("client_class", [DomainsClient, DomainsAsyncClient,]) def test_domains_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: @@ -103,7 +132,7 @@ def test_domains_client_from_service_account_info(client_class): @pytest.mark.parametrize("client_class", [DomainsClient, DomainsAsyncClient,]) def test_domains_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: @@ -146,7 +175,7 @@ def test_domains_client_get_transport_class(): def test_domains_client_client_options(client_class, transport_class, transport_name): # Check that if channel is provided we won't create a new one. with mock.patch.object(DomainsClient, "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() @@ -420,7 +449,7 @@ def test_search_domains( transport: str = "grpc", request_type=domains.SearchDomainsRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -431,17 +460,14 @@ def test_search_domains( with mock.patch.object(type(client.transport.search_domains), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = domains.SearchDomainsResponse() - response = client.search_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] == domains.SearchDomainsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, domains.SearchDomainsResponse) @@ -453,7 +479,7 @@ def test_search_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 = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -461,7 +487,6 @@ def test_search_domains_empty_call(): client.search_domains() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.SearchDomainsRequest() @@ -470,7 +495,7 @@ async def test_search_domains_async( transport: str = "grpc_asyncio", request_type=domains.SearchDomainsRequest ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -483,13 +508,11 @@ async def test_search_domains_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.SearchDomainsResponse() ) - response = await client.search_domains(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.SearchDomainsRequest() # Establish that the response is the type that we expect. @@ -502,17 +525,17 @@ async def test_search_domains_async_from_dict(): def test_search_domains_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(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 = domains.SearchDomainsRequest() + request.location = "location/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.search_domains), "__call__") as call: call.return_value = domains.SearchDomainsResponse() - client.search_domains(request) # Establish that the underlying gRPC stub method was called. @@ -527,11 +550,12 @@ def test_search_domains_field_headers(): @pytest.mark.asyncio async def test_search_domains_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(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 = domains.SearchDomainsRequest() + request.location = "location/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -539,7 +563,6 @@ async def test_search_domains_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.SearchDomainsResponse() ) - await client.search_domains(request) # Establish that the underlying gRPC stub method was called. @@ -553,13 +576,12 @@ async def test_search_domains_field_headers_async(): def test_search_domains_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.search_domains), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = domains.SearchDomainsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.search_domains( @@ -570,14 +592,12 @@ def test_search_domains_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].location == "location_value" - assert args[0].query == "query_value" def test_search_domains_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -591,7 +611,7 @@ def test_search_domains_flattened_error(): @pytest.mark.asyncio async def test_search_domains_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.search_domains), "__call__") as call: @@ -611,15 +631,13 @@ async def test_search_domains_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].location == "location_value" - assert args[0].query == "query_value" @pytest.mark.asyncio async def test_search_domains_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -635,7 +653,7 @@ def test_retrieve_register_parameters( transport: str = "grpc", request_type=domains.RetrieveRegisterParametersRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -648,17 +666,14 @@ def test_retrieve_register_parameters( ) as call: # Designate an appropriate return value for the call. call.return_value = domains.RetrieveRegisterParametersResponse() - response = client.retrieve_register_parameters(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.RetrieveRegisterParametersRequest() # Establish that the response is the type that we expect. - assert isinstance(response, domains.RetrieveRegisterParametersResponse) @@ -670,7 +685,7 @@ def test_retrieve_register_parameters_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 = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -680,7 +695,6 @@ def test_retrieve_register_parameters_empty_call(): client.retrieve_register_parameters() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.RetrieveRegisterParametersRequest() @@ -690,7 +704,7 @@ async def test_retrieve_register_parameters_async( request_type=domains.RetrieveRegisterParametersRequest, ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -705,13 +719,11 @@ async def test_retrieve_register_parameters_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.RetrieveRegisterParametersResponse() ) - response = await client.retrieve_register_parameters(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.RetrieveRegisterParametersRequest() # Establish that the response is the type that we expect. @@ -724,11 +736,12 @@ async def test_retrieve_register_parameters_async_from_dict(): def test_retrieve_register_parameters_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(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 = domains.RetrieveRegisterParametersRequest() + request.location = "location/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -736,7 +749,6 @@ def test_retrieve_register_parameters_field_headers(): type(client.transport.retrieve_register_parameters), "__call__" ) as call: call.return_value = domains.RetrieveRegisterParametersResponse() - client.retrieve_register_parameters(request) # Establish that the underlying gRPC stub method was called. @@ -751,11 +763,12 @@ def test_retrieve_register_parameters_field_headers(): @pytest.mark.asyncio async def test_retrieve_register_parameters_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(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 = domains.RetrieveRegisterParametersRequest() + request.location = "location/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -765,7 +778,6 @@ async def test_retrieve_register_parameters_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.RetrieveRegisterParametersResponse() ) - await client.retrieve_register_parameters(request) # Establish that the underlying gRPC stub method was called. @@ -779,7 +791,7 @@ async def test_retrieve_register_parameters_field_headers_async(): def test_retrieve_register_parameters_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -787,7 +799,6 @@ def test_retrieve_register_parameters_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = domains.RetrieveRegisterParametersResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.retrieve_register_parameters( @@ -798,14 +809,12 @@ def test_retrieve_register_parameters_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].location == "location_value" - assert args[0].domain_name == "domain_name_value" def test_retrieve_register_parameters_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -819,7 +828,7 @@ def test_retrieve_register_parameters_flattened_error(): @pytest.mark.asyncio async def test_retrieve_register_parameters_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -841,15 +850,13 @@ async def test_retrieve_register_parameters_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].location == "location_value" - assert args[0].domain_name == "domain_name_value" @pytest.mark.asyncio async def test_retrieve_register_parameters_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -865,7 +872,7 @@ def test_register_domain( transport: str = "grpc", request_type=domains.RegisterDomainRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -876,13 +883,11 @@ def test_register_domain( with mock.patch.object(type(client.transport.register_domain), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.register_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] == domains.RegisterDomainRequest() # Establish that the response is the type that we expect. @@ -897,7 +902,7 @@ def test_register_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 = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -905,7 +910,6 @@ def test_register_domain_empty_call(): client.register_domain() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.RegisterDomainRequest() @@ -914,7 +918,7 @@ async def test_register_domain_async( transport: str = "grpc_asyncio", request_type=domains.RegisterDomainRequest ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -927,13 +931,11 @@ async def test_register_domain_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.register_domain(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.RegisterDomainRequest() # Establish that the response is the type that we expect. @@ -946,17 +948,17 @@ async def test_register_domain_async_from_dict(): def test_register_domain_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(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 = domains.RegisterDomainRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.register_domain), "__call__") as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.register_domain(request) # Establish that the underlying gRPC stub method was called. @@ -971,11 +973,12 @@ def test_register_domain_field_headers(): @pytest.mark.asyncio async def test_register_domain_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(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 = domains.RegisterDomainRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -983,7 +986,6 @@ async def test_register_domain_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.register_domain(request) # Establish that the underlying gRPC stub method was called. @@ -997,35 +999,33 @@ async def test_register_domain_field_headers_async(): def test_register_domain_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.register_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.register_domain( parent="parent_value", registration=domains.Registration(name="name_value"), - yearly_price=money.Money(currency_code="currency_code_value"), + yearly_price=money_pb2.Money(currency_code="currency_code_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].parent == "parent_value" - assert args[0].registration == domains.Registration(name="name_value") - - assert args[0].yearly_price == money.Money(currency_code="currency_code_value") + assert args[0].yearly_price == money_pb2.Money( + currency_code="currency_code_value" + ) def test_register_domain_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1034,13 +1034,13 @@ def test_register_domain_flattened_error(): domains.RegisterDomainRequest(), parent="parent_value", registration=domains.Registration(name="name_value"), - yearly_price=money.Money(currency_code="currency_code_value"), + yearly_price=money_pb2.Money(currency_code="currency_code_value"), ) @pytest.mark.asyncio async def test_register_domain_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.register_domain), "__call__") as call: @@ -1055,24 +1055,23 @@ async def test_register_domain_flattened_async(): response = await client.register_domain( parent="parent_value", registration=domains.Registration(name="name_value"), - yearly_price=money.Money(currency_code="currency_code_value"), + yearly_price=money_pb2.Money(currency_code="currency_code_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].parent == "parent_value" - assert args[0].registration == domains.Registration(name="name_value") - - assert args[0].yearly_price == money.Money(currency_code="currency_code_value") + assert args[0].yearly_price == money_pb2.Money( + currency_code="currency_code_value" + ) @pytest.mark.asyncio async def test_register_domain_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1081,7 +1080,7 @@ async def test_register_domain_flattened_error_async(): domains.RegisterDomainRequest(), parent="parent_value", registration=domains.Registration(name="name_value"), - yearly_price=money.Money(currency_code="currency_code_value"), + yearly_price=money_pb2.Money(currency_code="currency_code_value"), ) @@ -1089,7 +1088,7 @@ def test_list_registrations( transport: str = "grpc", request_type=domains.ListRegistrationsRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1104,19 +1103,15 @@ def test_list_registrations( call.return_value = domains.ListRegistrationsResponse( next_page_token="next_page_token_value", ) - response = client.list_registrations(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.ListRegistrationsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListRegistrationsPager) - assert response.next_page_token == "next_page_token_value" @@ -1128,7 +1123,7 @@ def test_list_registrations_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 = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1138,7 +1133,6 @@ def test_list_registrations_empty_call(): client.list_registrations() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.ListRegistrationsRequest() @@ -1147,7 +1141,7 @@ async def test_list_registrations_async( transport: str = "grpc_asyncio", request_type=domains.ListRegistrationsRequest ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1162,18 +1156,15 @@ async def test_list_registrations_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.ListRegistrationsResponse(next_page_token="next_page_token_value",) ) - response = await client.list_registrations(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.ListRegistrationsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListRegistrationsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -1183,11 +1174,12 @@ async def test_list_registrations_async_from_dict(): def test_list_registrations_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(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 = domains.ListRegistrationsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1195,7 +1187,6 @@ def test_list_registrations_field_headers(): type(client.transport.list_registrations), "__call__" ) as call: call.return_value = domains.ListRegistrationsResponse() - client.list_registrations(request) # Establish that the underlying gRPC stub method was called. @@ -1210,11 +1201,12 @@ def test_list_registrations_field_headers(): @pytest.mark.asyncio async def test_list_registrations_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(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 = domains.ListRegistrationsRequest() + request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1224,7 +1216,6 @@ async def test_list_registrations_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.ListRegistrationsResponse() ) - await client.list_registrations(request) # Establish that the underlying gRPC stub method was called. @@ -1238,7 +1229,7 @@ async def test_list_registrations_field_headers_async(): def test_list_registrations_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1246,7 +1237,6 @@ def test_list_registrations_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = domains.ListRegistrationsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_registrations(parent="parent_value",) @@ -1255,12 +1245,11 @@ def test_list_registrations_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" def test_list_registrations_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1272,7 +1261,7 @@ def test_list_registrations_flattened_error(): @pytest.mark.asyncio async def test_list_registrations_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1292,13 +1281,12 @@ async def test_list_registrations_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_registrations_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1309,7 +1297,7 @@ async def test_list_registrations_flattened_error_async(): def test_list_registrations_pager(): - client = DomainsClient(credentials=credentials.AnonymousCredentials,) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1349,7 +1337,7 @@ def test_list_registrations_pager(): def test_list_registrations_pages(): - client = DomainsClient(credentials=credentials.AnonymousCredentials,) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1381,7 +1369,7 @@ def test_list_registrations_pages(): @pytest.mark.asyncio async def test_list_registrations_async_pager(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1420,7 +1408,7 @@ async def test_list_registrations_async_pager(): @pytest.mark.asyncio async def test_list_registrations_async_pages(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials,) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1458,7 +1446,7 @@ def test_get_registration( transport: str = "grpc", request_type=domains.GetRegistrationRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1475,27 +1463,19 @@ def test_get_registration( issues=[domains.Registration.Issue.CONTACT_SUPPORT], supported_privacy=[domains.ContactPrivacy.PUBLIC_CONTACT_DATA], ) - response = client.get_registration(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.GetRegistrationRequest() # Establish that the response is the type that we expect. - assert isinstance(response, domains.Registration) - assert response.name == "name_value" - assert response.domain_name == "domain_name_value" - assert response.state == domains.Registration.State.REGISTRATION_PENDING - assert response.issues == [domains.Registration.Issue.CONTACT_SUPPORT] - assert response.supported_privacy == [domains.ContactPrivacy.PUBLIC_CONTACT_DATA] @@ -1507,7 +1487,7 @@ def test_get_registration_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 = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1515,7 +1495,6 @@ def test_get_registration_empty_call(): client.get_registration() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.GetRegistrationRequest() @@ -1524,7 +1503,7 @@ async def test_get_registration_async( transport: str = "grpc_asyncio", request_type=domains.GetRegistrationRequest ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1543,26 +1522,19 @@ async def test_get_registration_async( supported_privacy=[domains.ContactPrivacy.PUBLIC_CONTACT_DATA], ) ) - response = await client.get_registration(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.GetRegistrationRequest() # Establish that the response is the type that we expect. assert isinstance(response, domains.Registration) - assert response.name == "name_value" - assert response.domain_name == "domain_name_value" - assert response.state == domains.Registration.State.REGISTRATION_PENDING - assert response.issues == [domains.Registration.Issue.CONTACT_SUPPORT] - assert response.supported_privacy == [domains.ContactPrivacy.PUBLIC_CONTACT_DATA] @@ -1572,17 +1544,17 @@ async def test_get_registration_async_from_dict(): def test_get_registration_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(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 = domains.GetRegistrationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_registration), "__call__") as call: call.return_value = domains.Registration() - client.get_registration(request) # Establish that the underlying gRPC stub method was called. @@ -1597,11 +1569,12 @@ def test_get_registration_field_headers(): @pytest.mark.asyncio async def test_get_registration_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(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 = domains.GetRegistrationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1609,7 +1582,6 @@ async def test_get_registration_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.Registration() ) - await client.get_registration(request) # Establish that the underlying gRPC stub method was called. @@ -1623,13 +1595,12 @@ async def test_get_registration_field_headers_async(): def test_get_registration_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_registration), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = domains.Registration() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_registration(name="name_value",) @@ -1638,12 +1609,11 @@ def test_get_registration_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_get_registration_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1655,7 +1625,7 @@ def test_get_registration_flattened_error(): @pytest.mark.asyncio async def test_get_registration_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_registration), "__call__") as call: @@ -1673,13 +1643,12 @@ async def test_get_registration_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_registration_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1693,7 +1662,7 @@ def test_update_registration( transport: str = "grpc", request_type=domains.UpdateRegistrationRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1706,13 +1675,11 @@ def test_update_registration( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.update_registration(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.UpdateRegistrationRequest() # Establish that the response is the type that we expect. @@ -1727,7 +1694,7 @@ def test_update_registration_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 = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1737,7 +1704,6 @@ def test_update_registration_empty_call(): client.update_registration() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.UpdateRegistrationRequest() @@ -1746,7 +1712,7 @@ async def test_update_registration_async( transport: str = "grpc_asyncio", request_type=domains.UpdateRegistrationRequest ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1761,13 +1727,11 @@ async def test_update_registration_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.update_registration(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.UpdateRegistrationRequest() # Establish that the response is the type that we expect. @@ -1780,11 +1744,12 @@ async def test_update_registration_async_from_dict(): def test_update_registration_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(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 = domains.UpdateRegistrationRequest() + request.registration.name = "registration.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1792,7 +1757,6 @@ def test_update_registration_field_headers(): type(client.transport.update_registration), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.update_registration(request) # Establish that the underlying gRPC stub method was called. @@ -1810,11 +1774,12 @@ def test_update_registration_field_headers(): @pytest.mark.asyncio async def test_update_registration_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(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 = domains.UpdateRegistrationRequest() + request.registration.name = "registration.name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -1824,7 +1789,6 @@ async def test_update_registration_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.update_registration(request) # Establish that the underlying gRPC stub method was called. @@ -1841,7 +1805,7 @@ async def test_update_registration_field_headers_async(): def test_update_registration_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1849,26 +1813,23 @@ def test_update_registration_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.update_registration( registration=domains.Registration(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].registration == domains.Registration(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_registration_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1876,13 +1837,13 @@ def test_update_registration_flattened_error(): client.update_registration( domains.UpdateRegistrationRequest(), registration=domains.Registration(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_registration_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1898,22 +1859,20 @@ async def test_update_registration_flattened_async(): # using the keyword arguments to the method. response = await client.update_registration( registration=domains.Registration(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].registration == domains.Registration(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_registration_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1921,7 +1880,7 @@ async def test_update_registration_flattened_error_async(): await client.update_registration( domains.UpdateRegistrationRequest(), registration=domains.Registration(name="name_value"), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -1929,7 +1888,7 @@ def test_configure_management_settings( transport: str = "grpc", request_type=domains.ConfigureManagementSettingsRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1942,13 +1901,11 @@ def test_configure_management_settings( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.configure_management_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.ConfigureManagementSettingsRequest() # Establish that the response is the type that we expect. @@ -1963,7 +1920,7 @@ def test_configure_management_settings_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 = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1973,7 +1930,6 @@ def test_configure_management_settings_empty_call(): client.configure_management_settings() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.ConfigureManagementSettingsRequest() @@ -1983,7 +1939,7 @@ async def test_configure_management_settings_async( request_type=domains.ConfigureManagementSettingsRequest, ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1998,13 +1954,11 @@ async def test_configure_management_settings_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.configure_management_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.ConfigureManagementSettingsRequest() # Establish that the response is the type that we expect. @@ -2017,11 +1971,12 @@ async def test_configure_management_settings_async_from_dict(): def test_configure_management_settings_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(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 = domains.ConfigureManagementSettingsRequest() + request.registration = "registration/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2029,7 +1984,6 @@ def test_configure_management_settings_field_headers(): type(client.transport.configure_management_settings), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.configure_management_settings(request) # Establish that the underlying gRPC stub method was called. @@ -2046,11 +2000,12 @@ def test_configure_management_settings_field_headers(): @pytest.mark.asyncio async def test_configure_management_settings_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(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 = domains.ConfigureManagementSettingsRequest() + request.registration = "registration/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2060,7 +2015,6 @@ async def test_configure_management_settings_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.configure_management_settings(request) # Establish that the underlying gRPC stub method was called. @@ -2076,7 +2030,7 @@ async def test_configure_management_settings_field_headers_async(): def test_configure_management_settings_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2084,7 +2038,6 @@ def test_configure_management_settings_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.configure_management_settings( @@ -2092,25 +2045,22 @@ def test_configure_management_settings_flattened(): management_settings=domains.ManagementSettings( renewal_method=domains.ManagementSettings.RenewalMethod.AUTOMATIC_RENEWAL ), - 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].registration == "registration_value" - assert args[0].management_settings == domains.ManagementSettings( renewal_method=domains.ManagementSettings.RenewalMethod.AUTOMATIC_RENEWAL ) - - 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_configure_management_settings_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2121,13 +2071,13 @@ def test_configure_management_settings_flattened_error(): management_settings=domains.ManagementSettings( renewal_method=domains.ManagementSettings.RenewalMethod.AUTOMATIC_RENEWAL ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_configure_management_settings_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2146,26 +2096,23 @@ async def test_configure_management_settings_flattened_async(): management_settings=domains.ManagementSettings( renewal_method=domains.ManagementSettings.RenewalMethod.AUTOMATIC_RENEWAL ), - 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].registration == "registration_value" - assert args[0].management_settings == domains.ManagementSettings( renewal_method=domains.ManagementSettings.RenewalMethod.AUTOMATIC_RENEWAL ) - - 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_configure_management_settings_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2176,7 +2123,7 @@ async def test_configure_management_settings_flattened_error_async(): management_settings=domains.ManagementSettings( renewal_method=domains.ManagementSettings.RenewalMethod.AUTOMATIC_RENEWAL ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -2184,7 +2131,7 @@ def test_configure_dns_settings( transport: str = "grpc", request_type=domains.ConfigureDnsSettingsRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2197,13 +2144,11 @@ def test_configure_dns_settings( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.configure_dns_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.ConfigureDnsSettingsRequest() # Establish that the response is the type that we expect. @@ -2218,7 +2163,7 @@ def test_configure_dns_settings_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 = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2228,7 +2173,6 @@ def test_configure_dns_settings_empty_call(): client.configure_dns_settings() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.ConfigureDnsSettingsRequest() @@ -2237,7 +2181,7 @@ async def test_configure_dns_settings_async( transport: str = "grpc_asyncio", request_type=domains.ConfigureDnsSettingsRequest ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2252,13 +2196,11 @@ async def test_configure_dns_settings_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.configure_dns_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.ConfigureDnsSettingsRequest() # Establish that the response is the type that we expect. @@ -2271,11 +2213,12 @@ async def test_configure_dns_settings_async_from_dict(): def test_configure_dns_settings_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(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 = domains.ConfigureDnsSettingsRequest() + request.registration = "registration/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2283,7 +2226,6 @@ def test_configure_dns_settings_field_headers(): type(client.transport.configure_dns_settings), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.configure_dns_settings(request) # Establish that the underlying gRPC stub method was called. @@ -2300,11 +2242,12 @@ def test_configure_dns_settings_field_headers(): @pytest.mark.asyncio async def test_configure_dns_settings_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(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 = domains.ConfigureDnsSettingsRequest() + request.registration = "registration/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2314,7 +2257,6 @@ async def test_configure_dns_settings_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.configure_dns_settings(request) # Establish that the underlying gRPC stub method was called. @@ -2330,7 +2272,7 @@ async def test_configure_dns_settings_field_headers_async(): def test_configure_dns_settings_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2338,7 +2280,6 @@ def test_configure_dns_settings_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.configure_dns_settings( @@ -2348,27 +2289,24 @@ def test_configure_dns_settings_flattened(): name_servers=["name_servers_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].registration == "registration_value" - assert args[0].dns_settings == domains.DnsSettings( custom_dns=domains.DnsSettings.CustomDns( name_servers=["name_servers_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_configure_dns_settings_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2381,13 +2319,13 @@ def test_configure_dns_settings_flattened_error(): name_servers=["name_servers_value"] ) ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_configure_dns_settings_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2408,28 +2346,25 @@ async def test_configure_dns_settings_flattened_async(): name_servers=["name_servers_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].registration == "registration_value" - assert args[0].dns_settings == domains.DnsSettings( custom_dns=domains.DnsSettings.CustomDns( name_servers=["name_servers_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_configure_dns_settings_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2442,7 +2377,7 @@ async def test_configure_dns_settings_flattened_error_async(): name_servers=["name_servers_value"] ) ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -2450,7 +2385,7 @@ def test_configure_contact_settings( transport: str = "grpc", request_type=domains.ConfigureContactSettingsRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2463,13 +2398,11 @@ def test_configure_contact_settings( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.configure_contact_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.ConfigureContactSettingsRequest() # Establish that the response is the type that we expect. @@ -2484,7 +2417,7 @@ def test_configure_contact_settings_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 = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2494,7 +2427,6 @@ def test_configure_contact_settings_empty_call(): client.configure_contact_settings() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.ConfigureContactSettingsRequest() @@ -2504,7 +2436,7 @@ async def test_configure_contact_settings_async( request_type=domains.ConfigureContactSettingsRequest, ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2519,13 +2451,11 @@ async def test_configure_contact_settings_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.configure_contact_settings(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.ConfigureContactSettingsRequest() # Establish that the response is the type that we expect. @@ -2538,11 +2468,12 @@ async def test_configure_contact_settings_async_from_dict(): def test_configure_contact_settings_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(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 = domains.ConfigureContactSettingsRequest() + request.registration = "registration/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2550,7 +2481,6 @@ def test_configure_contact_settings_field_headers(): type(client.transport.configure_contact_settings), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.configure_contact_settings(request) # Establish that the underlying gRPC stub method was called. @@ -2567,11 +2497,12 @@ def test_configure_contact_settings_field_headers(): @pytest.mark.asyncio async def test_configure_contact_settings_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(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 = domains.ConfigureContactSettingsRequest() + request.registration = "registration/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2581,7 +2512,6 @@ async def test_configure_contact_settings_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.configure_contact_settings(request) # Establish that the underlying gRPC stub method was called. @@ -2597,7 +2527,7 @@ async def test_configure_contact_settings_field_headers_async(): def test_configure_contact_settings_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2605,7 +2535,6 @@ def test_configure_contact_settings_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.configure_contact_settings( @@ -2613,25 +2542,22 @@ def test_configure_contact_settings_flattened(): contact_settings=domains.ContactSettings( privacy=domains.ContactPrivacy.PUBLIC_CONTACT_DATA ), - 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].registration == "registration_value" - assert args[0].contact_settings == domains.ContactSettings( privacy=domains.ContactPrivacy.PUBLIC_CONTACT_DATA ) - - 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_configure_contact_settings_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2642,13 +2568,13 @@ def test_configure_contact_settings_flattened_error(): contact_settings=domains.ContactSettings( privacy=domains.ContactPrivacy.PUBLIC_CONTACT_DATA ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @pytest.mark.asyncio async def test_configure_contact_settings_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2667,26 +2593,23 @@ async def test_configure_contact_settings_flattened_async(): contact_settings=domains.ContactSettings( privacy=domains.ContactPrivacy.PUBLIC_CONTACT_DATA ), - 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].registration == "registration_value" - assert args[0].contact_settings == domains.ContactSettings( privacy=domains.ContactPrivacy.PUBLIC_CONTACT_DATA ) - - 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_configure_contact_settings_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2697,7 +2620,7 @@ async def test_configure_contact_settings_flattened_error_async(): contact_settings=domains.ContactSettings( privacy=domains.ContactPrivacy.PUBLIC_CONTACT_DATA ), - update_mask=field_mask.FieldMask(paths=["paths_value"]), + update_mask=field_mask_pb2.FieldMask(paths=["paths_value"]), ) @@ -2705,7 +2628,7 @@ def test_export_registration( transport: str = "grpc", request_type=domains.ExportRegistrationRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2718,13 +2641,11 @@ def test_export_registration( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.export_registration(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.ExportRegistrationRequest() # Establish that the response is the type that we expect. @@ -2739,7 +2660,7 @@ def test_export_registration_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 = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2749,7 +2670,6 @@ def test_export_registration_empty_call(): client.export_registration() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.ExportRegistrationRequest() @@ -2758,7 +2678,7 @@ async def test_export_registration_async( transport: str = "grpc_asyncio", request_type=domains.ExportRegistrationRequest ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2773,13 +2693,11 @@ async def test_export_registration_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.export_registration(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.ExportRegistrationRequest() # Establish that the response is the type that we expect. @@ -2792,11 +2710,12 @@ async def test_export_registration_async_from_dict(): def test_export_registration_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(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 = domains.ExportRegistrationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2804,7 +2723,6 @@ def test_export_registration_field_headers(): type(client.transport.export_registration), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.export_registration(request) # Establish that the underlying gRPC stub method was called. @@ -2819,11 +2737,12 @@ def test_export_registration_field_headers(): @pytest.mark.asyncio async def test_export_registration_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(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 = domains.ExportRegistrationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -2833,7 +2752,6 @@ async def test_export_registration_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.export_registration(request) # Establish that the underlying gRPC stub method was called. @@ -2847,7 +2765,7 @@ async def test_export_registration_field_headers_async(): def test_export_registration_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2855,7 +2773,6 @@ def test_export_registration_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.export_registration(name="name_value",) @@ -2864,12 +2781,11 @@ def test_export_registration_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_export_registration_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2881,7 +2797,7 @@ def test_export_registration_flattened_error(): @pytest.mark.asyncio async def test_export_registration_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2901,13 +2817,12 @@ async def test_export_registration_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_export_registration_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2921,7 +2836,7 @@ def test_delete_registration( transport: str = "grpc", request_type=domains.DeleteRegistrationRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2934,13 +2849,11 @@ def test_delete_registration( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.delete_registration(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.DeleteRegistrationRequest() # Establish that the response is the type that we expect. @@ -2955,7 +2868,7 @@ def test_delete_registration_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 = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2965,7 +2878,6 @@ def test_delete_registration_empty_call(): client.delete_registration() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.DeleteRegistrationRequest() @@ -2974,7 +2886,7 @@ async def test_delete_registration_async( transport: str = "grpc_asyncio", request_type=domains.DeleteRegistrationRequest ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2989,13 +2901,11 @@ async def test_delete_registration_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.delete_registration(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.DeleteRegistrationRequest() # Establish that the response is the type that we expect. @@ -3008,11 +2918,12 @@ async def test_delete_registration_async_from_dict(): def test_delete_registration_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(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 = domains.DeleteRegistrationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3020,7 +2931,6 @@ def test_delete_registration_field_headers(): type(client.transport.delete_registration), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") - client.delete_registration(request) # Establish that the underlying gRPC stub method was called. @@ -3035,11 +2945,12 @@ def test_delete_registration_field_headers(): @pytest.mark.asyncio async def test_delete_registration_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(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 = domains.DeleteRegistrationRequest() + request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3049,7 +2960,6 @@ async def test_delete_registration_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") ) - await client.delete_registration(request) # Establish that the underlying gRPC stub method was called. @@ -3063,7 +2973,7 @@ async def test_delete_registration_field_headers_async(): def test_delete_registration_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3071,7 +2981,6 @@ def test_delete_registration_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.delete_registration(name="name_value",) @@ -3080,12 +2989,11 @@ def test_delete_registration_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" def test_delete_registration_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3097,7 +3005,7 @@ def test_delete_registration_flattened_error(): @pytest.mark.asyncio async def test_delete_registration_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3117,13 +3025,12 @@ async def test_delete_registration_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_registration_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3137,7 +3044,7 @@ def test_retrieve_authorization_code( transport: str = "grpc", request_type=domains.RetrieveAuthorizationCodeRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3150,19 +3057,15 @@ def test_retrieve_authorization_code( ) as call: # Designate an appropriate return value for the call. call.return_value = domains.AuthorizationCode(code="code_value",) - response = client.retrieve_authorization_code(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.RetrieveAuthorizationCodeRequest() # Establish that the response is the type that we expect. - assert isinstance(response, domains.AuthorizationCode) - assert response.code == "code_value" @@ -3174,7 +3077,7 @@ def test_retrieve_authorization_code_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 = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3184,7 +3087,6 @@ def test_retrieve_authorization_code_empty_call(): client.retrieve_authorization_code() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.RetrieveAuthorizationCodeRequest() @@ -3194,7 +3096,7 @@ async def test_retrieve_authorization_code_async( request_type=domains.RetrieveAuthorizationCodeRequest, ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3209,18 +3111,15 @@ async def test_retrieve_authorization_code_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.AuthorizationCode(code="code_value",) ) - response = await client.retrieve_authorization_code(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.RetrieveAuthorizationCodeRequest() # Establish that the response is the type that we expect. assert isinstance(response, domains.AuthorizationCode) - assert response.code == "code_value" @@ -3230,11 +3129,12 @@ async def test_retrieve_authorization_code_async_from_dict(): def test_retrieve_authorization_code_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(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 = domains.RetrieveAuthorizationCodeRequest() + request.registration = "registration/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3242,7 +3142,6 @@ def test_retrieve_authorization_code_field_headers(): type(client.transport.retrieve_authorization_code), "__call__" ) as call: call.return_value = domains.AuthorizationCode() - client.retrieve_authorization_code(request) # Establish that the underlying gRPC stub method was called. @@ -3259,11 +3158,12 @@ def test_retrieve_authorization_code_field_headers(): @pytest.mark.asyncio async def test_retrieve_authorization_code_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(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 = domains.RetrieveAuthorizationCodeRequest() + request.registration = "registration/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3273,7 +3173,6 @@ async def test_retrieve_authorization_code_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.AuthorizationCode() ) - await client.retrieve_authorization_code(request) # Establish that the underlying gRPC stub method was called. @@ -3289,7 +3188,7 @@ async def test_retrieve_authorization_code_field_headers_async(): def test_retrieve_authorization_code_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3297,7 +3196,6 @@ def test_retrieve_authorization_code_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = domains.AuthorizationCode() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.retrieve_authorization_code(registration="registration_value",) @@ -3306,12 +3204,11 @@ def test_retrieve_authorization_code_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].registration == "registration_value" def test_retrieve_authorization_code_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3324,7 +3221,7 @@ def test_retrieve_authorization_code_flattened_error(): @pytest.mark.asyncio async def test_retrieve_authorization_code_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3346,13 +3243,12 @@ async def test_retrieve_authorization_code_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].registration == "registration_value" @pytest.mark.asyncio async def test_retrieve_authorization_code_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3367,7 +3263,7 @@ def test_reset_authorization_code( transport: str = "grpc", request_type=domains.ResetAuthorizationCodeRequest ): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3380,19 +3276,15 @@ def test_reset_authorization_code( ) as call: # Designate an appropriate return value for the call. call.return_value = domains.AuthorizationCode(code="code_value",) - response = client.reset_authorization_code(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == domains.ResetAuthorizationCodeRequest() # Establish that the response is the type that we expect. - assert isinstance(response, domains.AuthorizationCode) - assert response.code == "code_value" @@ -3404,7 +3296,7 @@ def test_reset_authorization_code_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 = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3414,7 +3306,6 @@ def test_reset_authorization_code_empty_call(): client.reset_authorization_code() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == domains.ResetAuthorizationCodeRequest() @@ -3423,7 +3314,7 @@ async def test_reset_authorization_code_async( transport: str = "grpc_asyncio", request_type=domains.ResetAuthorizationCodeRequest ): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3438,18 +3329,15 @@ async def test_reset_authorization_code_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.AuthorizationCode(code="code_value",) ) - response = await client.reset_authorization_code(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == domains.ResetAuthorizationCodeRequest() # Establish that the response is the type that we expect. assert isinstance(response, domains.AuthorizationCode) - assert response.code == "code_value" @@ -3459,11 +3347,12 @@ async def test_reset_authorization_code_async_from_dict(): def test_reset_authorization_code_field_headers(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(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 = domains.ResetAuthorizationCodeRequest() + request.registration = "registration/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3471,7 +3360,6 @@ def test_reset_authorization_code_field_headers(): type(client.transport.reset_authorization_code), "__call__" ) as call: call.return_value = domains.AuthorizationCode() - client.reset_authorization_code(request) # Establish that the underlying gRPC stub method was called. @@ -3488,11 +3376,12 @@ def test_reset_authorization_code_field_headers(): @pytest.mark.asyncio async def test_reset_authorization_code_field_headers_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(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 = domains.ResetAuthorizationCodeRequest() + request.registration = "registration/value" # Mock the actual call within the gRPC stub, and fake the request. @@ -3502,7 +3391,6 @@ async def test_reset_authorization_code_field_headers_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( domains.AuthorizationCode() ) - await client.reset_authorization_code(request) # Establish that the underlying gRPC stub method was called. @@ -3518,7 +3406,7 @@ async def test_reset_authorization_code_field_headers_async(): def test_reset_authorization_code_flattened(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3526,7 +3414,6 @@ def test_reset_authorization_code_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = domains.AuthorizationCode() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.reset_authorization_code(registration="registration_value",) @@ -3535,12 +3422,11 @@ def test_reset_authorization_code_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].registration == "registration_value" def test_reset_authorization_code_flattened_error(): - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3552,7 +3438,7 @@ def test_reset_authorization_code_flattened_error(): @pytest.mark.asyncio async def test_reset_authorization_code_flattened_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3574,13 +3460,12 @@ async def test_reset_authorization_code_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].registration == "registration_value" @pytest.mark.asyncio async def test_reset_authorization_code_flattened_error_async(): - client = DomainsAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3593,16 +3478,16 @@ async def test_reset_authorization_code_flattened_error_async(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.DomainsGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = DomainsClient( - 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.DomainsGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = DomainsClient( @@ -3612,7 +3497,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.DomainsGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = DomainsClient( @@ -3623,7 +3508,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.DomainsGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = DomainsClient(transport=transport) assert client.transport is transport @@ -3632,13 +3517,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.DomainsGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.DomainsGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -3650,23 +3535,23 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = DomainsClient(credentials=credentials.AnonymousCredentials(),) + client = DomainsClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.DomainsGrpcTransport,) def test_domains_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.DomainsTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -3678,7 +3563,7 @@ def test_domains_base_transport(): ) as Transport: Transport.return_value = None transport = transports.DomainsTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -3708,15 +3593,37 @@ def test_domains_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_domains_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.domains_v1beta1.services.domains.transports.DomainsTransport._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.DomainsTransport( + 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_domains_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.domains_v1beta1.services.domains.transports.DomainsTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.DomainsTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -3729,19 +3636,33 @@ def test_domains_base_transport_with_credentials_file(): def test_domains_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.domains_v1beta1.services.domains.transports.DomainsTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.DomainsTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_domains_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) + DomainsClient() + 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_domains_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) DomainsClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -3749,26 +3670,152 @@ def test_domains_auth_adc(): ) -def test_domains_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [transports.DomainsGrpcTransport, transports.DomainsGrpcAsyncIOTransport,], +) +@requires_google_auth_gte_1_25_0 +def test_domains_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.DomainsGrpcTransport( - 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.DomainsGrpcTransport, transports.DomainsGrpcAsyncIOTransport,], +) +@requires_google_auth_lt_1_25_0 +def test_domains_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.DomainsGrpcTransport, grpc_helpers), + (transports.DomainsGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_domains_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( + "domains.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="domains.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.DomainsGrpcTransport, grpc_helpers), + (transports.DomainsGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_domains_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( + "domains.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.DomainsGrpcTransport, grpc_helpers), + (transports.DomainsGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_domains_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( + "domains.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", [transports.DomainsGrpcTransport, transports.DomainsGrpcAsyncIOTransport], ) def test_domains_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: @@ -3807,7 +3854,7 @@ def test_domains_grpc_transport_client_cert_source_for_mtls(transport_class): def test_domains_host_no_port(): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="domains.googleapis.com" ), @@ -3817,7 +3864,7 @@ def test_domains_host_no_port(): def test_domains_host_with_port(): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="domains.googleapis.com:8000" ), @@ -3868,9 +3915,9 @@ def test_domains_transport_channel_mtls_with_client_cert_source(transport_class) 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", @@ -3943,7 +3990,7 @@ def test_domains_transport_channel_mtls_with_adc(transport_class): def test_domains_grpc_lro_client(): client = DomainsClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -3956,7 +4003,7 @@ def test_domains_grpc_lro_client(): def test_domains_grpc_lro_async_client(): client = DomainsAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -3971,7 +4018,6 @@ def test_registration_path(): project = "squid" location = "clam" registration = "whelk" - expected = "projects/{project}/locations/{location}/registrations/{registration}".format( project=project, location=location, registration=registration, ) @@ -3994,7 +4040,6 @@ def test_parse_registration_path(): def test_common_billing_account_path(): billing_account = "cuttlefish" - expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -4015,7 +4060,6 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "winkle" - expected = "folders/{folder}".format(folder=folder,) actual = DomainsClient.common_folder_path(folder) assert expected == actual @@ -4034,7 +4078,6 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "scallop" - expected = "organizations/{organization}".format(organization=organization,) actual = DomainsClient.common_organization_path(organization) assert expected == actual @@ -4053,7 +4096,6 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "squid" - expected = "projects/{project}".format(project=project,) actual = DomainsClient.common_project_path(project) assert expected == actual @@ -4073,7 +4115,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, ) @@ -4100,7 +4141,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.DomainsTransport, "_prep_wrapped_messages" ) as prep: client = DomainsClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -4109,6 +4150,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = DomainsClient.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) From b621826298eb4001c8ddd202ebcc318a9a4746dc Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sun, 16 May 2021 11:24:01 +0000 Subject: [PATCH 13/27] chore: new owl bot post processor docker image (#26) gcr.io/repo-automation-bots/owlbot-python:latest@sha256:4c981a6b6f2b8914a448d7b3a01688365be03e3ed26dfee399a6aa77fb112eaa --- .github/.OwlBot.lock.yaml | 5 ++--- .pre-commit-config.yaml | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index d49860b..864c176 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,4 +1,3 @@ docker: - digest: sha256:457583330eec64daa02aeb7a72a04d33e7be2428f646671ce4045dcbc0191b1e - image: gcr.io/repo-automation-bots/owlbot-python:latest - + image: gcr.io/repo-automation-bots/owlbot-python:latest + digest: sha256:4c981a6b6f2b8914a448d7b3a01688365be03e3ed26dfee399a6aa77fb112eaa diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1bbd787..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.9.1 + rev: 3.9.2 hooks: - id: flake8 From 15e7d566bb72e7ce36908da00955c504fc20dda8 Mon Sep 17 00:00:00 2001 From: "google-cloud-policy-bot[bot]" <80869356+google-cloud-policy-bot[bot]@users.noreply.github.com> Date: Sun, 16 May 2021 11:30:02 +0000 Subject: [PATCH 14/27] chore: add SECURITY.md (#18) chore: add SECURITY.md --- SECURITY.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 SECURITY.md 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. From 6766142d6c091556fde4dfda89eddbdc7c22c8a1 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sat, 22 May 2021 09:30:05 +0000 Subject: [PATCH 15/27] chore: new owl bot post processor docker image (#27) gcr.io/repo-automation-bots/owlbot-python:latest@sha256:3c3a445b3ddc99ccd5d31edc4b4519729635d20693900db32c4f587ed51f7479 --- .github/.OwlBot.lock.yaml | 2 +- noxfile.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 864c176..46e3f02 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/repo-automation-bots/owlbot-python:latest - digest: sha256:4c981a6b6f2b8914a448d7b3a01688365be03e3ed26dfee399a6aa77fb112eaa + digest: sha256:3c3a445b3ddc99ccd5d31edc4b4519729635d20693900db32c4f587ed51f7479 diff --git a/noxfile.py b/noxfile.py index 1d45cad..94ee6a8 100644 --- a/noxfile.py +++ b/noxfile.py @@ -179,7 +179,7 @@ def docs(session): """Build the docs for this library.""" session.install("-e", ".") - session.install("sphinx", "alabaster", "recommonmark") + session.install("sphinx==4.0.1", "alabaster", "recommonmark") shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) session.run( @@ -201,7 +201,9 @@ def docfx(session): """Build the docfx yaml files for this library.""" session.install("-e", ".") - session.install("sphinx", "alabaster", "recommonmark", "gcp-sphinx-docfx-yaml") + session.install( + "sphinx==4.0.1", "alabaster", "recommonmark", "gcp-sphinx-docfx-yaml" + ) shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) session.run( From d671dcf0a94435e97132e09c5d6730770a818bf8 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 27 May 2021 19:10:01 +0000 Subject: [PATCH 16/27] chore: new owl bot post processor docker image (#28) gcr.io/repo-automation-bots/owlbot-python:latest@sha256:0856ca711da1fd5ec9d6d7da6c50aa0bbf550fb94acb47b55159a640791987bf --- .github/.OwlBot.lock.yaml | 2 +- docs/multiprocessing.rst | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 46e3f02..127c2cd 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/repo-automation-bots/owlbot-python:latest - digest: sha256:3c3a445b3ddc99ccd5d31edc4b4519729635d20693900db32c4f587ed51f7479 + digest: sha256:0856ca711da1fd5ec9d6d7da6c50aa0bbf550fb94acb47b55159a640791987bf diff --git a/docs/multiprocessing.rst b/docs/multiprocessing.rst index 1cb29d4..536d17b 100644 --- a/docs/multiprocessing.rst +++ b/docs/multiprocessing.rst @@ -1,7 +1,7 @@ .. note:: - Because this client uses :mod:`grpcio` library, it is safe to + Because this client uses :mod:`grpc` library, it is safe to share instances across threads. In multiprocessing scenarios, the best practice is to create client instances *after* the invocation of - :func:`os.fork` by :class:`multiprocessing.Pool` or + :func:`os.fork` by :class:`multiprocessing.pool.Pool` or :class:`multiprocessing.Process`. From 0176399f1c98996150ec12e39c3abd329e1c575b Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 28 May 2021 11:52:02 +0000 Subject: [PATCH 17/27] chore: new owl bot post processor docker image (#29) Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:c66ba3c8d7bc8566f47df841f98cd0097b28fff0b1864c86f5817f4c8c3e8600 --- .github/.OwlBot.lock.yaml | 2 +- docs/conf.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 127c2cd..4ef4414 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/repo-automation-bots/owlbot-python:latest - digest: sha256:0856ca711da1fd5ec9d6d7da6c50aa0bbf550fb94acb47b55159a640791987bf + digest: sha256:c66ba3c8d7bc8566f47df841f98cd0097b28fff0b1864c86f5817f4c8c3e8600 \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 5c31a89..4ccf5e1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -363,6 +363,7 @@ "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), "grpc": ("https://grpc.github.io/grpc/python/", None), "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), + "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), } From 20ebc4790a7ed3c0013b6ce2fa0baea760ac6b51 Mon Sep 17 00:00:00 2001 From: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Date: Tue, 15 Jun 2021 18:52:19 -0600 Subject: [PATCH 18/27] fix: exclude docs and tests from package (#30) Only include packages that start with google in the published artifact --- setup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d9144a6..6bdb5d9 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,11 @@ author_email="googleapis-packages@google.com", license="Apache 2.0", url="https://github.com/googleapis/python-domains", - packages=setuptools.PEP420PackageFinder.find(), + packages=[ + package + for package in setuptools.PEP420PackageFinder.find() + if package.startswith("google") + ], include_package_data=True, install_requires=( "google-api-core[grpc] >= 1.22.2, < 2.0.0dev", From 942b7dadaac43081a937eb993725d670df7519e4 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Wed, 16 Jun 2021 11:08:02 -0400 Subject: [PATCH 19/27] fix(deps): add packaging requirement (#31) --- setup.py | 1 + testing/constraints-3.6.txt | 2 ++ 2 files changed, 3 insertions(+) diff --git a/setup.py b/setup.py index 6bdb5d9..54a5a37 100644 --- a/setup.py +++ b/setup.py @@ -45,6 +45,7 @@ install_requires=( "google-api-core[grpc] >= 1.22.2, < 2.0.0dev", "proto-plus >= 1.4.0", + "packaging >= 14.3", ), python_requires=">=3.6", classifiers=[ diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index 650f2c5..27906e5 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -21,3 +21,5 @@ # Then this file should have foo==1.14.0 google-api-core==1.22.2 proto-plus==1.4.0 +packaging==14.3 +google-auth==1.24.0 # TODO: remove when google-auth>=1.25.0 is required through google-api-core From f52bd05436ec7192b85c78d983708d3def629006 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 17 Jun 2021 10:54:06 +0000 Subject: [PATCH 20/27] chore: new owl bot post processor docker image (#32) Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:58c7342b0bccf85028100adaa3d856cb4a871c22ca9c01960d996e66c40548ce --- .github/.OwlBot.lock.yaml | 2 +- docs/conf.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 4ef4414..ea06d39 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/repo-automation-bots/owlbot-python:latest - digest: sha256:c66ba3c8d7bc8566f47df841f98cd0097b28fff0b1864c86f5817f4c8c3e8600 \ No newline at end of file + digest: sha256:58c7342b0bccf85028100adaa3d856cb4a871c22ca9c01960d996e66c40548ce diff --git a/docs/conf.py b/docs/conf.py index 4ccf5e1..1a2b3ae 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -80,9 +80,9 @@ master_doc = "index" # General information about the project. -project = u"google-cloud-domains" -copyright = u"2019, Google" -author = u"Google APIs" +project = "google-cloud-domains" +copyright = "2019, Google" +author = "Google APIs" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -281,7 +281,7 @@ ( master_doc, "google-cloud-domains.tex", - u"google-cloud-domains Documentation", + "google-cloud-domains Documentation", author, "manual", ) @@ -316,7 +316,7 @@ ( master_doc, "google-cloud-domains", - u"google-cloud-domains Documentation", + "google-cloud-domains Documentation", [author], 1, ) @@ -335,7 +335,7 @@ ( master_doc, "google-cloud-domains", - u"google-cloud-domains Documentation", + "google-cloud-domains Documentation", author, "google-cloud-domains", "google-cloud-domains Library", From 5b9e3d5bacf94fda61f06a35125f80683f3ac7d7 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sat, 19 Jun 2021 01:38:24 +0000 Subject: [PATCH 21/27] docs: omit mention of Python 2.7 in 'CONTRIBUTING.rst' (#1127) (#33) Closes #1126 Source-Link: https://github.com/googleapis/synthtool/commit/b91f129527853d5b756146a0b5044481fb4e09a8 Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:b6169fc6a5207b11800a7c002d0c5c2bc6d82697185ca12e666f44031468cfcd --- .github/.OwlBot.lock.yaml | 2 +- CONTRIBUTING.rst | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index ea06d39..cc49c6a 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/repo-automation-bots/owlbot-python:latest - digest: sha256:58c7342b0bccf85028100adaa3d856cb4a871c22ca9c01960d996e66c40548ce + digest: sha256:b6169fc6a5207b11800a7c002d0c5c2bc6d82697185ca12e666f44031468cfcd diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 5047131..704c3ef 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -69,7 +69,6 @@ We use `nox `__ to instrument our tests. - To test your changes, run unit tests with ``nox``:: - $ nox -s unit-2.7 $ nox -s unit-3.8 $ ... @@ -144,7 +143,6 @@ Running System Tests # Run all system tests $ nox -s system-3.8 - $ nox -s system-2.7 # Run a single system test $ nox -s system-3.8 -- -k @@ -152,9 +150,8 @@ Running System Tests .. note:: - System tests are only configured to run under Python 2.7 and - Python 3.8. For expediency, we do not run them in older versions - of Python 3. + System tests are only configured to run under Python 3.8. + For expediency, we do not run them in older versions of Python 3. This alone will not run the tests. You'll need to change some local auth settings and change some configuration in your project to From f95975f5e7c074f1be2d0a92bb50bc3acd8fb7c0 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sun, 20 Jun 2021 14:04:02 +0000 Subject: [PATCH 22/27] chore: update precommit hook pre-commit/pre-commit-hooks to v4 (#1083) (#34) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [pre-commit/pre-commit-hooks](https://togithub.com/pre-commit/pre-commit-hooks) | repository | major | `v3.4.0` -> `v4.0.1` | --- ### Release Notes
pre-commit/pre-commit-hooks ### [`v4.0.1`](https://togithub.com/pre-commit/pre-commit-hooks/releases/v4.0.1) [Compare Source](https://togithub.com/pre-commit/pre-commit-hooks/compare/v4.0.0...v4.0.1) ##### Fixes - `check-shebang-scripts-are-executable` fix entry point. - [#​602](https://togithub.com/pre-commit/pre-commit-hooks/issues/602) issue by [@​Person-93](https://togithub.com/Person-93). - [#​603](https://togithub.com/pre-commit/pre-commit-hooks/issues/603) PR by [@​scop](https://togithub.com/scop). ### [`v4.0.0`](https://togithub.com/pre-commit/pre-commit-hooks/releases/v4.0.0) [Compare Source](https://togithub.com/pre-commit/pre-commit-hooks/compare/v3.4.0...v4.0.0) ##### Features - `check-json`: report duplicate keys. - [#​558](https://togithub.com/pre-commit/pre-commit-hooks/issues/558) PR by [@​AdityaKhursale](https://togithub.com/AdityaKhursale). - [#​554](https://togithub.com/pre-commit/pre-commit-hooks/issues/554) issue by [@​adamchainz](https://togithub.com/adamchainz). - `no-commit-to-branch`: add `main` to default blocked branches. - [#​565](https://togithub.com/pre-commit/pre-commit-hooks/issues/565) PR by [@​ndevenish](https://togithub.com/ndevenish). - `check-case-conflict`: check conflicts in directory names as well. - [#​575](https://togithub.com/pre-commit/pre-commit-hooks/issues/575) PR by [@​slsyy](https://togithub.com/slsyy). - [#​70](https://togithub.com/pre-commit/pre-commit-hooks/issues/70) issue by [@​andyjack](https://togithub.com/andyjack). - `check-vcs-permalinks`: forbid other branch names. - [#​582](https://togithub.com/pre-commit/pre-commit-hooks/issues/582) PR by [@​jack1142](https://togithub.com/jack1142). - [#​581](https://togithub.com/pre-commit/pre-commit-hooks/issues/581) issue by [@​jack1142](https://togithub.com/jack1142). - `check-shebang-scripts-are-executable`: new hook which ensures shebang'd scripts are executable. - [#​545](https://togithub.com/pre-commit/pre-commit-hooks/issues/545) PR by [@​scop](https://togithub.com/scop). ##### Fixes - `check-executables-have-shebangs`: Short circuit shebang lookup on windows. - [#​544](https://togithub.com/pre-commit/pre-commit-hooks/issues/544) PR by [@​scop](https://togithub.com/scop). - `requirements-txt-fixer`: Fix comments which have indentation - [#​549](https://togithub.com/pre-commit/pre-commit-hooks/issues/549) PR by [@​greshilov](https://togithub.com/greshilov). - [#​548](https://togithub.com/pre-commit/pre-commit-hooks/issues/548) issue by [@​greshilov](https://togithub.com/greshilov). - `pretty-format-json`: write to stdout using UTF-8 encoding. - [#​571](https://togithub.com/pre-commit/pre-commit-hooks/issues/571) PR by [@​jack1142](https://togithub.com/jack1142). - [#​570](https://togithub.com/pre-commit/pre-commit-hooks/issues/570) issue by [@​jack1142](https://togithub.com/jack1142). - Use more inclusive language. - [#​599](https://togithub.com/pre-commit/pre-commit-hooks/issues/599) PR by [@​asottile](https://togithub.com/asottile). ##### Breaking changes - Remove deprecated hooks: `flake8`, `pyflakes`, `autopep8-wrapper`. - [#​597](https://togithub.com/pre-commit/pre-commit-hooks/issues/597) PR by [@​asottile](https://togithub.com/asottile).
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻️ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/synthtool). Source-Link: https://github.com/googleapis/synthtool/commit/333fd90856f1454380514bc59fc0936cdaf1c202 Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:b8c131c558606d3cea6e18f8e87befbd448c1482319b0db3c5d5388fa6ea72e3 --- .github/.OwlBot.lock.yaml | 2 +- .pre-commit-config.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index cc49c6a..9602d54 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/repo-automation-bots/owlbot-python:latest - digest: sha256:b6169fc6a5207b11800a7c002d0c5c2bc6d82697185ca12e666f44031468cfcd + digest: sha256:b8c131c558606d3cea6e18f8e87befbd448c1482319b0db3c5d5388fa6ea72e3 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4f00c7c..62eb5a7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.4.0 + rev: v4.0.1 hooks: - id: trailing-whitespace - id: end-of-file-fixer From 472c9a79c4bd105ca7a1c8d5dae8cf9fc6dc9f7c Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 22 Jun 2021 19:36:12 +0000 Subject: [PATCH 23/27] chore: add kokoro 3.9 config templates (#1128) (#35) Source-Link: https://github.com/googleapis/synthtool/commit/b0eb8a8b30b46a3c98d23c23107acb748c6601a1 Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:df50e8d462f86d6bcb42f27ecad55bb12c404f1c65de9c6fe4c4d25120080bd6 --- .github/.OwlBot.lock.yaml | 2 +- .kokoro/samples/python3.9/common.cfg | 40 +++++++++++++++++++++ .kokoro/samples/python3.9/continuous.cfg | 6 ++++ .kokoro/samples/python3.9/periodic-head.cfg | 11 ++++++ .kokoro/samples/python3.9/periodic.cfg | 6 ++++ .kokoro/samples/python3.9/presubmit.cfg | 6 ++++ 6 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 .kokoro/samples/python3.9/common.cfg create mode 100644 .kokoro/samples/python3.9/continuous.cfg create mode 100644 .kokoro/samples/python3.9/periodic-head.cfg create mode 100644 .kokoro/samples/python3.9/periodic.cfg create mode 100644 .kokoro/samples/python3.9/presubmit.cfg diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 9602d54..0954585 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/repo-automation-bots/owlbot-python:latest - digest: sha256:b8c131c558606d3cea6e18f8e87befbd448c1482319b0db3c5d5388fa6ea72e3 + digest: sha256:df50e8d462f86d6bcb42f27ecad55bb12c404f1c65de9c6fe4c4d25120080bd6 diff --git a/.kokoro/samples/python3.9/common.cfg b/.kokoro/samples/python3.9/common.cfg new file mode 100644 index 0000000..6926c86 --- /dev/null +++ b/.kokoro/samples/python3.9/common.cfg @@ -0,0 +1,40 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Specify which tests to run +env_vars: { + key: "RUN_TESTS_SESSION" + value: "py-3.9" +} + +# Declare build specific Cloud project. +env_vars: { + key: "BUILD_SPECIFIC_GCLOUD_PROJECT" + value: "python-docs-samples-tests-py39" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/python-domains/.kokoro/test-samples.sh" +} + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker" +} + +# Download secrets for samples +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples" + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "python-domains/.kokoro/trampoline.sh" \ No newline at end of file diff --git a/.kokoro/samples/python3.9/continuous.cfg b/.kokoro/samples/python3.9/continuous.cfg new file mode 100644 index 0000000..a1c8d97 --- /dev/null +++ b/.kokoro/samples/python3.9/continuous.cfg @@ -0,0 +1,6 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "True" +} \ No newline at end of file diff --git a/.kokoro/samples/python3.9/periodic-head.cfg b/.kokoro/samples/python3.9/periodic-head.cfg new file mode 100644 index 0000000..f9cfcd3 --- /dev/null +++ b/.kokoro/samples/python3.9/periodic-head.cfg @@ -0,0 +1,11 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "True" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/python-pubsub/.kokoro/test-samples-against-head.sh" +} diff --git a/.kokoro/samples/python3.9/periodic.cfg b/.kokoro/samples/python3.9/periodic.cfg new file mode 100644 index 0000000..50fec96 --- /dev/null +++ b/.kokoro/samples/python3.9/periodic.cfg @@ -0,0 +1,6 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "False" +} \ No newline at end of file diff --git a/.kokoro/samples/python3.9/presubmit.cfg b/.kokoro/samples/python3.9/presubmit.cfg new file mode 100644 index 0000000..a1c8d97 --- /dev/null +++ b/.kokoro/samples/python3.9/presubmit.cfg @@ -0,0 +1,6 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "True" +} \ No newline at end of file From a7d16704d5682c3fb17c7f0354a688871b1ba298 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 25 Jun 2021 10:14:58 -0600 Subject: [PATCH 24/27] feat: add always_use_jwt_access (#36) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: remove all monolith Bazel deps chore: release gapic-generator-csharp v1.3.7 chore: release gapic-generator-go 0.20.5 chore: release gapic-generator-java 1.0.14 chore: release gapic-generator-php 1.0.1 chore: release gapic-generator-python 0.50.0 chore: update gapic-generator-ruby to the latest commit chore: release gapic-generator-typescript 1.5.0 Committer: @miraleung PiperOrigin-RevId: 380641501 Source-Link: https://github.com/googleapis/googleapis/commit/076f7e9f0b258bdb54338895d7251b202e8f0de3 Source-Link: https://github.com/googleapis/googleapis-gen/commit/27e4c88b4048e5f56508d4e1aa417d60a3380892 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/master/packages/owl-bot/README.md * fix: require google-api-core>=1.26.0 * fix: fix typo in setup.py Co-authored-by: Owl Bot Co-authored-by: Bu Sun Kim Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> --- .coveragerc | 1 - .../services/domains/transports/base.py | 40 +++----- .../services/domains/transports/grpc.py | 7 +- .../domains/transports/grpc_asyncio.py | 7 +- setup.py | 2 +- testing/constraints-3.6.txt | 2 +- .../gapic/domains_v1beta1/test_domains.py | 98 +++---------------- 7 files changed, 37 insertions(+), 120 deletions(-) diff --git a/.coveragerc b/.coveragerc index 14ba4a3..88f3701 100644 --- a/.coveragerc +++ b/.coveragerc @@ -2,7 +2,6 @@ branch = True [report] -fail_under = 100 show_missing = True omit = google/cloud/domains/__init__.py diff --git a/google/cloud/domains_v1beta1/services/domains/transports/base.py b/google/cloud/domains_v1beta1/services/domains/transports/base.py index 11e66a5..a38fbd3 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/base.py +++ b/google/cloud/domains_v1beta1/services/domains/transports/base.py @@ -25,6 +25,7 @@ from google.api_core import retry as retries # type: ignore from google.api_core import operations_v1 # type: ignore from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore from google.cloud.domains_v1beta1.types import domains from google.longrunning import operations_pb2 # type: ignore @@ -45,8 +46,6 @@ except pkg_resources.DistributionNotFound: # pragma: NO COVER _GOOGLE_AUTH_VERSION = None -_API_CORE_VERSION = google.api_core.__version__ - class DomainsTransport(abc.ABC): """Abstract transport class for Domains.""" @@ -64,6 +63,7 @@ def __init__( scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, **kwargs, ) -> None: """Instantiate the transport. @@ -87,6 +87,8 @@ def __init__( API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. """ # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: @@ -115,13 +117,20 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) + # If the credentials is service account credentials, then always try to use self signed JWT. + if ( + always_use_jwt_access + and isinstance(credentials, service_account.Credentials) + and hasattr(service_account.Credentials, "with_always_use_jwt_access") + ): + credentials = credentials.with_always_use_jwt_access(True) + # Save the credentials. self._credentials = credentials - # TODO(busunkim): These two class methods are in the base transport + # TODO(busunkim): This method is in the base transport # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-api-core - # and google-auth are increased. + # should be deleted once the minimum required versions of google-auth is increased. # TODO: Remove this function once google-auth >= 1.25.0 is required @classmethod @@ -142,27 +151,6 @@ def _get_scopes_kwargs( 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. self._wrapped_methods = { diff --git a/google/cloud/domains_v1beta1/services/domains/transports/grpc.py b/google/cloud/domains_v1beta1/services/domains/transports/grpc.py index f6700ca..7365e31 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/grpc.py +++ b/google/cloud/domains_v1beta1/services/domains/transports/grpc.py @@ -153,6 +153,7 @@ def __init__( scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, + always_use_jwt_access=True, ) if not self._grpc_channel: @@ -208,14 +209,14 @@ def create_channel( and ``credentials_file`` are passed. """ - self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) - return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, quota_project_id=quota_project_id, - **self_signed_jwt_kwargs, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, **kwargs, ) diff --git a/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py b/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py index 8ef4a15..f2fa949 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py +++ b/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py @@ -81,14 +81,14 @@ def create_channel( aio.Channel: A gRPC AsyncIO channel object. """ - 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, quota_project_id=quota_project_id, - **self_signed_jwt_kwargs, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, **kwargs, ) @@ -199,6 +199,7 @@ def __init__( scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, + always_use_jwt_access=True, ) if not self._grpc_channel: diff --git a/setup.py b/setup.py index 54a5a37..92a988c 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ ], include_package_data=True, install_requires=( - "google-api-core[grpc] >= 1.22.2, < 2.0.0dev", + "google-api-core[grpc] >= 1.26.0, <2.0.0dev", "proto-plus >= 1.4.0", "packaging >= 14.3", ), diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index 27906e5..22b1805 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -19,7 +19,7 @@ # # 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 +google-api-core==1.26.0 proto-plus==1.4.0 packaging==14.3 google-auth==1.24.0 # TODO: remove when google-auth>=1.25.0 is required through google-api-core diff --git a/tests/unit/gapic/domains_v1beta1/test_domains.py b/tests/unit/gapic/domains_v1beta1/test_domains.py index 7e1092f..8757a02 100644 --- a/tests/unit/gapic/domains_v1beta1/test_domains.py +++ b/tests/unit/gapic/domains_v1beta1/test_domains.py @@ -38,9 +38,6 @@ from google.cloud.domains_v1beta1.services.domains import DomainsClient from google.cloud.domains_v1beta1.services.domains import pagers from google.cloud.domains_v1beta1.services.domains import transports -from google.cloud.domains_v1beta1.services.domains.transports.base import ( - _API_CORE_VERSION, -) from google.cloud.domains_v1beta1.services.domains.transports.base import ( _GOOGLE_AUTH_VERSION, ) @@ -54,8 +51,9 @@ 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 +# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively +# through google-api-core: +# - Delete the auth "less than" test cases # - Delete these pytest markers (Make the "greater than or equal to" tests the default). requires_google_auth_lt_1_25_0 = pytest.mark.skipif( packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), @@ -66,16 +64,6 @@ 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(): return b"cert bytes", b"key bytes" @@ -130,6 +118,16 @@ def test_domains_client_from_service_account_info(client_class): assert client.transport._host == "domains.googleapis.com:443" +@pytest.mark.parametrize("client_class", [DomainsClient, DomainsAsyncClient,]) +def test_domains_client_service_account_always_use_jwt(client_class): + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + client = client_class(credentials=creds) + use_jwt.assert_called_with(True) + + @pytest.mark.parametrize("client_class", [DomainsClient, DomainsAsyncClient,]) def test_domains_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() @@ -3712,7 +3710,6 @@ def test_domains_transport_auth_adc_old_google_auth(transport_class): (transports.DomainsGrpcAsyncIOTransport, grpc_helpers_async), ], ) -@requires_api_core_gte_1_26_0 def test_domains_transport_create_channel(transport_class, grpc_helpers): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -3741,75 +3738,6 @@ def test_domains_transport_create_channel(transport_class, grpc_helpers): ) -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.DomainsGrpcTransport, grpc_helpers), - (transports.DomainsGrpcAsyncIOTransport, grpc_helpers_async), - ], -) -@requires_api_core_lt_1_26_0 -def test_domains_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( - "domains.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.DomainsGrpcTransport, grpc_helpers), - (transports.DomainsGrpcAsyncIOTransport, grpc_helpers_async), - ], -) -@requires_api_core_lt_1_26_0 -def test_domains_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( - "domains.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", [transports.DomainsGrpcTransport, transports.DomainsGrpcAsyncIOTransport], From bc64518043c26d62e38db0d438949426d7061325 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sat, 26 Jun 2021 11:38:10 +0000 Subject: [PATCH 25/27] chore(python): simplify nox steps in CONTRIBUTING.rst (#37) Source-Link: https://github.com/googleapis/synthtool/commit/26558bae8976a985d73c2d98c31d8612273f907d Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:99d90d097e4a4710cc8658ee0b5b963f4426d0e424819787c3ac1405c9a26719 --- .github/.OwlBot.lock.yaml | 2 +- CONTRIBUTING.rst | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 0954585..e2b39f9 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/repo-automation-bots/owlbot-python:latest - digest: sha256:df50e8d462f86d6bcb42f27ecad55bb12c404f1c65de9c6fe4c4d25120080bd6 + digest: sha256:99d90d097e4a4710cc8658ee0b5b963f4426d0e424819787c3ac1405c9a26719 diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 704c3ef..9ceed54 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -68,14 +68,12 @@ Using ``nox`` We use `nox `__ to instrument our tests. - To test your changes, run unit tests with ``nox``:: + $ nox -s unit - $ nox -s unit-3.8 - $ ... +- To run a single unit test:: -- Args to pytest can be passed through the nox command separated by a `--`. For - example, to run a single test:: + $ nox -s unit-3.9 -- -k - $ nox -s unit-3.8 -- -k .. note:: @@ -142,7 +140,7 @@ Running System Tests - To run system tests, you can execute:: # Run all system tests - $ nox -s system-3.8 + $ nox -s system # Run a single system test $ nox -s system-3.8 -- -k @@ -215,8 +213,8 @@ Supported versions can be found in our ``noxfile.py`` `config`_. .. _config: https://github.com/googleapis/python-domains/blob/master/noxfile.py -We also explicitly decided to support Python 3 beginning with version -3.6. Reasons for this include: +We also explicitly decided to support Python 3 beginning with version 3.6. +Reasons for this include: - Encouraging use of newest versions of Python 3 - Taking the lead of `prominent`_ open-source `projects`_ From 7830b846538d3331f76cc7ca41f80b3c6f13ae45 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 1 Jul 2021 02:18:09 +0000 Subject: [PATCH 26/27] fix: disable always_use_jwt_access (#39) Committer: @busunkim96 PiperOrigin-RevId: 382142900 Source-Link: https://github.com/googleapis/googleapis/commit/513440fda515f3c799c22a30e3906dcda325004e Source-Link: https://github.com/googleapis/googleapis-gen/commit/7b1e2c31233f79a704ec21ca410bf661d6bc68d0 --- .../services/domains/transports/base.py | 2 +- .../services/domains/transports/grpc.py | 5 +++- .../domains/transports/grpc_asyncio.py | 5 +++- .../gapic/domains_v1beta1/test_domains.py | 26 ++++++++++++++++--- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/google/cloud/domains_v1beta1/services/domains/transports/base.py b/google/cloud/domains_v1beta1/services/domains/transports/base.py index a38fbd3..0eaf586 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/base.py +++ b/google/cloud/domains_v1beta1/services/domains/transports/base.py @@ -98,7 +98,7 @@ def __init__( scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) # Save the scopes. - self._scopes = scopes or self.AUTH_SCOPES + self._scopes = scopes # If no credentials are provided, then determine the appropriate # defaults. diff --git a/google/cloud/domains_v1beta1/services/domains/transports/grpc.py b/google/cloud/domains_v1beta1/services/domains/transports/grpc.py index 7365e31..3fe57b7 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/grpc.py +++ b/google/cloud/domains_v1beta1/services/domains/transports/grpc.py @@ -60,6 +60,7 @@ def __init__( client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, ) -> None: """Instantiate the transport. @@ -100,6 +101,8 @@ def __init__( API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. Raises: google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport @@ -153,7 +156,7 @@ def __init__( scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, - always_use_jwt_access=True, + always_use_jwt_access=always_use_jwt_access, ) if not self._grpc_channel: diff --git a/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py b/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py index f2fa949..09fc1d4 100644 --- a/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py +++ b/google/cloud/domains_v1beta1/services/domains/transports/grpc_asyncio.py @@ -106,6 +106,7 @@ def __init__( client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, quota_project_id=None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, ) -> None: """Instantiate the transport. @@ -147,6 +148,8 @@ def __init__( API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. Raises: google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport @@ -199,7 +202,7 @@ def __init__( scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, - always_use_jwt_access=True, + always_use_jwt_access=always_use_jwt_access, ) if not self._grpc_channel: diff --git a/tests/unit/gapic/domains_v1beta1/test_domains.py b/tests/unit/gapic/domains_v1beta1/test_domains.py index 8757a02..5ce0a36 100644 --- a/tests/unit/gapic/domains_v1beta1/test_domains.py +++ b/tests/unit/gapic/domains_v1beta1/test_domains.py @@ -125,7 +125,25 @@ def test_domains_client_service_account_always_use_jwt(client_class): ) as use_jwt: creds = service_account.Credentials(None, None, None) client = client_class(credentials=creds) - use_jwt.assert_called_with(True) + use_jwt.assert_not_called() + + +@pytest.mark.parametrize( + "transport_class,transport_name", + [ + (transports.DomainsGrpcTransport, "grpc"), + (transports.DomainsGrpcAsyncIOTransport, "grpc_asyncio"), + ], +) +def test_domains_client_service_account_always_use_jwt_true( + transport_class, transport_name +): + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=True) + use_jwt.assert_called_once_with(True) @pytest.mark.parametrize("client_class", [DomainsClient, DomainsAsyncClient,]) @@ -3757,7 +3775,7 @@ def test_domains_grpc_transport_client_cert_source_for_mtls(transport_class): "squid.clam.whelk:443", credentials=cred, credentials_file=None, - scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, ssl_credentials=mock_ssl_channel_creds, quota_project_id=None, options=[ @@ -3861,7 +3879,7 @@ def test_domains_transport_channel_mtls_with_client_cert_source(transport_class) "mtls.squid.clam.whelk:443", credentials=cred, credentials_file=None, - scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, ssl_credentials=mock_ssl_cred, quota_project_id=None, options=[ @@ -3905,7 +3923,7 @@ def test_domains_transport_channel_mtls_with_adc(transport_class): "mtls.squid.clam.whelk:443", credentials=mock_cred, credentials_file=None, - scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, ssl_credentials=mock_ssl_cred, quota_project_id=None, options=[ From cd59ed75369c6c1c0707eea795399d5613ae8f10 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 12 Jul 2021 19:46:11 +0000 Subject: [PATCH 27/27] chore: release 0.2.0 (#25) :robot: I have created a release \*beep\* \*boop\* --- ## [0.2.0](https://www.github.com/googleapis/python-domains/compare/v0.1.0...v0.2.0) (2021-07-01) ### Features * add always_use_jwt_access ([#36](https://www.github.com/googleapis/python-domains/issues/36)) ([a7d1670](https://www.github.com/googleapis/python-domains/commit/a7d16704d5682c3fb17c7f0354a688871b1ba298)) * support self-signed JWT flow for service accounts ([4b24611](https://www.github.com/googleapis/python-domains/commit/4b246112d770cd4d4409b8a84a72f13713a59881)) ### Bug Fixes * add async client to %name_%version/init.py ([4b24611](https://www.github.com/googleapis/python-domains/commit/4b246112d770cd4d4409b8a84a72f13713a59881)) * **deps:** add packaging requirement ([#31](https://www.github.com/googleapis/python-domains/issues/31)) ([942b7da](https://www.github.com/googleapis/python-domains/commit/942b7dadaac43081a937eb993725d670df7519e4)) * disable always_use_jwt_access ([#39](https://www.github.com/googleapis/python-domains/issues/39)) ([7830b84](https://www.github.com/googleapis/python-domains/commit/7830b846538d3331f76cc7ca41f80b3c6f13ae45)) * exclude docs and tests from package ([#30](https://www.github.com/googleapis/python-domains/issues/30)) ([20ebc47](https://www.github.com/googleapis/python-domains/commit/20ebc4790a7ed3c0013b6ce2fa0baea760ac6b51)) ### Documentation * omit mention of Python 2.7 in 'CONTRIBUTING.rst' ([#1127](https://www.github.com/googleapis/python-domains/issues/1127)) ([#33](https://www.github.com/googleapis/python-domains/issues/33)) ([5b9e3d5](https://www.github.com/googleapis/python-domains/commit/5b9e3d5bacf94fda61f06a35125f80683f3ac7d7)), closes [#1126](https://www.github.com/googleapis/python-domains/issues/1126) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- CHANGELOG.md | 21 +++++++++++++++++++++ setup.py | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c076c23..56e5ddb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,26 @@ # Changelog +## [0.2.0](https://www.github.com/googleapis/python-domains/compare/v0.1.0...v0.2.0) (2021-07-01) + + +### Features + +* add always_use_jwt_access ([#36](https://www.github.com/googleapis/python-domains/issues/36)) ([a7d1670](https://www.github.com/googleapis/python-domains/commit/a7d16704d5682c3fb17c7f0354a688871b1ba298)) +* support self-signed JWT flow for service accounts ([4b24611](https://www.github.com/googleapis/python-domains/commit/4b246112d770cd4d4409b8a84a72f13713a59881)) + + +### Bug Fixes + +* add async client to %name_%version/init.py ([4b24611](https://www.github.com/googleapis/python-domains/commit/4b246112d770cd4d4409b8a84a72f13713a59881)) +* **deps:** add packaging requirement ([#31](https://www.github.com/googleapis/python-domains/issues/31)) ([942b7da](https://www.github.com/googleapis/python-domains/commit/942b7dadaac43081a937eb993725d670df7519e4)) +* disable always_use_jwt_access ([#39](https://www.github.com/googleapis/python-domains/issues/39)) ([7830b84](https://www.github.com/googleapis/python-domains/commit/7830b846538d3331f76cc7ca41f80b3c6f13ae45)) +* exclude docs and tests from package ([#30](https://www.github.com/googleapis/python-domains/issues/30)) ([20ebc47](https://www.github.com/googleapis/python-domains/commit/20ebc4790a7ed3c0013b6ce2fa0baea760ac6b51)) + + +### Documentation + +* omit mention of Python 2.7 in 'CONTRIBUTING.rst' ([#1127](https://www.github.com/googleapis/python-domains/issues/1127)) ([#33](https://www.github.com/googleapis/python-domains/issues/33)) ([5b9e3d5](https://www.github.com/googleapis/python-domains/commit/5b9e3d5bacf94fda61f06a35125f80683f3ac7d7)), closes [#1126](https://www.github.com/googleapis/python-domains/issues/1126) + ## 0.1.0 (2021-02-01) diff --git a/setup.py b/setup.py index 92a988c..163a43a 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ import os import setuptools # type: ignore -version = "0.1.0" +version = "0.2.0" package_root = os.path.abspath(os.path.dirname(__file__))