diff --git a/packages/google-cloud-video-transcoder/.coveragerc b/packages/google-cloud-video-transcoder/.coveragerc new file mode 100644 index 000000000000..8b12d807c1b3 --- /dev/null +++ b/packages/google-cloud-video-transcoder/.coveragerc @@ -0,0 +1,18 @@ +[run] +branch = True + +[report] +fail_under = 100 +show_missing = True +omit = + google/cloud/video/transcoder/__init__.py +exclude_lines = + # Re-enable the standard pragma + pragma: NO COVER + # Ignore debug-only repr + def __repr__ + # Ignore pkg_resources exceptions. + # This is added at the module level as a safeguard for if someone + # generates the code and tries to run it without pip installing. This + # makes it virtually impossible to test properly. + except pkg_resources.DistributionNotFound diff --git a/packages/google-cloud-video-transcoder/.github/header-checker-lint.yml b/packages/google-cloud-video-transcoder/.github/header-checker-lint.yml new file mode 100644 index 000000000000..fc281c05bd55 --- /dev/null +++ b/packages/google-cloud-video-transcoder/.github/header-checker-lint.yml @@ -0,0 +1,15 @@ +{"allowedCopyrightHolders": ["Google LLC"], + "allowedLicenses": ["Apache-2.0", "MIT", "BSD-3"], + "ignoreFiles": ["**/requirements.txt", "**/requirements-test.txt"], + "sourceFileExtensions": [ + "ts", + "js", + "java", + "sh", + "Dockerfile", + "yaml", + "py", + "html", + "txt" + ] +} \ No newline at end of file diff --git a/packages/google-cloud-video-transcoder/.gitignore b/packages/google-cloud-video-transcoder/.gitignore index b9daa52f118d..b4243ced74e4 100644 --- a/packages/google-cloud-video-transcoder/.gitignore +++ b/packages/google-cloud-video-transcoder/.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/packages/google-cloud-video-transcoder/.kokoro/build.sh b/packages/google-cloud-video-transcoder/.kokoro/build.sh index 9838acdd62cb..971b17b05be0 100755 --- a/packages/google-cloud-video-transcoder/.kokoro/build.sh +++ b/packages/google-cloud-video-transcoder/.kokoro/build.sh @@ -15,7 +15,11 @@ set -eo pipefail -cd github/python-video-transcoder +if [[ -z "${PROJECT_ROOT:-}" ]]; then + PROJECT_ROOT="github/python-video-transcoder" +fi + +cd "${PROJECT_ROOT}" # Disable buffering, so that the logs stream through. export PYTHONUNBUFFERED=1 @@ -30,16 +34,26 @@ export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json export PROJECT_ID=$(cat "${KOKORO_GFILE_DIR}/project-id.json") # Remove old nox -python3.6 -m pip uninstall --yes --quiet nox-automation +python3 -m pip uninstall --yes --quiet nox-automation # Install nox -python3.6 -m pip install --upgrade --quiet nox -python3.6 -m nox --version +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 - python3.6 -m nox -s "${NOX_SESSION:-}" + python3 -m nox -s ${NOX_SESSION:-} else - python3.6 -m nox + python3 -m nox fi diff --git a/packages/google-cloud-video-transcoder/.kokoro/docs/docs-presubmit.cfg b/packages/google-cloud-video-transcoder/.kokoro/docs/docs-presubmit.cfg index 1118107829b7..2fd51992cf47 100644 --- a/packages/google-cloud-video-transcoder/.kokoro/docs/docs-presubmit.cfg +++ b/packages/google-cloud-video-transcoder/.kokoro/docs/docs-presubmit.cfg @@ -15,3 +15,14 @@ env_vars: { key: "TRAMPOLINE_IMAGE_UPLOAD" value: "false" } + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/python-video-transcoder/.kokoro/build.sh" +} + +# Only run this nox session. +env_vars: { + key: "NOX_SESSION" + value: "docs docfx" +} diff --git a/packages/google-cloud-video-transcoder/.kokoro/samples/python3.6/periodic-head.cfg b/packages/google-cloud-video-transcoder/.kokoro/samples/python3.6/periodic-head.cfg new file mode 100644 index 000000000000..f9cfcd33e058 --- /dev/null +++ b/packages/google-cloud-video-transcoder/.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/packages/google-cloud-video-transcoder/.kokoro/samples/python3.7/periodic-head.cfg b/packages/google-cloud-video-transcoder/.kokoro/samples/python3.7/periodic-head.cfg new file mode 100644 index 000000000000..f9cfcd33e058 --- /dev/null +++ b/packages/google-cloud-video-transcoder/.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/packages/google-cloud-video-transcoder/.kokoro/samples/python3.8/periodic-head.cfg b/packages/google-cloud-video-transcoder/.kokoro/samples/python3.8/periodic-head.cfg new file mode 100644 index 000000000000..f9cfcd33e058 --- /dev/null +++ b/packages/google-cloud-video-transcoder/.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/packages/google-cloud-video-transcoder/.kokoro/test-samples-against-head.sh b/packages/google-cloud-video-transcoder/.kokoro/test-samples-against-head.sh new file mode 100755 index 000000000000..fd9ccdba28e0 --- /dev/null +++ b/packages/google-cloud-video-transcoder/.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-video-transcoder + +exec .kokoro/test-samples-impl.sh diff --git a/packages/google-cloud-video-transcoder/.kokoro/test-samples-impl.sh b/packages/google-cloud-video-transcoder/.kokoro/test-samples-impl.sh new file mode 100755 index 000000000000..cf5de74c17a5 --- /dev/null +++ b/packages/google-cloud-video-transcoder/.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/packages/google-cloud-video-transcoder/.kokoro/test-samples.sh b/packages/google-cloud-video-transcoder/.kokoro/test-samples.sh index 02f565c293bc..ef463cc0685b 100755 --- a/packages/google-cloud-video-transcoder/.kokoro/test-samples.sh +++ b/packages/google-cloud-video-transcoder/.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-video-transcoder # 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/packages/google-cloud-video-transcoder/.pre-commit-config.yaml b/packages/google-cloud-video-transcoder/.pre-commit-config.yaml index a9024b15d725..32302e4883a1 100644 --- a/packages/google-cloud-video-transcoder/.pre-commit-config.yaml +++ b/packages/google-cloud-video-transcoder/.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/packages/google-cloud-video-transcoder/.trampolinerc b/packages/google-cloud-video-transcoder/.trampolinerc index 995ee29111e1..383b6ec89fbc 100644 --- a/packages/google-cloud-video-transcoder/.trampolinerc +++ b/packages/google-cloud-video-transcoder/.trampolinerc @@ -24,6 +24,7 @@ required_envvars+=( pass_down_envvars+=( "STAGING_BUCKET" "V2_STAGING_BUCKET" + "NOX_SESSION" ) # Prevent unintentional override on the default image. diff --git a/packages/google-cloud-video-transcoder/CONTRIBUTING.rst b/packages/google-cloud-video-transcoder/CONTRIBUTING.rst index e0492277929e..00e316067f9f 100644 --- a/packages/google-cloud-video-transcoder/CONTRIBUTING.rst +++ b/packages/google-cloud-video-transcoder/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/packages/google-cloud-video-transcoder/LICENSE b/packages/google-cloud-video-transcoder/LICENSE index a8ee855de2aa..d64569567334 100644 --- a/packages/google-cloud-video-transcoder/LICENSE +++ b/packages/google-cloud-video-transcoder/LICENSE @@ -1,6 +1,7 @@ - Apache License + + Apache License Version 2.0, January 2004 - https://www.apache.org/licenses/ + http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION @@ -192,7 +193,7 @@ 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 + 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, diff --git a/packages/google-cloud-video-transcoder/MANIFEST.in b/packages/google-cloud-video-transcoder/MANIFEST.in index e9e29d12033d..e783f4c6209b 100644 --- a/packages/google-cloud-video-transcoder/MANIFEST.in +++ b/packages/google-cloud-video-transcoder/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/packages/google-cloud-video-transcoder/docs/README.rst b/packages/google-cloud-video-transcoder/docs/README.rst deleted file mode 100644 index e0d38471904e..000000000000 --- a/packages/google-cloud-video-transcoder/docs/README.rst +++ /dev/null @@ -1,82 +0,0 @@ -Python Client for Transcoder API -================================================= - -|beta| |pypi| |versions| - -`Transcoder API`_: This API converts video files into formats suitable for consumer distribution. - -- `Client Library Documentation`_ -- `Product Documentation`_ - -.. |beta| image:: https://img.shields.io/badge/support-beta-orange.svg - :target: https://github.com/googleapis/google-cloud-python/blob/master/README.rst#beta-support -.. |pypi| image:: https://img.shields.io/pypi/v/google-cloud-video-transcoder.svg - :target: https://pypi.org/project/google-cloud-video-transcoder/ -.. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-video-transcoder.svg - :target: https://pypi.org/project/google-cloud-video-transcoder/ -.. _Transcoder API: https://cloud.google.com/transcoder -.. _Client Library Documentation: https://googleapis.dev/python/transcoder/latest -.. _Product Documentation: https://cloud.google.com/transcoder - -Quick Start ------------ - -In order to use this library, you first need to go through the following steps: - -1. `Select or create a Cloud Platform project.`_ -2. `Enable billing for your project.`_ -3. `Enable the Transcoder API.`_ -4. `Setup Authentication.`_ - -.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project -.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project -.. _Enable the Transcoder API.: https://cloud.google.com/transcoder -.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html - -Installation -~~~~~~~~~~~~ - -Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to -create isolated Python environments. The basic problem it addresses is one of -dependencies and versions, and indirectly permissions. - -With `virtualenv`_, it's possible to install this library without needing system -install permissions, and without clashing with the installed system -dependencies. - -.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/ - - -Mac/Linux -^^^^^^^^^ - -.. code-block:: console - - pip install virtualenv - virtualenv - source /bin/activate - /bin/pip install google-cloud-video-transcoder - - -Windows -^^^^^^^ - -.. code-block:: console - - pip install virtualenv - virtualenv - \Scripts\activate - \Scripts\pip.exe install google-cloud-video-transcoder - -Next Steps -~~~~~~~~~~ - -- Read the `Client Library Documentation`_ for Cloud Transcoder API - API to see other available methods on the client. -- Read the `Transcoder API Product documentation`_ to learn - more about the product and see How-to Guides. -- View this `README`_ to see the full list of Cloud - APIs that we cover. - -.. _Transcoder API Product documentation: https://cloud.google.com/transcoder/docs -.. _README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst \ No newline at end of file diff --git a/packages/google-cloud-video-transcoder/docs/README.rst b/packages/google-cloud-video-transcoder/docs/README.rst new file mode 120000 index 000000000000..89a0106941ff --- /dev/null +++ b/packages/google-cloud-video-transcoder/docs/README.rst @@ -0,0 +1 @@ +../README.rst \ No newline at end of file diff --git a/packages/google-cloud-video-transcoder/docs/_static/custom.css b/packages/google-cloud-video-transcoder/docs/_static/custom.css index 0abaf229fce3..bcd37bbd3c4a 100644 --- a/packages/google-cloud-video-transcoder/docs/_static/custom.css +++ b/packages/google-cloud-video-transcoder/docs/_static/custom.css @@ -1,4 +1,9 @@ div#python2-eol { border-color: red; border-width: medium; -} \ No newline at end of file +} + +/* Ensure minimum width for 'Parameters' / 'Returns' column */ +dl.field-list > dt { + min-width: 100px +} diff --git a/packages/google-cloud-video-transcoder/docs/transcoder_v1beta1/services.rst b/packages/google-cloud-video-transcoder/docs/transcoder_v1beta1/services.rst index 8442591e4bd4..a3b6569030ed 100644 --- a/packages/google-cloud-video-transcoder/docs/transcoder_v1beta1/services.rst +++ b/packages/google-cloud-video-transcoder/docs/transcoder_v1beta1/services.rst @@ -1,6 +1,6 @@ Services for Google Cloud Video Transcoder v1beta1 API ====================================================== +.. toctree:: + :maxdepth: 2 -.. automodule:: google.cloud.video.transcoder_v1beta1.services.transcoder_service - :members: - :inherited-members: + transcoder_service diff --git a/packages/google-cloud-video-transcoder/docs/transcoder_v1beta1/transcoder_service.rst b/packages/google-cloud-video-transcoder/docs/transcoder_v1beta1/transcoder_service.rst new file mode 100644 index 000000000000..d4800d9066ef --- /dev/null +++ b/packages/google-cloud-video-transcoder/docs/transcoder_v1beta1/transcoder_service.rst @@ -0,0 +1,11 @@ +TranscoderService +----------------------------------- + +.. automodule:: google.cloud.video.transcoder_v1beta1.services.transcoder_service + :members: + :inherited-members: + + +.. automodule:: google.cloud.video.transcoder_v1beta1.services.transcoder_service.pagers + :members: + :inherited-members: diff --git a/packages/google-cloud-video-transcoder/docs/transcoder_v1beta1/types.rst b/packages/google-cloud-video-transcoder/docs/transcoder_v1beta1/types.rst index a3f02bd0c04b..cb38b8a020d2 100644 --- a/packages/google-cloud-video-transcoder/docs/transcoder_v1beta1/types.rst +++ b/packages/google-cloud-video-transcoder/docs/transcoder_v1beta1/types.rst @@ -3,4 +3,5 @@ Types for Google Cloud Video Transcoder v1beta1 API .. automodule:: google.cloud.video.transcoder_v1beta1.types :members: + :undoc-members: :show-inheritance: diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/async_client.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/async_client.py index 727193f03e33..fb8a43b4c8bc 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/async_client.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/async_client.py @@ -89,7 +89,36 @@ class TranscoderServiceAsyncClient: TranscoderServiceClient.parse_common_location_path ) - from_service_account_file = TranscoderServiceClient.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: + TranscoderServiceAsyncClient: The constructed client. + """ + return TranscoderServiceClient.from_service_account_info.__func__(TranscoderServiceAsyncClient, 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: + TranscoderServiceAsyncClient: The constructed client. + """ + return TranscoderServiceClient.from_service_account_file.__func__(TranscoderServiceAsyncClient, filename, *args, **kwargs) # type: ignore + from_service_account_json = from_service_account_file @property @@ -166,18 +195,20 @@ async def create_job( r"""Creates a job in the specified region. Args: - request (:class:`~.services.CreateJobRequest`): + request (:class:`google.cloud.video.transcoder_v1beta1.types.CreateJobRequest`): The request object. Request message for `TranscoderService.CreateJob`. parent (:class:`str`): Required. The parent location to create and process this job. Format: ``projects/{project}/locations/{location}`` + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - job (:class:`~.resources.Job`): + job (:class:`google.cloud.video.transcoder_v1beta1.types.Job`): Required. Parameters for creating transcoding job. + This corresponds to the ``job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -189,7 +220,7 @@ async def create_job( sent along with the request as metadata. Returns: - ~.resources.Job: + google.cloud.video.transcoder_v1beta1.types.Job: Transcoding job resource. """ # Create or coerce a protobuf request object. @@ -244,13 +275,14 @@ async def list_jobs( r"""Lists jobs in the specified region. Args: - request (:class:`~.services.ListJobsRequest`): + request (:class:`google.cloud.video.transcoder_v1beta1.types.ListJobsRequest`): The request object. Request message for `TranscoderService.ListJobs`. The parent location from which to retrieve the collection of jobs. parent (:class:`str`): Required. Format: ``projects/{project}/locations/{location}`` + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -262,8 +294,8 @@ async def list_jobs( sent along with the request as metadata. Returns: - ~.pagers.ListJobsAsyncPager: - Response message for ``TranscoderService.ListJobs``. + google.cloud.video.transcoder_v1beta1.services.transcoder_service.pagers.ListJobsAsyncPager: + Response message for TranscoderService.ListJobs. Iterating over this object will yield results and resolve additional pages automatically. @@ -325,12 +357,13 @@ async def get_job( r"""Returns the job data. Args: - request (:class:`~.services.GetJobRequest`): + request (:class:`google.cloud.video.transcoder_v1beta1.types.GetJobRequest`): The request object. Request message for `TranscoderService.GetJob`. name (:class:`str`): Required. The name of the job to retrieve. Format: ``projects/{project}/locations/{location}/jobs/{job}`` + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -342,7 +375,7 @@ async def get_job( sent along with the request as metadata. Returns: - ~.resources.Job: + google.cloud.video.transcoder_v1beta1.types.Job: Transcoding job resource. """ # Create or coerce a protobuf request object. @@ -395,12 +428,13 @@ async def delete_job( r"""Deletes a job. Args: - request (:class:`~.services.DeleteJobRequest`): + request (:class:`google.cloud.video.transcoder_v1beta1.types.DeleteJobRequest`): The request object. Request message for `TranscoderService.DeleteJob`. name (:class:`str`): Required. The name of the job to delete. Format: ``projects/{project}/locations/{location}/jobs/{job}`` + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -462,19 +496,21 @@ async def create_job_template( r"""Creates a job template in the specified region. Args: - request (:class:`~.services.CreateJobTemplateRequest`): + request (:class:`google.cloud.video.transcoder_v1beta1.types.CreateJobTemplateRequest`): The request object. Request message for `TranscoderService.CreateJobTemplate`. parent (:class:`str`): Required. The parent location to create this job template. Format: ``projects/{project}/locations/{location}`` + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - job_template (:class:`~.resources.JobTemplate`): + job_template (:class:`google.cloud.video.transcoder_v1beta1.types.JobTemplate`): Required. Parameters for creating job template. + This corresponds to the ``job_template`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -486,6 +522,7 @@ async def create_job_template( This value should be 4-63 characters, and valid characters must match the regular expression ``[a-zA-Z][a-zA-Z0-9_-]*``. + This corresponds to the ``job_template_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -497,7 +534,7 @@ async def create_job_template( sent along with the request as metadata. Returns: - ~.resources.JobTemplate: + google.cloud.video.transcoder_v1beta1.types.JobTemplate: Transcoding job template resource. """ # Create or coerce a protobuf request object. @@ -554,13 +591,14 @@ async def list_job_templates( r"""Lists job templates in the specified region. Args: - request (:class:`~.services.ListJobTemplatesRequest`): + request (:class:`google.cloud.video.transcoder_v1beta1.types.ListJobTemplatesRequest`): The request object. Request message for `TranscoderService.ListJobTemplates`. parent (:class:`str`): Required. The parent location from which to retrieve the collection of job templates. Format: ``projects/{project}/locations/{location}`` + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -572,9 +610,8 @@ async def list_job_templates( sent along with the request as metadata. Returns: - ~.pagers.ListJobTemplatesAsyncPager: - Response message for - ``TranscoderService.ListJobTemplates``. + google.cloud.video.transcoder_v1beta1.services.transcoder_service.pagers.ListJobTemplatesAsyncPager: + Response message for TranscoderService.ListJobTemplates. Iterating over this object will yield results and resolve additional pages automatically. @@ -636,13 +673,14 @@ async def get_job_template( r"""Returns the job template data. Args: - request (:class:`~.services.GetJobTemplateRequest`): + request (:class:`google.cloud.video.transcoder_v1beta1.types.GetJobTemplateRequest`): The request object. Request message for `TranscoderService.GetJobTemplate`. name (:class:`str`): Required. The name of the job template to retrieve. Format: ``projects/{project}/locations/{location}/jobTemplates/{job_template}`` + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -654,7 +692,7 @@ async def get_job_template( sent along with the request as metadata. Returns: - ~.resources.JobTemplate: + google.cloud.video.transcoder_v1beta1.types.JobTemplate: Transcoding job template resource. """ # Create or coerce a protobuf request object. @@ -707,12 +745,13 @@ async def delete_job_template( r"""Deletes a job template. Args: - request (:class:`~.services.DeleteJobTemplateRequest`): + request (:class:`google.cloud.video.transcoder_v1beta1.types.DeleteJobTemplateRequest`): The request object. Request message for `TranscoderService.DeleteJobTemplate`. name (:class:`str`): Required. The name of the job template to delete. ``projects/{project}/locations/{location}/jobTemplates/{job_template}`` + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/client.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/client.py index f91a9ebc8295..4fda2f5ba09d 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/client.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/client.py @@ -121,6 +121,22 @@ def _get_default_mtls_endpoint(api_endpoint): DEFAULT_ENDPOINT ) + @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: + TranscoderServiceClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_info(info) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials @@ -133,7 +149,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): kwargs: Additional arguments to pass to the constructor. Returns: - {@api.name}: The constructed client. + TranscoderServiceClient: The constructed client. """ credentials = service_account.Credentials.from_service_account_file(filename) kwargs["credentials"] = credentials @@ -257,10 +273,10 @@ def __init__( credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment. - transport (Union[str, ~.TranscoderServiceTransport]): The + transport (Union[str, TranscoderServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (client_options_lib.ClientOptions): Custom options for the + client_options (google.api_core.client_options.ClientOptions): Custom options for the client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT @@ -296,21 +312,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: @@ -353,7 +365,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, ) @@ -371,18 +383,20 @@ def create_job( r"""Creates a job in the specified region. Args: - request (:class:`~.services.CreateJobRequest`): + request (google.cloud.video.transcoder_v1beta1.types.CreateJobRequest): The request object. Request message for `TranscoderService.CreateJob`. - parent (:class:`str`): + parent (str): Required. The parent location to create and process this job. Format: ``projects/{project}/locations/{location}`` + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - job (:class:`~.resources.Job`): + job (google.cloud.video.transcoder_v1beta1.types.Job): Required. Parameters for creating transcoding job. + This corresponds to the ``job`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -394,7 +408,7 @@ def create_job( sent along with the request as metadata. Returns: - ~.resources.Job: + google.cloud.video.transcoder_v1beta1.types.Job: Transcoding job resource. """ # Create or coerce a protobuf request object. @@ -450,13 +464,14 @@ def list_jobs( r"""Lists jobs in the specified region. Args: - request (:class:`~.services.ListJobsRequest`): + request (google.cloud.video.transcoder_v1beta1.types.ListJobsRequest): The request object. Request message for `TranscoderService.ListJobs`. The parent location from which to retrieve the collection of jobs. - parent (:class:`str`): + parent (str): Required. Format: ``projects/{project}/locations/{location}`` + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -468,8 +483,8 @@ def list_jobs( sent along with the request as metadata. Returns: - ~.pagers.ListJobsPager: - Response message for ``TranscoderService.ListJobs``. + google.cloud.video.transcoder_v1beta1.services.transcoder_service.pagers.ListJobsPager: + Response message for TranscoderService.ListJobs. Iterating over this object will yield results and resolve additional pages automatically. @@ -532,12 +547,13 @@ def get_job( r"""Returns the job data. Args: - request (:class:`~.services.GetJobRequest`): + request (google.cloud.video.transcoder_v1beta1.types.GetJobRequest): The request object. Request message for `TranscoderService.GetJob`. - name (:class:`str`): + name (str): Required. The name of the job to retrieve. Format: ``projects/{project}/locations/{location}/jobs/{job}`` + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -549,7 +565,7 @@ def get_job( sent along with the request as metadata. Returns: - ~.resources.Job: + google.cloud.video.transcoder_v1beta1.types.Job: Transcoding job resource. """ # Create or coerce a protobuf request object. @@ -603,12 +619,13 @@ def delete_job( r"""Deletes a job. Args: - request (:class:`~.services.DeleteJobRequest`): + request (google.cloud.video.transcoder_v1beta1.types.DeleteJobRequest): The request object. Request message for `TranscoderService.DeleteJob`. - name (:class:`str`): + name (str): Required. The name of the job to delete. Format: ``projects/{project}/locations/{location}/jobs/{job}`` + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -671,23 +688,25 @@ def create_job_template( r"""Creates a job template in the specified region. Args: - request (:class:`~.services.CreateJobTemplateRequest`): + request (google.cloud.video.transcoder_v1beta1.types.CreateJobTemplateRequest): The request object. Request message for `TranscoderService.CreateJobTemplate`. - parent (:class:`str`): + parent (str): Required. The parent location to create this job template. Format: ``projects/{project}/locations/{location}`` + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - job_template (:class:`~.resources.JobTemplate`): + job_template (google.cloud.video.transcoder_v1beta1.types.JobTemplate): Required. Parameters for creating job template. + This corresponds to the ``job_template`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - job_template_id (:class:`str`): + job_template_id (str): Required. The ID to use for the job template, which will become the final component of the job template's resource name. @@ -695,6 +714,7 @@ def create_job_template( This value should be 4-63 characters, and valid characters must match the regular expression ``[a-zA-Z][a-zA-Z0-9_-]*``. + This corresponds to the ``job_template_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -706,7 +726,7 @@ def create_job_template( sent along with the request as metadata. Returns: - ~.resources.JobTemplate: + google.cloud.video.transcoder_v1beta1.types.JobTemplate: Transcoding job template resource. """ # Create or coerce a protobuf request object. @@ -764,13 +784,14 @@ def list_job_templates( r"""Lists job templates in the specified region. Args: - request (:class:`~.services.ListJobTemplatesRequest`): + request (google.cloud.video.transcoder_v1beta1.types.ListJobTemplatesRequest): The request object. Request message for `TranscoderService.ListJobTemplates`. - parent (:class:`str`): + parent (str): Required. The parent location from which to retrieve the collection of job templates. Format: ``projects/{project}/locations/{location}`` + This corresponds to the ``parent`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -782,9 +803,8 @@ def list_job_templates( sent along with the request as metadata. Returns: - ~.pagers.ListJobTemplatesPager: - Response message for - ``TranscoderService.ListJobTemplates``. + google.cloud.video.transcoder_v1beta1.services.transcoder_service.pagers.ListJobTemplatesPager: + Response message for TranscoderService.ListJobTemplates. Iterating over this object will yield results and resolve additional pages automatically. @@ -847,13 +867,14 @@ def get_job_template( r"""Returns the job template data. Args: - request (:class:`~.services.GetJobTemplateRequest`): + request (google.cloud.video.transcoder_v1beta1.types.GetJobTemplateRequest): The request object. Request message for `TranscoderService.GetJobTemplate`. - name (:class:`str`): + name (str): Required. The name of the job template to retrieve. Format: ``projects/{project}/locations/{location}/jobTemplates/{job_template}`` + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. @@ -865,7 +886,7 @@ def get_job_template( sent along with the request as metadata. Returns: - ~.resources.JobTemplate: + google.cloud.video.transcoder_v1beta1.types.JobTemplate: Transcoding job template resource. """ # Create or coerce a protobuf request object. @@ -919,12 +940,13 @@ def delete_job_template( r"""Deletes a job template. Args: - request (:class:`~.services.DeleteJobTemplateRequest`): + request (google.cloud.video.transcoder_v1beta1.types.DeleteJobTemplateRequest): The request object. Request message for `TranscoderService.DeleteJobTemplate`. - name (:class:`str`): + name (str): Required. The name of the job template to delete. ``projects/{project}/locations/{location}/jobTemplates/{job_template}`` + This corresponds to the ``name`` field on the ``request`` instance; if ``request`` is provided, this should not be set. diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/pagers.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/pagers.py index fded4ec90902..c49103559ad9 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/pagers.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/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.video.transcoder_v1beta1.types import resources from google.cloud.video.transcoder_v1beta1.types import services @@ -25,7 +34,7 @@ class ListJobsPager: """A pager for iterating through ``list_jobs`` requests. This class thinly wraps an initial - :class:`~.services.ListJobsResponse` object, and + :class:`google.cloud.video.transcoder_v1beta1.types.ListJobsResponse` object, and provides an ``__iter__`` method to iterate through its ``jobs`` field. @@ -34,7 +43,7 @@ class ListJobsPager: through the ``jobs`` field on the corresponding responses. - All the usual :class:`~.services.ListJobsResponse` + All the usual :class:`google.cloud.video.transcoder_v1beta1.types.ListJobsResponse` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ @@ -52,9 +61,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.services.ListJobsRequest`): + request (google.cloud.video.transcoder_v1beta1.types.ListJobsRequest): The initial request object. - response (:class:`~.services.ListJobsResponse`): + response (google.cloud.video.transcoder_v1beta1.types.ListJobsResponse): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. @@ -87,7 +96,7 @@ class ListJobsAsyncPager: """A pager for iterating through ``list_jobs`` requests. This class thinly wraps an initial - :class:`~.services.ListJobsResponse` object, and + :class:`google.cloud.video.transcoder_v1beta1.types.ListJobsResponse` object, and provides an ``__aiter__`` method to iterate through its ``jobs`` field. @@ -96,7 +105,7 @@ class ListJobsAsyncPager: through the ``jobs`` field on the corresponding responses. - All the usual :class:`~.services.ListJobsResponse` + All the usual :class:`google.cloud.video.transcoder_v1beta1.types.ListJobsResponse` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ @@ -114,9 +123,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.services.ListJobsRequest`): + request (google.cloud.video.transcoder_v1beta1.types.ListJobsRequest): The initial request object. - response (:class:`~.services.ListJobsResponse`): + response (google.cloud.video.transcoder_v1beta1.types.ListJobsResponse): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. @@ -153,7 +162,7 @@ class ListJobTemplatesPager: """A pager for iterating through ``list_job_templates`` requests. This class thinly wraps an initial - :class:`~.services.ListJobTemplatesResponse` object, and + :class:`google.cloud.video.transcoder_v1beta1.types.ListJobTemplatesResponse` object, and provides an ``__iter__`` method to iterate through its ``job_templates`` field. @@ -162,7 +171,7 @@ class ListJobTemplatesPager: through the ``job_templates`` field on the corresponding responses. - All the usual :class:`~.services.ListJobTemplatesResponse` + All the usual :class:`google.cloud.video.transcoder_v1beta1.types.ListJobTemplatesResponse` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ @@ -180,9 +189,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.services.ListJobTemplatesRequest`): + request (google.cloud.video.transcoder_v1beta1.types.ListJobTemplatesRequest): The initial request object. - response (:class:`~.services.ListJobTemplatesResponse`): + response (google.cloud.video.transcoder_v1beta1.types.ListJobTemplatesResponse): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. @@ -215,7 +224,7 @@ class ListJobTemplatesAsyncPager: """A pager for iterating through ``list_job_templates`` requests. This class thinly wraps an initial - :class:`~.services.ListJobTemplatesResponse` object, and + :class:`google.cloud.video.transcoder_v1beta1.types.ListJobTemplatesResponse` object, and provides an ``__aiter__`` method to iterate through its ``job_templates`` field. @@ -224,7 +233,7 @@ class ListJobTemplatesAsyncPager: through the ``job_templates`` field on the corresponding responses. - All the usual :class:`~.services.ListJobTemplatesResponse` + All the usual :class:`google.cloud.video.transcoder_v1beta1.types.ListJobTemplatesResponse` attributes are available on the pager. If multiple requests are made, only the most recent response is retained, and thus used for attribute lookup. """ @@ -242,9 +251,9 @@ def __init__( Args: method (Callable): The method that was originally called, and which instantiated this pager. - request (:class:`~.services.ListJobTemplatesRequest`): + request (google.cloud.video.transcoder_v1beta1.types.ListJobTemplatesRequest): The initial request object. - response (:class:`~.services.ListJobTemplatesResponse`): + response (google.cloud.video.transcoder_v1beta1.types.ListJobTemplatesResponse): The initial response object. metadata (Sequence[Tuple[str, str]]): Strings which should be sent along with the request as metadata. diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/base.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/base.py index dbb7824096e2..6fadda63b3dd 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/base.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/base.py @@ -71,10 +71,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. @@ -82,6 +82,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: @@ -91,20 +94,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/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/grpc.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/grpc.py index 451b25f56740..edaf816dbb5c 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/grpc.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/grpc.py @@ -65,6 +65,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: @@ -95,6 +96,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): @@ -109,72 +114,60 @@ 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] = {} + + 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 - - # 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 client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) - if 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), @@ -182,17 +175,8 @@ def __init__( ], ) - self._stubs = {} # type: Dict[str, Callable] - - # 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( @@ -206,7 +190,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/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/grpc_asyncio.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/grpc_asyncio.py index 282c6caa7e52..5edbb59001dd 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/grpc_asyncio.py @@ -69,7 +69,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 @@ -109,6 +109,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: @@ -140,12 +141,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: @@ -154,72 +159,60 @@ 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] = {} + + 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 - - # 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 client_cert_source_for_mtls and not ssl_channel_credentials: + cert, key = client_cert_source_for_mtls() + self._ssl_channel_credentials = grpc.ssl_channel_credentials( + certificate_chain=cert, private_key=key + ) - if 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), @@ -227,17 +220,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 = {} + # 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/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/types/__init__.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/types/__init__.py index 971841eecd1b..091563dd1eca 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/types/__init__.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/types/__init__.py @@ -16,71 +16,71 @@ # from .resources import ( - Job, - JobTemplate, - JobConfig, - Input, - Output, - EditAtom, AdBreak, + AudioStream, + EditAtom, ElementaryStream, - MuxStream, + Encryption, + FailureDetail, + Input, + Job, + JobConfig, + JobTemplate, Manifest, - PubsubDestination, - SpriteSheet, + MuxStream, + Output, Overlay, PreprocessingConfig, - VideoStream, - AudioStream, - TextStream, - SegmentSettings, - Encryption, Progress, - FailureDetail, + PubsubDestination, + SegmentSettings, + SpriteSheet, + TextStream, + VideoStream, ) from .services import ( CreateJobRequest, - ListJobsRequest, - GetJobRequest, + CreateJobTemplateRequest, DeleteJobRequest, + DeleteJobTemplateRequest, + GetJobRequest, + GetJobTemplateRequest, + ListJobsRequest, ListJobsResponse, - CreateJobTemplateRequest, ListJobTemplatesRequest, - GetJobTemplateRequest, - DeleteJobTemplateRequest, ListJobTemplatesResponse, ) __all__ = ( - "Job", - "JobTemplate", - "JobConfig", - "Input", - "Output", - "EditAtom", "AdBreak", + "AudioStream", + "EditAtom", "ElementaryStream", - "MuxStream", + "Encryption", + "FailureDetail", + "Input", + "Job", + "JobConfig", + "JobTemplate", "Manifest", - "PubsubDestination", - "SpriteSheet", + "MuxStream", + "Output", "Overlay", "PreprocessingConfig", - "VideoStream", - "AudioStream", - "TextStream", - "SegmentSettings", - "Encryption", "Progress", - "FailureDetail", + "PubsubDestination", + "SegmentSettings", + "SpriteSheet", + "TextStream", + "VideoStream", "CreateJobRequest", - "ListJobsRequest", - "GetJobRequest", + "CreateJobTemplateRequest", "DeleteJobRequest", + "DeleteJobTemplateRequest", + "GetJobRequest", + "GetJobTemplateRequest", + "ListJobsRequest", "ListJobsResponse", - "CreateJobTemplateRequest", "ListJobTemplatesRequest", - "GetJobTemplateRequest", - "DeleteJobTemplateRequest", "ListJobTemplatesResponse", ) diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/types/resources.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/types/resources.py index 886df3bbf33a..38bac9e03438 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/types/resources.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/types/resources.py @@ -78,34 +78,34 @@ class Job(proto.Message): - ``preset/{preset_id}`` - User defined JobTemplate: ``{job_template_id}`` - config (~.resources.JobConfig): + config (google.cloud.video.transcoder_v1beta1.types.JobConfig): The configuration for this job. priority (int): Specify the priority of the job. Enter a value between 0 and 100, where 0 is the lowest priority and 100 is the highest priority. The default is 0. - origin_uri (~.resources.Job.OriginUri): + origin_uri (google.cloud.video.transcoder_v1beta1.types.Job.OriginUri): Output only. The origin URI. - state (~.resources.Job.ProcessingState): + state (google.cloud.video.transcoder_v1beta1.types.Job.ProcessingState): Output only. The current state of the job. - progress (~.resources.Progress): + progress (google.cloud.video.transcoder_v1beta1.types.Progress): Output only. Estimated fractional progress, from ``0`` to ``1`` for each step. failure_reason (str): Output only. A description of the reason for the failure. This property is always present when ``state`` is ``FAILED``. - failure_details (Sequence[~.resources.FailureDetail]): + failure_details (Sequence[google.cloud.video.transcoder_v1beta1.types.FailureDetail]): Output only. List of failure details. This property may contain additional information about the failure when ``failure_reason`` is present. - create_time (~.timestamp.Timestamp): + create_time (google.protobuf.timestamp_pb2.Timestamp): Output only. The time the job was created. - start_time (~.timestamp.Timestamp): + start_time (google.protobuf.timestamp_pb2.Timestamp): Output only. The time the transcoding started. - end_time (~.timestamp.Timestamp): + end_time (google.protobuf.timestamp_pb2.Timestamp): Output only. The time the transcoding finished. """ @@ -175,7 +175,7 @@ class JobTemplate(proto.Message): name (str): The resource name of the job template. Format: ``projects/{project}/locations/{location}/jobTemplates/{job_template}`` - config (~.resources.JobConfig): + config (google.cloud.video.transcoder_v1beta1.types.JobConfig): The configuration for this template. """ @@ -188,28 +188,28 @@ class JobConfig(proto.Message): r"""Job configuration Attributes: - inputs (Sequence[~.resources.Input]): + inputs (Sequence[google.cloud.video.transcoder_v1beta1.types.Input]): List of input assets stored in Cloud Storage. - edit_list (Sequence[~.resources.EditAtom]): + edit_list (Sequence[google.cloud.video.transcoder_v1beta1.types.EditAtom]): List of ``Edit atom``\ s. Defines the ultimate timeline of the resulting file or manifest. - elementary_streams (Sequence[~.resources.ElementaryStream]): + elementary_streams (Sequence[google.cloud.video.transcoder_v1beta1.types.ElementaryStream]): List of elementary streams. - mux_streams (Sequence[~.resources.MuxStream]): + mux_streams (Sequence[google.cloud.video.transcoder_v1beta1.types.MuxStream]): List of multiplexing settings for output streams. - manifests (Sequence[~.resources.Manifest]): + manifests (Sequence[google.cloud.video.transcoder_v1beta1.types.Manifest]): List of output manifests. - output (~.resources.Output): + output (google.cloud.video.transcoder_v1beta1.types.Output): Output configuration. - ad_breaks (Sequence[~.resources.AdBreak]): + ad_breaks (Sequence[google.cloud.video.transcoder_v1beta1.types.AdBreak]): List of ad breaks. Specifies where to insert ad break tags in the output manifests. - pubsub_destination (~.resources.PubsubDestination): + pubsub_destination (google.cloud.video.transcoder_v1beta1.types.PubsubDestination): Destination on Pub/Sub. - sprite_sheets (Sequence[~.resources.SpriteSheet]): + sprite_sheets (Sequence[google.cloud.video.transcoder_v1beta1.types.SpriteSheet]): List of output sprite sheets. - overlays (Sequence[~.resources.Overlay]): + overlays (Sequence[google.cloud.video.transcoder_v1beta1.types.Overlay]): List of overlays on the output video, in descending Z-order. """ @@ -251,7 +251,7 @@ class Input(proto.Message): URI of the media. It must be stored in Cloud Storage. Example ``gs://bucket/inputs/file.mp4``. If empty the value will be populated from ``Job.input_uri``. - preprocessing_config (~.resources.PreprocessingConfig): + preprocessing_config (google.cloud.video.transcoder_v1beta1.types.PreprocessingConfig): Preprocessing configurations. """ @@ -288,11 +288,11 @@ class EditAtom(proto.Message): List of ``Input.key``\ s identifying files that should be used in this atom. The listed ``inputs`` must have the same timeline. - end_time_offset (~.duration.Duration): + end_time_offset (google.protobuf.duration_pb2.Duration): End time in seconds for the atom, relative to the input file timeline. When ``end_time_offset`` is not specified, the ``inputs`` are used until the end of the atom. - start_time_offset (~.duration.Duration): + start_time_offset (google.protobuf.duration_pb2.Duration): Start time in seconds for the atom, relative to the input file timeline. The default is ``0s``. """ @@ -310,7 +310,7 @@ class AdBreak(proto.Message): r"""Ad break. Attributes: - start_time_offset (~.duration.Duration): + start_time_offset (google.protobuf.duration_pb2.Duration): Start time in seconds for the ad break, relative to the output file timeline. The default is ``0s``. """ @@ -326,11 +326,11 @@ class ElementaryStream(proto.Message): Attributes: key (str): A unique key for this elementary stream. - video_stream (~.resources.VideoStream): + video_stream (google.cloud.video.transcoder_v1beta1.types.VideoStream): Encoding of a video stream. - audio_stream (~.resources.AudioStream): + audio_stream (google.cloud.video.transcoder_v1beta1.types.AudioStream): Encoding of an audio stream. - text_stream (~.resources.TextStream): + text_stream (google.cloud.video.transcoder_v1beta1.types.TextStream): Encoding of a text stream. For example, closed captions or subtitles. """ @@ -378,9 +378,9 @@ class MuxStream(proto.Message): elementary_streams (Sequence[str]): List of ``ElementaryStream.key``\ s multiplexed in this stream. - segment_settings (~.resources.SegmentSettings): + segment_settings (google.cloud.video.transcoder_v1beta1.types.SegmentSettings): Segment settings for ``"ts"``, ``"fmp4"`` and ``"vtt"``. - encryption (~.resources.Encryption): + encryption (google.cloud.video.transcoder_v1beta1.types.Encryption): Encryption settings. """ @@ -405,7 +405,7 @@ class Manifest(proto.Message): The name of the generated file. The default is ``"manifest"`` with the extension suffix corresponding to the ``Manifest.type``. - type_ (~.resources.Manifest.ManifestType): + type_ (google.cloud.video.transcoder_v1beta1.types.Manifest.ManifestType): Required. Type of the manifest, can be "HLS" or "DASH". mux_streams (Sequence[str]): @@ -474,10 +474,10 @@ class SpriteSheet(proto.Message): When the sprite sheet is full, a new sprite sheet is created. The default is 0, which indicates no maximum limit. - start_time_offset (~.duration.Duration): + start_time_offset (google.protobuf.duration_pb2.Duration): Start time in seconds, relative to the output file timeline. Determines the first sprite to pick. The default is ``0s``. - end_time_offset (~.duration.Duration): + end_time_offset (google.protobuf.duration_pb2.Duration): End time in seconds, relative to the output file timeline. When ``end_time_offset`` is not specified, the sprites are generated until the end of the output file. @@ -486,7 +486,7 @@ class SpriteSheet(proto.Message): number of sprites distributed evenly across the timeline of the output media. The default is 100. - interval (~.duration.Duration): + interval (google.protobuf.duration_pb2.Duration): Starting from ``0s``, create sprites at regular intervals. Specify the interval value in seconds. """ @@ -521,9 +521,9 @@ class Overlay(proto.Message): r"""Overlay configuration. Attributes: - image (~.resources.Overlay.Image): + image (google.cloud.video.transcoder_v1beta1.types.Overlay.Image): Image overlay. - animations (Sequence[~.resources.Overlay.Animation]): + animations (Sequence[google.cloud.video.transcoder_v1beta1.types.Overlay.Animation]): List of Animations. The list should be chronological, without any time overlap. """ @@ -555,7 +555,7 @@ class Image(proto.Message): uri (str): Required. URI of the image in Cloud Storage. For example, ``gs://bucket/inputs/image.jpeg``. - resolution (~.resources.Overlay.NormalizedCoordinate): + resolution (google.cloud.video.transcoder_v1beta1.types.Overlay.NormalizedCoordinate): Normalized image resolution, based on output video resolution. Valid values: ``0.0``–``1.0``. To respect the original image aspect ratio, set either ``x`` or ``y`` to @@ -578,11 +578,11 @@ class AnimationStatic(proto.Message): r"""Display static overlay object. Attributes: - xy (~.resources.Overlay.NormalizedCoordinate): + xy (google.cloud.video.transcoder_v1beta1.types.Overlay.NormalizedCoordinate): Normalized coordinates based on output video resolution. Valid values: ``0.0``–``1.0``. ``xy`` is the upper-left coordinate of the overlay object. - start_time_offset (~.duration.Duration): + start_time_offset (google.protobuf.duration_pb2.Duration): The time to start displaying the overlay object, in seconds. Default: 0 """ @@ -599,17 +599,17 @@ class AnimationFade(proto.Message): r"""Display overlay object with fade animation. Attributes: - fade_type (~.resources.Overlay.FadeType): + fade_type (google.cloud.video.transcoder_v1beta1.types.Overlay.FadeType): Required. Type of fade animation: ``FADE_IN`` or ``FADE_OUT``. - xy (~.resources.Overlay.NormalizedCoordinate): + xy (google.cloud.video.transcoder_v1beta1.types.Overlay.NormalizedCoordinate): Normalized coordinates based on output video resolution. Valid values: ``0.0``–``1.0``. ``xy`` is the upper-left coordinate of the overlay object. - start_time_offset (~.duration.Duration): + start_time_offset (google.protobuf.duration_pb2.Duration): The time to start the fade animation, in seconds. Default: 0 - end_time_offset (~.duration.Duration): + end_time_offset (google.protobuf.duration_pb2.Duration): The time to end the fade animation, in seconds. Default: ``start_time_offset`` + 1s """ @@ -634,7 +634,7 @@ class AnimationEnd(proto.Message): animation until the end of the video. Attributes: - start_time_offset (~.duration.Duration): + start_time_offset (google.protobuf.duration_pb2.Duration): The time to end overlay object, in seconds. Default: 0 """ @@ -647,11 +647,11 @@ class Animation(proto.Message): r"""Animation types. Attributes: - animation_static (~.resources.Overlay.AnimationStatic): + animation_static (google.cloud.video.transcoder_v1beta1.types.Overlay.AnimationStatic): Display static overlay object. - animation_fade (~.resources.Overlay.AnimationFade): + animation_fade (google.cloud.video.transcoder_v1beta1.types.Overlay.AnimationFade): Display overlay object with fade animation. - animation_end (~.resources.Overlay.AnimationEnd): + animation_end (google.cloud.video.transcoder_v1beta1.types.Overlay.AnimationEnd): End previous animation. """ @@ -685,13 +685,13 @@ class PreprocessingConfig(proto.Message): r"""Preprocessing configurations. Attributes: - color (~.resources.PreprocessingConfig.Color): + color (google.cloud.video.transcoder_v1beta1.types.PreprocessingConfig.Color): Color preprocessing configuration. - denoise (~.resources.PreprocessingConfig.Denoise): + denoise (google.cloud.video.transcoder_v1beta1.types.PreprocessingConfig.Denoise): Denoise preprocessing configuration. - deblock (~.resources.PreprocessingConfig.Deblock): + deblock (google.cloud.video.transcoder_v1beta1.types.PreprocessingConfig.Deblock): Deblock preprocessing configuration. - audio (~.resources.PreprocessingConfig.Audio): + audio (google.cloud.video.transcoder_v1beta1.types.PreprocessingConfig.Audio): Audio preprocessing configuration. """ @@ -883,7 +883,7 @@ class VideoStream(proto.Message): gop_frame_count (int): Select the GOP size based on the specified frame count. Must be greater than zero. - gop_duration (~.duration.Duration): + gop_duration (google.protobuf.duration_pb2.Duration): Select the GOP size based on the specified duration. The default is ``"3s"``. entropy_coder (str): @@ -1017,7 +1017,7 @@ class AudioStream(proto.Message): - 'sr' - Side right channel - 'fc' - Front center channel - 'lfe' - Low frequency - mapping (Sequence[~.resources.AudioStream.AudioAtom]): + mapping (Sequence[google.cloud.video.transcoder_v1beta1.types.AudioStream.AudioAtom]): The mapping for the ``Job.edit_list`` atoms with audio ``EditAtom.inputs``. sample_rate_hertz (int): @@ -1033,7 +1033,7 @@ class AudioAtom(proto.Message): key (str): Required. The ``EditAtom.key`` that references the atom with audio inputs in the ``Job.edit_list``. - channels (Sequence[~.resources.AudioStream.AudioAtom.AudioChannel]): + channels (Sequence[google.cloud.video.transcoder_v1beta1.types.AudioStream.AudioAtom.AudioChannel]): List of ``Channel``\ s for this audio stream. for in-depth explanation. """ @@ -1042,7 +1042,7 @@ class AudioChannel(proto.Message): r"""The audio channel. Attributes: - inputs (Sequence[~.resources.AudioStream.AudioAtom.AudioChannel.AudioChannelInput]): + inputs (Sequence[google.cloud.video.transcoder_v1beta1.types.AudioStream.AudioAtom.AudioChannel.AudioChannelInput]): List of ``Job.inputs`` for this audio channel. """ @@ -1117,7 +1117,7 @@ class TextStream(proto.Message): Required. The BCP-47 language code, such as ``"en-US"`` or ``"sr-Latn"``. For more information, see https://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - mapping (Sequence[~.resources.TextStream.TextAtom]): + mapping (Sequence[google.cloud.video.transcoder_v1beta1.types.TextStream.TextAtom]): The mapping for the ``Job.edit_list`` atoms with text ``EditAtom.inputs``. """ @@ -1130,7 +1130,7 @@ class TextAtom(proto.Message): key (str): Required. The ``EditAtom.key`` that references atom with text inputs in the ``Job.edit_list``. - inputs (Sequence[~.resources.TextStream.TextAtom.TextInput]): + inputs (Sequence[google.cloud.video.transcoder_v1beta1.types.TextStream.TextAtom.TextInput]): List of ``Job.inputs`` that should be embedded in this atom. Only one input is supported. """ @@ -1167,7 +1167,7 @@ class SegmentSettings(proto.Message): r"""Segment settings for ``"ts"``, ``"fmp4"`` and ``"vtt"``. Attributes: - segment_duration (~.duration.Duration): + segment_duration (google.protobuf.duration_pb2.Duration): Duration of the segments in seconds. The default is ``"6.0s"``. individual_segments (bool): @@ -1190,11 +1190,11 @@ class Encryption(proto.Message): iv (str): Required. 128 bit Initialization Vector (IV) represented as lowercase hexadecimal digits. - aes_128 (~.resources.Encryption.Aes128Encryption): + aes_128 (google.cloud.video.transcoder_v1beta1.types.Encryption.Aes128Encryption): Configuration for AES-128 encryption. - sample_aes (~.resources.Encryption.SampleAesEncryption): + sample_aes (google.cloud.video.transcoder_v1beta1.types.Encryption.SampleAesEncryption): Configuration for SAMPLE-AES encryption. - mpeg_cenc (~.resources.Encryption.MpegCommonEncryption): + mpeg_cenc (google.cloud.video.transcoder_v1beta1.types.Encryption.MpegCommonEncryption): Configuration for MPEG Common Encryption (MPEG-CENC). """ diff --git a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/types/services.py b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/types/services.py index 7e272354ae9c..f04de5f3bbfb 100644 --- a/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/types/services.py +++ b/packages/google-cloud-video-transcoder/google/cloud/video/transcoder_v1beta1/types/services.py @@ -45,7 +45,7 @@ class CreateJobRequest(proto.Message): parent (str): Required. The parent location to create and process this job. Format: ``projects/{project}/locations/{location}`` - job (~.resources.Job): + job (google.cloud.video.transcoder_v1beta1.types.Job): Required. Parameters for creating transcoding job. """ @@ -105,7 +105,7 @@ class ListJobsResponse(proto.Message): r"""Response message for ``TranscoderService.ListJobs``. Attributes: - jobs (Sequence[~.resources.Job]): + jobs (Sequence[google.cloud.video.transcoder_v1beta1.types.Job]): List of jobs in the specified region. next_page_token (str): The pagination token. @@ -127,7 +127,7 @@ class CreateJobTemplateRequest(proto.Message): parent (str): Required. The parent location to create this job template. Format: ``projects/{project}/locations/{location}`` - job_template (~.resources.JobTemplate): + job_template (google.cloud.video.transcoder_v1beta1.types.JobTemplate): Required. Parameters for creating job template. job_template_id (str): @@ -197,7 +197,7 @@ class ListJobTemplatesResponse(proto.Message): r"""Response message for ``TranscoderService.ListJobTemplates``. Attributes: - job_templates (Sequence[~.resources.JobTemplate]): + job_templates (Sequence[google.cloud.video.transcoder_v1beta1.types.JobTemplate]): List of job templates in the specified region. next_page_token (str): diff --git a/packages/google-cloud-video-transcoder/noxfile.py b/packages/google-cloud-video-transcoder/noxfile.py index a57e24be11e3..ae8392be56e2 100644 --- a/packages/google-cloud-video-transcoder/noxfile.py +++ b/packages/google-cloud-video-transcoder/noxfile.py @@ -18,6 +18,7 @@ from __future__ import absolute_import import os +import pathlib import shutil import nox @@ -30,6 +31,22 @@ 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", + "system", + "cover", + "lint", + "lint_setup_py", + "blacken", + "docs", +] + +# Error if a python version is missing +nox.options.error_on_missing_interpreters = True + @nox.session(python=DEFAULT_PYTHON_VERSION) def lint(session): @@ -70,17 +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("-e", ".") + session.install("asyncmock", "pytest-asyncio", "-c", constraints_path) + + 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", @@ -101,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") @@ -110,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) @@ -122,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) diff --git a/packages/google-cloud-video-transcoder/renovate.json b/packages/google-cloud-video-transcoder/renovate.json index 4fa949311b20..f08bc22c9a55 100644 --- a/packages/google-cloud-video-transcoder/renovate.json +++ b/packages/google-cloud-video-transcoder/renovate.json @@ -1,5 +1,6 @@ { "extends": [ "config:base", ":preserveSemverRanges" - ] + ], + "ignorePaths": [".pre-commit-config.yaml"] } diff --git a/packages/google-cloud-video-transcoder/setup.py b/packages/google-cloud-video-transcoder/setup.py index ede496d66e99..5d7d4b46a7e0 100644 --- a/packages/google-cloud-video-transcoder/setup.py +++ b/packages/google-cloud-video-transcoder/setup.py @@ -41,7 +41,7 @@ platforms="Posix; MacOS X; Windows", include_package_data=True, install_requires=( - "google-api-core[grpc] >= 1.22.0, < 2.0.0dev", + "google-api-core[grpc] >= 1.22.2, < 2.0.0dev", "proto-plus >= 1.4.0", ), python_requires=">=3.6", diff --git a/packages/google-cloud-video-transcoder/synth.metadata b/packages/google-cloud-video-transcoder/synth.metadata index a24835831a5e..838c7ddc22b3 100644 --- a/packages/google-cloud-video-transcoder/synth.metadata +++ b/packages/google-cloud-video-transcoder/synth.metadata @@ -3,30 +3,30 @@ { "git": { "name": ".", - "remote": "https://github.com/googleapis/python-video-transcoder.git", - "sha": "03332a4287ad31d2fd41f4de27c3fea5f20e1d53" + "remote": "git@github.com:googleapis/python-video-transcoder", + "sha": "86e91c228dc17f07d31fa4dd117a55bee49123ed" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "69697504d9eba1d064820c3085b4750767be6d08", - "internalRef": "348952930" + "sha": "336d6f419fe9466e4540083bbfa46a57f67dc92e", + "internalRef": "364666178" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "6b026e1443948dcfc0b9e3289c85e940eb70f694" + "sha": "86ed43d4f56e6404d068e62e497029018879c771" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "6b026e1443948dcfc0b9e3289c85e940eb70f694" + "sha": "86ed43d4f56e6404d068e62e497029018879c771" } } ], @@ -40,93 +40,5 @@ "generator": "bazel" } } - ], - "generatedFiles": [ - ".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/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/multiprocessing.rst", - "docs/transcoder_v1beta1/services.rst", - "docs/transcoder_v1beta1/types.rst", - "google/cloud/video/transcoder/__init__.py", - "google/cloud/video/transcoder/py.typed", - "google/cloud/video/transcoder_v1beta1/__init__.py", - "google/cloud/video/transcoder_v1beta1/py.typed", - "google/cloud/video/transcoder_v1beta1/services/__init__.py", - "google/cloud/video/transcoder_v1beta1/services/transcoder_service/__init__.py", - "google/cloud/video/transcoder_v1beta1/services/transcoder_service/async_client.py", - "google/cloud/video/transcoder_v1beta1/services/transcoder_service/client.py", - "google/cloud/video/transcoder_v1beta1/services/transcoder_service/pagers.py", - "google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/__init__.py", - "google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/base.py", - "google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/grpc.py", - "google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/grpc_asyncio.py", - "google/cloud/video/transcoder_v1beta1/types/__init__.py", - "google/cloud/video/transcoder_v1beta1/types/resources.py", - "google/cloud/video/transcoder_v1beta1/types/services.py", - "mypy.ini", - "noxfile.py", - "renovate.json", - "scripts/decrypt-secrets.sh", - "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/transcoder_v1beta1/__init__.py", - "tests/unit/gapic/transcoder_v1beta1/test_transcoder_service.py", - "video-transcoder-v1beta1-py.tar.gz" ] } \ No newline at end of file diff --git a/packages/google-cloud-video-transcoder/synth.py b/packages/google-cloud-video-transcoder/synth.py index ffa41fff56e4..d1b9e9cbfec5 100644 --- a/packages/google-cloud-video-transcoder/synth.py +++ b/packages/google-cloud-video-transcoder/synth.py @@ -37,6 +37,7 @@ library, excludes=[ "setup.py", + "README.rst", "docs/index.rst", "noxfile.py", f"scripts/fixup_transcoder_{version}_keywords.py", diff --git a/packages/google-cloud-video-transcoder/testing/constraints-3.6.txt b/packages/google-cloud-video-transcoder/testing/constraints-3.6.txt index 8bee7da4448b..a37a34aff5e9 100644 --- a/packages/google-cloud-video-transcoder/testing/constraints-3.6.txt +++ b/packages/google-cloud-video-transcoder/testing/constraints-3.6.txt @@ -5,5 +5,5 @@ # # 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.0 -proto-plus==1.4.0 \ No newline at end of file +google-api-core==1.22.2 +proto-plus==1.4.0 diff --git a/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1beta1/__init__.py b/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1beta1/__init__.py index 8b137891791f..42ffdf2bc43d 100644 --- a/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1beta1/__init__.py +++ b/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_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/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1beta1/test_transcoder_service.py b/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1beta1/test_transcoder_service.py index 3fd09ab81a84..c4a9e7ab6ff4 100644 --- a/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1beta1/test_transcoder_service.py +++ b/packages/google-cloud-video-transcoder/tests/unit/gapic/transcoder_v1beta1/test_transcoder_service.py @@ -93,7 +93,24 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", [TranscoderServiceClient, TranscoderServiceAsyncClient] + "client_class", [TranscoderServiceClient, TranscoderServiceAsyncClient,] +) +def test_transcoder_service_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 = client_class.from_service_account_info(info) + assert client.transport._credentials == creds + assert isinstance(client, client_class) + + assert client.transport._host == "transcoder.googleapis.com:443" + + +@pytest.mark.parametrize( + "client_class", [TranscoderServiceClient, TranscoderServiceAsyncClient,] ) def test_transcoder_service_client_from_service_account_file(client_class): creds = credentials.AnonymousCredentials() @@ -103,16 +120,21 @@ def test_transcoder_service_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 == "transcoder.googleapis.com:443" def test_transcoder_service_client_get_transport_class(): transport = TranscoderServiceClient.get_transport_class() - assert transport == transports.TranscoderServiceGrpcTransport + available_transports = [ + transports.TranscoderServiceGrpcTransport, + ] + assert transport in available_transports transport = TranscoderServiceClient.get_transport_class("grpc") assert transport == transports.TranscoderServiceGrpcTransport @@ -163,7 +185,7 @@ def test_transcoder_service_client_client_options( 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, ) @@ -179,7 +201,7 @@ def test_transcoder_service_client_client_options( 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, ) @@ -195,7 +217,7 @@ def test_transcoder_service_client_client_options( 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, ) @@ -223,7 +245,7 @@ def test_transcoder_service_client_client_options( 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, ) @@ -284,29 +306,25 @@ def test_transcoder_service_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. @@ -315,66 +333,53 @@ def test_transcoder_service_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", @@ -400,7 +405,7 @@ def test_transcoder_service_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, ) @@ -430,7 +435,7 @@ def test_transcoder_service_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, ) @@ -449,7 +454,7 @@ def test_transcoder_service_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, ) @@ -506,6 +511,22 @@ def test_create_job_from_dict(): test_create_job(request_type=dict) +def test_create_job_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 = TranscoderServiceClient( + credentials=credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_job), "__call__") as call: + client.create_job() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == services.CreateJobRequest() + + @pytest.mark.asyncio async def test_create_job_async( transport: str = "grpc_asyncio", request_type=services.CreateJobRequest @@ -728,6 +749,22 @@ def test_list_jobs_from_dict(): test_list_jobs(request_type=dict) +def test_list_jobs_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 = TranscoderServiceClient( + 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_jobs), "__call__") as call: + client.list_jobs() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == services.ListJobsRequest() + + @pytest.mark.asyncio async def test_list_jobs_async( transport: str = "grpc_asyncio", request_type=services.ListJobsRequest @@ -1047,6 +1084,22 @@ def test_get_job_from_dict(): test_get_job(request_type=dict) +def test_get_job_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 = TranscoderServiceClient( + 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_job), "__call__") as call: + client.get_job() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == services.GetJobRequest() + + @pytest.mark.asyncio async def test_get_job_async( transport: str = "grpc_asyncio", request_type=services.GetJobRequest @@ -1252,6 +1305,22 @@ def test_delete_job_from_dict(): test_delete_job(request_type=dict) +def test_delete_job_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 = TranscoderServiceClient( + 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_job), "__call__") as call: + client.delete_job() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == services.DeleteJobRequest() + + @pytest.mark.asyncio async def test_delete_job_async( transport: str = "grpc_asyncio", request_type=services.DeleteJobRequest @@ -1443,6 +1512,24 @@ def test_create_job_template_from_dict(): test_create_job_template(request_type=dict) +def test_create_job_template_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 = TranscoderServiceClient( + credentials=credentials.AnonymousCredentials(), transport="grpc", + ) + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_job_template), "__call__" + ) as call: + client.create_job_template() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == services.CreateJobTemplateRequest() + + @pytest.mark.asyncio async def test_create_job_template_async( transport: str = "grpc_asyncio", request_type=services.CreateJobTemplateRequest @@ -1676,6 +1763,24 @@ def test_list_job_templates_from_dict(): test_list_job_templates(request_type=dict) +def test_list_job_templates_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 = TranscoderServiceClient( + 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_job_templates), "__call__" + ) as call: + client.list_job_templates() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == services.ListJobTemplatesRequest() + + @pytest.mark.asyncio async def test_list_job_templates_async( transport: str = "grpc_asyncio", request_type=services.ListJobTemplatesRequest @@ -2029,6 +2134,22 @@ def test_get_job_template_from_dict(): test_get_job_template(request_type=dict) +def test_get_job_template_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 = TranscoderServiceClient( + 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_job_template), "__call__") as call: + client.get_job_template() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == services.GetJobTemplateRequest() + + @pytest.mark.asyncio async def test_get_job_template_async( transport: str = "grpc_asyncio", request_type=services.GetJobTemplateRequest @@ -2225,6 +2346,24 @@ def test_delete_job_template_from_dict(): test_delete_job_template(request_type=dict) +def test_delete_job_template_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 = TranscoderServiceClient( + 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_job_template), "__call__" + ) as call: + client.delete_job_template() + call.assert_called() + _, args, _ = call.mock_calls[0] + + assert args[0] == services.DeleteJobTemplateRequest() + + @pytest.mark.asyncio async def test_delete_job_template_async( transport: str = "grpc_asyncio", request_type=services.DeleteJobTemplateRequest @@ -2555,6 +2694,51 @@ def test_transcoder_service_transport_auth_adc(): ) +@pytest.mark.parametrize( + "transport_class", + [ + transports.TranscoderServiceGrpcTransport, + transports.TranscoderServiceGrpcAsyncIOTransport, + ], +) +def test_transcoder_service_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_transcoder_service_host_no_port(): client = TranscoderServiceClient( credentials=credentials.AnonymousCredentials(), @@ -2576,7 +2760,7 @@ def test_transcoder_service_host_with_port(): def test_transcoder_service_grpc_transport_channel(): - channel = grpc.insecure_channel("http://localhost/") + channel = grpc.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.TranscoderServiceGrpcTransport( @@ -2588,7 +2772,7 @@ def test_transcoder_service_grpc_transport_channel(): def test_transcoder_service_grpc_asyncio_transport_channel(): - channel = aio.insecure_channel("http://localhost/") + channel = aio.secure_channel("http://localhost/", grpc.local_channel_credentials()) # Check that channel is used if provided. transport = transports.TranscoderServiceGrpcAsyncIOTransport( @@ -2599,6 +2783,8 @@ def test_transcoder_service_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", [ @@ -2613,7 +2799,7 @@ def test_transcoder_service_transport_channel_mtls_with_client_cert_source( "grpc.ssl_channel_credentials", autospec=True ) as grpc_ssl_channel_cred: with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_ssl_cred = mock.Mock() grpc_ssl_channel_cred.return_value = mock_ssl_cred @@ -2651,6 +2837,8 @@ def test_transcoder_service_transport_channel_mtls_with_client_cert_source( 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", [ @@ -2666,7 +2854,7 @@ def test_transcoder_service_transport_channel_mtls_with_adc(transport_class): ssl_credentials=mock.PropertyMock(return_value=mock_ssl_cred), ): with mock.patch.object( - transport_class, "create_channel", autospec=True + transport_class, "create_channel" ) as grpc_create_channel: mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel diff --git a/packages/google-cloud-video-transcoder/video-transcoder-v1beta1-py.tar.gz b/packages/google-cloud-video-transcoder/video-transcoder-v1beta1-py.tar.gz deleted file mode 100644 index e69de29bb2d1..000000000000