diff --git a/google/cloud/bigquery_storage_v1/services/big_query_read/async_client.py b/google/cloud/bigquery_storage_v1/services/big_query_read/async_client.py index 522b3437..2215c6cd 100644 --- a/google/cloud/bigquery_storage_v1/services/big_query_read/async_client.py +++ b/google/cloud/bigquery_storage_v1/services/big_query_read/async_client.py @@ -467,6 +467,12 @@ async def split_read_stream( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/bigquery_storage_v1/services/big_query_read/client.py b/google/cloud/bigquery_storage_v1/services/big_query_read/client.py index cceb8def..40ec76d9 100644 --- a/google/cloud/bigquery_storage_v1/services/big_query_read/client.py +++ b/google/cloud/bigquery_storage_v1/services/big_query_read/client.py @@ -381,10 +381,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def create_read_session( @@ -660,6 +657,19 @@ def split_read_stream( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/bigquery_storage_v1/services/big_query_read/transports/base.py b/google/cloud/bigquery_storage_v1/services/big_query_read/transports/base.py index 3c5ad5af..db38c893 100644 --- a/google/cloud/bigquery_storage_v1/services/big_query_read/transports/base.py +++ b/google/cloud/bigquery_storage_v1/services/big_query_read/transports/base.py @@ -205,6 +205,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def create_read_session( self, diff --git a/google/cloud/bigquery_storage_v1/services/big_query_read/transports/grpc.py b/google/cloud/bigquery_storage_v1/services/big_query_read/transports/grpc.py index 6ad37c10..3f33cc87 100644 --- a/google/cloud/bigquery_storage_v1/services/big_query_read/transports/grpc.py +++ b/google/cloud/bigquery_storage_v1/services/big_query_read/transports/grpc.py @@ -346,5 +346,8 @@ def split_read_stream( ) return self._stubs["split_read_stream"] + def close(self): + self.grpc_channel.close() + __all__ = ("BigQueryReadGrpcTransport",) diff --git a/google/cloud/bigquery_storage_v1/services/big_query_read/transports/grpc_asyncio.py b/google/cloud/bigquery_storage_v1/services/big_query_read/transports/grpc_asyncio.py index 60a07966..7c075872 100644 --- a/google/cloud/bigquery_storage_v1/services/big_query_read/transports/grpc_asyncio.py +++ b/google/cloud/bigquery_storage_v1/services/big_query_read/transports/grpc_asyncio.py @@ -351,5 +351,8 @@ def split_read_stream( ) return self._stubs["split_read_stream"] + def close(self): + return self.grpc_channel.close() + __all__ = ("BigQueryReadGrpcAsyncIOTransport",) diff --git a/google/cloud/bigquery_storage_v1/services/big_query_write/async_client.py b/google/cloud/bigquery_storage_v1/services/big_query_write/async_client.py index 0f3753b4..e167c0c6 100644 --- a/google/cloud/bigquery_storage_v1/services/big_query_write/async_client.py +++ b/google/cloud/bigquery_storage_v1/services/big_query_write/async_client.py @@ -700,6 +700,12 @@ async def flush_rows( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/bigquery_storage_v1/services/big_query_write/client.py b/google/cloud/bigquery_storage_v1/services/big_query_write/client.py index 17d319d5..fbbed83e 100644 --- a/google/cloud/bigquery_storage_v1/services/big_query_write/client.py +++ b/google/cloud/bigquery_storage_v1/services/big_query_write/client.py @@ -365,10 +365,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def create_write_stream( @@ -831,6 +828,19 @@ def flush_rows( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/bigquery_storage_v1/services/big_query_write/transports/base.py b/google/cloud/bigquery_storage_v1/services/big_query_write/transports/base.py index d6d7e078..21e4b644 100644 --- a/google/cloud/bigquery_storage_v1/services/big_query_write/transports/base.py +++ b/google/cloud/bigquery_storage_v1/services/big_query_write/transports/base.py @@ -250,6 +250,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def create_write_stream( self, diff --git a/google/cloud/bigquery_storage_v1/services/big_query_write/transports/grpc.py b/google/cloud/bigquery_storage_v1/services/big_query_write/transports/grpc.py index eaf0756c..d54334ae 100644 --- a/google/cloud/bigquery_storage_v1/services/big_query_write/transports/grpc.py +++ b/google/cloud/bigquery_storage_v1/services/big_query_write/transports/grpc.py @@ -444,5 +444,8 @@ def flush_rows( ) return self._stubs["flush_rows"] + def close(self): + self.grpc_channel.close() + __all__ = ("BigQueryWriteGrpcTransport",) diff --git a/google/cloud/bigquery_storage_v1/services/big_query_write/transports/grpc_asyncio.py b/google/cloud/bigquery_storage_v1/services/big_query_write/transports/grpc_asyncio.py index 100342b9..d3b096a8 100644 --- a/google/cloud/bigquery_storage_v1/services/big_query_write/transports/grpc_asyncio.py +++ b/google/cloud/bigquery_storage_v1/services/big_query_write/transports/grpc_asyncio.py @@ -448,5 +448,8 @@ def flush_rows( ) return self._stubs["flush_rows"] + def close(self): + return self.grpc_channel.close() + __all__ = ("BigQueryWriteGrpcAsyncIOTransport",) diff --git a/google/cloud/bigquery_storage_v1/types/avro.py b/google/cloud/bigquery_storage_v1/types/avro.py index 1a582f46..09b8ebef 100644 --- a/google/cloud/bigquery_storage_v1/types/avro.py +++ b/google/cloud/bigquery_storage_v1/types/avro.py @@ -23,6 +23,7 @@ class AvroSchema(proto.Message): r"""Avro schema. + Attributes: schema (str): Json serialized schema, as described at @@ -34,6 +35,7 @@ class AvroSchema(proto.Message): class AvroRows(proto.Message): r"""Avro rows. + Attributes: serialized_binary_rows (bytes): Binary serialized rows in a block. diff --git a/google/cloud/bigquery_storage_v1/types/protobuf.py b/google/cloud/bigquery_storage_v1/types/protobuf.py index c5dab2d3..4e73b375 100644 --- a/google/cloud/bigquery_storage_v1/types/protobuf.py +++ b/google/cloud/bigquery_storage_v1/types/protobuf.py @@ -49,6 +49,7 @@ class ProtoSchema(proto.Message): class ProtoRows(proto.Message): r""" + Attributes: serialized_rows (Sequence[bytes]): A sequence of rows serialized as a Protocol diff --git a/google/cloud/bigquery_storage_v1/types/storage.py b/google/cloud/bigquery_storage_v1/types/storage.py index 8299a175..822a1ca2 100644 --- a/google/cloud/bigquery_storage_v1/types/storage.py +++ b/google/cloud/bigquery_storage_v1/types/storage.py @@ -52,6 +52,7 @@ class CreateReadSessionRequest(proto.Message): r"""Request message for ``CreateReadSession``. + Attributes: parent (str): Required. The request project that owns the session, in the @@ -79,6 +80,7 @@ class CreateReadSessionRequest(proto.Message): class ReadRowsRequest(proto.Message): r"""Request message for ``ReadRows``. + Attributes: read_stream (str): Required. Stream to read rows from. @@ -95,6 +97,7 @@ class ReadRowsRequest(proto.Message): class ThrottleState(proto.Message): r"""Information on if the current connection is being throttled. + Attributes: throttle_percent (int): How much this connection is being throttled. @@ -107,6 +110,7 @@ class ThrottleState(proto.Message): class StreamStats(proto.Message): r"""Estimated stream statistics for a given read Stream. + Attributes: progress (google.cloud.bigquery_storage_v1.types.StreamStats.Progress): Represents the progress of the current @@ -115,6 +119,7 @@ class StreamStats(proto.Message): class Progress(proto.Message): r""" + Attributes: at_response_start (float): The fraction of rows assigned to the stream that have been @@ -183,6 +188,7 @@ class ReadRowsResponse(proto.Message): class SplitReadStreamRequest(proto.Message): r"""Request message for ``SplitReadStream``. + Attributes: name (str): Required. Name of the stream to split. @@ -207,6 +213,7 @@ class SplitReadStreamRequest(proto.Message): class SplitReadStreamResponse(proto.Message): r"""Response message for ``SplitReadStream``. + Attributes: primary_stream (google.cloud.bigquery_storage_v1.types.ReadStream): Primary stream, which contains the beginning portion of @@ -224,6 +231,7 @@ class SplitReadStreamResponse(proto.Message): class CreateWriteStreamRequest(proto.Message): r"""Request message for ``CreateWriteStream``. + Attributes: parent (str): Required. Reference to the table to which the stream @@ -303,6 +311,7 @@ class ProtoData(proto.Message): class AppendRowsResponse(proto.Message): r"""Response message for ``AppendRows``. + Attributes: append_result (google.cloud.bigquery_storage_v1.types.AppendRowsResponse.AppendResult): Result if the append is successful. @@ -339,6 +348,7 @@ class AppendRowsResponse(proto.Message): class AppendResult(proto.Message): r"""AppendResult is returned for successful append requests. + Attributes: offset (google.protobuf.wrappers_pb2.Int64Value): The row offset at which the last append @@ -359,6 +369,7 @@ class AppendResult(proto.Message): class GetWriteStreamRequest(proto.Message): r"""Request message for ``GetWriteStreamRequest``. + Attributes: name (str): Required. Name of the stream to get, in the form of @@ -370,6 +381,7 @@ class GetWriteStreamRequest(proto.Message): class BatchCommitWriteStreamsRequest(proto.Message): r"""Request message for ``BatchCommitWriteStreams``. + Attributes: parent (str): Required. Parent table that all the streams should belong @@ -386,6 +398,7 @@ class BatchCommitWriteStreamsRequest(proto.Message): class BatchCommitWriteStreamsResponse(proto.Message): r"""Response message for ``BatchCommitWriteStreams``. + Attributes: commit_time (google.protobuf.timestamp_pb2.Timestamp): The time at which streams were committed in microseconds @@ -409,6 +422,7 @@ class BatchCommitWriteStreamsResponse(proto.Message): class FinalizeWriteStreamRequest(proto.Message): r"""Request message for invoking ``FinalizeWriteStream``. + Attributes: name (str): Required. Name of the stream to finalize, in the form of @@ -420,6 +434,7 @@ class FinalizeWriteStreamRequest(proto.Message): class FinalizeWriteStreamResponse(proto.Message): r"""Response message for ``FinalizeWriteStream``. + Attributes: row_count (int): Number of rows in the finalized stream. @@ -430,6 +445,7 @@ class FinalizeWriteStreamResponse(proto.Message): class FlushRowsRequest(proto.Message): r"""Request message for ``FlushRows``. + Attributes: write_stream (str): Required. The stream that is the target of @@ -446,6 +462,7 @@ class FlushRowsRequest(proto.Message): class FlushRowsResponse(proto.Message): r"""Respond message for ``FlushRows``. + Attributes: offset (int): The rows before this offset (including this diff --git a/google/cloud/bigquery_storage_v1/types/stream.py b/google/cloud/bigquery_storage_v1/types/stream.py index a4311e3a..c49a8a3f 100644 --- a/google/cloud/bigquery_storage_v1/types/stream.py +++ b/google/cloud/bigquery_storage_v1/types/stream.py @@ -36,6 +36,7 @@ class DataFormat(proto.Enum): class ReadSession(proto.Message): r"""Information about the ReadSession. + Attributes: name (str): Output only. Unique identifier for the session, in the form @@ -79,6 +80,7 @@ class ReadSession(proto.Message): class TableModifiers(proto.Message): r"""Additional attributes when reading a table. + Attributes: snapshot_time (google.protobuf.timestamp_pb2.Timestamp): The snapshot time of the table. If not set, @@ -91,6 +93,7 @@ class TableModifiers(proto.Message): class TableReadOptions(proto.Message): r"""Options dictating how we read a table. + Attributes: selected_fields (Sequence[str]): Names of the fields in the table that should be read. If diff --git a/google/cloud/bigquery_storage_v1/types/table.py b/google/cloud/bigquery_storage_v1/types/table.py index 295f3b50..a33ffd37 100644 --- a/google/cloud/bigquery_storage_v1/types/table.py +++ b/google/cloud/bigquery_storage_v1/types/table.py @@ -24,6 +24,7 @@ class TableSchema(proto.Message): r"""Schema of a table. + Attributes: fields (Sequence[google.cloud.bigquery_storage_v1.types.TableFieldSchema]): Describes the fields in a table. diff --git a/google/cloud/bigquery_storage_v1beta2/services/big_query_read/async_client.py b/google/cloud/bigquery_storage_v1beta2/services/big_query_read/async_client.py index 9a91feae..fbc7a25f 100644 --- a/google/cloud/bigquery_storage_v1beta2/services/big_query_read/async_client.py +++ b/google/cloud/bigquery_storage_v1beta2/services/big_query_read/async_client.py @@ -469,6 +469,12 @@ async def split_read_stream( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/bigquery_storage_v1beta2/services/big_query_read/client.py b/google/cloud/bigquery_storage_v1beta2/services/big_query_read/client.py index 3e2f7d5d..bfdd0ac0 100644 --- a/google/cloud/bigquery_storage_v1beta2/services/big_query_read/client.py +++ b/google/cloud/bigquery_storage_v1beta2/services/big_query_read/client.py @@ -383,10 +383,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def create_read_session( @@ -662,6 +659,19 @@ def split_read_stream( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/bigquery_storage_v1beta2/services/big_query_read/transports/base.py b/google/cloud/bigquery_storage_v1beta2/services/big_query_read/transports/base.py index 621fef4b..ba5b0694 100644 --- a/google/cloud/bigquery_storage_v1beta2/services/big_query_read/transports/base.py +++ b/google/cloud/bigquery_storage_v1beta2/services/big_query_read/transports/base.py @@ -205,6 +205,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def create_read_session( self, diff --git a/google/cloud/bigquery_storage_v1beta2/services/big_query_read/transports/grpc.py b/google/cloud/bigquery_storage_v1beta2/services/big_query_read/transports/grpc.py index 287ad3a7..611340a1 100644 --- a/google/cloud/bigquery_storage_v1beta2/services/big_query_read/transports/grpc.py +++ b/google/cloud/bigquery_storage_v1beta2/services/big_query_read/transports/grpc.py @@ -348,5 +348,8 @@ def split_read_stream( ) return self._stubs["split_read_stream"] + def close(self): + self.grpc_channel.close() + __all__ = ("BigQueryReadGrpcTransport",) diff --git a/google/cloud/bigquery_storage_v1beta2/services/big_query_read/transports/grpc_asyncio.py b/google/cloud/bigquery_storage_v1beta2/services/big_query_read/transports/grpc_asyncio.py index f605d3ce..f715be36 100644 --- a/google/cloud/bigquery_storage_v1beta2/services/big_query_read/transports/grpc_asyncio.py +++ b/google/cloud/bigquery_storage_v1beta2/services/big_query_read/transports/grpc_asyncio.py @@ -353,5 +353,8 @@ def split_read_stream( ) return self._stubs["split_read_stream"] + def close(self): + return self.grpc_channel.close() + __all__ = ("BigQueryReadGrpcAsyncIOTransport",) diff --git a/google/cloud/bigquery_storage_v1beta2/services/big_query_write/async_client.py b/google/cloud/bigquery_storage_v1beta2/services/big_query_write/async_client.py index 9c6ba354..37f11c64 100644 --- a/google/cloud/bigquery_storage_v1beta2/services/big_query_write/async_client.py +++ b/google/cloud/bigquery_storage_v1beta2/services/big_query_write/async_client.py @@ -678,6 +678,12 @@ async def flush_rows( # Done; return the response. return response + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + await self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/bigquery_storage_v1beta2/services/big_query_write/client.py b/google/cloud/bigquery_storage_v1beta2/services/big_query_write/client.py index 6ebdddb3..896b9a81 100644 --- a/google/cloud/bigquery_storage_v1beta2/services/big_query_write/client.py +++ b/google/cloud/bigquery_storage_v1beta2/services/big_query_write/client.py @@ -363,10 +363,7 @@ def __init__( client_cert_source_for_mtls=client_cert_source_func, quota_project_id=client_options.quota_project_id, client_info=client_info, - always_use_jwt_access=( - Transport == type(self).get_transport_class("grpc") - or Transport == type(self).get_transport_class("grpc_asyncio") - ), + always_use_jwt_access=True, ) def create_write_stream( @@ -807,6 +804,19 @@ def flush_rows( # Done; return the response. return response + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + """Releases underlying transport's resources. + + .. warning:: + ONLY use as a context manager if the transport is NOT shared + with other clients! Exiting the with block will CLOSE the transport + and may cause errors in other clients! + """ + self.transport.close() + try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( diff --git a/google/cloud/bigquery_storage_v1beta2/services/big_query_write/transports/base.py b/google/cloud/bigquery_storage_v1beta2/services/big_query_write/transports/base.py index 399f110b..7c883bb0 100644 --- a/google/cloud/bigquery_storage_v1beta2/services/big_query_write/transports/base.py +++ b/google/cloud/bigquery_storage_v1beta2/services/big_query_write/transports/base.py @@ -252,6 +252,15 @@ def _prep_wrapped_messages(self, client_info): ), } + def close(self): + """Closes resources associated with the transport. + + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! + """ + raise NotImplementedError() + @property def create_write_stream( self, diff --git a/google/cloud/bigquery_storage_v1beta2/services/big_query_write/transports/grpc.py b/google/cloud/bigquery_storage_v1beta2/services/big_query_write/transports/grpc.py index e212be91..255a40f2 100644 --- a/google/cloud/bigquery_storage_v1beta2/services/big_query_write/transports/grpc.py +++ b/google/cloud/bigquery_storage_v1beta2/services/big_query_write/transports/grpc.py @@ -424,5 +424,8 @@ def flush_rows( ) return self._stubs["flush_rows"] + def close(self): + self.grpc_channel.close() + __all__ = ("BigQueryWriteGrpcTransport",) diff --git a/google/cloud/bigquery_storage_v1beta2/services/big_query_write/transports/grpc_asyncio.py b/google/cloud/bigquery_storage_v1beta2/services/big_query_write/transports/grpc_asyncio.py index 2b24dce6..aafd2022 100644 --- a/google/cloud/bigquery_storage_v1beta2/services/big_query_write/transports/grpc_asyncio.py +++ b/google/cloud/bigquery_storage_v1beta2/services/big_query_write/transports/grpc_asyncio.py @@ -428,5 +428,8 @@ def flush_rows( ) return self._stubs["flush_rows"] + def close(self): + return self.grpc_channel.close() + __all__ = ("BigQueryWriteGrpcAsyncIOTransport",) diff --git a/google/cloud/bigquery_storage_v1beta2/types/avro.py b/google/cloud/bigquery_storage_v1beta2/types/avro.py index 863c7177..0783c58c 100644 --- a/google/cloud/bigquery_storage_v1beta2/types/avro.py +++ b/google/cloud/bigquery_storage_v1beta2/types/avro.py @@ -24,6 +24,7 @@ class AvroSchema(proto.Message): r"""Avro schema. + Attributes: schema (str): Json serialized schema, as described at @@ -35,6 +36,7 @@ class AvroSchema(proto.Message): class AvroRows(proto.Message): r"""Avro rows. + Attributes: serialized_binary_rows (bytes): Binary serialized rows in a block. diff --git a/google/cloud/bigquery_storage_v1beta2/types/protobuf.py b/google/cloud/bigquery_storage_v1beta2/types/protobuf.py index 7a7b5d8c..7810c251 100644 --- a/google/cloud/bigquery_storage_v1beta2/types/protobuf.py +++ b/google/cloud/bigquery_storage_v1beta2/types/protobuf.py @@ -45,6 +45,7 @@ class ProtoSchema(proto.Message): class ProtoRows(proto.Message): r""" + Attributes: serialized_rows (Sequence[bytes]): A sequence of rows serialized as a Protocol diff --git a/google/cloud/bigquery_storage_v1beta2/types/storage.py b/google/cloud/bigquery_storage_v1beta2/types/storage.py index aff3c1bf..00586f9a 100644 --- a/google/cloud/bigquery_storage_v1beta2/types/storage.py +++ b/google/cloud/bigquery_storage_v1beta2/types/storage.py @@ -52,6 +52,7 @@ class CreateReadSessionRequest(proto.Message): r"""Request message for ``CreateReadSession``. + Attributes: parent (str): Required. The request project that owns the session, in the @@ -79,6 +80,7 @@ class CreateReadSessionRequest(proto.Message): class ReadRowsRequest(proto.Message): r"""Request message for ``ReadRows``. + Attributes: read_stream (str): Required. Stream to read rows from. @@ -95,6 +97,7 @@ class ReadRowsRequest(proto.Message): class ThrottleState(proto.Message): r"""Information on if the current connection is being throttled. + Attributes: throttle_percent (int): How much this connection is being throttled. @@ -107,6 +110,7 @@ class ThrottleState(proto.Message): class StreamStats(proto.Message): r"""Estimated stream statistics for a given Stream. + Attributes: progress (google.cloud.bigquery_storage_v1beta2.types.StreamStats.Progress): Represents the progress of the current @@ -115,6 +119,7 @@ class StreamStats(proto.Message): class Progress(proto.Message): r""" + Attributes: at_response_start (float): The fraction of rows assigned to the stream that have been @@ -183,6 +188,7 @@ class ReadRowsResponse(proto.Message): class SplitReadStreamRequest(proto.Message): r"""Request message for ``SplitReadStream``. + Attributes: name (str): Required. Name of the stream to split. @@ -207,6 +213,7 @@ class SplitReadStreamRequest(proto.Message): class SplitReadStreamResponse(proto.Message): r""" + Attributes: primary_stream (google.cloud.bigquery_storage_v1beta2.types.ReadStream): Primary stream, which contains the beginning portion of @@ -224,6 +231,7 @@ class SplitReadStreamResponse(proto.Message): class CreateWriteStreamRequest(proto.Message): r"""Request message for ``CreateWriteStream``. + Attributes: parent (str): Required. Reference to the table to which the stream @@ -239,6 +247,7 @@ class CreateWriteStreamRequest(proto.Message): class AppendRowsRequest(proto.Message): r"""Request message for ``AppendRows``. + Attributes: write_stream (str): Required. The stream that is the target of the append @@ -263,6 +272,7 @@ class AppendRowsRequest(proto.Message): class ProtoData(proto.Message): r"""Proto schema and data. + Attributes: writer_schema (google.cloud.bigquery_storage_v1beta2.types.ProtoSchema): Proto schema used to serialize the data. @@ -284,6 +294,7 @@ class ProtoData(proto.Message): class AppendRowsResponse(proto.Message): r"""Response message for ``AppendRows``. + Attributes: append_result (google.cloud.bigquery_storage_v1beta2.types.AppendRowsResponse.AppendResult): Result if the append is successful. @@ -320,6 +331,7 @@ class AppendRowsResponse(proto.Message): class AppendResult(proto.Message): r"""AppendResult is returned for successful append requests. + Attributes: offset (google.protobuf.wrappers_pb2.Int64Value): The row offset at which the last append @@ -340,6 +352,7 @@ class AppendResult(proto.Message): class GetWriteStreamRequest(proto.Message): r"""Request message for ``GetWriteStreamRequest``. + Attributes: name (str): Required. Name of the stream to get, in the form of @@ -351,6 +364,7 @@ class GetWriteStreamRequest(proto.Message): class BatchCommitWriteStreamsRequest(proto.Message): r"""Request message for ``BatchCommitWriteStreams``. + Attributes: parent (str): Required. Parent table that all the streams should belong @@ -367,6 +381,7 @@ class BatchCommitWriteStreamsRequest(proto.Message): class BatchCommitWriteStreamsResponse(proto.Message): r"""Response message for ``BatchCommitWriteStreams``. + Attributes: commit_time (google.protobuf.timestamp_pb2.Timestamp): The time at which streams were committed in microseconds @@ -390,6 +405,7 @@ class BatchCommitWriteStreamsResponse(proto.Message): class FinalizeWriteStreamRequest(proto.Message): r"""Request message for invoking ``FinalizeWriteStream``. + Attributes: name (str): Required. Name of the stream to finalize, in the form of @@ -401,6 +417,7 @@ class FinalizeWriteStreamRequest(proto.Message): class FinalizeWriteStreamResponse(proto.Message): r"""Response message for ``FinalizeWriteStream``. + Attributes: row_count (int): Number of rows in the finalized stream. @@ -411,6 +428,7 @@ class FinalizeWriteStreamResponse(proto.Message): class FlushRowsRequest(proto.Message): r"""Request message for ``FlushRows``. + Attributes: write_stream (str): Required. The stream that is the target of @@ -427,6 +445,7 @@ class FlushRowsRequest(proto.Message): class FlushRowsResponse(proto.Message): r"""Respond message for ``FlushRows``. + Attributes: offset (int): The rows before this offset (including this diff --git a/google/cloud/bigquery_storage_v1beta2/types/stream.py b/google/cloud/bigquery_storage_v1beta2/types/stream.py index 278be047..9a658bba 100644 --- a/google/cloud/bigquery_storage_v1beta2/types/stream.py +++ b/google/cloud/bigquery_storage_v1beta2/types/stream.py @@ -36,6 +36,7 @@ class DataFormat(proto.Enum): class ReadSession(proto.Message): r"""Information about the ReadSession. + Attributes: name (str): Output only. Unique identifier for the session, in the form @@ -73,6 +74,7 @@ class ReadSession(proto.Message): class TableModifiers(proto.Message): r"""Additional attributes when reading a table. + Attributes: snapshot_time (google.protobuf.timestamp_pb2.Timestamp): The snapshot time of the table. If not set, @@ -85,6 +87,7 @@ class TableModifiers(proto.Message): class TableReadOptions(proto.Message): r"""Options dictating how we read a table. + Attributes: selected_fields (Sequence[str]): Names of the fields in the table that should be read. If diff --git a/google/cloud/bigquery_storage_v1beta2/types/table.py b/google/cloud/bigquery_storage_v1beta2/types/table.py index 8e8538fb..2026f576 100644 --- a/google/cloud/bigquery_storage_v1beta2/types/table.py +++ b/google/cloud/bigquery_storage_v1beta2/types/table.py @@ -24,6 +24,7 @@ class TableSchema(proto.Message): r"""Schema of a table + Attributes: fields (Sequence[google.cloud.bigquery_storage_v1beta2.types.TableFieldSchema]): Describes the fields in a table. @@ -34,6 +35,7 @@ class TableSchema(proto.Message): class TableFieldSchema(proto.Message): r"""A field in TableSchema + Attributes: name (str): Required. The field name. The name must contain only letters diff --git a/tests/unit/gapic/bigquery_storage_v1/test_big_query_read.py b/tests/unit/gapic/bigquery_storage_v1/test_big_query_read.py index 9d2ee3cb..23480a74 100644 --- a/tests/unit/gapic/bigquery_storage_v1/test_big_query_read.py +++ b/tests/unit/gapic/bigquery_storage_v1/test_big_query_read.py @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.bigquery_storage_v1.services.big_query_read import ( @@ -1176,6 +1177,9 @@ def test_big_query_read_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_big_query_read_base_transport_with_credentials_file(): @@ -1725,3 +1729,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = BigQueryReadAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = BigQueryReadClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = BigQueryReadClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/bigquery_storage_v1/test_big_query_write.py b/tests/unit/gapic/bigquery_storage_v1/test_big_query_write.py index 28d36177..a6b1f1f8 100644 --- a/tests/unit/gapic/bigquery_storage_v1/test_big_query_write.py +++ b/tests/unit/gapic/bigquery_storage_v1/test_big_query_write.py @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.bigquery_storage_v1.services.big_query_write import ( @@ -1745,6 +1746,9 @@ def test_big_query_write_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_big_query_write_base_transport_with_credentials_file(): @@ -2281,3 +2285,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = BigQueryWriteAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = BigQueryWriteClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = BigQueryWriteClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/bigquery_storage_v1beta2/test_big_query_read.py b/tests/unit/gapic/bigquery_storage_v1beta2/test_big_query_read.py index 59f08ae5..c519ab6e 100644 --- a/tests/unit/gapic/bigquery_storage_v1beta2/test_big_query_read.py +++ b/tests/unit/gapic/bigquery_storage_v1beta2/test_big_query_read.py @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.bigquery_storage_v1beta2.services.big_query_read import ( @@ -1174,6 +1175,9 @@ def test_big_query_read_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_big_query_read_base_transport_with_credentials_file(): @@ -1723,3 +1727,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = BigQueryReadAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = BigQueryReadClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = BigQueryReadClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() diff --git a/tests/unit/gapic/bigquery_storage_v1beta2/test_big_query_write.py b/tests/unit/gapic/bigquery_storage_v1beta2/test_big_query_write.py index 482a1868..df48cf45 100644 --- a/tests/unit/gapic/bigquery_storage_v1beta2/test_big_query_write.py +++ b/tests/unit/gapic/bigquery_storage_v1beta2/test_big_query_write.py @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.bigquery_storage_v1beta2.services.big_query_write import ( @@ -1745,6 +1746,9 @@ def test_big_query_write_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_big_query_write_base_transport_with_credentials_file(): @@ -2281,3 +2285,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = BigQueryWriteAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = BigQueryWriteClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = BigQueryWriteClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called()