cloud-sql-python-connector 1.11.0__py2.py3-none-any.whl → 1.12.0__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cloud-sql-python-connector
3
- Version: 1.11.0
3
+ Version: 1.12.0
4
4
  Summary: The Cloud SQL Python Connector is a library that can be used alongside a database driver to allow users with sufficient permissions to connect to a Cloud SQL database without having to manually allowlist IPs or manage SSL certificates.
5
5
  Home-page: https://github.com/GoogleCloudPlatform/cloud-sql-python-connector
6
6
  Author: Google LLC
@@ -19,6 +19,7 @@ Classifier: Programming Language :: Python :: 3.12
19
19
  Requires-Python: >=3.8
20
20
  Description-Content-Type: text/markdown
21
21
  License-File: LICENSE
22
+ Requires-Dist: aiofiles
22
23
  Requires-Dist: aiohttp
23
24
  Requires-Dist: cryptography (>=42.0.0)
24
25
  Requires-Dist: Requests
@@ -1,8 +1,8 @@
1
1
  google/cloud/sql/connector/__init__.py,sha256=x8ui7u3gMlMI-LLJkKTtUU9yvzZvQkTJ-yzr2FH4VTU,983
2
2
  google/cloud/sql/connector/asyncpg.py,sha256=c4lAlvEgGf_eBq0G8MVNPRAJQQvo6DcwybiXDW36qkU,1838
3
3
  google/cloud/sql/connector/client.py,sha256=wGO6ESxWWYT5qZ-Utg_qh-Rtl_4k5tIjoD-ILcP4REQ,11481
4
- google/cloud/sql/connector/connection_info.py,sha256=3nFuPtGPLUEZRy3Zx9Z2DvTdh6TJqmhOOoE6yKmSGBQ,4308
5
- google/cloud/sql/connector/connector.py,sha256=NTubTmsT8rPpGYuhxXgKDW3MX7KUi4WSalKCHJkHFY8,21417
4
+ google/cloud/sql/connector/connection_info.py,sha256=exxhtb0-rk8J3OIotf8drEPMx8pke17hAX_Mbt7gOts,4336
5
+ google/cloud/sql/connector/connector.py,sha256=4BeJAZNBg_2vbF7XtJvsESKXW7-hM1pyyBu5NIWGbHk,21429
6
6
  google/cloud/sql/connector/enums.py,sha256=44tfMm8D_t0ls6GfKwiQ6YkslWM21PZR40RhJPWntkc,2882
7
7
  google/cloud/sql/connector/exceptions.py,sha256=OVenqBkkn98xFeytHuOXFTWa9R5bCmemBtbSIm8caoM,1665
8
8
  google/cloud/sql/connector/instance.py,sha256=EySszNNHMFjAFskf6-G6Upikvb-tYjEwXx9A_OJBl14,10136
@@ -13,10 +13,10 @@ google/cloud/sql/connector/pymysql.py,sha256=wldUgwDPlPa8Nj5F3JaipuP8hJyvzlgOAJb
13
13
  google/cloud/sql/connector/pytds.py,sha256=vKJoE7E2P0GrhZojg8bGZkqCMLc8dgKAcXE4ee7vEVc,2452
14
14
  google/cloud/sql/connector/rate_limiter.py,sha256=bPTupfM4f5QRSCmCAWMqjQylEB7bUM-50plVBU3W2CA,2993
15
15
  google/cloud/sql/connector/refresh_utils.py,sha256=CajL-MOcQBBRUkywowdHB3GNOr0WpQn37DXG7dRpkMk,5069
16
- google/cloud/sql/connector/utils.py,sha256=FQs7RgoViJLIFgJIynVT-_DwAVWnpyXIKu5WZ4m10Ts,3448
17
- google/cloud/sql/connector/version.py,sha256=l5iWT7w_8JLh0wHTJOCrcxkaD1xxBwPGJDzeSMQLXTI,598
18
- cloud_sql_python_connector-1.11.0.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
19
- cloud_sql_python_connector-1.11.0.dist-info/METADATA,sha256=4NukfHGYVymtt0NbBrH6bFW3BM544K072H-_f8gx6KM,25925
20
- cloud_sql_python_connector-1.11.0.dist-info/WHEEL,sha256=bb2Ot9scclHKMOLDEHY6B2sicWOgugjFKaJsT7vwMQo,110
21
- cloud_sql_python_connector-1.11.0.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
22
- cloud_sql_python_connector-1.11.0.dist-info/RECORD,,
16
+ google/cloud/sql/connector/utils.py,sha256=nQVZVfEijbO3XEj1oU68cR-u8Nx99rRM2a8aXaygOg0,3534
17
+ google/cloud/sql/connector/version.py,sha256=QmuVMbUhLPcMOkkWA-fPpOpI__yRbL45K8wgkam4960,598
18
+ cloud_sql_python_connector-1.12.0.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
19
+ cloud_sql_python_connector-1.12.0.dist-info/METADATA,sha256=LZkFfR0wlQVzFYCJgoQ_AlB8EDT3soKmVdPdF66mDTU,25949
20
+ cloud_sql_python_connector-1.12.0.dist-info/WHEEL,sha256=bb2Ot9scclHKMOLDEHY6B2sicWOgugjFKaJsT7vwMQo,110
21
+ cloud_sql_python_connector-1.12.0.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
22
+ cloud_sql_python_connector-1.12.0.dist-info/RECORD,,
@@ -17,9 +17,10 @@ from __future__ import annotations
17
17
  from dataclasses import dataclass
18
18
  import logging
19
19
  import ssl
20
- from tempfile import TemporaryDirectory
21
20
  from typing import Any, Dict, Optional, TYPE_CHECKING
22
21
 
22
+ from aiofiles.tempfile import TemporaryDirectory
23
+
23
24
  from google.cloud.sql.connector.exceptions import CloudSQLIPTypeError
24
25
  from google.cloud.sql.connector.exceptions import TLSVersionError
25
26
  from google.cloud.sql.connector.utils import write_to_file
@@ -45,7 +46,7 @@ class ConnectionInfo:
45
46
  expiration: datetime.datetime
46
47
  context: Optional[ssl.SSLContext] = None
47
48
 
48
- def create_ssl_context(self, enable_iam_auth: bool = False) -> ssl.SSLContext:
49
+ async def create_ssl_context(self, enable_iam_auth: bool = False) -> ssl.SSLContext:
49
50
  """Constructs a SSL/TLS context for the given connection info.
50
51
 
51
52
  Cache the SSL context to ensure we don't read from disk repeatedly when
@@ -83,8 +84,8 @@ class ConnectionInfo:
83
84
  # tmpdir and its contents are automatically deleted after the CA cert
84
85
  # and ephemeral cert are loaded into the SSLcontext. The values
85
86
  # need to be written to files in order to be loaded by the SSLContext
86
- with TemporaryDirectory() as tmpdir:
87
- ca_filename, cert_filename, key_filename = write_to_file(
87
+ async with TemporaryDirectory() as tmpdir:
88
+ ca_filename, cert_filename, key_filename = await write_to_file(
88
89
  tmpdir, self.server_ca_cert, self.client_cert, self.private_key
89
90
  )
90
91
  context.load_cert_chain(cert_filename, keyfile=key_filename)
@@ -365,14 +365,14 @@ class Connector:
365
365
  if driver in ASYNC_DRIVERS:
366
366
  return await connector(
367
367
  ip_address,
368
- conn_info.create_ssl_context(enable_iam_auth),
368
+ await conn_info.create_ssl_context(enable_iam_auth),
369
369
  **kwargs,
370
370
  )
371
371
  # synchronous drivers are blocking and run using executor
372
372
  connect_partial = partial(
373
373
  connector,
374
374
  ip_address,
375
- conn_info.create_ssl_context(enable_iam_auth),
375
+ await conn_info.create_ssl_context(enable_iam_auth),
376
376
  **kwargs,
377
377
  )
378
378
  return await self._loop.run_in_executor(None, connect_partial)
@@ -13,8 +13,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  """
16
+
16
17
  from typing import Tuple
17
18
 
19
+ import aiofiles
18
20
  from cryptography.hazmat.backends import default_backend
19
21
  from cryptography.hazmat.primitives import serialization
20
22
  from cryptography.hazmat.primitives.asymmetric import rsa
@@ -57,7 +59,7 @@ async def generate_keys() -> Tuple[bytes, str]:
57
59
  return priv_key, pub_key
58
60
 
59
61
 
60
- def write_to_file(
62
+ async def write_to_file(
61
63
  dir_path: str, serverCaCert: str, ephemeralCert: str, priv_key: bytes
62
64
  ) -> Tuple[str, str, str]:
63
65
  """
@@ -68,12 +70,12 @@ def write_to_file(
68
70
  cert_filename = f"{dir_path}/cert.pem"
69
71
  key_filename = f"{dir_path}/priv.pem"
70
72
 
71
- with open(ca_filename, "w+") as ca_out:
72
- ca_out.write(serverCaCert)
73
- with open(cert_filename, "w+") as ephemeral_out:
74
- ephemeral_out.write(ephemeralCert)
75
- with open(key_filename, "wb") as priv_out:
76
- priv_out.write(priv_key)
73
+ async with aiofiles.open(ca_filename, "w+") as ca_out:
74
+ await ca_out.write(serverCaCert)
75
+ async with aiofiles.open(cert_filename, "w+") as ephemeral_out:
76
+ await ephemeral_out.write(ephemeralCert)
77
+ async with aiofiles.open(key_filename, "wb") as priv_out:
78
+ await priv_out.write(priv_key)
77
79
 
78
80
  return (ca_filename, cert_filename, key_filename)
79
81
 
@@ -12,4 +12,4 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- __version__ = "1.11.0"
15
+ __version__ = "1.12.0"