Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Commit eadcf91

Browse files
committed
add getter for grpc_client
1 parent 920e39a commit eadcf91

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

google/cloud/storage/_experimental/grpc_client.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,17 @@ def _create_gapic_client(
106106
client_info=client_info,
107107
client_options=client_options,
108108
)
109+
110+
@property
111+
def grpc_client(self):
112+
"""The underlying gRPC client.
113+
114+
This property gives users direct access to the `storage_v2.StorageClient`
115+
instance. This can be useful for accessing
116+
newly added or experimental RPCs that are not yet exposed through
117+
the high-level GrpcClient.
118+
119+
Returns:
120+
google.cloud.storage_v2.StorageClient: The configured GAPIC client.
121+
"""
122+
return self._grpc_client

tests/unit/test_grpc_client.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,18 @@ def test_constructor_handles_api_key(self, mock_storage_client, mock_base_client
107107
# that contains the api_key.
108108
_, kwargs = mock_storage_client.call_args
109109
self.assertEqual(kwargs["client_options"]["api_key"], "test-api-key")
110+
111+
@mock.patch("google.cloud.storage._experimental.grpc_client.ClientWithProject")
112+
@mock.patch("google.cloud._storage_v2.StorageClient")
113+
def test_grpc_client_property(self, mock_storage_client, mock_base_client):
114+
from google.cloud.storage._experimental import grpc_client
115+
116+
mock_creds = mock.Mock(spec=auth_credentials.Credentials)
117+
mock_base_instance = mock_base_client.return_value
118+
mock_base_instance._credentials = mock_creds
119+
120+
client = grpc_client.GrpcClient(project="test-project", credentials=mock_creds)
121+
122+
retrieved_client = client.grpc_client
123+
124+
self.assertIs(retrieved_client, mock_storage_client.return_value)

0 commit comments

Comments
 (0)