diff --git a/.flake8 b/.flake8 index 20fe9bd..ed93163 100644 --- a/.flake8 +++ b/.flake8 @@ -21,6 +21,8 @@ exclude = # Exclude generated code. **/proto/** **/gapic/** + **/services/** + **/types/** *_pb2.py # Standard linting exemptions. diff --git a/.gitignore b/.gitignore index 3fb06e0..b87e1ed 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ dist build eggs +.eggs parts bin var @@ -49,6 +50,7 @@ bigquery/docs/generated # Virtual environment env/ coverage.xml +sponge_log.xml # System test environment variables. system_tests/local_test_setup diff --git a/.kokoro/publish-docs.sh b/.kokoro/publish-docs.sh index c6dbfc6..8443de2 100755 --- a/.kokoro/publish-docs.sh +++ b/.kokoro/publish-docs.sh @@ -13,8 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -#!/bin/bash - set -eo pipefail # Disable buffering, so that the logs stream through. diff --git a/.kokoro/release.sh b/.kokoro/release.sh index 4bbc99a..6247293 100755 --- a/.kokoro/release.sh +++ b/.kokoro/release.sh @@ -13,8 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -#!/bin/bash - set -eo pipefail # Start the releasetool reporter diff --git a/.kokoro/samples/lint/common.cfg b/.kokoro/samples/lint/common.cfg new file mode 100644 index 0000000..2434791 --- /dev/null +++ b/.kokoro/samples/lint/common.cfg @@ -0,0 +1,34 @@ +# 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: "lint" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/python-iam/.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-iam/.kokoro/trampoline.sh" \ No newline at end of file diff --git a/.kokoro/samples/lint/continuous.cfg b/.kokoro/samples/lint/continuous.cfg new file mode 100644 index 0000000..a1c8d97 --- /dev/null +++ b/.kokoro/samples/lint/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/lint/periodic.cfg b/.kokoro/samples/lint/periodic.cfg new file mode 100644 index 0000000..50fec96 --- /dev/null +++ b/.kokoro/samples/lint/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/lint/presubmit.cfg b/.kokoro/samples/lint/presubmit.cfg new file mode 100644 index 0000000..a1c8d97 --- /dev/null +++ b/.kokoro/samples/lint/presubmit.cfg @@ -0,0 +1,6 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "True" +} \ No newline at end of file diff --git a/.kokoro/samples/python3.6/common.cfg b/.kokoro/samples/python3.6/common.cfg new file mode 100644 index 0000000..de558b5 --- /dev/null +++ b/.kokoro/samples/python3.6/common.cfg @@ -0,0 +1,34 @@ +# 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.6" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/python-iam/.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-iam/.kokoro/trampoline.sh" \ No newline at end of file diff --git a/.kokoro/samples/python3.6/continuous.cfg b/.kokoro/samples/python3.6/continuous.cfg new file mode 100644 index 0000000..7218af1 --- /dev/null +++ b/.kokoro/samples/python3.6/continuous.cfg @@ -0,0 +1,7 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "True" +} + diff --git a/.kokoro/samples/python3.6/periodic.cfg b/.kokoro/samples/python3.6/periodic.cfg new file mode 100644 index 0000000..50fec96 --- /dev/null +++ b/.kokoro/samples/python3.6/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.6/presubmit.cfg b/.kokoro/samples/python3.6/presubmit.cfg new file mode 100644 index 0000000..a1c8d97 --- /dev/null +++ b/.kokoro/samples/python3.6/presubmit.cfg @@ -0,0 +1,6 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "True" +} \ No newline at end of file diff --git a/.kokoro/samples/python3.7/common.cfg b/.kokoro/samples/python3.7/common.cfg new file mode 100644 index 0000000..594e2ba --- /dev/null +++ b/.kokoro/samples/python3.7/common.cfg @@ -0,0 +1,34 @@ +# 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.7" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/python-iam/.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-iam/.kokoro/trampoline.sh" \ No newline at end of file diff --git a/.kokoro/samples/python3.7/continuous.cfg b/.kokoro/samples/python3.7/continuous.cfg new file mode 100644 index 0000000..a1c8d97 --- /dev/null +++ b/.kokoro/samples/python3.7/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.7/periodic.cfg b/.kokoro/samples/python3.7/periodic.cfg new file mode 100644 index 0000000..50fec96 --- /dev/null +++ b/.kokoro/samples/python3.7/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.7/presubmit.cfg b/.kokoro/samples/python3.7/presubmit.cfg new file mode 100644 index 0000000..a1c8d97 --- /dev/null +++ b/.kokoro/samples/python3.7/presubmit.cfg @@ -0,0 +1,6 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "True" +} \ No newline at end of file diff --git a/.kokoro/samples/python3.8/common.cfg b/.kokoro/samples/python3.8/common.cfg new file mode 100644 index 0000000..2145f2b --- /dev/null +++ b/.kokoro/samples/python3.8/common.cfg @@ -0,0 +1,34 @@ +# 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.8" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/python-iam/.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-iam/.kokoro/trampoline.sh" \ No newline at end of file diff --git a/.kokoro/samples/python3.8/continuous.cfg b/.kokoro/samples/python3.8/continuous.cfg new file mode 100644 index 0000000..a1c8d97 --- /dev/null +++ b/.kokoro/samples/python3.8/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.8/periodic.cfg b/.kokoro/samples/python3.8/periodic.cfg new file mode 100644 index 0000000..50fec96 --- /dev/null +++ b/.kokoro/samples/python3.8/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.8/presubmit.cfg b/.kokoro/samples/python3.8/presubmit.cfg new file mode 100644 index 0000000..a1c8d97 --- /dev/null +++ b/.kokoro/samples/python3.8/presubmit.cfg @@ -0,0 +1,6 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "True" +} \ No newline at end of file diff --git a/.kokoro/test-samples.sh b/.kokoro/test-samples.sh new file mode 100755 index 0000000..b4b7b4a --- /dev/null +++ b/.kokoro/test-samples.sh @@ -0,0 +1,104 @@ +#!/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. + + +# `-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-iam + +# Run periodic samples tests at latest release +if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then + LATEST_RELEASE=$(git describe --abbrev=0 --tags) + git checkout $LATEST_RELEASE +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 Build Cop Bot. + # See https://github.com/googleapis/repo-automation-bots/tree/master/packages/buildcop. + if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then + chmod +x $KOKORO_GFILE_DIR/linux_amd64/buildcop + $KOKORO_GFILE_DIR/linux_amd64/buildcop + 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" \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in index 68855ab..e9e29d1 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -20,3 +20,6 @@ recursive-include google *.json *.proto 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 diff --git a/docs/conf.py b/docs/conf.py index 8a13782..3a43107 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -38,21 +38,18 @@ "sphinx.ext.napoleon", "sphinx.ext.todo", "sphinx.ext.viewcode", + "recommonmark", ] # autodoc/autosummary flags autoclass_content = "both" -autodoc_default_flags = ["members"] +autodoc_default_options = {"members": True} autosummary_generate = True # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] -# Allow markdown includes (so releases.md can include CHANGLEOG.md) -# http://www.sphinx-doc.org/en/master/markdown.html -source_parsers = {".md": "recommonmark.parser.CommonMarkParser"} - # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # source_suffix = ['.rst', '.md'] @@ -293,7 +290,7 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, "google-cloud-iam", u"google-cloud-iam Documentation", [author], 1) + (master_doc, "google-cloud-iam", u"google-cloud-iam Documentation", [author], 1,) ] # If true, show URL addresses after external links. @@ -334,7 +331,7 @@ intersphinx_mapping = { "python": ("http://python.readthedocs.org/en/latest/", None), "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None), + "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), "grpc": ("https://grpc.io/grpc/python/", None), } diff --git a/docs/index.rst b/docs/index.rst index 882915f..d895c74 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,5 +1,8 @@ .. include:: README.rst +.. include:: multiprocessing.rst + + API Reference ------------- .. toctree:: diff --git a/docs/multiprocessing.rst b/docs/multiprocessing.rst new file mode 100644 index 0000000..1cb29d4 --- /dev/null +++ b/docs/multiprocessing.rst @@ -0,0 +1,7 @@ +.. note:: + + Because this client uses :mod:`grpcio` 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 + :class:`multiprocessing.Process`. diff --git a/google/cloud/iam_credentials.py b/google/cloud/iam_credentials.py index ac6ae35..d3f7f63 100644 --- a/google/cloud/iam_credentials.py +++ b/google/cloud/iam_credentials.py @@ -21,4 +21,7 @@ from google.cloud.iam_credentials_v1 import types -__all__ = ("types", "IAMCredentialsClient") +__all__ = ( + "types", + "IAMCredentialsClient", +) diff --git a/google/cloud/iam_credentials_v1/__init__.py b/google/cloud/iam_credentials_v1/__init__.py index ba52c48..11c380f 100644 --- a/google/cloud/iam_credentials_v1/__init__.py +++ b/google/cloud/iam_credentials_v1/__init__.py @@ -25,8 +25,8 @@ if sys.version_info[:2] == (2, 7): message = ( - "A future version of this library will drop support for Python 2.7." - "More details about Python 2 support for Google Cloud Client Libraries" + "A future version of this library will drop support for Python 2.7. " + "More details about Python 2 support for Google Cloud Client Libraries " "can be found at https://cloud.google.com/python/docs/python2-sunset/" ) warnings.warn(message, DeprecationWarning) @@ -36,4 +36,7 @@ class IAMCredentialsClient(iam_credentials_client.IAMCredentialsClient): __doc__ = iam_credentials_client.IAMCredentialsClient.__doc__ -__all__ = ("types", "IAMCredentialsClient") +__all__ = ( + "types", + "IAMCredentialsClient", +) diff --git a/google/cloud/iam_credentials_v1/gapic/iam_credentials_client.py b/google/cloud/iam_credentials_v1/gapic/iam_credentials_client.py index 8581185..d4aacc7 100644 --- a/google/cloud/iam_credentials_v1/gapic/iam_credentials_client.py +++ b/google/cloud/iam_credentials_v1/gapic/iam_credentials_client.py @@ -38,7 +38,7 @@ from google.protobuf import duration_pb2 -_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution("google-cloud-iam").version +_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution("google-cloud-iam",).version class IAMCredentialsClient(object): @@ -177,12 +177,12 @@ def __init__( self.transport = transport else: self.transport = iam_credentials_grpc_transport.IamCredentialsGrpcTransport( - address=api_endpoint, channel=channel, credentials=credentials + address=api_endpoint, channel=channel, credentials=credentials, ) if client_info is None: client_info = google.api_core.gapic_v1.client_info.ClientInfo( - gapic_version=_GAPIC_LIBRARY_VERSION + gapic_version=_GAPIC_LIBRARY_VERSION, ) else: client_info.gapic_version = _GAPIC_LIBRARY_VERSION @@ -193,7 +193,7 @@ def __init__( # (Ordinarily, these are the defaults specified in the `*_config.py` # file next to this one.) self._method_configs = google.api_core.gapic_v1.config.parse_method_configs( - client_config["interfaces"][self._INTERFACE_NAME] + client_config["interfaces"][self._INTERFACE_NAME], ) # Save a dictionary of cached API call functions. @@ -287,7 +287,7 @@ def generate_access_token( ) request = common_pb2.GenerateAccessTokenRequest( - name=name, scope=scope, delegates=delegates, lifetime=lifetime + name=name, scope=scope, delegates=delegates, lifetime=lifetime, ) if metadata is None: metadata = [] @@ -350,8 +350,8 @@ def generate_id_token( ``projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}``. The ``-`` wildcard character is required; replacing it with a project ID is invalid. - include_email (bool): Include the service account email in the token. If set to ``true``, the - token will contain ``email`` and ``email_verified`` claims. + include_email (bool): Include the service account email in the token. If set to ``true``, + the token will contain ``email`` and ``email_verified`` claims. retry (Optional[google.api_core.retry.Retry]): A retry object used to retry requests. If ``None`` is specified, requests will be retried using a default configuration. @@ -478,7 +478,7 @@ def sign_blob( ) request = common_pb2.SignBlobRequest( - name=name, payload=payload, delegates=delegates + name=name, payload=payload, delegates=delegates, ) if metadata is None: metadata = [] @@ -570,7 +570,7 @@ def sign_jwt( ) request = common_pb2.SignJwtRequest( - name=name, payload=payload, delegates=delegates + name=name, payload=payload, delegates=delegates, ) if metadata is None: metadata = [] diff --git a/google/cloud/iam_credentials_v1/gapic/iam_credentials_client_config.py b/google/cloud/iam_credentials_v1/gapic/iam_credentials_client_config.py index 35c007c..5c4cbe1 100644 --- a/google/cloud/iam_credentials_v1/gapic/iam_credentials_client_config.py +++ b/google/cloud/iam_credentials_v1/gapic/iam_credentials_client_config.py @@ -2,40 +2,49 @@ "interfaces": { "google.iam.credentials.v1.IAMCredentials": { "retry_codes": { - "idempotent": ["DEADLINE_EXCEEDED", "UNAVAILABLE"], - "non_idempotent": [], + "retry_policy_1_codes": ["UNAVAILABLE", "DEADLINE_EXCEEDED"], + "no_retry_codes": [], }, "retry_params": { - "default": { + "retry_policy_1_params": { "initial_retry_delay_millis": 100, "retry_delay_multiplier": 1.3, "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 20000, + "initial_rpc_timeout_millis": 60000, "rpc_timeout_multiplier": 1.0, - "max_rpc_timeout_millis": 20000, - "total_timeout_millis": 600000, - } + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 60000, + }, + "no_retry_params": { + "initial_retry_delay_millis": 0, + "retry_delay_multiplier": 0.0, + "max_retry_delay_millis": 0, + "initial_rpc_timeout_millis": 0, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 0, + "total_timeout_millis": 0, + }, }, "methods": { "GenerateAccessToken": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params", }, "GenerateIdToken": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params", }, "SignBlob": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params", }, "SignJwt": { "timeout_millis": 60000, - "retry_codes_name": "idempotent", - "retry_params_name": "default", + "retry_codes_name": "retry_policy_1_codes", + "retry_params_name": "retry_policy_1_params", }, }, } diff --git a/google/cloud/iam_credentials_v1/gapic/transports/iam_credentials_grpc_transport.py b/google/cloud/iam_credentials_v1/gapic/transports/iam_credentials_grpc_transport.py index 39be27f..6363037 100644 --- a/google/cloud/iam_credentials_v1/gapic/transports/iam_credentials_grpc_transport.py +++ b/google/cloud/iam_credentials_v1/gapic/transports/iam_credentials_grpc_transport.py @@ -56,7 +56,7 @@ def __init__( # exception (channels come with credentials baked in already). if channel is not None and credentials is not None: raise ValueError( - "The `channel` and `credentials` arguments are mutually " "exclusive." + "The `channel` and `credentials` arguments are mutually " "exclusive.", ) # Create the channel. @@ -75,7 +75,7 @@ def __init__( # gRPC uses objects called "stubs" that are bound to the # channel and provide a basic method for each RPC. self._stubs = { - "iam_credentials_stub": iamcredentials_pb2_grpc.IAMCredentialsStub(channel) + "iam_credentials_stub": iamcredentials_pb2_grpc.IAMCredentialsStub(channel), } @classmethod diff --git a/google/cloud/iam_credentials_v1/proto/common_pb2.py b/google/cloud/iam_credentials_v1/proto/common_pb2.py index 0843861..417c55b 100644 --- a/google/cloud/iam_credentials_v1/proto/common_pb2.py +++ b/google/cloud/iam_credentials_v1/proto/common_pb2.py @@ -1,10 +1,7 @@ # -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/iam/credentials/v1/common.proto +# source: google/cloud/iam_credentials_v1/proto/common.proto -import sys - -_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) from google.protobuf import descriptor as _descriptor from google.protobuf import message as _message from google.protobuf import reflection as _reflection @@ -22,15 +19,12 @@ DESCRIPTOR = _descriptor.FileDescriptor( - name="google/iam/credentials/v1/common.proto", + name="google/cloud/iam_credentials_v1/proto/common.proto", package="google.iam.credentials.v1", syntax="proto3", - serialized_options=_b( - "\n#com.google.cloud.iam.credentials.v1B\031IAMCredentialsCommonProtoP\001ZDgoogle.golang.org/genproto/googleapis/iam/credentials/v1;credentials\370\001\001\352AY\n!iam.googleapis.com/ServiceAccount\0224projects/{project}/serviceAccounts/{service_account}" - ), - serialized_pb=_b( - '\n&google/iam/credentials/v1/common.proto\x12\x19google.iam.credentials.v1\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto"\xa9\x01\n\x1aGenerateAccessTokenRequest\x12\x37\n\x04name\x18\x01 \x01(\tB)\xe0\x41\x02\xfa\x41#\n!iam.googleapis.com/ServiceAccount\x12\x11\n\tdelegates\x18\x02 \x03(\t\x12\x12\n\x05scope\x18\x04 \x03(\tB\x03\xe0\x41\x02\x12+\n\x08lifetime\x18\x07 \x01(\x0b\x32\x19.google.protobuf.Duration"d\n\x1bGenerateAccessTokenResponse\x12\x14\n\x0c\x61\x63\x63\x65ss_token\x18\x01 \x01(\t\x12/\n\x0b\x65xpire_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"s\n\x0fSignBlobRequest\x12\x37\n\x04name\x18\x01 \x01(\tB)\xe0\x41\x02\xfa\x41#\n!iam.googleapis.com/ServiceAccount\x12\x11\n\tdelegates\x18\x03 \x03(\t\x12\x14\n\x07payload\x18\x05 \x01(\x0c\x42\x03\xe0\x41\x02"7\n\x10SignBlobResponse\x12\x0e\n\x06key_id\x18\x01 \x01(\t\x12\x13\n\x0bsigned_blob\x18\x04 \x01(\x0c"r\n\x0eSignJwtRequest\x12\x37\n\x04name\x18\x01 \x01(\tB)\xe0\x41\x02\xfa\x41#\n!iam.googleapis.com/ServiceAccount\x12\x11\n\tdelegates\x18\x03 \x03(\t\x12\x14\n\x07payload\x18\x05 \x01(\tB\x03\xe0\x41\x02"5\n\x0fSignJwtResponse\x12\x0e\n\x06key_id\x18\x01 \x01(\t\x12\x12\n\nsigned_jwt\x18\x02 \x01(\t"\x92\x01\n\x16GenerateIdTokenRequest\x12\x37\n\x04name\x18\x01 \x01(\tB)\xe0\x41\x02\xfa\x41#\n!iam.googleapis.com/ServiceAccount\x12\x11\n\tdelegates\x18\x02 \x03(\t\x12\x15\n\x08\x61udience\x18\x03 \x01(\tB\x03\xe0\x41\x02\x12\x15\n\rinclude_email\x18\x04 \x01(\x08"(\n\x17GenerateIdTokenResponse\x12\r\n\x05token\x18\x01 \x01(\tB\xe7\x01\n#com.google.cloud.iam.credentials.v1B\x19IAMCredentialsCommonProtoP\x01ZDgoogle.golang.org/genproto/googleapis/iam/credentials/v1;credentials\xf8\x01\x01\xea\x41Y\n!iam.googleapis.com/ServiceAccount\x12\x34projects/{project}/serviceAccounts/{service_account}b\x06proto3' - ), + serialized_options=b"\n#com.google.cloud.iam.credentials.v1B\031IAMCredentialsCommonProtoP\001ZDgoogle.golang.org/genproto/googleapis/iam/credentials/v1;credentials\370\001\001\352AY\n!iam.googleapis.com/ServiceAccount\0224projects/{project}/serviceAccounts/{service_account}", + create_key=_descriptor._internal_create_key, + serialized_pb=b'\n2google/cloud/iam_credentials_v1/proto/common.proto\x12\x19google.iam.credentials.v1\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto"\xa9\x01\n\x1aGenerateAccessTokenRequest\x12\x37\n\x04name\x18\x01 \x01(\tB)\xe0\x41\x02\xfa\x41#\n!iam.googleapis.com/ServiceAccount\x12\x11\n\tdelegates\x18\x02 \x03(\t\x12\x12\n\x05scope\x18\x04 \x03(\tB\x03\xe0\x41\x02\x12+\n\x08lifetime\x18\x07 \x01(\x0b\x32\x19.google.protobuf.Duration"d\n\x1bGenerateAccessTokenResponse\x12\x14\n\x0c\x61\x63\x63\x65ss_token\x18\x01 \x01(\t\x12/\n\x0b\x65xpire_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"s\n\x0fSignBlobRequest\x12\x37\n\x04name\x18\x01 \x01(\tB)\xe0\x41\x02\xfa\x41#\n!iam.googleapis.com/ServiceAccount\x12\x11\n\tdelegates\x18\x03 \x03(\t\x12\x14\n\x07payload\x18\x05 \x01(\x0c\x42\x03\xe0\x41\x02"7\n\x10SignBlobResponse\x12\x0e\n\x06key_id\x18\x01 \x01(\t\x12\x13\n\x0bsigned_blob\x18\x04 \x01(\x0c"r\n\x0eSignJwtRequest\x12\x37\n\x04name\x18\x01 \x01(\tB)\xe0\x41\x02\xfa\x41#\n!iam.googleapis.com/ServiceAccount\x12\x11\n\tdelegates\x18\x03 \x03(\t\x12\x14\n\x07payload\x18\x05 \x01(\tB\x03\xe0\x41\x02"5\n\x0fSignJwtResponse\x12\x0e\n\x06key_id\x18\x01 \x01(\t\x12\x12\n\nsigned_jwt\x18\x02 \x01(\t"\x92\x01\n\x16GenerateIdTokenRequest\x12\x37\n\x04name\x18\x01 \x01(\tB)\xe0\x41\x02\xfa\x41#\n!iam.googleapis.com/ServiceAccount\x12\x11\n\tdelegates\x18\x02 \x03(\t\x12\x15\n\x08\x61udience\x18\x03 \x01(\tB\x03\xe0\x41\x02\x12\x15\n\rinclude_email\x18\x04 \x01(\x08"(\n\x17GenerateIdTokenResponse\x12\r\n\x05token\x18\x01 \x01(\tB\xe7\x01\n#com.google.cloud.iam.credentials.v1B\x19IAMCredentialsCommonProtoP\x01ZDgoogle.golang.org/genproto/googleapis/iam/credentials/v1;credentials\xf8\x01\x01\xea\x41Y\n!iam.googleapis.com/ServiceAccount\x12\x34projects/{project}/serviceAccounts/{service_account}b\x06proto3', dependencies=[ google_dot_api_dot_field__behavior__pb2.DESCRIPTOR, google_dot_api_dot_resource__pb2.DESCRIPTOR, @@ -46,6 +40,7 @@ filename=None, file=DESCRIPTOR, containing_type=None, + create_key=_descriptor._internal_create_key, fields=[ _descriptor.FieldDescriptor( name="name", @@ -56,16 +51,15 @@ cpp_type=9, label=1, has_default_value=False, - default_value=_b("").decode("utf-8"), + default_value=b"".decode("utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - serialized_options=_b( - "\340A\002\372A#\n!iam.googleapis.com/ServiceAccount" - ), + serialized_options=b"\340A\002\372A#\n!iam.googleapis.com/ServiceAccount", file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, ), _descriptor.FieldDescriptor( name="delegates", @@ -84,6 +78,7 @@ extension_scope=None, serialized_options=None, file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, ), _descriptor.FieldDescriptor( name="scope", @@ -100,8 +95,9 @@ containing_type=None, is_extension=False, extension_scope=None, - serialized_options=_b("\340A\002"), + serialized_options=b"\340A\002", file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, ), _descriptor.FieldDescriptor( name="lifetime", @@ -120,6 +116,7 @@ extension_scope=None, serialized_options=None, file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, ), ], extensions=[], @@ -130,8 +127,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=195, - serialized_end=364, + serialized_start=207, + serialized_end=376, ) @@ -141,6 +138,7 @@ filename=None, file=DESCRIPTOR, containing_type=None, + create_key=_descriptor._internal_create_key, fields=[ _descriptor.FieldDescriptor( name="access_token", @@ -151,7 +149,7 @@ cpp_type=9, label=1, has_default_value=False, - default_value=_b("").decode("utf-8"), + default_value=b"".decode("utf-8"), message_type=None, enum_type=None, containing_type=None, @@ -159,6 +157,7 @@ extension_scope=None, serialized_options=None, file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, ), _descriptor.FieldDescriptor( name="expire_time", @@ -177,6 +176,7 @@ extension_scope=None, serialized_options=None, file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, ), ], extensions=[], @@ -187,8 +187,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=366, - serialized_end=466, + serialized_start=378, + serialized_end=478, ) @@ -198,6 +198,7 @@ filename=None, file=DESCRIPTOR, containing_type=None, + create_key=_descriptor._internal_create_key, fields=[ _descriptor.FieldDescriptor( name="name", @@ -208,16 +209,15 @@ cpp_type=9, label=1, has_default_value=False, - default_value=_b("").decode("utf-8"), + default_value=b"".decode("utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - serialized_options=_b( - "\340A\002\372A#\n!iam.googleapis.com/ServiceAccount" - ), + serialized_options=b"\340A\002\372A#\n!iam.googleapis.com/ServiceAccount", file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, ), _descriptor.FieldDescriptor( name="delegates", @@ -236,6 +236,7 @@ extension_scope=None, serialized_options=None, file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, ), _descriptor.FieldDescriptor( name="payload", @@ -246,14 +247,15 @@ cpp_type=9, label=1, has_default_value=False, - default_value=_b(""), + default_value=b"", message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - serialized_options=_b("\340A\002"), + serialized_options=b"\340A\002", file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, ), ], extensions=[], @@ -264,8 +266,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=468, - serialized_end=583, + serialized_start=480, + serialized_end=595, ) @@ -275,6 +277,7 @@ filename=None, file=DESCRIPTOR, containing_type=None, + create_key=_descriptor._internal_create_key, fields=[ _descriptor.FieldDescriptor( name="key_id", @@ -285,7 +288,7 @@ cpp_type=9, label=1, has_default_value=False, - default_value=_b("").decode("utf-8"), + default_value=b"".decode("utf-8"), message_type=None, enum_type=None, containing_type=None, @@ -293,6 +296,7 @@ extension_scope=None, serialized_options=None, file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, ), _descriptor.FieldDescriptor( name="signed_blob", @@ -303,7 +307,7 @@ cpp_type=9, label=1, has_default_value=False, - default_value=_b(""), + default_value=b"", message_type=None, enum_type=None, containing_type=None, @@ -311,6 +315,7 @@ extension_scope=None, serialized_options=None, file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, ), ], extensions=[], @@ -321,8 +326,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=585, - serialized_end=640, + serialized_start=597, + serialized_end=652, ) @@ -332,6 +337,7 @@ filename=None, file=DESCRIPTOR, containing_type=None, + create_key=_descriptor._internal_create_key, fields=[ _descriptor.FieldDescriptor( name="name", @@ -342,16 +348,15 @@ cpp_type=9, label=1, has_default_value=False, - default_value=_b("").decode("utf-8"), + default_value=b"".decode("utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - serialized_options=_b( - "\340A\002\372A#\n!iam.googleapis.com/ServiceAccount" - ), + serialized_options=b"\340A\002\372A#\n!iam.googleapis.com/ServiceAccount", file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, ), _descriptor.FieldDescriptor( name="delegates", @@ -370,6 +375,7 @@ extension_scope=None, serialized_options=None, file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, ), _descriptor.FieldDescriptor( name="payload", @@ -380,14 +386,15 @@ cpp_type=9, label=1, has_default_value=False, - default_value=_b("").decode("utf-8"), + default_value=b"".decode("utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - serialized_options=_b("\340A\002"), + serialized_options=b"\340A\002", file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, ), ], extensions=[], @@ -398,8 +405,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=642, - serialized_end=756, + serialized_start=654, + serialized_end=768, ) @@ -409,6 +416,7 @@ filename=None, file=DESCRIPTOR, containing_type=None, + create_key=_descriptor._internal_create_key, fields=[ _descriptor.FieldDescriptor( name="key_id", @@ -419,7 +427,7 @@ cpp_type=9, label=1, has_default_value=False, - default_value=_b("").decode("utf-8"), + default_value=b"".decode("utf-8"), message_type=None, enum_type=None, containing_type=None, @@ -427,6 +435,7 @@ extension_scope=None, serialized_options=None, file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, ), _descriptor.FieldDescriptor( name="signed_jwt", @@ -437,7 +446,7 @@ cpp_type=9, label=1, has_default_value=False, - default_value=_b("").decode("utf-8"), + default_value=b"".decode("utf-8"), message_type=None, enum_type=None, containing_type=None, @@ -445,6 +454,7 @@ extension_scope=None, serialized_options=None, file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, ), ], extensions=[], @@ -455,8 +465,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=758, - serialized_end=811, + serialized_start=770, + serialized_end=823, ) @@ -466,6 +476,7 @@ filename=None, file=DESCRIPTOR, containing_type=None, + create_key=_descriptor._internal_create_key, fields=[ _descriptor.FieldDescriptor( name="name", @@ -476,16 +487,15 @@ cpp_type=9, label=1, has_default_value=False, - default_value=_b("").decode("utf-8"), + default_value=b"".decode("utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - serialized_options=_b( - "\340A\002\372A#\n!iam.googleapis.com/ServiceAccount" - ), + serialized_options=b"\340A\002\372A#\n!iam.googleapis.com/ServiceAccount", file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, ), _descriptor.FieldDescriptor( name="delegates", @@ -504,6 +514,7 @@ extension_scope=None, serialized_options=None, file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, ), _descriptor.FieldDescriptor( name="audience", @@ -514,14 +525,15 @@ cpp_type=9, label=1, has_default_value=False, - default_value=_b("").decode("utf-8"), + default_value=b"".decode("utf-8"), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - serialized_options=_b("\340A\002"), + serialized_options=b"\340A\002", file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, ), _descriptor.FieldDescriptor( name="include_email", @@ -540,6 +552,7 @@ extension_scope=None, serialized_options=None, file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, ), ], extensions=[], @@ -550,8 +563,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=814, - serialized_end=960, + serialized_start=826, + serialized_end=972, ) @@ -561,6 +574,7 @@ filename=None, file=DESCRIPTOR, containing_type=None, + create_key=_descriptor._internal_create_key, fields=[ _descriptor.FieldDescriptor( name="token", @@ -571,7 +585,7 @@ cpp_type=9, label=1, has_default_value=False, - default_value=_b("").decode("utf-8"), + default_value=b"".decode("utf-8"), message_type=None, enum_type=None, containing_type=None, @@ -579,7 +593,8 @@ extension_scope=None, serialized_options=None, file=DESCRIPTOR, - ) + create_key=_descriptor._internal_create_key, + ), ], extensions=[], nested_types=[], @@ -589,8 +604,8 @@ syntax="proto3", extension_ranges=[], oneofs=[], - serialized_start=962, - serialized_end=1002, + serialized_start=974, + serialized_end=1014, ) _GENERATEACCESSTOKENREQUEST.fields_by_name[ @@ -616,10 +631,10 @@ GenerateAccessTokenRequest = _reflection.GeneratedProtocolMessageType( "GenerateAccessTokenRequest", (_message.Message,), - dict( - DESCRIPTOR=_GENERATEACCESSTOKENREQUEST, - __module__="google.iam.credentials.v1.common_pb2", - __doc__=""" + { + "DESCRIPTOR": _GENERATEACCESSTOKENREQUEST, + "__module__": "google.cloud.iam_credentials_v1.proto.common_pb2", + "__doc__": """ Attributes: name: Required. The resource name of the service account for which @@ -647,21 +662,21 @@ lifetime: The desired lifetime duration of the access token in seconds. Must be set to a value less than or equal to 3600 (1 hour). If - a value is not specified, the token's lifetime will be set to + a value is not specified, the token’s lifetime will be set to a default value of one hour. """, # @@protoc_insertion_point(class_scope:google.iam.credentials.v1.GenerateAccessTokenRequest) - ), + }, ) _sym_db.RegisterMessage(GenerateAccessTokenRequest) GenerateAccessTokenResponse = _reflection.GeneratedProtocolMessageType( "GenerateAccessTokenResponse", (_message.Message,), - dict( - DESCRIPTOR=_GENERATEACCESSTOKENRESPONSE, - __module__="google.iam.credentials.v1.common_pb2", - __doc__=""" + { + "DESCRIPTOR": _GENERATEACCESSTOKENRESPONSE, + "__module__": "google.cloud.iam_credentials_v1.proto.common_pb2", + "__doc__": """ Attributes: access_token: The OAuth 2.0 access token. @@ -669,17 +684,17 @@ Token expiration time. The expiration time is always set. """, # @@protoc_insertion_point(class_scope:google.iam.credentials.v1.GenerateAccessTokenResponse) - ), + }, ) _sym_db.RegisterMessage(GenerateAccessTokenResponse) SignBlobRequest = _reflection.GeneratedProtocolMessageType( "SignBlobRequest", (_message.Message,), - dict( - DESCRIPTOR=_SIGNBLOBREQUEST, - __module__="google.iam.credentials.v1.common_pb2", - __doc__=""" + { + "DESCRIPTOR": _SIGNBLOBREQUEST, + "__module__": "google.cloud.iam_credentials_v1.proto.common_pb2", + "__doc__": """ Attributes: name: Required. The resource name of the service account for which @@ -703,17 +718,17 @@ Required. The bytes to sign. """, # @@protoc_insertion_point(class_scope:google.iam.credentials.v1.SignBlobRequest) - ), + }, ) _sym_db.RegisterMessage(SignBlobRequest) SignBlobResponse = _reflection.GeneratedProtocolMessageType( "SignBlobResponse", (_message.Message,), - dict( - DESCRIPTOR=_SIGNBLOBRESPONSE, - __module__="google.iam.credentials.v1.common_pb2", - __doc__=""" + { + "DESCRIPTOR": _SIGNBLOBRESPONSE, + "__module__": "google.cloud.iam_credentials_v1.proto.common_pb2", + "__doc__": """ Attributes: key_id: The ID of the key used to sign the blob. @@ -721,17 +736,17 @@ The signed blob. """, # @@protoc_insertion_point(class_scope:google.iam.credentials.v1.SignBlobResponse) - ), + }, ) _sym_db.RegisterMessage(SignBlobResponse) SignJwtRequest = _reflection.GeneratedProtocolMessageType( "SignJwtRequest", (_message.Message,), - dict( - DESCRIPTOR=_SIGNJWTREQUEST, - __module__="google.iam.credentials.v1.common_pb2", - __doc__=""" + { + "DESCRIPTOR": _SIGNJWTREQUEST, + "__module__": "google.cloud.iam_credentials_v1.proto.common_pb2", + "__doc__": """ Attributes: name: Required. The resource name of the service account for which @@ -756,17 +771,17 @@ a JWT Claims Set. """, # @@protoc_insertion_point(class_scope:google.iam.credentials.v1.SignJwtRequest) - ), + }, ) _sym_db.RegisterMessage(SignJwtRequest) SignJwtResponse = _reflection.GeneratedProtocolMessageType( "SignJwtResponse", (_message.Message,), - dict( - DESCRIPTOR=_SIGNJWTRESPONSE, - __module__="google.iam.credentials.v1.common_pb2", - __doc__=""" + { + "DESCRIPTOR": _SIGNJWTRESPONSE, + "__module__": "google.cloud.iam_credentials_v1.proto.common_pb2", + "__doc__": """ Attributes: key_id: The ID of the key used to sign the JWT. @@ -774,17 +789,17 @@ The signed JWT. """, # @@protoc_insertion_point(class_scope:google.iam.credentials.v1.SignJwtResponse) - ), + }, ) _sym_db.RegisterMessage(SignJwtResponse) GenerateIdTokenRequest = _reflection.GeneratedProtocolMessageType( "GenerateIdTokenRequest", (_message.Message,), - dict( - DESCRIPTOR=_GENERATEIDTOKENREQUEST, - __module__="google.iam.credentials.v1.common_pb2", - __doc__=""" + { + "DESCRIPTOR": _GENERATEIDTOKENREQUEST, + "__module__": "google.cloud.iam_credentials_v1.proto.common_pb2", + "__doc__": """ Attributes: name: Required. The resource name of the service account for which @@ -813,23 +828,23 @@ ``email_verified`` claims. """, # @@protoc_insertion_point(class_scope:google.iam.credentials.v1.GenerateIdTokenRequest) - ), + }, ) _sym_db.RegisterMessage(GenerateIdTokenRequest) GenerateIdTokenResponse = _reflection.GeneratedProtocolMessageType( "GenerateIdTokenResponse", (_message.Message,), - dict( - DESCRIPTOR=_GENERATEIDTOKENRESPONSE, - __module__="google.iam.credentials.v1.common_pb2", - __doc__=""" + { + "DESCRIPTOR": _GENERATEIDTOKENRESPONSE, + "__module__": "google.cloud.iam_credentials_v1.proto.common_pb2", + "__doc__": """ Attributes: token: The OpenId Connect ID token. """, # @@protoc_insertion_point(class_scope:google.iam.credentials.v1.GenerateIdTokenResponse) - ), + }, ) _sym_db.RegisterMessage(GenerateIdTokenResponse) diff --git a/google/cloud/iam_credentials_v1/proto/iamcredentials_pb2.py b/google/cloud/iam_credentials_v1/proto/iamcredentials_pb2.py index 9269e5f..f90b81a 100644 --- a/google/cloud/iam_credentials_v1/proto/iamcredentials_pb2.py +++ b/google/cloud/iam_credentials_v1/proto/iamcredentials_pb2.py @@ -1,10 +1,7 @@ # -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! -# source: google/iam/credentials/v1/iamcredentials.proto +# source: google/cloud/iam_credentials_v1/proto/iamcredentials.proto -import sys - -_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) from google.protobuf import descriptor as _descriptor from google.protobuf import message as _message from google.protobuf import reflection as _reflection @@ -18,24 +15,21 @@ from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 from google.api import client_pb2 as google_dot_api_dot_client__pb2 from google.cloud.iam_credentials_v1.proto import ( - common_pb2 as google_dot_iam_dot_credentials_dot_v1_dot_common__pb2, + common_pb2 as google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2, ) DESCRIPTOR = _descriptor.FileDescriptor( - name="google/iam/credentials/v1/iamcredentials.proto", + name="google/cloud/iam_credentials_v1/proto/iamcredentials.proto", package="google.iam.credentials.v1", syntax="proto3", - serialized_options=_b( - "\n#com.google.cloud.iam.credentials.v1B\023IAMCredentialsProtoP\001ZDgoogle.golang.org/genproto/googleapis/iam/credentials/v1;credentials\370\001\001" - ), - serialized_pb=_b( - '\n.google/iam/credentials/v1/iamcredentials.proto\x12\x19google.iam.credentials.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a&google/iam/credentials/v1/common.proto2\xad\x07\n\x0eIAMCredentials\x12\xec\x01\n\x13GenerateAccessToken\x12\x35.google.iam.credentials.v1.GenerateAccessTokenRequest\x1a\x36.google.iam.credentials.v1.GenerateAccessTokenResponse"f\x82\xd3\xe4\x93\x02@";/v1/{name=projects/*/serviceAccounts/*}:generateAccessToken:\x01*\xda\x41\x1dname,delegates,scope,lifetime\x12\xe4\x01\n\x0fGenerateIdToken\x12\x31.google.iam.credentials.v1.GenerateIdTokenRequest\x1a\x32.google.iam.credentials.v1.GenerateIdTokenResponse"j\x82\xd3\xe4\x93\x02<"7/v1/{name=projects/*/serviceAccounts/*}:generateIdToken:\x01*\xda\x41%name,delegates,audience,include_email\x12\xb9\x01\n\x08SignBlob\x12*.google.iam.credentials.v1.SignBlobRequest\x1a+.google.iam.credentials.v1.SignBlobResponse"T\x82\xd3\xe4\x93\x02\x35"0/v1/{name=projects/*/serviceAccounts/*}:signBlob:\x01*\xda\x41\x16name,delegates,payload\x12\xb5\x01\n\x07SignJwt\x12).google.iam.credentials.v1.SignJwtRequest\x1a*.google.iam.credentials.v1.SignJwtResponse"S\x82\xd3\xe4\x93\x02\x34"//v1/{name=projects/*/serviceAccounts/*}:signJwt:\x01*\xda\x41\x16name,delegates,payload\x1aQ\xca\x41\x1diamcredentials.googleapis.com\xd2\x41.https://www.googleapis.com/auth/cloud-platformB\x85\x01\n#com.google.cloud.iam.credentials.v1B\x13IAMCredentialsProtoP\x01ZDgoogle.golang.org/genproto/googleapis/iam/credentials/v1;credentials\xf8\x01\x01\x62\x06proto3' - ), + serialized_options=b"\n#com.google.cloud.iam.credentials.v1B\023IAMCredentialsProtoP\001ZDgoogle.golang.org/genproto/googleapis/iam/credentials/v1;credentials\370\001\001", + create_key=_descriptor._internal_create_key, + serialized_pb=b'\n:google/cloud/iam_credentials_v1/proto/iamcredentials.proto\x12\x19google.iam.credentials.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x32google/cloud/iam_credentials_v1/proto/common.proto2\xad\x07\n\x0eIAMCredentials\x12\xec\x01\n\x13GenerateAccessToken\x12\x35.google.iam.credentials.v1.GenerateAccessTokenRequest\x1a\x36.google.iam.credentials.v1.GenerateAccessTokenResponse"f\x82\xd3\xe4\x93\x02@";/v1/{name=projects/*/serviceAccounts/*}:generateAccessToken:\x01*\xda\x41\x1dname,delegates,scope,lifetime\x12\xe4\x01\n\x0fGenerateIdToken\x12\x31.google.iam.credentials.v1.GenerateIdTokenRequest\x1a\x32.google.iam.credentials.v1.GenerateIdTokenResponse"j\x82\xd3\xe4\x93\x02<"7/v1/{name=projects/*/serviceAccounts/*}:generateIdToken:\x01*\xda\x41%name,delegates,audience,include_email\x12\xb9\x01\n\x08SignBlob\x12*.google.iam.credentials.v1.SignBlobRequest\x1a+.google.iam.credentials.v1.SignBlobResponse"T\x82\xd3\xe4\x93\x02\x35"0/v1/{name=projects/*/serviceAccounts/*}:signBlob:\x01*\xda\x41\x16name,delegates,payload\x12\xb5\x01\n\x07SignJwt\x12).google.iam.credentials.v1.SignJwtRequest\x1a*.google.iam.credentials.v1.SignJwtResponse"S\x82\xd3\xe4\x93\x02\x34"//v1/{name=projects/*/serviceAccounts/*}:signJwt:\x01*\xda\x41\x16name,delegates,payload\x1aQ\xca\x41\x1diamcredentials.googleapis.com\xd2\x41.https://www.googleapis.com/auth/cloud-platformB\x85\x01\n#com.google.cloud.iam.credentials.v1B\x13IAMCredentialsProtoP\x01ZDgoogle.golang.org/genproto/googleapis/iam/credentials/v1;credentials\xf8\x01\x01\x62\x06proto3', dependencies=[ google_dot_api_dot_annotations__pb2.DESCRIPTOR, google_dot_api_dot_client__pb2.DESCRIPTOR, - google_dot_iam_dot_credentials_dot_v1_dot_common__pb2.DESCRIPTOR, + google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2.DESCRIPTOR, ], ) @@ -50,55 +44,50 @@ full_name="google.iam.credentials.v1.IAMCredentials", file=DESCRIPTOR, index=0, - serialized_options=_b( - "\312A\035iamcredentials.googleapis.com\322A.https://www.googleapis.com/auth/cloud-platform" - ), - serialized_start=173, - serialized_end=1114, + serialized_options=b"\312A\035iamcredentials.googleapis.com\322A.https://www.googleapis.com/auth/cloud-platform", + create_key=_descriptor._internal_create_key, + serialized_start=197, + serialized_end=1138, methods=[ _descriptor.MethodDescriptor( name="GenerateAccessToken", full_name="google.iam.credentials.v1.IAMCredentials.GenerateAccessToken", index=0, containing_service=None, - input_type=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2._GENERATEACCESSTOKENREQUEST, - output_type=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2._GENERATEACCESSTOKENRESPONSE, - serialized_options=_b( - '\202\323\344\223\002@";/v1/{name=projects/*/serviceAccounts/*}:generateAccessToken:\001*\332A\035name,delegates,scope,lifetime' - ), + input_type=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2._GENERATEACCESSTOKENREQUEST, + output_type=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2._GENERATEACCESSTOKENRESPONSE, + serialized_options=b'\202\323\344\223\002@";/v1/{name=projects/*/serviceAccounts/*}:generateAccessToken:\001*\332A\035name,delegates,scope,lifetime', + create_key=_descriptor._internal_create_key, ), _descriptor.MethodDescriptor( name="GenerateIdToken", full_name="google.iam.credentials.v1.IAMCredentials.GenerateIdToken", index=1, containing_service=None, - input_type=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2._GENERATEIDTOKENREQUEST, - output_type=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2._GENERATEIDTOKENRESPONSE, - serialized_options=_b( - '\202\323\344\223\002<"7/v1/{name=projects/*/serviceAccounts/*}:generateIdToken:\001*\332A%name,delegates,audience,include_email' - ), + input_type=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2._GENERATEIDTOKENREQUEST, + output_type=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2._GENERATEIDTOKENRESPONSE, + serialized_options=b'\202\323\344\223\002<"7/v1/{name=projects/*/serviceAccounts/*}:generateIdToken:\001*\332A%name,delegates,audience,include_email', + create_key=_descriptor._internal_create_key, ), _descriptor.MethodDescriptor( name="SignBlob", full_name="google.iam.credentials.v1.IAMCredentials.SignBlob", index=2, containing_service=None, - input_type=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2._SIGNBLOBREQUEST, - output_type=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2._SIGNBLOBRESPONSE, - serialized_options=_b( - '\202\323\344\223\0025"0/v1/{name=projects/*/serviceAccounts/*}:signBlob:\001*\332A\026name,delegates,payload' - ), + input_type=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2._SIGNBLOBREQUEST, + output_type=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2._SIGNBLOBRESPONSE, + serialized_options=b'\202\323\344\223\0025"0/v1/{name=projects/*/serviceAccounts/*}:signBlob:\001*\332A\026name,delegates,payload', + create_key=_descriptor._internal_create_key, ), _descriptor.MethodDescriptor( name="SignJwt", full_name="google.iam.credentials.v1.IAMCredentials.SignJwt", index=3, containing_service=None, - input_type=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2._SIGNJWTREQUEST, - output_type=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2._SIGNJWTRESPONSE, - serialized_options=_b( - '\202\323\344\223\0024"//v1/{name=projects/*/serviceAccounts/*}:signJwt:\001*\332A\026name,delegates,payload' - ), + input_type=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2._SIGNJWTREQUEST, + output_type=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2._SIGNJWTRESPONSE, + serialized_options=b'\202\323\344\223\0024"//v1/{name=projects/*/serviceAccounts/*}:signJwt:\001*\332A\026name,delegates,payload', + create_key=_descriptor._internal_create_key, ), ], ) diff --git a/google/cloud/iam_credentials_v1/proto/iamcredentials_pb2_grpc.py b/google/cloud/iam_credentials_v1/proto/iamcredentials_pb2_grpc.py index 277e724..ddbae1a 100644 --- a/google/cloud/iam_credentials_v1/proto/iamcredentials_pb2_grpc.py +++ b/google/cloud/iam_credentials_v1/proto/iamcredentials_pb2_grpc.py @@ -2,7 +2,7 @@ import grpc from google.cloud.iam_credentials_v1.proto import ( - common_pb2 as google_dot_iam_dot_credentials_dot_v1_dot_common__pb2, + common_pb2 as google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2, ) @@ -26,23 +26,23 @@ def __init__(self, channel): """ self.GenerateAccessToken = channel.unary_unary( "/google.iam.credentials.v1.IAMCredentials/GenerateAccessToken", - request_serializer=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2.GenerateAccessTokenRequest.SerializeToString, - response_deserializer=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2.GenerateAccessTokenResponse.FromString, + request_serializer=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2.GenerateAccessTokenRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2.GenerateAccessTokenResponse.FromString, ) self.GenerateIdToken = channel.unary_unary( "/google.iam.credentials.v1.IAMCredentials/GenerateIdToken", - request_serializer=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2.GenerateIdTokenRequest.SerializeToString, - response_deserializer=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2.GenerateIdTokenResponse.FromString, + request_serializer=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2.GenerateIdTokenRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2.GenerateIdTokenResponse.FromString, ) self.SignBlob = channel.unary_unary( "/google.iam.credentials.v1.IAMCredentials/SignBlob", - request_serializer=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2.SignBlobRequest.SerializeToString, - response_deserializer=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2.SignBlobResponse.FromString, + request_serializer=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2.SignBlobRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2.SignBlobResponse.FromString, ) self.SignJwt = channel.unary_unary( "/google.iam.credentials.v1.IAMCredentials/SignJwt", - request_serializer=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2.SignJwtRequest.SerializeToString, - response_deserializer=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2.SignJwtResponse.FromString, + request_serializer=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2.SignJwtRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2.SignJwtResponse.FromString, ) @@ -91,23 +91,23 @@ def add_IAMCredentialsServicer_to_server(servicer, server): rpc_method_handlers = { "GenerateAccessToken": grpc.unary_unary_rpc_method_handler( servicer.GenerateAccessToken, - request_deserializer=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2.GenerateAccessTokenRequest.FromString, - response_serializer=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2.GenerateAccessTokenResponse.SerializeToString, + request_deserializer=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2.GenerateAccessTokenRequest.FromString, + response_serializer=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2.GenerateAccessTokenResponse.SerializeToString, ), "GenerateIdToken": grpc.unary_unary_rpc_method_handler( servicer.GenerateIdToken, - request_deserializer=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2.GenerateIdTokenRequest.FromString, - response_serializer=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2.GenerateIdTokenResponse.SerializeToString, + request_deserializer=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2.GenerateIdTokenRequest.FromString, + response_serializer=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2.GenerateIdTokenResponse.SerializeToString, ), "SignBlob": grpc.unary_unary_rpc_method_handler( servicer.SignBlob, - request_deserializer=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2.SignBlobRequest.FromString, - response_serializer=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2.SignBlobResponse.SerializeToString, + request_deserializer=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2.SignBlobRequest.FromString, + response_serializer=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2.SignBlobResponse.SerializeToString, ), "SignJwt": grpc.unary_unary_rpc_method_handler( servicer.SignJwt, - request_deserializer=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2.SignJwtRequest.FromString, - response_serializer=google_dot_iam_dot_credentials_dot_v1_dot_common__pb2.SignJwtResponse.SerializeToString, + request_deserializer=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2.SignJwtRequest.FromString, + response_serializer=google_dot_cloud_dot_iam__credentials__v1_dot_proto_dot_common__pb2.SignJwtResponse.SerializeToString, ), } generic_handler = grpc.method_handlers_generic_handler( diff --git a/google/cloud/iam_credentials_v1/types.py b/google/cloud/iam_credentials_v1/types.py index 0e1eb55..ea51aaf 100644 --- a/google/cloud/iam_credentials_v1/types.py +++ b/google/cloud/iam_credentials_v1/types.py @@ -25,9 +25,14 @@ from google.protobuf import timestamp_pb2 -_shared_modules = [duration_pb2, timestamp_pb2] - -_local_modules = [common_pb2] +_shared_modules = [ + duration_pb2, + timestamp_pb2, +] + +_local_modules = [ + common_pb2, +] names = [] diff --git a/noxfile.py b/noxfile.py index d699cea..df5b36a 100644 --- a/noxfile.py +++ b/noxfile.py @@ -23,14 +23,15 @@ import nox -BLACK_VERSION = "black==19.3b0" +BLACK_VERSION = "black==19.10b0" BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] -if os.path.exists("samples"): - BLACK_PATHS.append("samples") +DEFAULT_PYTHON_VERSION = "3.8" +SYSTEM_TEST_PYTHON_VERSIONS = ["2.7", "3.8"] +UNIT_TEST_PYTHON_VERSIONS = ["2.7", "3.5", "3.6", "3.7", "3.8"] -@nox.session(python="3.7") +@nox.session(python=DEFAULT_PYTHON_VERSION) def lint(session): """Run linters. @@ -38,7 +39,9 @@ def lint(session): serious code quality issues. """ session.install("flake8", BLACK_VERSION) - session.run("black", "--check", *BLACK_PATHS) + session.run( + "black", "--check", *BLACK_PATHS, + ) session.run("flake8", "google", "tests") @@ -53,10 +56,12 @@ def blacken(session): check the state of the `gcp_ubuntu_config` we use for that Kokoro run. """ session.install(BLACK_VERSION) - session.run("black", *BLACK_PATHS) + session.run( + "black", *BLACK_PATHS, + ) -@nox.session(python="3.7") +@nox.session(python=DEFAULT_PYTHON_VERSION) def lint_setup_py(session): """Verify that setup.py is valid (including RST check).""" session.install("docutils", "pygments") @@ -72,7 +77,7 @@ def default(session): session.run( "py.test", "--quiet", - "--cov=google.cloud.iamcredentials", + "--cov=google.cloud.iam", "--cov=google.cloud", "--cov=tests.unit", "--cov-append", @@ -84,13 +89,13 @@ def default(session): ) -@nox.session(python=["2.7", "3.5", "3.6", "3.7", "3.8"]) +@nox.session(python=UNIT_TEST_PYTHON_VERSIONS) def unit(session): """Run the unit test suite.""" default(session) -@nox.session(python=["2.7", "3.7"]) +@nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) def system(session): """Run the system test suite.""" system_test_path = os.path.join("tests", "system.py") @@ -110,7 +115,9 @@ 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( + "mock", "pytest", "google-cloud-testutils", + ) session.install("-e", ".") # Run py.test against the system tests. @@ -120,7 +127,7 @@ def system(session): session.run("py.test", "--quiet", system_test_folder_path, *session.posargs) -@nox.session(python="3.7") +@nox.session(python=DEFAULT_PYTHON_VERSION) def cover(session): """Run the final coverage report. @@ -133,7 +140,7 @@ def cover(session): session.run("coverage", "erase") -@nox.session(python="3.7") +@nox.session(python=DEFAULT_PYTHON_VERSION) def docs(session): """Build the docs for this library.""" diff --git a/scripts/decrypt-secrets.sh b/scripts/decrypt-secrets.sh new file mode 100755 index 0000000..ff599eb --- /dev/null +++ b/scripts/decrypt-secrets.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Copyright 2015 Google Inc. All rights reserved. +# +# 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. + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +ROOT=$( dirname "$DIR" ) + +# Work from the project root. +cd $ROOT + +# Use SECRET_MANAGER_PROJECT if set, fallback to cloud-devrel-kokoro-resources. +PROJECT_ID="${SECRET_MANAGER_PROJECT:-cloud-devrel-kokoro-resources}" + +gcloud secrets versions access latest --secret="python-docs-samples-test-env" \ + > testing/test-env.sh +gcloud secrets versions access latest \ + --secret="python-docs-samples-service-account" \ + > testing/service-account.json +gcloud secrets versions access latest \ + --secret="python-docs-samples-client-secrets" \ + > testing/client-secrets.json \ No newline at end of file diff --git a/scripts/readme-gen/readme_gen.py b/scripts/readme-gen/readme_gen.py new file mode 100644 index 0000000..d309d6e --- /dev/null +++ b/scripts/readme-gen/readme_gen.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python + +# Copyright 2016 Google Inc +# +# 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. + +"""Generates READMEs using configuration defined in yaml.""" + +import argparse +import io +import os +import subprocess + +import jinja2 +import yaml + + +jinja_env = jinja2.Environment( + trim_blocks=True, + loader=jinja2.FileSystemLoader( + os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates')))) + +README_TMPL = jinja_env.get_template('README.tmpl.rst') + + +def get_help(file): + return subprocess.check_output(['python', file, '--help']).decode() + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('source') + parser.add_argument('--destination', default='README.rst') + + args = parser.parse_args() + + source = os.path.abspath(args.source) + root = os.path.dirname(source) + destination = os.path.join(root, args.destination) + + jinja_env.globals['get_help'] = get_help + + with io.open(source, 'r') as f: + config = yaml.load(f) + + # This allows get_help to execute in the right directory. + os.chdir(root) + + output = README_TMPL.render(config) + + with io.open(destination, 'w') as f: + f.write(output) + + +if __name__ == '__main__': + main() diff --git a/scripts/readme-gen/templates/README.tmpl.rst b/scripts/readme-gen/templates/README.tmpl.rst new file mode 100644 index 0000000..4fd2397 --- /dev/null +++ b/scripts/readme-gen/templates/README.tmpl.rst @@ -0,0 +1,87 @@ +{# The following line is a lie. BUT! Once jinja2 is done with it, it will + become truth! #} +.. This file is automatically generated. Do not edit this file directly. + +{{product.name}} Python Samples +=============================================================================== + +.. image:: https://gstatic.com/cloudssh/images/open-btn.png + :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor={{folder}}/README.rst + + +This directory contains samples for {{product.name}}. {{product.description}} + +{{description}} + +.. _{{product.name}}: {{product.url}} + +{% if required_api_url %} +To run the sample, you need to enable the API at: {{required_api_url}} +{% endif %} + +{% if required_role %} +To run the sample, you need to have `{{required_role}}` role. +{% endif %} + +{{other_required_steps}} + +{% if setup %} +Setup +------------------------------------------------------------------------------- + +{% for section in setup %} + +{% include section + '.tmpl.rst' %} + +{% endfor %} +{% endif %} + +{% if samples %} +Samples +------------------------------------------------------------------------------- + +{% for sample in samples %} +{{sample.name}} ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +{% if not sample.hide_cloudshell_button %} +.. image:: https://gstatic.com/cloudssh/images/open-btn.png + :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor={{folder}}/{{sample.file}},{{folder}}/README.rst +{% endif %} + + +{{sample.description}} + +To run this sample: + +.. code-block:: bash + + $ python {{sample.file}} +{% if sample.show_help %} + + {{get_help(sample.file)|indent}} +{% endif %} + + +{% endfor %} +{% endif %} + +{% if cloud_client_library %} + +The client library +------------------------------------------------------------------------------- + +This sample uses the `Google Cloud Client Library for Python`_. +You can read the documentation for more details on API usage and use GitHub +to `browse the source`_ and `report issues`_. + +.. _Google Cloud Client Library for Python: + https://googlecloudplatform.github.io/google-cloud-python/ +.. _browse the source: + https://github.com/GoogleCloudPlatform/google-cloud-python +.. _report issues: + https://github.com/GoogleCloudPlatform/google-cloud-python/issues + +{% endif %} + +.. _Google Cloud SDK: https://cloud.google.com/sdk/ \ No newline at end of file diff --git a/scripts/readme-gen/templates/auth.tmpl.rst b/scripts/readme-gen/templates/auth.tmpl.rst new file mode 100644 index 0000000..1446b94 --- /dev/null +++ b/scripts/readme-gen/templates/auth.tmpl.rst @@ -0,0 +1,9 @@ +Authentication +++++++++++++++ + +This sample requires you to have authentication setup. Refer to the +`Authentication Getting Started Guide`_ for instructions on setting up +credentials for applications. + +.. _Authentication Getting Started Guide: + https://cloud.google.com/docs/authentication/getting-started diff --git a/scripts/readme-gen/templates/auth_api_key.tmpl.rst b/scripts/readme-gen/templates/auth_api_key.tmpl.rst new file mode 100644 index 0000000..11957ce --- /dev/null +++ b/scripts/readme-gen/templates/auth_api_key.tmpl.rst @@ -0,0 +1,14 @@ +Authentication +++++++++++++++ + +Authentication for this service is done via an `API Key`_. To obtain an API +Key: + +1. Open the `Cloud Platform Console`_ +2. Make sure that billing is enabled for your project. +3. From the **Credentials** page, create a new **API Key** or use an existing + one for your project. + +.. _API Key: + https://developers.google.com/api-client-library/python/guide/aaa_apikeys +.. _Cloud Console: https://console.cloud.google.com/project?_ diff --git a/scripts/readme-gen/templates/install_deps.tmpl.rst b/scripts/readme-gen/templates/install_deps.tmpl.rst new file mode 100644 index 0000000..a0406db --- /dev/null +++ b/scripts/readme-gen/templates/install_deps.tmpl.rst @@ -0,0 +1,29 @@ +Install Dependencies +++++++++++++++++++++ + +#. Clone python-docs-samples and change directory to the sample directory you want to use. + + .. code-block:: bash + + $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git + +#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions. + + .. _Python Development Environment Setup Guide: + https://cloud.google.com/python/setup + +#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. + + .. code-block:: bash + + $ virtualenv env + $ source env/bin/activate + +#. Install the dependencies needed to run the samples. + + .. code-block:: bash + + $ pip install -r requirements.txt + +.. _pip: https://pip.pypa.io/ +.. _virtualenv: https://virtualenv.pypa.io/ diff --git a/scripts/readme-gen/templates/install_portaudio.tmpl.rst b/scripts/readme-gen/templates/install_portaudio.tmpl.rst new file mode 100644 index 0000000..5ea33d1 --- /dev/null +++ b/scripts/readme-gen/templates/install_portaudio.tmpl.rst @@ -0,0 +1,35 @@ +Install PortAudio ++++++++++++++++++ + +Install `PortAudio`_. This is required by the `PyAudio`_ library to stream +audio from your computer's microphone. PyAudio depends on PortAudio for cross-platform compatibility, and is installed differently depending on the +platform. + +* For Mac OS X, you can use `Homebrew`_:: + + brew install portaudio + + **Note**: if you encounter an error when running `pip install` that indicates + it can't find `portaudio.h`, try running `pip install` with the following + flags:: + + pip install --global-option='build_ext' \ + --global-option='-I/usr/local/include' \ + --global-option='-L/usr/local/lib' \ + pyaudio + +* For Debian / Ubuntu Linux:: + + apt-get install portaudio19-dev python-all-dev + +* Windows may work without having to install PortAudio explicitly (it will get + installed with PyAudio). + +For more details, see the `PyAudio installation`_ page. + + +.. _PyAudio: https://people.csail.mit.edu/hubert/pyaudio/ +.. _PortAudio: http://www.portaudio.com/ +.. _PyAudio installation: + https://people.csail.mit.edu/hubert/pyaudio/#downloads +.. _Homebrew: http://brew.sh diff --git a/synth.metadata b/synth.metadata index f9b627a..e5db4ea 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,32 +1,25 @@ { "sources": [ - { - "generator": { - "name": "artman", - "version": "2.0.0", - "dockerImage": "googleapis/artman@sha256:b3b47805231a305d0f40c4bf069df20f6a2635574e6d4259fac651d3f9f6e098" - } - }, { "git": { "name": ".", - "remote": "git@github.com:googleapis/python-iam", - "sha": "b393c9bbfd3ac81bdffcee2abe9607665d80c782" + "remote": "https://github.com/googleapis/python-iam.git", + "sha": "c9202fc00dc9c5c59d378bca6dd9ff46ca3ceecb" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "756b174de4a122461993c1c583345533d819936d", - "internalRef": "308824110" + "sha": "cf41866c6f14f10a07aa1e2a1260fc0a2727d889", + "internalRef": "317812187" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "01b6f23d24b27878b48667ce597876d66b59780e" + "sha": "cf2eff09d0f5319a4dc5cdce2b6356d85af4a798" } } ], @@ -37,8 +30,7 @@ "apiName": "iam_credentials", "apiVersion": "v1", "language": "python", - "generator": "gapic", - "config": "google/iam/credentials/artman_iamcredentials_v1.yaml" + "generator": "bazel" } } ] diff --git a/synth.py b/synth.py index 46468d7..ec38dd0 100644 --- a/synth.py +++ b/synth.py @@ -72,4 +72,7 @@ templated_files = common.py_library(cov_level=76) s.move(templated_files) +# TODO(busunkim): Use latest sphinx after microgenerator transition +s.replace("noxfile.py", """['"]sphinx['"]""", '"sphinx<3.0.0"') + s.shell.run(["nox", "-s", "blacken"], hide_output=False) diff --git a/testing/.gitignore b/testing/.gitignore new file mode 100644 index 0000000..b05fbd6 --- /dev/null +++ b/testing/.gitignore @@ -0,0 +1,3 @@ +test-env.sh +service-account.json +client-secrets.json \ No newline at end of file