From c1c87bde4ca517690efb1d298e4867619a104c4f Mon Sep 17 00:00:00 2001 From: Takashi Matsuo Date: Tue, 26 May 2020 14:42:53 -0700 Subject: [PATCH] [bigquery] opt in to use the build specific projects [(#3883)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/3883) fixes #3882 --- samples/snippets/README.rst | 8 +++++-- samples/snippets/README.rst.in | 4 +++- samples/snippets/noxfile_config.py | 37 ++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 samples/snippets/noxfile_config.py diff --git a/samples/snippets/README.rst b/samples/snippets/README.rst index 02bc856f9..9446125cd 100644 --- a/samples/snippets/README.rst +++ b/samples/snippets/README.rst @@ -14,6 +14,11 @@ This directory contains samples for Google BigQuery. `Google BigQuery`_ is Googl .. _Google BigQuery: https://cloud.google.com/bigquery/docs + +To run the sample, you need to have `BigQuery Admin` role. + + + Setup ------------------------------------------------------------------------------- @@ -108,7 +113,7 @@ To run this sample: $ python user_credentials.py - usage: user_credentials.py [-h] [--launch-browser] project query + usage: user_credentials.py [-h] [--launch-browser] project Command-line application to run a query using user credentials. @@ -117,7 +122,6 @@ To run this sample: positional arguments: project Project to use for BigQuery billing. - query BigQuery SQL Query. optional arguments: -h, --help show this help message and exit diff --git a/samples/snippets/README.rst.in b/samples/snippets/README.rst.in index 008b51795..74b7fa940 100644 --- a/samples/snippets/README.rst.in +++ b/samples/snippets/README.rst.in @@ -11,6 +11,8 @@ product: analyzing data to find meaningful insights, use familiar SQL, and take advantage of our pay-as-you-go model. +required_role: BigQuery Admin + setup: - auth - install_deps @@ -26,4 +28,4 @@ samples: cloud_client_library: true -folder: bigquery/cloud-client \ No newline at end of file +folder: bigquery/cloud-client diff --git a/samples/snippets/noxfile_config.py b/samples/snippets/noxfile_config.py new file mode 100644 index 000000000..950c3a070 --- /dev/null +++ b/samples/snippets/noxfile_config.py @@ -0,0 +1,37 @@ +# 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. + +# Default TEST_CONFIG_OVERRIDE for python repos. + +# You can copy this file into your directory, then it will be inported from +# the noxfile.py. + +# The source of truth: +# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/noxfile_config.py + +TEST_CONFIG_OVERRIDE = { + # You can opt out from the test for specific Python versions. + 'ignored_versions': ["2.7"], + + # An envvar key for determining the project id to use. Change it + # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a + # build specific Cloud project. You can also use your own string + # to use your own Cloud project. + # 'gcloud_project_env': 'GCLOUD_PROJECT', + 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT', + + # A dictionary you want to inject into your test. Don't put any + # secrets here. These values will override predefined values. + 'envs': {}, +}