From 48c939d1662cfad8b56cddd7f874c19672580ec3 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 25 Oct 2021 20:15:53 -0400 Subject: [PATCH 1/4] chore(python): push cloud library docs to staging bucket for Cloud RAD (#111) Source-Link: https://github.com/googleapis/synthtool/commit/7fd61f8efae782a7cfcecc599faf52f9737fe584 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:4ee57a76a176ede9087c14330c625a71553cf9c72828b2c0ca12f5338171ba60 Co-authored-by: Owl Bot --- .github/.OwlBot.lock.yaml | 2 +- .kokoro/docs/common.cfg | 1 + noxfile.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 7d98291..108063d 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:58f73ba196b5414782605236dd0712a73541b44ff2ff4d3a36ec41092dd6fa5b + digest: sha256:4ee57a76a176ede9087c14330c625a71553cf9c72828b2c0ca12f5338171ba60 diff --git a/.kokoro/docs/common.cfg b/.kokoro/docs/common.cfg index b35d666..5a57dda 100644 --- a/.kokoro/docs/common.cfg +++ b/.kokoro/docs/common.cfg @@ -30,6 +30,7 @@ env_vars: { env_vars: { key: "V2_STAGING_BUCKET" + # Push google cloud library docs to the Cloud RAD bucket `docs-staging-v2` value: "docs-staging-v2" } diff --git a/noxfile.py b/noxfile.py index f885c68..de41c6b 100644 --- a/noxfile.py +++ b/noxfile.py @@ -101,7 +101,7 @@ def default(session): "py.test", "--quiet", f"--junitxml=unit_{session.python}_sponge_log.xml", - "--cov=google/cloud", + "--cov=google", "--cov=tests/unit", "--cov-append", "--cov-config=.coveragerc", From c6878381c63dd863b164299997c9bd9f8b8dcaef Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Thu, 28 Oct 2021 11:54:14 -0400 Subject: [PATCH 2/4] chore: delete owlbot.py (#110) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: delete owlbot.py * update post processor image * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- docs/index.rst | 9 ++++++-- noxfile.py | 2 +- owlbot.py | 58 -------------------------------------------------- 3 files changed, 8 insertions(+), 61 deletions(-) delete mode 100644 owlbot.py diff --git a/docs/index.rst b/docs/index.rst index 4996c80..b69c1f1 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -2,6 +2,10 @@ .. include:: multiprocessing.rst +This package includes clients for multiple versions of Transcoder. +By default, you will get version ``transcoder_v1``. + + API Reference ------------- .. toctree:: @@ -18,12 +22,13 @@ API Reference transcoder_v1beta1/services transcoder_v1beta1/types + Changelog --------- For a list of all ``google-cloud-video-transcoder`` releases: .. toctree:: - :maxdepth: 2 + :maxdepth: 2 - changelog + changelog diff --git a/noxfile.py b/noxfile.py index de41c6b..2a2001c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -175,7 +175,7 @@ def cover(session): test runs (not system test runs), and then erases coverage data. """ session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=99") + session.run("coverage", "report", "--show-missing", "--fail-under=100") session.run("coverage", "erase") diff --git a/owlbot.py b/owlbot.py deleted file mode 100644 index a0200e7..0000000 --- a/owlbot.py +++ /dev/null @@ -1,58 +0,0 @@ -# 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. - -"""This script is used to synthesize generated parts of this library.""" -import os - -import synthtool as s -import synthtool.gcp as gcp -from synthtool.languages import python - -common = gcp.CommonTemplates() - -default_version = "v1" - -for library in s.get_staging_dirs(default_version): - # Work around generator issue https://github.com/googleapis/gapic-generator-python/issues/902 - s.replace(library / f"google/cloud/video/transcoder_{library.name}/types/resources.py", - r"""Sprite sheet configuration. - Attributes:""", - r"""Sprite sheet configuration.\n - Attributes:""") - - s.move( - library, - excludes=[ - "setup.py", - "README.rst", - "docs/index.rst", - "noxfile.py", - f"scripts/fixup_transcoder_{library.name}_keywords.py", - ], - ) - -s.remove_staging_dirs() - -# ---------------------------------------------------------------------------- -# Add templated files -# ---------------------------------------------------------------------------- -templated_files = common.py_library(cov_level=99, microgenerator=True) - -s.move( - templated_files, excludes=[".coveragerc"] -) # the microgenerator has a good coveragerc file - -python.py_samples(skip_readmes=True) - -s.shell.run(["nox", "-s", "blacken"], hide_output=False) From 985061433802e6a49a23e53b77aecbaafe7bf12a Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 4 Nov 2021 10:10:13 +0000 Subject: [PATCH 3/4] chore: use gapic-generator-python 0.53.4 (#112) - [ ] Regenerate this pull request now. docs: list oneofs in docstring fix(deps): require google-api-core >= 1.28.0 fix(deps): drop packaging dependency committer: busunkim96@ PiperOrigin-RevId: 406468269 Source-Link: https://github.com/googleapis/googleapis/commit/83d81b0c8fc22291a13398d6d77f02dc97a5b6f4 Source-Link: https://github.com/googleapis/googleapis-gen/commit/2ff001fbacb9e77e71d734de5f955c05fdae8526 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMmZmMDAxZmJhY2I5ZTc3ZTcxZDczNGRlNWY5NTVjMDVmZGFlODUyNiJ9 --- .../transcoder_service/async_client.py | 52 ++--- .../services/transcoder_service/client.py | 18 +- .../transcoder_service/transports/base.py | 35 +--- .../transports/grpc_asyncio.py | 1 - .../video/transcoder_v1/types/resources.py | 76 ++++++++ .../transcoder_service/async_client.py | 52 ++--- .../services/transcoder_service/client.py | 18 +- .../transcoder_service/transports/base.py | 35 +--- .../transports/grpc_asyncio.py | 1 - .../transcoder_v1beta1/types/resources.py | 58 ++++++ scripts/fixup_transcoder_v1_keywords.py | 183 ++++++++++++++++++ scripts/fixup_transcoder_v1beta1_keywords.py | 183 ++++++++++++++++++ setup.py | 3 +- testing/constraints-3.6.txt | 4 +- .../transcoder_v1/test_transcoder_service.py | 91 +-------- .../test_transcoder_service.py | 91 +-------- 16 files changed, 596 insertions(+), 305 deletions(-) create mode 100644 scripts/fixup_transcoder_v1_keywords.py create mode 100644 scripts/fixup_transcoder_v1beta1_keywords.py diff --git a/google/cloud/video/transcoder_v1/services/transcoder_service/async_client.py b/google/cloud/video/transcoder_v1/services/transcoder_service/async_client.py index d7cce70..b7daea9 100644 --- a/google/cloud/video/transcoder_v1/services/transcoder_service/async_client.py +++ b/google/cloud/video/transcoder_v1/services/transcoder_service/async_client.py @@ -19,13 +19,15 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core.client_options import ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.video.transcoder_v1.services.transcoder_service import pagers from google.cloud.video.transcoder_v1.types import resources from google.cloud.video.transcoder_v1.types import services @@ -177,18 +179,18 @@ def __init__( async def create_job( self, - request: services.CreateJobRequest = None, + request: Union[services.CreateJobRequest, dict] = None, *, parent: str = None, job: resources.Job = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Job: r"""Creates a job in the specified region. Args: - request (:class:`google.cloud.video.transcoder_v1.types.CreateJobRequest`): + request (Union[google.cloud.video.transcoder_v1.types.CreateJobRequest, dict]): The request object. Request message for `TranscoderService.CreateJob`. parent (:class:`str`): @@ -256,17 +258,17 @@ async def create_job( async def list_jobs( self, - request: services.ListJobsRequest = None, + request: Union[services.ListJobsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListJobsAsyncPager: r"""Lists jobs in the specified region. Args: - request (:class:`google.cloud.video.transcoder_v1.types.ListJobsRequest`): + request (Union[google.cloud.video.transcoder_v1.types.ListJobsRequest, dict]): The request object. Request message for `TranscoderService.ListJobs`. The parent location from which to retrieve the collection of jobs. @@ -336,17 +338,17 @@ async def list_jobs( async def get_job( self, - request: services.GetJobRequest = None, + request: Union[services.GetJobRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Job: r"""Returns the job data. Args: - request (:class:`google.cloud.video.transcoder_v1.types.GetJobRequest`): + request (Union[google.cloud.video.transcoder_v1.types.GetJobRequest, dict]): The request object. Request message for `TranscoderService.GetJob`. name (:class:`str`): @@ -405,17 +407,17 @@ async def get_job( async def delete_job( self, - request: services.DeleteJobRequest = None, + request: Union[services.DeleteJobRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes a job. Args: - request (:class:`google.cloud.video.transcoder_v1.types.DeleteJobRequest`): + request (Union[google.cloud.video.transcoder_v1.types.DeleteJobRequest, dict]): The request object. Request message for `TranscoderService.DeleteJob`. name (:class:`str`): @@ -469,19 +471,19 @@ async def delete_job( async def create_job_template( self, - request: services.CreateJobTemplateRequest = None, + request: Union[services.CreateJobTemplateRequest, dict] = None, *, parent: str = None, job_template: resources.JobTemplate = None, job_template_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.JobTemplate: r"""Creates a job template in the specified region. Args: - request (:class:`google.cloud.video.transcoder_v1.types.CreateJobTemplateRequest`): + request (Union[google.cloud.video.transcoder_v1.types.CreateJobTemplateRequest, dict]): The request object. Request message for `TranscoderService.CreateJobTemplate`. parent (:class:`str`): @@ -564,17 +566,17 @@ async def create_job_template( async def list_job_templates( self, - request: services.ListJobTemplatesRequest = None, + request: Union[services.ListJobTemplatesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListJobTemplatesAsyncPager: r"""Lists job templates in the specified region. Args: - request (:class:`google.cloud.video.transcoder_v1.types.ListJobTemplatesRequest`): + request (Union[google.cloud.video.transcoder_v1.types.ListJobTemplatesRequest, dict]): The request object. Request message for `TranscoderService.ListJobTemplates`. parent (:class:`str`): @@ -644,17 +646,17 @@ async def list_job_templates( async def get_job_template( self, - request: services.GetJobTemplateRequest = None, + request: Union[services.GetJobTemplateRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.JobTemplate: r"""Returns the job template data. Args: - request (:class:`google.cloud.video.transcoder_v1.types.GetJobTemplateRequest`): + request (Union[google.cloud.video.transcoder_v1.types.GetJobTemplateRequest, dict]): The request object. Request message for `TranscoderService.GetJobTemplate`. name (:class:`str`): @@ -714,17 +716,17 @@ async def get_job_template( async def delete_job_template( self, - request: services.DeleteJobTemplateRequest = None, + request: Union[services.DeleteJobTemplateRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes a job template. Args: - request (:class:`google.cloud.video.transcoder_v1.types.DeleteJobTemplateRequest`): + request (Union[google.cloud.video.transcoder_v1.types.DeleteJobTemplateRequest, dict]): The request object. Request message for `TranscoderService.DeleteJobTemplate`. name (:class:`str`): diff --git a/google/cloud/video/transcoder_v1/services/transcoder_service/client.py b/google/cloud/video/transcoder_v1/services/transcoder_service/client.py index 00a2235..be4298d 100644 --- a/google/cloud/video/transcoder_v1/services/transcoder_service/client.py +++ b/google/cloud/video/transcoder_v1/services/transcoder_service/client.py @@ -30,6 +30,8 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.video.transcoder_v1.services.transcoder_service import pagers from google.cloud.video.transcoder_v1.types import resources from google.cloud.video.transcoder_v1.types import services @@ -381,7 +383,7 @@ def create_job( *, parent: str = None, job: resources.Job = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Job: @@ -459,7 +461,7 @@ def list_jobs( request: Union[services.ListJobsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListJobsPager: @@ -539,7 +541,7 @@ def get_job( request: Union[services.GetJobRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Job: @@ -608,7 +610,7 @@ def delete_job( request: Union[services.DeleteJobRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -674,7 +676,7 @@ def create_job_template( parent: str = None, job_template: resources.JobTemplate = None, job_template_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.JobTemplate: @@ -767,7 +769,7 @@ def list_job_templates( request: Union[services.ListJobTemplatesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListJobTemplatesPager: @@ -847,7 +849,7 @@ def get_job_template( request: Union[services.GetJobTemplateRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.JobTemplate: @@ -917,7 +919,7 @@ def delete_job_template( request: Union[services.DeleteJobTemplateRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: diff --git a/google/cloud/video/transcoder_v1/services/transcoder_service/transports/base.py b/google/cloud/video/transcoder_v1/services/transcoder_service/transports/base.py index cf9d646..2e7bc75 100644 --- a/google/cloud/video/transcoder_v1/services/transcoder_service/transports/base.py +++ b/google/cloud/video/transcoder_v1/services/transcoder_service/transports/base.py @@ -15,7 +15,6 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version import pkg_resources import google.auth # type: ignore @@ -39,15 +38,6 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - class TranscoderServiceTransport(abc.ABC): """Abstract transport class for TranscoderService.""" @@ -97,7 +87,7 @@ def __init__( host += ":443" self._host = host - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. self._scopes = scopes @@ -130,29 +120,6 @@ def __init__( # Save the credentials. self._credentials = credentials - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc_asyncio.py b/google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc_asyncio.py index 512ba37..0a07613 100644 --- a/google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc_asyncio.py +++ b/google/cloud/video/transcoder_v1/services/transcoder_service/transports/grpc_asyncio.py @@ -20,7 +20,6 @@ from google.api_core import grpc_helpers_async # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/video/transcoder_v1/types/resources.py b/google/cloud/video/transcoder_v1/types/resources.py index 2bd7328..23248b0 100644 --- a/google/cloud/video/transcoder_v1/types/resources.py +++ b/google/cloud/video/transcoder_v1/types/resources.py @@ -48,6 +48,13 @@ class Job(proto.Message): r"""Transcoding job resource. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: name (str): The resource name of the job. Format: @@ -74,8 +81,11 @@ class Job(proto.Message): - ``preset/{preset_id}`` - User defined JobTemplate: ``{job_template_id}`` + + This field is a member of `oneof`_ ``job_config``. config (google.cloud.video.transcoder_v1.types.JobConfig): The configuration for this job. + This field is a member of `oneof`_ ``job_config``. state (google.cloud.video.transcoder_v1.types.Job.ProcessingState): Output only. The current state of the job. create_time (google.protobuf.timestamp_pb2.Timestamp): @@ -269,16 +279,26 @@ class ElementaryStream(proto.Message): track. Elementary streams must be packaged before mapping and sharing between different output formats. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: key (str): A unique key for this elementary stream. video_stream (google.cloud.video.transcoder_v1.types.VideoStream): Encoding of a video stream. + This field is a member of `oneof`_ ``elementary_stream``. audio_stream (google.cloud.video.transcoder_v1.types.AudioStream): Encoding of an audio stream. + This field is a member of `oneof`_ ``elementary_stream``. text_stream (google.cloud.video.transcoder_v1.types.TextStream): Encoding of a text stream. For example, closed captions or subtitles. + This field is a member of `oneof`_ ``elementary_stream``. """ key = proto.Field(proto.STRING, number=4,) @@ -378,6 +398,13 @@ class PubsubDestination(proto.Message): class SpriteSheet(proto.Message): r"""Sprite sheet configuration. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: format_ (str): Format type. The default is ``jpeg``. @@ -428,9 +455,11 @@ class SpriteSheet(proto.Message): number of sprites distributed evenly across the timeline of the output media. The default is 100. + This field is a member of `oneof`_ ``extraction_strategy``. interval (google.protobuf.duration_pb2.Duration): Starting from ``0s``, create sprites at regular intervals. Specify the interval value in seconds. + This field is a member of `oneof`_ ``extraction_strategy``. quality (int): The quality of the generated sprite sheet. Enter a value between 1 and 100, where 1 is the @@ -592,13 +621,23 @@ class AnimationEnd(proto.Message): class Animation(proto.Message): r"""Animation types. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: animation_static (google.cloud.video.transcoder_v1.types.Overlay.AnimationStatic): Display static overlay object. + This field is a member of `oneof`_ ``animation_type``. animation_fade (google.cloud.video.transcoder_v1.types.Overlay.AnimationFade): Display overlay object with fade animation. + This field is a member of `oneof`_ ``animation_type``. animation_end (google.cloud.video.transcoder_v1.types.Overlay.AnimationEnd): End previous animation. + This field is a member of `oneof`_ ``animation_type``. """ animation_static = proto.Field( @@ -794,18 +833,35 @@ class Pad(proto.Message): class VideoStream(proto.Message): r"""Video stream resource. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: h264 (google.cloud.video.transcoder_v1.types.VideoStream.H264CodecSettings): H264 codec settings. + This field is a member of `oneof`_ ``codec_settings``. h265 (google.cloud.video.transcoder_v1.types.VideoStream.H265CodecSettings): H265 codec settings. + This field is a member of `oneof`_ ``codec_settings``. vp9 (google.cloud.video.transcoder_v1.types.VideoStream.Vp9CodecSettings): VP9 codec settings. + This field is a member of `oneof`_ ``codec_settings``. """ class H264CodecSettings(proto.Message): r"""H264 codec settings. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: width_pixels (int): The width of the video in pixels. Must be an @@ -863,12 +919,14 @@ class H264CodecSettings(proto.Message): gop_frame_count (int): Select the GOP size based on the specified frame count. Must be greater than zero. + This field is a member of `oneof`_ ``gop_mode``. gop_duration (google.protobuf.duration_pb2.Duration): Select the GOP size based on the specified duration. The default is ``3s``. Note that ``gopDuration`` must be less than or equal to ```segmentDuration`` <#SegmentSettings>`__, and ```segmentDuration`` <#SegmentSettings>`__ must be divisible by ``gopDuration``. + This field is a member of `oneof`_ ``gop_mode``. enable_two_pass (bool): Use two-pass encoding strategy to achieve better video quality. ``VideoStream.rate_control_mode`` must be ``vbr``. @@ -955,6 +1013,13 @@ class H264CodecSettings(proto.Message): class H265CodecSettings(proto.Message): r"""H265 codec settings. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: width_pixels (int): The width of the video in pixels. Must be an @@ -1012,12 +1077,14 @@ class H265CodecSettings(proto.Message): gop_frame_count (int): Select the GOP size based on the specified frame count. Must be greater than zero. + This field is a member of `oneof`_ ``gop_mode``. gop_duration (google.protobuf.duration_pb2.Duration): Select the GOP size based on the specified duration. The default is ``3s``. Note that ``gopDuration`` must be less than or equal to ```segmentDuration`` <#SegmentSettings>`__, and ```segmentDuration`` <#SegmentSettings>`__ must be divisible by ``gopDuration``. + This field is a member of `oneof`_ ``gop_mode``. enable_two_pass (bool): Use two-pass encoding strategy to achieve better video quality. ``VideoStream.rate_control_mode`` must be ``vbr``. @@ -1116,6 +1183,13 @@ class H265CodecSettings(proto.Message): class Vp9CodecSettings(proto.Message): r"""VP9 codec settings. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: width_pixels (int): The width of the video in pixels. Must be an @@ -1170,12 +1244,14 @@ class Vp9CodecSettings(proto.Message): gop_frame_count (int): Select the GOP size based on the specified frame count. Must be greater than zero. + This field is a member of `oneof`_ ``gop_mode``. gop_duration (google.protobuf.duration_pb2.Duration): Select the GOP size based on the specified duration. The default is ``3s``. Note that ``gopDuration`` must be less than or equal to ```segmentDuration`` <#SegmentSettings>`__, and ```segmentDuration`` <#SegmentSettings>`__ must be divisible by ``gopDuration``. + This field is a member of `oneof`_ ``gop_mode``. profile (str): Enforces the specified codec profile. The following profiles are supported: diff --git a/google/cloud/video/transcoder_v1beta1/services/transcoder_service/async_client.py b/google/cloud/video/transcoder_v1beta1/services/transcoder_service/async_client.py index 1929949..8aac7a0 100644 --- a/google/cloud/video/transcoder_v1beta1/services/transcoder_service/async_client.py +++ b/google/cloud/video/transcoder_v1beta1/services/transcoder_service/async_client.py @@ -19,13 +19,15 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core.client_options import ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.video.transcoder_v1beta1.services.transcoder_service import pagers from google.cloud.video.transcoder_v1beta1.types import resources from google.cloud.video.transcoder_v1beta1.types import services @@ -176,18 +178,18 @@ def __init__( async def create_job( self, - request: services.CreateJobRequest = None, + request: Union[services.CreateJobRequest, dict] = None, *, parent: str = None, job: resources.Job = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Job: r"""Creates a job in the specified region. Args: - request (:class:`google.cloud.video.transcoder_v1beta1.types.CreateJobRequest`): + request (Union[google.cloud.video.transcoder_v1beta1.types.CreateJobRequest, dict]): The request object. Request message for `TranscoderService.CreateJob`. parent (:class:`str`): @@ -255,17 +257,17 @@ async def create_job( async def list_jobs( self, - request: services.ListJobsRequest = None, + request: Union[services.ListJobsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListJobsAsyncPager: r"""Lists jobs in the specified region. Args: - request (:class:`google.cloud.video.transcoder_v1beta1.types.ListJobsRequest`): + request (Union[google.cloud.video.transcoder_v1beta1.types.ListJobsRequest, dict]): The request object. Request message for `TranscoderService.ListJobs`. The parent location from which to retrieve the collection of jobs. @@ -335,17 +337,17 @@ async def list_jobs( async def get_job( self, - request: services.GetJobRequest = None, + request: Union[services.GetJobRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Job: r"""Returns the job data. Args: - request (:class:`google.cloud.video.transcoder_v1beta1.types.GetJobRequest`): + request (Union[google.cloud.video.transcoder_v1beta1.types.GetJobRequest, dict]): The request object. Request message for `TranscoderService.GetJob`. name (:class:`str`): @@ -404,17 +406,17 @@ async def get_job( async def delete_job( self, - request: services.DeleteJobRequest = None, + request: Union[services.DeleteJobRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes a job. Args: - request (:class:`google.cloud.video.transcoder_v1beta1.types.DeleteJobRequest`): + request (Union[google.cloud.video.transcoder_v1beta1.types.DeleteJobRequest, dict]): The request object. Request message for `TranscoderService.DeleteJob`. name (:class:`str`): @@ -468,19 +470,19 @@ async def delete_job( async def create_job_template( self, - request: services.CreateJobTemplateRequest = None, + request: Union[services.CreateJobTemplateRequest, dict] = None, *, parent: str = None, job_template: resources.JobTemplate = None, job_template_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.JobTemplate: r"""Creates a job template in the specified region. Args: - request (:class:`google.cloud.video.transcoder_v1beta1.types.CreateJobTemplateRequest`): + request (Union[google.cloud.video.transcoder_v1beta1.types.CreateJobTemplateRequest, dict]): The request object. Request message for `TranscoderService.CreateJobTemplate`. parent (:class:`str`): @@ -563,17 +565,17 @@ async def create_job_template( async def list_job_templates( self, - request: services.ListJobTemplatesRequest = None, + request: Union[services.ListJobTemplatesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListJobTemplatesAsyncPager: r"""Lists job templates in the specified region. Args: - request (:class:`google.cloud.video.transcoder_v1beta1.types.ListJobTemplatesRequest`): + request (Union[google.cloud.video.transcoder_v1beta1.types.ListJobTemplatesRequest, dict]): The request object. Request message for `TranscoderService.ListJobTemplates`. parent (:class:`str`): @@ -643,17 +645,17 @@ async def list_job_templates( async def get_job_template( self, - request: services.GetJobTemplateRequest = None, + request: Union[services.GetJobTemplateRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.JobTemplate: r"""Returns the job template data. Args: - request (:class:`google.cloud.video.transcoder_v1beta1.types.GetJobTemplateRequest`): + request (Union[google.cloud.video.transcoder_v1beta1.types.GetJobTemplateRequest, dict]): The request object. Request message for `TranscoderService.GetJobTemplate`. name (:class:`str`): @@ -713,17 +715,17 @@ async def get_job_template( async def delete_job_template( self, - request: services.DeleteJobTemplateRequest = None, + request: Union[services.DeleteJobTemplateRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes a job template. Args: - request (:class:`google.cloud.video.transcoder_v1beta1.types.DeleteJobTemplateRequest`): + request (Union[google.cloud.video.transcoder_v1beta1.types.DeleteJobTemplateRequest, dict]): The request object. Request message for `TranscoderService.DeleteJobTemplate`. name (:class:`str`): diff --git a/google/cloud/video/transcoder_v1beta1/services/transcoder_service/client.py b/google/cloud/video/transcoder_v1beta1/services/transcoder_service/client.py index a6adc6f..f86e1c3 100644 --- a/google/cloud/video/transcoder_v1beta1/services/transcoder_service/client.py +++ b/google/cloud/video/transcoder_v1beta1/services/transcoder_service/client.py @@ -30,6 +30,8 @@ from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +OptionalRetry = Union[retries.Retry, object] + from google.cloud.video.transcoder_v1beta1.services.transcoder_service import pagers from google.cloud.video.transcoder_v1beta1.types import resources from google.cloud.video.transcoder_v1beta1.types import services @@ -380,7 +382,7 @@ def create_job( *, parent: str = None, job: resources.Job = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Job: @@ -458,7 +460,7 @@ def list_jobs( request: Union[services.ListJobsRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListJobsPager: @@ -538,7 +540,7 @@ def get_job( request: Union[services.GetJobRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Job: @@ -607,7 +609,7 @@ def delete_job( request: Union[services.DeleteJobRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -673,7 +675,7 @@ def create_job_template( parent: str = None, job_template: resources.JobTemplate = None, job_template_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.JobTemplate: @@ -766,7 +768,7 @@ def list_job_templates( request: Union[services.ListJobTemplatesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListJobTemplatesPager: @@ -846,7 +848,7 @@ def get_job_template( request: Union[services.GetJobTemplateRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.JobTemplate: @@ -916,7 +918,7 @@ def delete_job_template( request: Union[services.DeleteJobTemplateRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: diff --git a/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/base.py b/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/base.py index 35f9e9b..65661e8 100644 --- a/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/base.py +++ b/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/base.py @@ -15,7 +15,6 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version import pkg_resources import google.auth # type: ignore @@ -39,15 +38,6 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - class TranscoderServiceTransport(abc.ABC): """Abstract transport class for TranscoderService.""" @@ -97,7 +87,7 @@ def __init__( host += ":443" self._host = host - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. self._scopes = scopes @@ -130,29 +120,6 @@ def __init__( # Save the credentials. self._credentials = credentials - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/grpc_asyncio.py b/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/grpc_asyncio.py index 2b5324e..5d71361 100644 --- a/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/grpc_asyncio.py +++ b/google/cloud/video/transcoder_v1beta1/services/transcoder_service/transports/grpc_asyncio.py @@ -20,7 +20,6 @@ from google.api_core import grpc_helpers_async # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/video/transcoder_v1beta1/types/resources.py b/google/cloud/video/transcoder_v1beta1/types/resources.py index 50341f1..fae1432 100644 --- a/google/cloud/video/transcoder_v1beta1/types/resources.py +++ b/google/cloud/video/transcoder_v1beta1/types/resources.py @@ -50,6 +50,13 @@ class Job(proto.Message): r"""Transcoding job resource. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: name (str): The resource name of the job. Format: @@ -76,8 +83,11 @@ class Job(proto.Message): - ``preset/{preset_id}`` - User defined JobTemplate: ``{job_template_id}`` + + This field is a member of `oneof`_ ``job_config``. config (google.cloud.video.transcoder_v1beta1.types.JobConfig): The configuration for this job. + This field is a member of `oneof`_ ``job_config``. priority (int): Specify the priority of the job. Enter a value between 0 and 100, where 0 is the lowest @@ -318,16 +328,26 @@ class ElementaryStream(proto.Message): track. Elementary streams must be packaged before mapping and sharing between different output formats. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: key (str): A unique key for this elementary stream. video_stream (google.cloud.video.transcoder_v1beta1.types.VideoStream): Encoding of a video stream. + This field is a member of `oneof`_ ``elementary_stream``. audio_stream (google.cloud.video.transcoder_v1beta1.types.AudioStream): Encoding of an audio stream. + This field is a member of `oneof`_ ``elementary_stream``. text_stream (google.cloud.video.transcoder_v1beta1.types.TextStream): Encoding of a text stream. For example, closed captions or subtitles. + This field is a member of `oneof`_ ``elementary_stream``. """ key = proto.Field(proto.STRING, number=4,) @@ -431,6 +451,13 @@ class PubsubDestination(proto.Message): class SpriteSheet(proto.Message): r"""Sprite sheet configuration. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: format_ (str): Format type. The default is ``"jpeg"``. @@ -481,9 +508,11 @@ class SpriteSheet(proto.Message): number of sprites distributed evenly across the timeline of the output media. The default is 100. + This field is a member of `oneof`_ ``extraction_strategy``. interval (google.protobuf.duration_pb2.Duration): Starting from ``0s``, create sprites at regular intervals. Specify the interval value in seconds. + This field is a member of `oneof`_ ``extraction_strategy``. quality (int): The quality of the generated sprite sheet. Enter a value between 1 and 100, where 1 is the @@ -645,13 +674,23 @@ class AnimationEnd(proto.Message): class Animation(proto.Message): r"""Animation types. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: animation_static (google.cloud.video.transcoder_v1beta1.types.Overlay.AnimationStatic): Display static overlay object. + This field is a member of `oneof`_ ``animation_type``. animation_fade (google.cloud.video.transcoder_v1beta1.types.Overlay.AnimationFade): Display overlay object with fade animation. + This field is a member of `oneof`_ ``animation_type``. animation_end (google.cloud.video.transcoder_v1beta1.types.Overlay.AnimationEnd): End previous animation. + This field is a member of `oneof`_ ``animation_type``. """ animation_static = proto.Field( @@ -847,6 +886,13 @@ class Pad(proto.Message): class VideoStream(proto.Message): r"""Video stream resource. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: codec (str): Codec type. The following codecs are supported: @@ -937,12 +983,14 @@ class VideoStream(proto.Message): gop_frame_count (int): Select the GOP size based on the specified frame count. Must be greater than zero. + This field is a member of `oneof`_ ``gop_mode``. gop_duration (google.protobuf.duration_pb2.Duration): Select the GOP size based on the specified duration. The default is ``"3s"``. Note that ``gopDuration`` must be less than or equal to ```segmentDuration`` <#SegmentSettings>`__, and ```segmentDuration`` <#SegmentSettings>`__ must be divisible by ``gopDuration``. + This field is a member of `oneof`_ ``gop_mode``. entropy_coder (str): The entropy coder to use. The default is ``"cabac"``. @@ -1191,6 +1239,13 @@ class SegmentSettings(proto.Message): class Encryption(proto.Message): r"""Encryption settings. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: key (str): Required. 128 bit encryption key represented @@ -1200,11 +1255,14 @@ class Encryption(proto.Message): represented as lowercase hexadecimal digits. aes_128 (google.cloud.video.transcoder_v1beta1.types.Encryption.Aes128Encryption): Configuration for AES-128 encryption. + This field is a member of `oneof`_ ``encryption_mode``. sample_aes (google.cloud.video.transcoder_v1beta1.types.Encryption.SampleAesEncryption): Configuration for SAMPLE-AES encryption. + This field is a member of `oneof`_ ``encryption_mode``. mpeg_cenc (google.cloud.video.transcoder_v1beta1.types.Encryption.MpegCommonEncryption): Configuration for MPEG Common Encryption (MPEG-CENC). + This field is a member of `oneof`_ ``encryption_mode``. """ class Aes128Encryption(proto.Message): diff --git a/scripts/fixup_transcoder_v1_keywords.py b/scripts/fixup_transcoder_v1_keywords.py new file mode 100644 index 0000000..45f161d --- /dev/null +++ b/scripts/fixup_transcoder_v1_keywords.py @@ -0,0 +1,183 @@ +#! /usr/bin/env python3 +# -*- 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. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class transcoderCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'create_job': ('parent', 'job', ), + 'create_job_template': ('parent', 'job_template', 'job_template_id', ), + 'delete_job': ('name', 'allow_missing', ), + 'delete_job_template': ('name', 'allow_missing', ), + 'get_job': ('name', ), + 'get_job_template': ('name', ), + 'list_jobs': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + 'list_job_templates': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: a.keyword.value not in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=transcoderCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the transcoder client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/scripts/fixup_transcoder_v1beta1_keywords.py b/scripts/fixup_transcoder_v1beta1_keywords.py new file mode 100644 index 0000000..1d0bea5 --- /dev/null +++ b/scripts/fixup_transcoder_v1beta1_keywords.py @@ -0,0 +1,183 @@ +#! /usr/bin/env python3 +# -*- 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. +# +import argparse +import os +import libcst as cst +import pathlib +import sys +from typing import (Any, Callable, Dict, List, Sequence, Tuple) + + +def partition( + predicate: Callable[[Any], bool], + iterator: Sequence[Any] +) -> Tuple[List[Any], List[Any]]: + """A stable, out-of-place partition.""" + results = ([], []) + + for i in iterator: + results[int(predicate(i))].append(i) + + # Returns trueList, falseList + return results[1], results[0] + + +class transcoderCallTransformer(cst.CSTTransformer): + CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') + METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { + 'create_job': ('parent', 'job', ), + 'create_job_template': ('parent', 'job_template', 'job_template_id', ), + 'delete_job': ('name', ), + 'delete_job_template': ('name', ), + 'get_job': ('name', ), + 'get_job_template': ('name', ), + 'list_jobs': ('parent', 'page_size', 'page_token', ), + 'list_job_templates': ('parent', 'page_size', 'page_token', ), + } + + def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: + try: + key = original.func.attr.value + kword_params = self.METHOD_TO_PARAMS[key] + except (AttributeError, KeyError): + # Either not a method from the API or too convoluted to be sure. + return updated + + # If the existing code is valid, keyword args come after positional args. + # Therefore, all positional args must map to the first parameters. + args, kwargs = partition(lambda a: not bool(a.keyword), updated.args) + if any(k.keyword.value == "request" for k in kwargs): + # We've already fixed this file, don't fix it again. + return updated + + kwargs, ctrl_kwargs = partition( + lambda a: a.keyword.value not in self.CTRL_PARAMS, + kwargs + ) + + args, ctrl_args = args[:len(kword_params)], args[len(kword_params):] + ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl)) + for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS)) + + request_arg = cst.Arg( + value=cst.Dict([ + cst.DictElement( + cst.SimpleString("'{}'".format(name)), +cst.Element(value=arg.value) + ) + # Note: the args + kwargs looks silly, but keep in mind that + # the control parameters had to be stripped out, and that + # those could have been passed positionally or by keyword. + for name, arg in zip(kword_params, args + kwargs)]), + keyword=cst.Name("request") + ) + + return updated.with_changes( + args=[request_arg] + ctrl_kwargs + ) + + +def fix_files( + in_dir: pathlib.Path, + out_dir: pathlib.Path, + *, + transformer=transcoderCallTransformer(), +): + """Duplicate the input dir to the output dir, fixing file method calls. + + Preconditions: + * in_dir is a real directory + * out_dir is a real, empty directory + """ + pyfile_gen = ( + pathlib.Path(os.path.join(root, f)) + for root, _, files in os.walk(in_dir) + for f in files if os.path.splitext(f)[1] == ".py" + ) + + for fpath in pyfile_gen: + with open(fpath, 'r') as f: + src = f.read() + + # Parse the code and insert method call fixes. + tree = cst.parse_module(src) + updated = tree.visit(transformer) + + # Create the path and directory structure for the new file. + updated_path = out_dir.joinpath(fpath.relative_to(in_dir)) + updated_path.parent.mkdir(parents=True, exist_ok=True) + + # Generate the updated source file at the corresponding path. + with open(updated_path, 'w') as f: + f.write(updated.code) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="""Fix up source that uses the transcoder client library. + +The existing sources are NOT overwritten but are copied to output_dir with changes made. + +Note: This tool operates at a best-effort level at converting positional + parameters in client method calls to keyword based parameters. + Cases where it WILL FAIL include + A) * or ** expansion in a method call. + B) Calls via function or method alias (includes free function calls) + C) Indirect or dispatched calls (e.g. the method is looked up dynamically) + + These all constitute false negatives. The tool will also detect false + positives when an API method shares a name with another method. +""") + parser.add_argument( + '-d', + '--input-directory', + required=True, + dest='input_dir', + help='the input directory to walk for python files to fix up', + ) + parser.add_argument( + '-o', + '--output-directory', + required=True, + dest='output_dir', + help='the directory to output files fixed via un-flattening', + ) + args = parser.parse_args() + input_dir = pathlib.Path(args.input_dir) + output_dir = pathlib.Path(args.output_dir) + if not input_dir.is_dir(): + print( + f"input directory '{input_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if not output_dir.is_dir(): + print( + f"output directory '{output_dir}' does not exist or is not a directory", + file=sys.stderr, + ) + sys.exit(-1) + + if os.listdir(output_dir): + print( + f"output directory '{output_dir}' is not empty", + file=sys.stderr, + ) + sys.exit(-1) + + fix_files(input_dir, output_dir) diff --git a/setup.py b/setup.py index ed23928..aac1fbe 100644 --- a/setup.py +++ b/setup.py @@ -44,9 +44,8 @@ # NOTE: Maintainers, please do not require google-api-core>=2.x.x # Until this issue is closed # https://github.com/googleapis/google-cloud-python/issues/10566 - "google-api-core[grpc] >= 1.26.0, <3.0.0dev", + "google-api-core[grpc] >= 1.28.0, <3.0.0dev", "proto-plus >= 1.4.0", - "packaging >= 14.3", ), python_requires=">=3.6", classifiers=[ diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index 4fda429..6b451bc 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -5,7 +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.26.0 +google-api-core==1.28.0 proto-plus==1.4.0 -packaging==14.3 -google-auth==1.24.0 # TODO: remove when google-auth>=1.25.0 si transitively required through google-api-core diff --git a/tests/unit/gapic/transcoder_v1/test_transcoder_service.py b/tests/unit/gapic/transcoder_v1/test_transcoder_service.py index 44a2468..0a1c81f 100644 --- a/tests/unit/gapic/transcoder_v1/test_transcoder_service.py +++ b/tests/unit/gapic/transcoder_v1/test_transcoder_service.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -40,9 +39,6 @@ ) from google.cloud.video.transcoder_v1.services.transcoder_service import pagers from google.cloud.video.transcoder_v1.services.transcoder_service import transports -from google.cloud.video.transcoder_v1.services.transcoder_service.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.video.transcoder_v1.types import resources from google.cloud.video.transcoder_v1.types import services from google.oauth2 import service_account @@ -53,20 +49,6 @@ import google.auth -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -224,7 +206,7 @@ def test_transcoder_service_client_client_options( options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -241,7 +223,7 @@ def test_transcoder_service_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -258,7 +240,7 @@ def test_transcoder_service_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -287,7 +269,7 @@ def test_transcoder_service_client_client_options( options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -356,7 +338,7 @@ def test_transcoder_service_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) if use_client_cert_env == "false": expected_client_cert_source = None @@ -398,7 +380,7 @@ def test_transcoder_service_client_mtls_env_auto( expected_client_cert_source = client_cert_source_callback patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -420,7 +402,7 @@ def test_transcoder_service_client_mtls_env_auto( return_value=False, ): patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -451,7 +433,7 @@ def test_transcoder_service_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -482,7 +464,7 @@ def test_transcoder_service_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -2599,7 +2581,6 @@ def test_transcoder_service_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_transcoder_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -2620,26 +2601,6 @@ def test_transcoder_service_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_transcoder_service_base_transport_with_credentials_file_old_google_auth(): - # Instantiate the base transport with a credentials file - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch( - "google.cloud.video.transcoder_v1.services.transcoder_service.transports.TranscoderServiceTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.TranscoderServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - def test_transcoder_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( @@ -2651,7 +2612,6 @@ def test_transcoder_service_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_transcoder_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -2664,18 +2624,6 @@ def test_transcoder_service_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_transcoder_service_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - TranscoderServiceClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -2683,7 +2631,6 @@ def test_transcoder_service_auth_adc_old_google_auth(): transports.TranscoderServiceGrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_transcoder_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -2697,26 +2644,6 @@ def test_transcoder_service_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.TranscoderServiceGrpcTransport, - transports.TranscoderServiceGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_transcoder_service_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [ diff --git a/tests/unit/gapic/transcoder_v1beta1/test_transcoder_service.py b/tests/unit/gapic/transcoder_v1beta1/test_transcoder_service.py index 83c15c4..13b9639 100644 --- a/tests/unit/gapic/transcoder_v1beta1/test_transcoder_service.py +++ b/tests/unit/gapic/transcoder_v1beta1/test_transcoder_service.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -40,9 +39,6 @@ ) from google.cloud.video.transcoder_v1beta1.services.transcoder_service import pagers from google.cloud.video.transcoder_v1beta1.services.transcoder_service import transports -from google.cloud.video.transcoder_v1beta1.services.transcoder_service.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.video.transcoder_v1beta1.types import resources from google.cloud.video.transcoder_v1beta1.types import services from google.oauth2 import service_account @@ -51,20 +47,6 @@ import google.auth -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -222,7 +204,7 @@ def test_transcoder_service_client_client_options( options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -239,7 +221,7 @@ def test_transcoder_service_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -256,7 +238,7 @@ def test_transcoder_service_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -285,7 +267,7 @@ def test_transcoder_service_client_client_options( options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -354,7 +336,7 @@ def test_transcoder_service_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) if use_client_cert_env == "false": expected_client_cert_source = None @@ -396,7 +378,7 @@ def test_transcoder_service_client_mtls_env_auto( expected_client_cert_source = client_cert_source_callback patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -418,7 +400,7 @@ def test_transcoder_service_client_mtls_env_auto( return_value=False, ): patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -449,7 +431,7 @@ def test_transcoder_service_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -480,7 +462,7 @@ def test_transcoder_service_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -2603,7 +2585,6 @@ def test_transcoder_service_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_transcoder_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -2624,26 +2605,6 @@ def test_transcoder_service_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_transcoder_service_base_transport_with_credentials_file_old_google_auth(): - # Instantiate the base transport with a credentials file - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch( - "google.cloud.video.transcoder_v1beta1.services.transcoder_service.transports.TranscoderServiceTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.TranscoderServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - def test_transcoder_service_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( @@ -2655,7 +2616,6 @@ def test_transcoder_service_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_transcoder_service_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -2668,18 +2628,6 @@ def test_transcoder_service_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_transcoder_service_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - TranscoderServiceClient() - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -2687,7 +2635,6 @@ def test_transcoder_service_auth_adc_old_google_auth(): transports.TranscoderServiceGrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_transcoder_service_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -2701,26 +2648,6 @@ def test_transcoder_service_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.TranscoderServiceGrpcTransport, - transports.TranscoderServiceGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_transcoder_service_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with( - scopes=("https://www.googleapis.com/auth/cloud-platform",), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [ From 667b7a7884d4fc342e87b0fe191cd8a85f5d6f83 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 4 Nov 2021 14:24:13 +0000 Subject: [PATCH 4/4] chore: release 1.2.1 (#113) :robot: I have created a release \*beep\* \*boop\* --- ### [1.2.1](https://www.github.com/googleapis/python-video-transcoder/compare/v1.2.0...v1.2.1) (2021-11-04) ### Bug Fixes * **deps:** drop packaging dependency ([9850614](https://www.github.com/googleapis/python-video-transcoder/commit/985061433802e6a49a23e53b77aecbaafe7bf12a)) * **deps:** require google-api-core >= 1.28.0 ([9850614](https://www.github.com/googleapis/python-video-transcoder/commit/985061433802e6a49a23e53b77aecbaafe7bf12a)) ### Documentation * list oneofs in docstring ([9850614](https://www.github.com/googleapis/python-video-transcoder/commit/985061433802e6a49a23e53b77aecbaafe7bf12a)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- CHANGELOG.md | 13 +++++++++++++ setup.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32da332..eb3e903 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +### [1.2.1](https://www.github.com/googleapis/python-video-transcoder/compare/v1.2.0...v1.2.1) (2021-11-04) + + +### Bug Fixes + +* **deps:** drop packaging dependency ([9850614](https://www.github.com/googleapis/python-video-transcoder/commit/985061433802e6a49a23e53b77aecbaafe7bf12a)) +* **deps:** require google-api-core >= 1.28.0 ([9850614](https://www.github.com/googleapis/python-video-transcoder/commit/985061433802e6a49a23e53b77aecbaafe7bf12a)) + + +### Documentation + +* list oneofs in docstring ([9850614](https://www.github.com/googleapis/python-video-transcoder/commit/985061433802e6a49a23e53b77aecbaafe7bf12a)) + ## [1.2.0](https://www.github.com/googleapis/python-video-transcoder/compare/v1.1.0...v1.2.0) (2021-10-14) diff --git a/setup.py b/setup.py index aac1fbe..0a4dfc1 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ import os import setuptools # type: ignore -version = "1.2.0" +version = "1.2.1" package_root = os.path.abspath(os.path.dirname(__file__)) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy