2323from google .api_core .gapic_v1 .client_info import ClientInfo
2424from google .auth .credentials import TokenState
2525from google .auth .transport import requests
26+ import google .cloud .alloydb_v1beta as v1beta
27+ from google .protobuf import duration_pb2
2628
27- from google .cloud import alloydb_v1beta
2829from google .cloud .alloydb .connector .connection_info import ConnectionInfo
2930from google .cloud .alloydb .connector .version import __version__ as version
30- from google .protobuf import duration_pb2
3131
3232if TYPE_CHECKING :
3333 from google .auth .credentials import Credentials
@@ -58,7 +58,7 @@ def __init__(
5858 alloydb_api_endpoint : str ,
5959 quota_project : Optional [str ],
6060 credentials : Credentials ,
61- client : Optional [alloydb_v1beta .AlloyDBAdminAsyncClient ] = None ,
61+ client : Optional [v1beta .AlloyDBAdminAsyncClient ] = None ,
6262 driver : Optional [str ] = None ,
6363 user_agent : Optional [str ] = None ,
6464 ) -> None :
@@ -75,22 +75,26 @@ def __init__(
7575 A credentials object created from the google-auth Python library.
7676 Must have the AlloyDB Admin scopes. For more info check out
7777 https://google-auth.readthedocs.io/en/latest/.
78- client (alloydb_v1beta .AlloyDBAdminAsyncClient): Async client used to
79- make requests to AlloyDB APIs.
78+ client (v1beta .AlloyDBAdminAsyncClient): Async client used to make
79+ requests to AlloyDB APIs.
8080 Optional, defaults to None and creates new client.
8181 driver (str): Database driver to be used by the client.
8282 """
8383 user_agent = _format_user_agent (driver , user_agent )
8484
85- self ._client = client if client else alloydb_v1beta .AlloyDBAdminAsyncClient (
86- credentials = credentials ,
87- client_options = ClientOptions (
88- api_endpoint = alloydb_api_endpoint ,
89- quota_project_id = quota_project ,
90- ),
91- client_info = ClientInfo (
92- user_agent = user_agent ,
93- ),
85+ self ._client = (
86+ client
87+ if client
88+ else v1beta .AlloyDBAdminAsyncClient (
89+ credentials = credentials ,
90+ client_options = ClientOptions (
91+ api_endpoint = alloydb_api_endpoint ,
92+ quota_project_id = quota_project ,
93+ ),
94+ client_info = ClientInfo (
95+ user_agent = user_agent ,
96+ ),
97+ )
9498 )
9599 self ._credentials = credentials
96100 # asyncpg does not currently support using metadata exchange
@@ -122,9 +126,11 @@ async def _get_metadata(
122126 Returns:
123127 dict: IP addresses of the AlloyDB instance.
124128 """
125- parent = f"projects/{ project } /locations/{ region } /clusters/{ cluster } /instances/{ name } "
129+ parent = (
130+ f"projects/{ project } /locations/{ region } /clusters/{ cluster } /instances/{ name } "
131+ )
126132
127- req = alloydb_v1beta .GetConnectionInfoRequest (parent = parent )
133+ req = v1beta .GetConnectionInfoRequest (parent = parent )
128134 resp = await self ._client .get_connection_info (request = req )
129135
130136 # Remove trailing period from PSC DNS name.
@@ -166,7 +172,7 @@ async def _get_client_certificate(
166172 parent = f"projects/{ project } /locations/{ region } /clusters/{ cluster } "
167173 dur = duration_pb2 .Duration ()
168174 dur .seconds = 3600
169- req = alloydb_v1beta .GenerateClientCertificateRequest (
175+ req = v1beta .GenerateClientCertificateRequest (
170176 parent = parent ,
171177 cert_duration = dur ,
172178 public_key = pub_key ,
0 commit comments