diff --git a/packages/google-cloud-datastream/google/cloud/datastream_v1/services/datastream/async_client.py b/packages/google-cloud-datastream/google/cloud/datastream_v1/services/datastream/async_client.py index f7e91f39d77e..8305f36796c0 100644 --- a/packages/google-cloud-datastream/google/cloud/datastream_v1/services/datastream/async_client.py +++ b/packages/google-cloud-datastream/google/cloud/datastream_v1/services/datastream/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 @@ -228,7 +228,6 @@ async def list_connection_profiles( r"""Use this method to list connection profiles created in a project and location. - .. code-block:: python from google.cloud import datastream_v1 @@ -338,7 +337,6 @@ async def get_connection_profile( r"""Use this method to get details about a connection profile. - .. code-block:: python from google.cloud import datastream_v1 @@ -438,7 +436,6 @@ async def create_connection_profile( r"""Use this method to create a connection profile in a project and location. - .. code-block:: python from google.cloud import datastream_v1 @@ -577,7 +574,6 @@ async def update_connection_profile( r"""Use this method to update the parameters of a connection profile. - .. code-block:: python from google.cloud import datastream_v1 @@ -832,7 +828,6 @@ async def discover_connection_profile( returns children data objects of a parent data object that's optionally supplied in the request. - .. code-block:: python from google.cloud import datastream_v1 @@ -915,7 +910,6 @@ async def list_streams( r"""Use this method to list streams in a project and location. - .. code-block:: python from google.cloud import datastream_v1 @@ -1255,7 +1249,6 @@ async def update_stream( r"""Use this method to update the configuration of a stream. - .. code-block:: python from google.cloud import datastream_v1 @@ -1602,7 +1595,6 @@ async def lookup_stream_object( r"""Use this method to look up a stream object by its source object identifier. - .. code-block:: python from google.cloud import datastream_v1 @@ -1683,7 +1675,6 @@ async def list_stream_objects( r"""Use this method to list the objects of a specific stream. - .. code-block:: python from google.cloud import datastream_v1 @@ -1793,7 +1784,6 @@ async def start_backfill_job( r"""Use this method to start a backfill job for the specified stream object. - .. code-block:: python from google.cloud import datastream_v1 @@ -1892,7 +1882,6 @@ async def stop_backfill_job( r"""Use this method to stop a backfill job for the specified stream object. - .. code-block:: python from google.cloud import datastream_v1 @@ -1990,7 +1979,6 @@ async def fetch_static_ips( r"""The FetchStaticIps API call exposes the static IP addresses used by Datastream. - .. code-block:: python from google.cloud import datastream_v1 @@ -2103,7 +2091,6 @@ async def create_private_connection( r"""Use this method to create a private connectivity configuration. - .. code-block:: python from google.cloud import datastream_v1 @@ -2237,7 +2224,6 @@ async def get_private_connection( r"""Use this method to get details about a private connectivity configuration. - .. code-block:: python from google.cloud import datastream_v1 @@ -2336,7 +2322,6 @@ async def list_private_connections( r"""Use this method to list private connectivity configurations in a project and location. - .. code-block:: python from google.cloud import datastream_v1 @@ -2447,7 +2432,6 @@ async def delete_private_connection( r"""Use this method to delete a private connectivity configuration. - .. code-block:: python from google.cloud import datastream_v1 @@ -2571,7 +2555,6 @@ async def create_route( r"""Use this method to create a route for a private connectivity configuration in a project and location. - .. code-block:: python from google.cloud import datastream_v1 @@ -2799,7 +2782,6 @@ async def list_routes( r"""Use this method to list routes created for a private connectivity configuration in a project and location. - .. code-block:: python from google.cloud import datastream_v1 diff --git a/packages/google-cloud-datastream/google/cloud/datastream_v1/services/datastream/client.py b/packages/google-cloud-datastream/google/cloud/datastream_v1/services/datastream/client.py index 8bab25af28fd..851421db3166 100644 --- a/packages/google-cloud-datastream/google/cloud/datastream_v1/services/datastream/client.py +++ b/packages/google-cloud-datastream/google/cloud/datastream_v1/services/datastream/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 @@ -553,7 +553,6 @@ def list_connection_profiles( r"""Use this method to list connection profiles created in a project and location. - .. code-block:: python from google.cloud import datastream_v1 @@ -663,7 +662,6 @@ def get_connection_profile( r"""Use this method to get details about a connection profile. - .. code-block:: python from google.cloud import datastream_v1 @@ -763,7 +761,6 @@ def create_connection_profile( r"""Use this method to create a connection profile in a project and location. - .. code-block:: python from google.cloud import datastream_v1 @@ -904,7 +901,6 @@ def update_connection_profile( r"""Use this method to update the parameters of a connection profile. - .. code-block:: python from google.cloud import datastream_v1 @@ -1163,7 +1159,6 @@ def discover_connection_profile( returns children data objects of a parent data object that's optionally supplied in the request. - .. code-block:: python from google.cloud import datastream_v1 @@ -1249,7 +1244,6 @@ def list_streams( r"""Use this method to list streams in a project and location. - .. code-block:: python from google.cloud import datastream_v1 @@ -1589,7 +1583,6 @@ def update_stream( r"""Use this method to update the configuration of a stream. - .. code-block:: python from google.cloud import datastream_v1 @@ -1936,7 +1929,6 @@ def lookup_stream_object( r"""Use this method to look up a stream object by its source object identifier. - .. code-block:: python from google.cloud import datastream_v1 @@ -2018,7 +2010,6 @@ def list_stream_objects( r"""Use this method to list the objects of a specific stream. - .. code-block:: python from google.cloud import datastream_v1 @@ -2128,7 +2119,6 @@ def start_backfill_job( r"""Use this method to start a backfill job for the specified stream object. - .. code-block:: python from google.cloud import datastream_v1 @@ -2227,7 +2217,6 @@ def stop_backfill_job( r"""Use this method to stop a backfill job for the specified stream object. - .. code-block:: python from google.cloud import datastream_v1 @@ -2325,7 +2314,6 @@ def fetch_static_ips( r"""The FetchStaticIps API call exposes the static IP addresses used by Datastream. - .. code-block:: python from google.cloud import datastream_v1 @@ -2438,7 +2426,6 @@ def create_private_connection( r"""Use this method to create a private connectivity configuration. - .. code-block:: python from google.cloud import datastream_v1 @@ -2574,7 +2561,6 @@ def get_private_connection( r"""Use this method to get details about a private connectivity configuration. - .. code-block:: python from google.cloud import datastream_v1 @@ -2673,7 +2659,6 @@ def list_private_connections( r"""Use this method to list private connectivity configurations in a project and location. - .. code-block:: python from google.cloud import datastream_v1 @@ -2784,7 +2769,6 @@ def delete_private_connection( r"""Use this method to delete a private connectivity configuration. - .. code-block:: python from google.cloud import datastream_v1 @@ -2910,7 +2894,6 @@ def create_route( r"""Use this method to create a route for a private connectivity configuration in a project and location. - .. code-block:: python from google.cloud import datastream_v1 @@ -3138,7 +3121,6 @@ def list_routes( r"""Use this method to list routes created for a private connectivity configuration in a project and location. - .. code-block:: python from google.cloud import datastream_v1 diff --git a/packages/google-cloud-datastream/google/cloud/datastream_v1/services/datastream/transports/base.py b/packages/google-cloud-datastream/google/cloud/datastream_v1/services/datastream/transports/base.py index 8034d6236e0e..004e77824bf7 100644 --- a/packages/google-cloud-datastream/google/cloud/datastream_v1/services/datastream/transports/base.py +++ b/packages/google-cloud-datastream/google/cloud/datastream_v1/services/datastream/transports/base.py @@ -83,6 +83,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" @@ -524,5 +525,9 @@ def delete_route( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("DatastreamTransport",) diff --git a/packages/google-cloud-datastream/google/cloud/datastream_v1/services/datastream/transports/grpc.py b/packages/google-cloud-datastream/google/cloud/datastream_v1/services/datastream/transports/grpc.py index 58201b466de8..80ea09e59625 100644 --- a/packages/google-cloud-datastream/google/cloud/datastream_v1/services/datastream/transports/grpc.py +++ b/packages/google-cloud-datastream/google/cloud/datastream_v1/services/datastream/transports/grpc.py @@ -954,5 +954,9 @@ def delete_route( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("DatastreamGrpcTransport",) diff --git a/packages/google-cloud-datastream/google/cloud/datastream_v1/types/datastream_resources.py b/packages/google-cloud-datastream/google/cloud/datastream_v1/types/datastream_resources.py index 4d175797c943..756110b9e091 100644 --- a/packages/google-cloud-datastream/google/cloud/datastream_v1/types/datastream_resources.py +++ b/packages/google-cloud-datastream/google/cloud/datastream_v1/types/datastream_resources.py @@ -75,7 +75,7 @@ class OracleProfile(proto.Message): Required. Password for the Oracle connection. database_service (str): Required. Database for the Oracle connection. - connection_attributes (Sequence[google.cloud.datastream_v1.types.OracleProfile.ConnectionAttributesEntry]): + connection_attributes (Mapping[str, str]): Connection string attributes """ @@ -258,7 +258,7 @@ class PrivateConnection(proto.Message): Output only. The create time of the resource. update_time (google.protobuf.timestamp_pb2.Timestamp): Output only. The update time of the resource. - labels (Sequence[google.cloud.datastream_v1.types.PrivateConnection.LabelsEntry]): + labels (Mapping[str, str]): Labels. display_name (str): Required. Display name. @@ -348,7 +348,7 @@ class Route(proto.Message): Output only. The create time of the resource. update_time (google.protobuf.timestamp_pb2.Timestamp): Output only. The update time of the resource. - labels (Sequence[google.cloud.datastream_v1.types.Route.LabelsEntry]): + labels (Mapping[str, str]): Labels. display_name (str): Required. Display name. @@ -463,7 +463,7 @@ class ConnectionProfile(proto.Message): Output only. The create time of the resource. update_time (google.protobuf.timestamp_pb2.Timestamp): Output only. The update time of the resource. - labels (Sequence[google.cloud.datastream_v1.types.ConnectionProfile.LabelsEntry]): + labels (Mapping[str, str]): Labels. display_name (str): Required. Display name. @@ -1023,7 +1023,7 @@ class Stream(proto.Message): update_time (google.protobuf.timestamp_pb2.Timestamp): Output only. The last update time of the stream. - labels (Sequence[google.cloud.datastream_v1.types.Stream.LabelsEntry]): + labels (Mapping[str, str]): Labels. display_name (str): Required. Display name. @@ -1381,7 +1381,7 @@ class Error(proto.Message): the error that occurred. error_time (google.protobuf.timestamp_pb2.Timestamp): The time when the error occurred. - details (Sequence[google.cloud.datastream_v1.types.Error.DetailsEntry]): + details (Mapping[str, str]): Additional information about the error. """ @@ -1474,7 +1474,7 @@ class ValidationMessage(proto.Message): The result of the validation. level (google.cloud.datastream_v1.types.ValidationMessage.Level): Message severity level (warning or error). - metadata (Sequence[google.cloud.datastream_v1.types.ValidationMessage.MetadataEntry]): + metadata (Mapping[str, str]): Additional metadata related to the result. code (str): A custom code identifying this specific diff --git a/packages/google-cloud-datastream/google/cloud/datastream_v1alpha1/services/datastream/async_client.py b/packages/google-cloud-datastream/google/cloud/datastream_v1alpha1/services/datastream/async_client.py index 870277c7ce04..4c445718793c 100644 --- a/packages/google-cloud-datastream/google/cloud/datastream_v1alpha1/services/datastream/async_client.py +++ b/packages/google-cloud-datastream/google/cloud/datastream_v1alpha1/services/datastream/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 @@ -224,7 +224,6 @@ async def list_connection_profiles( r"""Use this method to list connection profiles created in a project and location. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -331,7 +330,6 @@ async def get_connection_profile( r"""Use this method to get details about a connection profile. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -427,7 +425,6 @@ async def create_connection_profile( r"""Use this method to create a connection profile in a project and location. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -565,7 +562,6 @@ async def update_connection_profile( r"""Use this method to update the parameters of a connection profile. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -819,7 +815,6 @@ async def discover_connection_profile( returns children data objects under a parent data object that's optionally supplied in the request. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -902,7 +897,6 @@ async def list_streams( r"""Use this method to list streams in a project and location. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -1235,7 +1229,6 @@ async def update_stream( r"""Use this method to update the configuration of a stream. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -1483,7 +1476,6 @@ async def fetch_errors( r"""Use this method to fetch any errors associated with a stream. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -1575,7 +1567,6 @@ async def fetch_static_ips( children data objects under a parent data object that's optionally supplied in the request. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -1687,7 +1678,6 @@ async def create_private_connection( r"""Use this method to create a private connectivity configuration. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -1820,7 +1810,6 @@ async def get_private_connection( r"""Use this method to get details about a private connectivity configuration. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -1918,7 +1907,6 @@ async def list_private_connections( r"""Use this method to list private connectivity configurations in a project and location. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -2026,7 +2014,6 @@ async def delete_private_connection( r"""Use this method to delete a private connectivity configuration. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -2149,7 +2136,6 @@ async def create_route( r"""Use this method to create a route for a private connectivity in a project and location. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -2378,7 +2364,6 @@ async def list_routes( r"""Use this method to list routes created for a private connectivity in a project and location. - .. code-block:: python from google.cloud import datastream_v1alpha1 diff --git a/packages/google-cloud-datastream/google/cloud/datastream_v1alpha1/services/datastream/client.py b/packages/google-cloud-datastream/google/cloud/datastream_v1alpha1/services/datastream/client.py index a042a5d5ad23..c78110e77f97 100644 --- a/packages/google-cloud-datastream/google/cloud/datastream_v1alpha1/services/datastream/client.py +++ b/packages/google-cloud-datastream/google/cloud/datastream_v1alpha1/services/datastream/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 @@ -510,7 +510,6 @@ def list_connection_profiles( r"""Use this method to list connection profiles created in a project and location. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -617,7 +616,6 @@ def get_connection_profile( r"""Use this method to get details about a connection profile. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -713,7 +711,6 @@ def create_connection_profile( r"""Use this method to create a connection profile in a project and location. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -853,7 +850,6 @@ def update_connection_profile( r"""Use this method to update the parameters of a connection profile. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -1111,7 +1107,6 @@ def discover_connection_profile( returns children data objects under a parent data object that's optionally supplied in the request. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -1197,7 +1192,6 @@ def list_streams( r"""Use this method to list streams in a project and location. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -1530,7 +1524,6 @@ def update_stream( r"""Use this method to update the configuration of a stream. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -1778,7 +1771,6 @@ def fetch_errors( r"""Use this method to fetch any errors associated with a stream. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -1871,7 +1863,6 @@ def fetch_static_ips( children data objects under a parent data object that's optionally supplied in the request. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -1983,7 +1974,6 @@ def create_private_connection( r"""Use this method to create a private connectivity configuration. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -2118,7 +2108,6 @@ def get_private_connection( r"""Use this method to get details about a private connectivity configuration. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -2216,7 +2205,6 @@ def list_private_connections( r"""Use this method to list private connectivity configurations in a project and location. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -2324,7 +2312,6 @@ def delete_private_connection( r"""Use this method to delete a private connectivity configuration. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -2449,7 +2436,6 @@ def create_route( r"""Use this method to create a route for a private connectivity in a project and location. - .. code-block:: python from google.cloud import datastream_v1alpha1 @@ -2678,7 +2664,6 @@ def list_routes( r"""Use this method to list routes created for a private connectivity in a project and location. - .. code-block:: python from google.cloud import datastream_v1alpha1 diff --git a/packages/google-cloud-datastream/google/cloud/datastream_v1alpha1/services/datastream/transports/base.py b/packages/google-cloud-datastream/google/cloud/datastream_v1alpha1/services/datastream/transports/base.py index 08831d3b4058..2e98a48ef02c 100644 --- a/packages/google-cloud-datastream/google/cloud/datastream_v1alpha1/services/datastream/transports/base.py +++ b/packages/google-cloud-datastream/google/cloud/datastream_v1alpha1/services/datastream/transports/base.py @@ -83,6 +83,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" @@ -453,5 +454,9 @@ def delete_route( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("DatastreamTransport",) diff --git a/packages/google-cloud-datastream/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc.py b/packages/google-cloud-datastream/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc.py index 4348b5906a95..4d09aa42c32b 100644 --- a/packages/google-cloud-datastream/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc.py +++ b/packages/google-cloud-datastream/google/cloud/datastream_v1alpha1/services/datastream/transports/grpc.py @@ -839,5 +839,9 @@ def delete_route( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("DatastreamGrpcTransport",) diff --git a/packages/google-cloud-datastream/google/cloud/datastream_v1alpha1/types/datastream_resources.py b/packages/google-cloud-datastream/google/cloud/datastream_v1alpha1/types/datastream_resources.py index 1e0ab45a1eec..7e5d70bde34a 100644 --- a/packages/google-cloud-datastream/google/cloud/datastream_v1alpha1/types/datastream_resources.py +++ b/packages/google-cloud-datastream/google/cloud/datastream_v1alpha1/types/datastream_resources.py @@ -89,7 +89,7 @@ class OracleProfile(proto.Message): Required. Password for the Oracle connection. database_service (str): Required. Database for the Oracle connection. - connection_attributes (Sequence[google.cloud.datastream_v1alpha1.types.OracleProfile.ConnectionAttributesEntry]): + connection_attributes (Mapping[str, str]): Connection string attributes """ @@ -276,7 +276,7 @@ class PrivateConnection(proto.Message): Output only. The create time of the resource. update_time (google.protobuf.timestamp_pb2.Timestamp): Output only. The update time of the resource. - labels (Sequence[google.cloud.datastream_v1alpha1.types.PrivateConnection.LabelsEntry]): + labels (Mapping[str, str]): Labels. display_name (str): Required. Display name. @@ -363,7 +363,7 @@ class Route(proto.Message): Output only. The create time of the resource. update_time (google.protobuf.timestamp_pb2.Timestamp): Output only. The update time of the resource. - labels (Sequence[google.cloud.datastream_v1alpha1.types.Route.LabelsEntry]): + labels (Mapping[str, str]): Labels. display_name (str): Required. Display name. @@ -477,7 +477,7 @@ class ConnectionProfile(proto.Message): Output only. The create time of the resource. update_time (google.protobuf.timestamp_pb2.Timestamp): Output only. The update time of the resource. - labels (Sequence[google.cloud.datastream_v1alpha1.types.ConnectionProfile.LabelsEntry]): + labels (Mapping[str, str]): Labels. display_name (str): Required. Display name. @@ -1046,7 +1046,7 @@ class Stream(proto.Message): update_time (google.protobuf.timestamp_pb2.Timestamp): Output only. The last update time of the stream. - labels (Sequence[google.cloud.datastream_v1alpha1.types.Stream.LabelsEntry]): + labels (Mapping[str, str]): Labels. display_name (str): Required. Display name. @@ -1200,7 +1200,7 @@ class Error(proto.Message): the error that occurred. error_time (google.protobuf.timestamp_pb2.Timestamp): The time when the error occurred. - details (Sequence[google.cloud.datastream_v1alpha1.types.Error.DetailsEntry]): + details (Mapping[str, str]): Additional information about the error. """ @@ -1293,7 +1293,7 @@ class ValidationMessage(proto.Message): The result of the validation. level (google.cloud.datastream_v1alpha1.types.ValidationMessage.Level): Message severity level (warning or error). - metadata (Sequence[google.cloud.datastream_v1alpha1.types.ValidationMessage.MetadataEntry]): + metadata (Mapping[str, str]): Additional metadata related to the result. code (str): A custom code identifying this specific diff --git a/packages/google-cloud-datastream/tests/unit/gapic/datastream_v1/test_datastream.py b/packages/google-cloud-datastream/tests/unit/gapic/datastream_v1/test_datastream.py index 5e1e7fdc8d7a..a9ec6ea92174 100644 --- a/packages/google-cloud-datastream/tests/unit/gapic/datastream_v1/test_datastream.py +++ b/packages/google-cloud-datastream/tests/unit/gapic/datastream_v1/test_datastream.py @@ -91,24 +91,24 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - DatastreamClient, - DatastreamAsyncClient, + (DatastreamClient, "grpc"), + (DatastreamAsyncClient, "grpc_asyncio"), ], ) -def test_datastream_client_from_service_account_info(client_class): +def test_datastream_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 == "datastream.googleapis.com:443" + assert client.transport._host == ("datastream.googleapis.com:443") @pytest.mark.parametrize( @@ -137,27 +137,31 @@ def test_datastream_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - DatastreamClient, - DatastreamAsyncClient, + (DatastreamClient, "grpc"), + (DatastreamAsyncClient, "grpc_asyncio"), ], ) -def test_datastream_client_from_service_account_file(client_class): +def test_datastream_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 == "datastream.googleapis.com:443" + assert client.transport._host == ("datastream.googleapis.com:443") def test_datastream_client_get_transport_class(): @@ -1020,7 +1024,7 @@ async def test_list_connection_profiles_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 @@ -1070,7 +1074,9 @@ async def test_list_connection_profiles_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_connection_profiles(request={})).pages: + async for page_ in ( + await client.list_connection_profiles(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 @@ -2630,7 +2636,7 @@ async def test_list_streams_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 @@ -2676,7 +2682,9 @@ async def test_list_streams_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_streams(request={})).pages: + async for page_ in ( + await client.list_streams(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 @@ -4447,7 +4455,7 @@ async def test_list_stream_objects_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 @@ -4495,7 +4503,9 @@ async def test_list_stream_objects_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_stream_objects(request={})).pages: + async for page_ in ( + await client.list_stream_objects(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 @@ -5351,7 +5361,7 @@ async def test_fetch_static_ips_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 @@ -5397,7 +5407,9 @@ async def test_fetch_static_ips_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.fetch_static_ips(request={})).pages: + async for page_ in ( + await client.fetch_static_ips(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 @@ -6319,7 +6331,7 @@ async def test_list_private_connections_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 @@ -6369,7 +6381,9 @@ async def test_list_private_connections_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_private_connections(request={})).pages: + async for page_ in ( + await client.list_private_connections(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 @@ -7476,7 +7490,7 @@ async def test_list_routes_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 @@ -7522,7 +7536,9 @@ async def test_list_routes_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_routes(request={})).pages: + async for page_ in ( + await client.list_routes(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 @@ -7845,6 +7861,19 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = DatastreamClient.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 = DatastreamClient( @@ -7916,6 +7945,14 @@ def test_datastream_base_transport(): with pytest.raises(NotImplementedError): transport.operations_client + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_datastream_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -8058,24 +8095,40 @@ def test_datastream_grpc_transport_client_cert_source_for_mtls(transport_class): ) -def test_datastream_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_datastream_host_no_port(transport_name): client = DatastreamClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="datastream.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "datastream.googleapis.com:443" + assert client.transport._host == ("datastream.googleapis.com:443") -def test_datastream_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_datastream_host_with_port(transport_name): client = DatastreamClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="datastream.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "datastream.googleapis.com:8000" + assert client.transport._host == ("datastream.googleapis.com:8000") def test_datastream_grpc_transport_channel(): diff --git a/packages/google-cloud-datastream/tests/unit/gapic/datastream_v1alpha1/test_datastream.py b/packages/google-cloud-datastream/tests/unit/gapic/datastream_v1alpha1/test_datastream.py index 7c0789e9ea82..68679cd19163 100644 --- a/packages/google-cloud-datastream/tests/unit/gapic/datastream_v1alpha1/test_datastream.py +++ b/packages/google-cloud-datastream/tests/unit/gapic/datastream_v1alpha1/test_datastream.py @@ -91,24 +91,24 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - DatastreamClient, - DatastreamAsyncClient, + (DatastreamClient, "grpc"), + (DatastreamAsyncClient, "grpc_asyncio"), ], ) -def test_datastream_client_from_service_account_info(client_class): +def test_datastream_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 == "datastream.googleapis.com:443" + assert client.transport._host == ("datastream.googleapis.com:443") @pytest.mark.parametrize( @@ -137,27 +137,31 @@ def test_datastream_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", + "client_class,transport_name", [ - DatastreamClient, - DatastreamAsyncClient, + (DatastreamClient, "grpc"), + (DatastreamAsyncClient, "grpc_asyncio"), ], ) -def test_datastream_client_from_service_account_file(client_class): +def test_datastream_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 == "datastream.googleapis.com:443" + assert client.transport._host == ("datastream.googleapis.com:443") def test_datastream_client_get_transport_class(): @@ -1020,7 +1024,7 @@ async def test_list_connection_profiles_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 @@ -1070,7 +1074,9 @@ async def test_list_connection_profiles_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_connection_profiles(request={})).pages: + async for page_ in ( + await client.list_connection_profiles(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 @@ -2630,7 +2636,7 @@ async def test_list_streams_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 @@ -2676,7 +2682,9 @@ async def test_list_streams_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_streams(request={})).pages: + async for page_ in ( + await client.list_streams(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 @@ -4153,7 +4161,7 @@ async def test_fetch_static_ips_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 @@ -4199,7 +4207,9 @@ async def test_fetch_static_ips_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.fetch_static_ips(request={})).pages: + async for page_ in ( + await client.fetch_static_ips(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 @@ -5121,7 +5131,7 @@ async def test_list_private_connections_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 @@ -5171,7 +5181,9 @@ async def test_list_private_connections_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_private_connections(request={})).pages: + async for page_ in ( + await client.list_private_connections(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 @@ -6278,7 +6290,7 @@ async def test_list_routes_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 @@ -6324,7 +6336,9 @@ async def test_list_routes_async_pages(): RuntimeError, ) pages = [] - async for page_ in (await client.list_routes(request={})).pages: + async for page_ in ( + await client.list_routes(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 @@ -6647,6 +6661,19 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = DatastreamClient.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 = DatastreamClient( @@ -6714,6 +6741,14 @@ def test_datastream_base_transport(): with pytest.raises(NotImplementedError): transport.operations_client + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_datastream_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -6856,24 +6891,40 @@ def test_datastream_grpc_transport_client_cert_source_for_mtls(transport_class): ) -def test_datastream_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_datastream_host_no_port(transport_name): client = DatastreamClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="datastream.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "datastream.googleapis.com:443" + assert client.transport._host == ("datastream.googleapis.com:443") -def test_datastream_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_datastream_host_with_port(transport_name): client = DatastreamClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="datastream.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "datastream.googleapis.com:8000" + assert client.transport._host == ("datastream.googleapis.com:8000") def test_datastream_grpc_transport_channel():