Skip to content

Commit

Permalink
fix: update create_async_connector args (#1016)
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtisvg authored Feb 16, 2024
1 parent a8481e0 commit c3f51a2
Showing 1 changed file with 49 additions and 25 deletions.
74 changes: 49 additions & 25 deletions google/cloud/sql/connector/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,36 +362,60 @@ async def create_async_connector(
timeout: int = 30,
credentials: Optional[Credentials] = None,
loop: Optional[asyncio.AbstractEventLoop] = None,
quota_project: Optional[str] = None,
sqladmin_api_endpoint: str = "https://sqladmin.googleapis.com",
user_agent: Optional[str] = None,
) -> Connector:
"""
Create Connector object for asyncio connections that can auto-detect
and use current thread's running event loop.
Create Connector object for asyncio connections that can auto-detect
and use current thread's running event loop.
:type ip_type: IPTypes
:param ip_type
The IP type (public or private) used to connect. IP types
can be either IPTypes.PUBLIC or IPTypes.PRIVATE.
:type enable_iam_auth: bool
:param enable_iam_auth
Enables automatic IAM database authentication for Postgres or MySQL
instances.
:type timeout: int
:param timeout
The time limit for a connection before raising a TimeoutError.
:type credentials: google.auth.credentials.Credentials
:param credentials
Credentials object used to authenticate connections to Cloud SQL server.
If not specified, Application Default Credentials are used.
:type loop: asyncio.AbstractEventLoop
:param loop
Event loop to run asyncio tasks, if not specified, defaults
to current thread's running event loop.
:param ip_type
The IP type (public or private) used to connect. IP types
can be either IPTypes.PUBLIC or IPTypes.PRIVATE.
:type enable_iam_auth: bool
:param enable_iam_auth
Enables automatic IAM database authentication for Postgres or MySQL
instances.
:type timeout: int
:param timeout
The time limit for a connection before raising a TimeoutError.
:type credentials: google.auth.credentials.Credentials
:param credentials
Credentials object used to authenticate connections to Cloud SQL server.
If not specified, Application Default Credentials are used.
:type quota_project: str
:param quota_project
The Project ID for an existing Google Cloud project. The project specified
is used for quota and billing purposes. If not specified, defaults to
project sourced from environment.
:type loop: asyncio.AbstractEventLoop
:param loop
Event loop to run asyncio tasks, if not specified, defaults to
creating new event loop on background thread.
:type sqladmin_api_endpoint: str
:param sqladmin_api_endpoint:
Base URL to use when calling the Cloud SQL Admin API endpoint.
Defaults to "https://sqladmin.googleapis.com", this argument should
only be used in development.
"""
# if no loop given, automatically detect running event loop
if loop is None:
loop = asyncio.get_running_loop()
return Connector(ip_type, enable_iam_auth, timeout, credentials, loop)
return Connector(
ip_type=ip_type,
enable_iam_auth=enable_iam_auth,
timeout=timeout,
credentials=credentials,
loop=loop,
quota_project=quota_project,
sqladmin_api_endpoint=sqladmin_api_endpoint,
user_agent=user_agent,
)

0 comments on commit c3f51a2

Please sign in to comment.