From 0248eaeb60c5d09ca174a74dcde8f9330955438b Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 11 Apr 2022 23:52:09 +0000 Subject: [PATCH] chore: Use gapic-generator-python 0.65.0 (#95) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 440970084 Source-Link: https://github.com/googleapis/googleapis/commit/5e0a3d57254ab9857ccac77fc6ffade7b69a2dc7 Source-Link: https://github.com/googleapis/googleapis-gen/commit/b0c628a3fade768f225d76992791ea1ba2a881be Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjBjNjI4YTNmYWRlNzY4ZjIyNWQ3Njk5Mjc5MWVhMWJhMmE4ODFiZSJ9 docs: fix type in docstring for map fields --- .../flex_templates_service/async_client.py | 2 +- .../services/flex_templates_service/client.py | 2 +- .../flex_templates_service/transports/base.py | 5 + .../flex_templates_service/transports/grpc.py | 4 + .../services/jobs_v1_beta3/async_client.py | 7 +- .../services/jobs_v1_beta3/client.py | 7 +- .../services/jobs_v1_beta3/transports/base.py | 5 + .../services/jobs_v1_beta3/transports/grpc.py | 4 + .../messages_v1_beta3/async_client.py | 3 +- .../services/messages_v1_beta3/client.py | 3 +- .../messages_v1_beta3/transports/base.py | 5 + .../messages_v1_beta3/transports/grpc.py | 4 + .../services/metrics_v1_beta3/async_client.py | 5 +- .../services/metrics_v1_beta3/client.py | 5 +- .../metrics_v1_beta3/transports/base.py | 5 + .../metrics_v1_beta3/transports/grpc.py | 4 + .../snapshots_v1_beta3/async_client.py | 2 +- .../services/snapshots_v1_beta3/client.py | 2 +- .../snapshots_v1_beta3/transports/base.py | 5 + .../snapshots_v1_beta3/transports/grpc.py | 4 + .../templates_service/async_client.py | 2 +- .../services/templates_service/client.py | 2 +- .../templates_service/transports/base.py | 5 + .../templates_service/transports/grpc.py | 4 + .../dataflow_v1beta3/types/environment.py | 2 +- .../cloud/dataflow_v1beta3/types/jobs.py | 6 +- .../cloud/dataflow_v1beta3/types/metrics.py | 2 +- .../cloud/dataflow_v1beta3/types/streaming.py | 2 +- .../cloud/dataflow_v1beta3/types/templates.py | 18 ++-- .../test_flex_templates_service.py | 79 ++++++++++++---- .../dataflow_v1beta3/test_jobs_v1_beta3.py | 87 +++++++++++++----- .../test_messages_v1_beta3.py | 85 +++++++++++++---- .../dataflow_v1beta3/test_metrics_v1_beta3.py | 91 ++++++++++++++----- .../test_snapshots_v1_beta3.py | 79 ++++++++++++---- .../test_templates_service.py | 79 ++++++++++++---- 35 files changed, 469 insertions(+), 157 deletions(-) diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/flex_templates_service/async_client.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/flex_templates_service/async_client.py index bb72c3ca5a3c..bd5a0d4bdd65 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/flex_templates_service/async_client.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/flex_templates_service/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/flex_templates_service/client.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/flex_templates_service/client.py index df9a8b99c5a3..bbd40e939cf7 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/flex_templates_service/client.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/flex_templates_service/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/flex_templates_service/transports/base.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/flex_templates_service/transports/base.py index f10c31f55153..f18f47ebef22 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/flex_templates_service/transports/base.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/flex_templates_service/transports/base.py @@ -85,6 +85,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -153,5 +154,9 @@ def launch_flex_template( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("FlexTemplatesServiceTransport",) diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/flex_templates_service/transports/grpc.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/flex_templates_service/transports/grpc.py index c8958257f7a7..d7848e6d2dba 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/flex_templates_service/transports/grpc.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/flex_templates_service/transports/grpc.py @@ -259,5 +259,9 @@ def launch_flex_template( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("FlexTemplatesServiceGrpcTransport",) diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/jobs_v1_beta3/async_client.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/jobs_v1_beta3/async_client.py index eb7423bdc8fe..9c93050e32ba 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/jobs_v1_beta3/async_client.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/jobs_v1_beta3/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -219,7 +219,6 @@ async def create_job( Using ``projects.jobs.create`` is not recommended, as your job will always start in ``us-central1``. - .. code-block:: python from google.cloud import dataflow_v1beta3 @@ -292,7 +291,6 @@ async def get_job( Using ``projects.jobs.get`` is not recommended, as you can only get the state of jobs that are running in ``us-central1``. - .. code-block:: python from google.cloud import dataflow_v1beta3 @@ -366,7 +364,6 @@ async def update_job( only update the state of jobs that are running in ``us-central1``. - .. code-block:: python from google.cloud import dataflow_v1beta3 @@ -441,7 +438,6 @@ async def list_jobs( not recommended, as you can only get the list of jobs that are running in ``us-central1``. - .. code-block:: python from google.cloud import dataflow_v1beta3 @@ -613,7 +609,6 @@ async def check_active_jobs( r"""Check for existence of active jobs in the given project across all regions. - .. code-block:: python from google.cloud import dataflow_v1beta3 diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/jobs_v1_beta3/client.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/jobs_v1_beta3/client.py index 6684bbabdfb5..66a779ad9558 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/jobs_v1_beta3/client.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/jobs_v1_beta3/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -425,7 +425,6 @@ def create_job( Using ``projects.jobs.create`` is not recommended, as your job will always start in ``us-central1``. - .. code-block:: python from google.cloud import dataflow_v1beta3 @@ -499,7 +498,6 @@ def get_job( Using ``projects.jobs.get`` is not recommended, as you can only get the state of jobs that are running in ``us-central1``. - .. code-block:: python from google.cloud import dataflow_v1beta3 @@ -574,7 +572,6 @@ def update_job( only update the state of jobs that are running in ``us-central1``. - .. code-block:: python from google.cloud import dataflow_v1beta3 @@ -650,7 +647,6 @@ def list_jobs( not recommended, as you can only get the list of jobs that are running in ``us-central1``. - .. code-block:: python from google.cloud import dataflow_v1beta3 @@ -824,7 +820,6 @@ def check_active_jobs( r"""Check for existence of active jobs in the given project across all regions. - .. code-block:: python from google.cloud import dataflow_v1beta3 diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/jobs_v1_beta3/transports/base.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/jobs_v1_beta3/transports/base.py index 65fcf8f5f7cd..cf4d08136075 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/jobs_v1_beta3/transports/base.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/jobs_v1_beta3/transports/base.py @@ -86,6 +86,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -226,5 +227,9 @@ def snapshot_job( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("JobsV1Beta3Transport",) diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/jobs_v1_beta3/transports/grpc.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/jobs_v1_beta3/transports/grpc.py index 1b86f41ee277..c559fefcfd22 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/jobs_v1_beta3/transports/grpc.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/jobs_v1_beta3/transports/grpc.py @@ -433,5 +433,9 @@ def snapshot_job(self) -> Callable[[jobs.SnapshotJobRequest], snapshots.Snapshot def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("JobsV1Beta3GrpcTransport",) diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/messages_v1_beta3/async_client.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/messages_v1_beta3/async_client.py index eeb60c5a43fe..1b771b290f56 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/messages_v1_beta3/async_client.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/messages_v1_beta3/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -220,7 +220,6 @@ async def list_job_messages( can only request the status of jobs that are running in ``us-central1``. - .. code-block:: python from google.cloud import dataflow_v1beta3 diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/messages_v1_beta3/client.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/messages_v1_beta3/client.py index 4f86a0878acc..2be2bb679d00 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/messages_v1_beta3/client.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/messages_v1_beta3/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -424,7 +424,6 @@ def list_job_messages( can only request the status of jobs that are running in ``us-central1``. - .. code-block:: python from google.cloud import dataflow_v1beta3 diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/messages_v1_beta3/transports/base.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/messages_v1_beta3/transports/base.py index 1d462612b6a3..3a294c1edc9a 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/messages_v1_beta3/transports/base.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/messages_v1_beta3/transports/base.py @@ -85,6 +85,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -153,5 +154,9 @@ def list_job_messages( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("MessagesV1Beta3Transport",) diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/messages_v1_beta3/transports/grpc.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/messages_v1_beta3/transports/grpc.py index 0ca2bc701a97..8c30e4bc910b 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/messages_v1_beta3/transports/grpc.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/messages_v1_beta3/transports/grpc.py @@ -265,5 +265,9 @@ def list_job_messages( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("MessagesV1Beta3GrpcTransport",) diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/metrics_v1_beta3/async_client.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/metrics_v1_beta3/async_client.py index 778ce22df034..f8c7c61a0639 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/metrics_v1_beta3/async_client.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/metrics_v1_beta3/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -221,7 +221,6 @@ async def get_job_metrics( can only request the status of jobs that are running in ``us-central1``. - .. code-block:: python from google.cloud import dataflow_v1beta3 @@ -299,7 +298,6 @@ async def get_job_execution_details( EXPERIMENTAL. This API is subject to change or removal without notice. - .. code-block:: python from google.cloud import dataflow_v1beta3 @@ -383,7 +381,6 @@ async def get_stage_execution_details( EXPERIMENTAL. This API is subject to change or removal without notice. - .. code-block:: python from google.cloud import dataflow_v1beta3 diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/metrics_v1_beta3/client.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/metrics_v1_beta3/client.py index a57112f4a516..1b149c2bcdda 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/metrics_v1_beta3/client.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/metrics_v1_beta3/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -425,7 +425,6 @@ def get_job_metrics( can only request the status of jobs that are running in ``us-central1``. - .. code-block:: python from google.cloud import dataflow_v1beta3 @@ -504,7 +503,6 @@ def get_job_execution_details( EXPERIMENTAL. This API is subject to change or removal without notice. - .. code-block:: python from google.cloud import dataflow_v1beta3 @@ -591,7 +589,6 @@ def get_stage_execution_details( EXPERIMENTAL. This API is subject to change or removal without notice. - .. code-block:: python from google.cloud import dataflow_v1beta3 diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/metrics_v1_beta3/transports/base.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/metrics_v1_beta3/transports/base.py index 0e3b707d39c7..d1ba521dee3b 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/metrics_v1_beta3/transports/base.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/metrics_v1_beta3/transports/base.py @@ -85,6 +85,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -178,5 +179,9 @@ def get_stage_execution_details( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("MetricsV1Beta3Transport",) diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/metrics_v1_beta3/transports/grpc.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/metrics_v1_beta3/transports/grpc.py index 72154ab99b3d..5c5ddf5b74ca 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/metrics_v1_beta3/transports/grpc.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/metrics_v1_beta3/transports/grpc.py @@ -326,5 +326,9 @@ def get_stage_execution_details( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("MetricsV1Beta3GrpcTransport",) diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/snapshots_v1_beta3/async_client.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/snapshots_v1_beta3/async_client.py index 4d2e389f90ab..1cfa9a2c9e12 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/snapshots_v1_beta3/async_client.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/snapshots_v1_beta3/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/snapshots_v1_beta3/client.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/snapshots_v1_beta3/client.py index fffbf68b6898..796a607a30e4 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/snapshots_v1_beta3/client.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/snapshots_v1_beta3/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/snapshots_v1_beta3/transports/base.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/snapshots_v1_beta3/transports/base.py index de0aeae1ef2d..a15147195743 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/snapshots_v1_beta3/transports/base.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/snapshots_v1_beta3/transports/base.py @@ -85,6 +85,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -183,5 +184,9 @@ def list_snapshots( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("SnapshotsV1Beta3Transport",) diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/snapshots_v1_beta3/transports/grpc.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/snapshots_v1_beta3/transports/grpc.py index 13a5cd81609b..22a14a94fd8f 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/snapshots_v1_beta3/transports/grpc.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/snapshots_v1_beta3/transports/grpc.py @@ -309,5 +309,9 @@ def list_snapshots( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("SnapshotsV1Beta3GrpcTransport",) diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/templates_service/async_client.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/templates_service/async_client.py index 5cfd6ebbd5cd..6cb469057a2d 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/templates_service/async_client.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/templates_service/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/templates_service/client.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/templates_service/client.py index ceb10c512459..bc25ba5e9e0b 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/templates_service/client.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/templates_service/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/templates_service/transports/base.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/templates_service/transports/base.py index d125dee57b21..ed993916facd 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/templates_service/transports/base.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/templates_service/transports/base.py @@ -86,6 +86,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -181,5 +182,9 @@ def get_template( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("TemplatesServiceTransport",) diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/templates_service/transports/grpc.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/templates_service/transports/grpc.py index ca247daa9035..30937cab6558 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/templates_service/transports/grpc.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/services/templates_service/transports/grpc.py @@ -310,5 +310,9 @@ def get_template( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("TemplatesServiceGrpcTransport",) diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/types/environment.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/types/environment.py index a9e119248262..dc15845a37ec 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/types/environment.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/types/environment.py @@ -731,7 +731,7 @@ class WorkerPool(proto.Message): data_disks (Sequence[google.cloud.dataflow_v1beta3.types.Disk]): Data disks that are used by a VM in this workflow. - metadata (Sequence[google.cloud.dataflow_v1beta3.types.WorkerPool.MetadataEntry]): + metadata (Mapping[str, str]): Metadata to set on the Google Compute Engine VMs. autoscaling_settings (google.cloud.dataflow_v1beta3.types.AutoscalingSettings): diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/types/jobs.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/types/jobs.py index 7ff6818176db..c028d7face8c 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/types/jobs.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/types/jobs.py @@ -171,7 +171,7 @@ class Job(proto.Message): When sending a ``CreateJobRequest``, you can update a job by specifying it here. The job named here is stopped, and its intermediate state is transferred to this job. - transform_name_mapping (Sequence[google.cloud.dataflow_v1beta3.types.Job.TransformNameMappingEntry]): + transform_name_mapping (Mapping[str, str]): The map of transform name prefixes of the job to be replaced to the corresponding name prefixes of the new job. @@ -204,7 +204,7 @@ class Job(proto.Message): storage.googleapis.com/{bucket}/{object} bucket.storage.googleapis.com/{object} - labels (Sequence[google.cloud.dataflow_v1beta3.types.Job.LabelsEntry]): + labels (Mapping[str, str]): User-defined labels for this job. The labels map can contain no more than 64 entries. Entries @@ -1074,7 +1074,7 @@ class JobExecutionInfo(proto.Message): executed that isn't contained in the submitted job. Attributes: - stages (Sequence[google.cloud.dataflow_v1beta3.types.JobExecutionInfo.StagesEntry]): + stages (Mapping[str, google.cloud.dataflow_v1beta3.types.JobExecutionStageInfo]): A mapping from each stage to the information about that stage. """ diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/types/metrics.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/types/metrics.py index 206bb059e04d..e20308033556 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/types/metrics.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/types/metrics.py @@ -61,7 +61,7 @@ class MetricStructuredName(proto.Message): service or SDK. name (str): Worker-defined metric name. - context (Sequence[google.cloud.dataflow_v1beta3.types.MetricStructuredName.ContextEntry]): + context (Mapping[str, str]): Zero or more labeled fields which identify the part of the job this metric is associated with, such as the name of a step or collection. diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/types/streaming.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/types/streaming.py index e067637bbd20..9fabbbd667c6 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/types/streaming.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/types/streaming.py @@ -48,7 +48,7 @@ class TopologyConfig(proto.Message): data_disk_assignments (Sequence[google.cloud.dataflow_v1beta3.types.DataDiskAssignment]): The disks assigned to a streaming Dataflow job. - user_stage_to_computation_name_map (Sequence[google.cloud.dataflow_v1beta3.types.TopologyConfig.UserStageToComputationNameMapEntry]): + user_stage_to_computation_name_map (Mapping[str, str]): Maps user stage names to stable computation names. forwarding_key_bits (int): diff --git a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/types/templates.py b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/types/templates.py index 7fd84332c7f2..72f09809472a 100644 --- a/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/types/templates.py +++ b/packages/google-cloud-dataflow-client/google/cloud/dataflow_v1beta3/types/templates.py @@ -140,9 +140,9 @@ class LaunchFlexTemplateParameter(proto.Message): serialized ContainerSpec as content. This field is a member of `oneof`_ ``template``. - parameters (Sequence[google.cloud.dataflow_v1beta3.types.LaunchFlexTemplateParameter.ParametersEntry]): + parameters (Mapping[str, str]): The parameters for FlexTemplate. Ex. {"num_workers":"5"} - launch_options (Sequence[google.cloud.dataflow_v1beta3.types.LaunchFlexTemplateParameter.LaunchOptionsEntry]): + launch_options (Mapping[str, str]): Launch options for this flex template job. This is a common set of options across languages and templates. This should not be used to pass @@ -154,7 +154,7 @@ class LaunchFlexTemplateParameter(proto.Message): Set this to true if you are sending a request to update a running streaming job. When set, the job name should be the same as the running job. - transform_name_mappings (Sequence[google.cloud.dataflow_v1beta3.types.LaunchFlexTemplateParameter.TransformNameMappingsEntry]): + transform_name_mappings (Mapping[str, str]): Use this to pass transform_name_mappings for streaming update jobs. Ex:{"oldTransformName":"newTransformName",...}' """ @@ -240,7 +240,7 @@ class FlexTemplateRuntimeEnvironment(proto.Message): or "regions/REGION/subnetworks/SUBNETWORK". If the subnetwork is located in a Shared VPC network, you must use the complete URL. - additional_user_labels (Sequence[google.cloud.dataflow_v1beta3.types.FlexTemplateRuntimeEnvironment.AdditionalUserLabelsEntry]): + additional_user_labels (Mapping[str, str]): Additional user labels to be specified for the job. Keys and values must follow the restrictions specified in the `labeling @@ -482,7 +482,7 @@ class RuntimeEnvironment(proto.Message): or "regions/REGION/subnetworks/SUBNETWORK". If the subnetwork is located in a Shared VPC network, you must use the complete URL. - additional_user_labels (Sequence[google.cloud.dataflow_v1beta3.types.RuntimeEnvironment.AdditionalUserLabelsEntry]): + additional_user_labels (Mapping[str, str]): Additional user labels to be specified for the job. Keys and values should follow the restrictions specified in the `labeling @@ -605,7 +605,7 @@ class ParameterMetadata(proto.Message): param_type (google.cloud.dataflow_v1beta3.types.ParameterType): Optional. The type of the parameter. Used for selecting input picker. - custom_metadata (Sequence[google.cloud.dataflow_v1beta3.types.ParameterMetadata.CustomMetadataEntry]): + custom_metadata (Mapping[str, str]): Optional. Additional metadata for describing this parameter. """ @@ -736,7 +736,7 @@ class CreateJobFromTemplateRequest(proto.Message): with ``gs://``. This field is a member of `oneof`_ ``template``. - parameters (Sequence[google.cloud.dataflow_v1beta3.types.CreateJobFromTemplateRequest.ParametersEntry]): + parameters (Mapping[str, str]): The runtime parameters to pass to the job. environment (google.cloud.dataflow_v1beta3.types.RuntimeEnvironment): The runtime environment for the job. @@ -875,7 +875,7 @@ class LaunchTemplateParameters(proto.Message): job_name (str): Required. The job name to use for the created job. - parameters (Sequence[google.cloud.dataflow_v1beta3.types.LaunchTemplateParameters.ParametersEntry]): + parameters (Mapping[str, str]): The runtime parameters to pass to the job. environment (google.cloud.dataflow_v1beta3.types.RuntimeEnvironment): The runtime environment for the job. @@ -883,7 +883,7 @@ class LaunchTemplateParameters(proto.Message): If set, replace the existing pipeline with the name specified by jobName with this pipeline, preserving state. - transform_name_mapping (Sequence[google.cloud.dataflow_v1beta3.types.LaunchTemplateParameters.TransformNameMappingEntry]): + transform_name_mapping (Mapping[str, str]): Only applicable when updating a pipeline. Map of transform name prefixes of the job to be replaced to the corresponding name prefixes of diff --git a/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_flex_templates_service.py b/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_flex_templates_service.py index 0ce68dba72cc..1f594c993b6b 100644 --- a/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_flex_templates_service.py +++ b/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_flex_templates_service.py @@ -91,24 +91,26 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - FlexTemplatesServiceClient, - FlexTemplatesServiceAsyncClient, + (FlexTemplatesServiceClient, "grpc"), + (FlexTemplatesServiceAsyncClient, "grpc_asyncio"), ], ) -def test_flex_templates_service_client_from_service_account_info(client_class): +def test_flex_templates_service_client_from_service_account_info( + client_class, transport_name +): creds = ga_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) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "dataflow.googleapis.com:443" + assert client.transport._host == ("dataflow.googleapis.com:443") @pytest.mark.parametrize( @@ -137,27 +139,33 @@ def test_flex_templates_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - FlexTemplatesServiceClient, - FlexTemplatesServiceAsyncClient, + (FlexTemplatesServiceClient, "grpc"), + (FlexTemplatesServiceAsyncClient, "grpc_asyncio"), ], ) -def test_flex_templates_service_client_from_service_account_file(client_class): +def test_flex_templates_service_client_from_service_account_file( + client_class, transport_name +): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "dataflow.googleapis.com:443" + assert client.transport._host == ("dataflow.googleapis.com:443") def test_flex_templates_service_client_get_transport_class(): @@ -850,6 +858,19 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = FlexTemplatesServiceClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = FlexTemplatesServiceClient( @@ -890,6 +911,14 @@ def test_flex_templates_service_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_flex_templates_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -1057,24 +1086,40 @@ def test_flex_templates_service_grpc_transport_client_cert_source_for_mtls( ) -def test_flex_templates_service_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_flex_templates_service_host_no_port(transport_name): client = FlexTemplatesServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="dataflow.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "dataflow.googleapis.com:443" + assert client.transport._host == ("dataflow.googleapis.com:443") -def test_flex_templates_service_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_flex_templates_service_host_with_port(transport_name): client = FlexTemplatesServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="dataflow.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "dataflow.googleapis.com:8000" + assert client.transport._host == ("dataflow.googleapis.com:8000") def test_flex_templates_service_grpc_transport_channel(): diff --git a/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_jobs_v1_beta3.py b/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_jobs_v1_beta3.py index 40fb0948ba4d..8f71d738f063 100644 --- a/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_jobs_v1_beta3.py +++ b/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_jobs_v1_beta3.py @@ -88,24 +88,24 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - JobsV1Beta3Client, - JobsV1Beta3AsyncClient, + (JobsV1Beta3Client, "grpc"), + (JobsV1Beta3AsyncClient, "grpc_asyncio"), ], ) -def test_jobs_v1_beta3_client_from_service_account_info(client_class): +def test_jobs_v1_beta3_client_from_service_account_info(client_class, transport_name): creds = ga_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) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "dataflow.googleapis.com:443" + assert client.transport._host == ("dataflow.googleapis.com:443") @pytest.mark.parametrize( @@ -134,27 +134,31 @@ def test_jobs_v1_beta3_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - JobsV1Beta3Client, - JobsV1Beta3AsyncClient, + (JobsV1Beta3Client, "grpc"), + (JobsV1Beta3AsyncClient, "grpc_asyncio"), ], ) -def test_jobs_v1_beta3_client_from_service_account_file(client_class): +def test_jobs_v1_beta3_client_from_service_account_file(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "dataflow.googleapis.com:443" + assert client.transport._host == ("dataflow.googleapis.com:443") def test_jobs_v1_beta3_client_get_transport_class(): @@ -1272,7 +1276,7 @@ async def test_list_jobs_async_pager(): ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -1318,7 +1322,9 @@ async def test_list_jobs_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_jobs(request={})).pages: + async for page_ in ( + await client.list_jobs(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -1556,7 +1562,7 @@ async def test_aggregated_list_jobs_async_pager(): ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -1604,7 +1610,9 @@ async def test_aggregated_list_jobs_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.aggregated_list_jobs(request={})).pages: + async for page_ in ( + await client.aggregated_list_jobs(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -1909,6 +1917,19 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = JobsV1Beta3Client.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = JobsV1Beta3Client( @@ -1957,6 +1978,14 @@ def test_jobs_v1_beta3_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_jobs_v1_beta3_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -2119,24 +2148,40 @@ def test_jobs_v1_beta3_grpc_transport_client_cert_source_for_mtls(transport_clas ) -def test_jobs_v1_beta3_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_jobs_v1_beta3_host_no_port(transport_name): client = JobsV1Beta3Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="dataflow.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "dataflow.googleapis.com:443" + assert client.transport._host == ("dataflow.googleapis.com:443") -def test_jobs_v1_beta3_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_jobs_v1_beta3_host_with_port(transport_name): client = JobsV1Beta3Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="dataflow.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "dataflow.googleapis.com:8000" + assert client.transport._host == ("dataflow.googleapis.com:8000") def test_jobs_v1_beta3_grpc_transport_channel(): diff --git a/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_messages_v1_beta3.py b/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_messages_v1_beta3.py index 5eed376f2453..5b2914567a06 100644 --- a/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_messages_v1_beta3.py +++ b/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_messages_v1_beta3.py @@ -90,24 +90,26 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - MessagesV1Beta3Client, - MessagesV1Beta3AsyncClient, + (MessagesV1Beta3Client, "grpc"), + (MessagesV1Beta3AsyncClient, "grpc_asyncio"), ], ) -def test_messages_v1_beta3_client_from_service_account_info(client_class): +def test_messages_v1_beta3_client_from_service_account_info( + client_class, transport_name +): creds = ga_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) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "dataflow.googleapis.com:443" + assert client.transport._host == ("dataflow.googleapis.com:443") @pytest.mark.parametrize( @@ -136,27 +138,33 @@ def test_messages_v1_beta3_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - MessagesV1Beta3Client, - MessagesV1Beta3AsyncClient, + (MessagesV1Beta3Client, "grpc"), + (MessagesV1Beta3AsyncClient, "grpc_asyncio"), ], ) -def test_messages_v1_beta3_client_from_service_account_file(client_class): +def test_messages_v1_beta3_client_from_service_account_file( + client_class, transport_name +): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "dataflow.googleapis.com:443" + assert client.transport._host == ("dataflow.googleapis.com:443") def test_messages_v1_beta3_client_get_transport_class(): @@ -893,7 +901,7 @@ async def test_list_job_messages_async_pager(): ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -941,7 +949,9 @@ async def test_list_job_messages_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_job_messages(request={})).pages: + async for page_ in ( + await client.list_job_messages(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -1038,6 +1048,19 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = MessagesV1Beta3Client.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = MessagesV1Beta3Client( @@ -1078,6 +1101,14 @@ def test_messages_v1_beta3_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_messages_v1_beta3_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -1243,24 +1274,40 @@ def test_messages_v1_beta3_grpc_transport_client_cert_source_for_mtls(transport_ ) -def test_messages_v1_beta3_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_messages_v1_beta3_host_no_port(transport_name): client = MessagesV1Beta3Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="dataflow.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "dataflow.googleapis.com:443" + assert client.transport._host == ("dataflow.googleapis.com:443") -def test_messages_v1_beta3_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_messages_v1_beta3_host_with_port(transport_name): client = MessagesV1Beta3Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="dataflow.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "dataflow.googleapis.com:8000" + assert client.transport._host == ("dataflow.googleapis.com:8000") def test_messages_v1_beta3_grpc_transport_channel(): diff --git a/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_metrics_v1_beta3.py b/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_metrics_v1_beta3.py index 81e16571dd36..6b7b3c2685b9 100644 --- a/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_metrics_v1_beta3.py +++ b/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_metrics_v1_beta3.py @@ -88,24 +88,26 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - MetricsV1Beta3Client, - MetricsV1Beta3AsyncClient, + (MetricsV1Beta3Client, "grpc"), + (MetricsV1Beta3AsyncClient, "grpc_asyncio"), ], ) -def test_metrics_v1_beta3_client_from_service_account_info(client_class): +def test_metrics_v1_beta3_client_from_service_account_info( + client_class, transport_name +): creds = ga_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) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "dataflow.googleapis.com:443" + assert client.transport._host == ("dataflow.googleapis.com:443") @pytest.mark.parametrize( @@ -134,27 +136,33 @@ def test_metrics_v1_beta3_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - MetricsV1Beta3Client, - MetricsV1Beta3AsyncClient, + (MetricsV1Beta3Client, "grpc"), + (MetricsV1Beta3AsyncClient, "grpc_asyncio"), ], ) -def test_metrics_v1_beta3_client_from_service_account_file(client_class): +def test_metrics_v1_beta3_client_from_service_account_file( + client_class, transport_name +): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "dataflow.googleapis.com:443" + assert client.transport._host == ("dataflow.googleapis.com:443") def test_metrics_v1_beta3_client_get_transport_class(): @@ -962,7 +970,7 @@ async def test_get_job_execution_details_async_pager(): ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -1010,7 +1018,9 @@ async def test_get_job_execution_details_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.get_job_execution_details(request={})).pages: + async for page_ in ( + await client.get_job_execution_details(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -1249,7 +1259,7 @@ async def test_get_stage_execution_details_async_pager(): ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -1297,7 +1307,9 @@ async def test_get_stage_execution_details_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.get_stage_execution_details(request={})).pages: + async for page_ in ( + await client.get_stage_execution_details(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -1394,6 +1406,19 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = MetricsV1Beta3Client.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = MetricsV1Beta3Client( @@ -1438,6 +1463,14 @@ def test_metrics_v1_beta3_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_metrics_v1_beta3_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -1603,24 +1636,40 @@ def test_metrics_v1_beta3_grpc_transport_client_cert_source_for_mtls(transport_c ) -def test_metrics_v1_beta3_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_metrics_v1_beta3_host_no_port(transport_name): client = MetricsV1Beta3Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="dataflow.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "dataflow.googleapis.com:443" + assert client.transport._host == ("dataflow.googleapis.com:443") -def test_metrics_v1_beta3_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_metrics_v1_beta3_host_with_port(transport_name): client = MetricsV1Beta3Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="dataflow.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "dataflow.googleapis.com:8000" + assert client.transport._host == ("dataflow.googleapis.com:8000") def test_metrics_v1_beta3_grpc_transport_channel(): diff --git a/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_snapshots_v1_beta3.py b/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_snapshots_v1_beta3.py index e07411030412..60b609f4c9a9 100644 --- a/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_snapshots_v1_beta3.py +++ b/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_snapshots_v1_beta3.py @@ -91,24 +91,26 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - SnapshotsV1Beta3Client, - SnapshotsV1Beta3AsyncClient, + (SnapshotsV1Beta3Client, "grpc"), + (SnapshotsV1Beta3AsyncClient, "grpc_asyncio"), ], ) -def test_snapshots_v1_beta3_client_from_service_account_info(client_class): +def test_snapshots_v1_beta3_client_from_service_account_info( + client_class, transport_name +): creds = ga_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) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "dataflow.googleapis.com:443" + assert client.transport._host == ("dataflow.googleapis.com:443") @pytest.mark.parametrize( @@ -137,27 +139,33 @@ def test_snapshots_v1_beta3_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - SnapshotsV1Beta3Client, - SnapshotsV1Beta3AsyncClient, + (SnapshotsV1Beta3Client, "grpc"), + (SnapshotsV1Beta3AsyncClient, "grpc_asyncio"), ], ) -def test_snapshots_v1_beta3_client_from_service_account_file(client_class): +def test_snapshots_v1_beta3_client_from_service_account_file( + client_class, transport_name +): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "dataflow.googleapis.com:443" + assert client.transport._host == ("dataflow.googleapis.com:443") def test_snapshots_v1_beta3_client_get_transport_class(): @@ -1032,6 +1040,19 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = SnapshotsV1Beta3Client.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = SnapshotsV1Beta3Client( @@ -1076,6 +1097,14 @@ def test_snapshots_v1_beta3_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_snapshots_v1_beta3_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -1241,24 +1270,40 @@ def test_snapshots_v1_beta3_grpc_transport_client_cert_source_for_mtls(transport ) -def test_snapshots_v1_beta3_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_snapshots_v1_beta3_host_no_port(transport_name): client = SnapshotsV1Beta3Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="dataflow.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "dataflow.googleapis.com:443" + assert client.transport._host == ("dataflow.googleapis.com:443") -def test_snapshots_v1_beta3_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_snapshots_v1_beta3_host_with_port(transport_name): client = SnapshotsV1Beta3Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="dataflow.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "dataflow.googleapis.com:8000" + assert client.transport._host == ("dataflow.googleapis.com:8000") def test_snapshots_v1_beta3_grpc_transport_channel(): diff --git a/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_templates_service.py b/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_templates_service.py index 1727a6ee2511..056fccb5c6fb 100644 --- a/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_templates_service.py +++ b/packages/google-cloud-dataflow-client/tests/unit/gapic/dataflow_v1beta3/test_templates_service.py @@ -93,24 +93,26 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - TemplatesServiceClient, - TemplatesServiceAsyncClient, + (TemplatesServiceClient, "grpc"), + (TemplatesServiceAsyncClient, "grpc_asyncio"), ], ) -def test_templates_service_client_from_service_account_info(client_class): +def test_templates_service_client_from_service_account_info( + client_class, transport_name +): creds = ga_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) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "dataflow.googleapis.com:443" + assert client.transport._host == ("dataflow.googleapis.com:443") @pytest.mark.parametrize( @@ -139,27 +141,33 @@ def test_templates_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - TemplatesServiceClient, - TemplatesServiceAsyncClient, + (TemplatesServiceClient, "grpc"), + (TemplatesServiceAsyncClient, "grpc_asyncio"), ], ) -def test_templates_service_client_from_service_account_file(client_class): +def test_templates_service_client_from_service_account_file( + client_class, transport_name +): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "dataflow.googleapis.com:443" + assert client.transport._host == ("dataflow.googleapis.com:443") def test_templates_service_client_get_transport_class(): @@ -1074,6 +1082,19 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = TemplatesServiceClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = TemplatesServiceClient( @@ -1118,6 +1139,14 @@ def test_templates_service_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_templates_service_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -1283,24 +1312,40 @@ def test_templates_service_grpc_transport_client_cert_source_for_mtls(transport_ ) -def test_templates_service_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_templates_service_host_no_port(transport_name): client = TemplatesServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="dataflow.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "dataflow.googleapis.com:443" + assert client.transport._host == ("dataflow.googleapis.com:443") -def test_templates_service_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_templates_service_host_with_port(transport_name): client = TemplatesServiceClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="dataflow.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "dataflow.googleapis.com:8000" + assert client.transport._host == ("dataflow.googleapis.com:8000") def test_templates_service_grpc_transport_channel():