Repository: GoogleCloudPlatform/cloud-sql-python-connector (python)

Issue:
Rename `InstanceMetadata` class to `ConnectionInfo`
Rename `InstanceMetadata` class to `ConnectionInfo` for consistency across connector languages.

https://github.com/GoogleCloudPlatform/cloud-sql-python-connector/blob/main/google/cloud/sql/connector/instance.py#L66

Pull request description:
chore: update naming of `InstanceMetadata` to `ConnectionInfo`
Make naming across languages with use of `ConnectionInfo`

Closes #877 

Patch:
diff --git a/google/cloud/sql/connector/instance.py b/google/cloud/sql/connector/instance.py
index 4b0814a..711346a 100644
--- a/google/cloud/sql/connector/instance.py
+++ b/google/cloud/sql/connector/instance.py
@@ -63,7 +63,7 @@ class IPTypes(Enum):
     PSC: str = "PSC"
 
 
-class InstanceMetadata:
+class ConnectionInfo:
     ip_addrs: Dict[str, Any]
     context: ssl.SSLContext
     database_version: str
@@ -205,7 +205,7 @@ class Instance:
 
     _refresh_rate_limiter: AsyncRateLimiter
     _refresh_in_progress: asyncio.locks.Event
-    _current: asyncio.Task  # task wraps coroutine that returns InstanceMetadata
+    _current: asyncio.Task  # task wraps coroutine that returns ConnectionInfo
     _next: asyncio.Task  # task wraps coroutine that returns another task
 
     def __init__(
@@ -267,11 +267,11 @@ class Instance:
         if not await _is_valid(self._current):
             self._current = self._next
 
-    async def _perform_refresh(self) -> InstanceMetadata:
+    async def _perform_refresh(self) -> ConnectionInfo:
         """Retrieves instance metadata and ephemeral certificate from the
         Cloud SQL Instance.
 
-        :rtype: InstanceMetadata
+        :rtype: ConnectionInfo
         :returns: A dataclass containing a string representing the ephemeral certificate, a dict
             containing the instances IP adresses, a string representing a PEM-encoded private key
             and a string representing a PEM-encoded certificate authority.
@@ -353,7 +353,7 @@ class Instance:
         finally:
             self._refresh_in_progress.clear()
 
-        return InstanceMetadata(
+        return ConnectionInfo(
             ephemeral_cert,
             metadata["database_version"],
             metadata["ip_addresses"],
@@ -365,7 +365,7 @@ class Instance:
 
     def _schedule_refresh(self, delay: int) -> asyncio.Task:
         """
-        Schedule task to sleep and then perform refresh to get InstanceMetadata.
+        Schedule task to sleep and then perform refresh to get ConnectionInfo.
 
         :type delay: int
         :param delay
@@ -375,7 +375,7 @@ class Instance:
         :returns: A Task representing the scheduled _perform_refresh.
         """
 
-        async def _refresh_task(self: Instance, delay: int) -> InstanceMetadata:
+        async def _refresh_task(self: Instance, delay: int) -> ConnectionInfo:
             """
             A coroutine that sleeps for the specified amount of time before
             running _perform_refresh.
@@ -422,7 +422,7 @@ class Instance:
     async def connect_info(
         self,
         ip_type: IPTypes,
-    ) -> Tuple[InstanceMetadata, str]:
+    ) -> Tuple[ConnectionInfo, str]:
         """Retrieve instance metadata and ip address required
         for making connection to Cloud SQL instance.
 
@@ -430,7 +430,7 @@ class Instance:
         :param ip_type: Enum specifying whether to look for public
             or private IP address.
 
-        :rtype instance_data: InstanceMetadata
+        :rtype instance_data: ConnectionInfo
         :returns: Instance metadata for Cloud SQL instance.
 
         :rtype ip_address: str
@@ -441,7 +441,7 @@ class Instance:
             f"['{self._instance_connection_string}']: Entered connect_info method"
         )
 
-        instance_data: InstanceMetadata
+        instance_data: ConnectionInfo
 
         instance_data = await self._current
         ip_address: str = instance_data.get_preferred_ip(ip_type)


Test patch:
diff --git a/tests/unit/mocks.py b/tests/unit/mocks.py
index 47b4605..f139563 100644
--- a/tests/unit/mocks.py
+++ b/tests/unit/mocks.py
@@ -28,7 +28,7 @@ from cryptography.hazmat.primitives.asymmetric import rsa
 from cryptography.x509.oid import NameOID
 
 from google.cloud.sql.connector import IPTypes
-from google.cloud.sql.connector.instance import InstanceMetadata
+from google.cloud.sql.connector.instance import ConnectionInfo
 from google.cloud.sql.connector.utils import generate_keys, write_to_file
 
 
@@ -55,8 +55,8 @@ class BadRefresh(Exception):
     pass
 
 
-class MockMetadata(InstanceMetadata):
-    """Mock class for InstanceMetadata"""
+class MockMetadata(ConnectionInfo):
+    """Mock class for ConnectionInfo"""
 
     def __init__(
         self, expiration: datetime.datetime, ip_addrs: Dict = {"PRIMARY": "0.0.0.0"}
diff --git a/tests/unit/test_instance.py b/tests/unit/test_instance.py
index 0bd0a11..e0fea74 100644
--- a/tests/unit/test_instance.py
+++ b/tests/unit/test_instance.py
@@ -29,8 +29,8 @@ from google.cloud.sql.connector.exceptions import (
     CredentialsTypeError,
 )
 from google.cloud.sql.connector.instance import (
+    ConnectionInfo,
     Instance,
-    InstanceMetadata,
     IPTypes,
 )
 from google.cloud.sql.connector.rate_limiter import AsyncRateLimiter
@@ -140,7 +140,7 @@ async def test_schedule_refresh_wont_replace_valid_result_with_invalid(
 
     # check that invalid refresh did not replace valid current metadata
     assert instance._current == old_task
-    assert isinstance(await instance._current, InstanceMetadata)
+    assert isinstance(await instance._current, ConnectionInfo)
 
 
 @pytest.mark.asyncio
@@ -202,7 +202,7 @@ async def test_force_refresh_cancels_pending_refresh(
 
     # verify pending_refresh has now been cancelled
     assert pending_refresh.cancelled() is True
-    assert isinstance(await instance._current, InstanceMetadata)
+    assert isinstance(await instance._current, ConnectionInfo)
 
 
 @pytest.mark.asyncio
@@ -230,12 +230,12 @@ async def test_perform_refresh(
     mock_instance: mocks.FakeCSQLInstance,
 ) -> None:
     """
-    Test that _perform_refresh returns valid InstanceMetadata object.
+    Test that _perform_refresh returns valid ConnectionInfo object.
     """
     instance_metadata = await instance._perform_refresh()
 
     # verify instance metadata object is returned
-    assert isinstance(instance_metadata, InstanceMetadata)
+    assert isinstance(instance_metadata, ConnectionInfo)
     # verify instance metadata expiration
     assert (
         mock_instance.cert._not_valid_after.replace(microsecond=0)  # type: ignore
@@ -248,7 +248,7 @@ async def test_perform_refresh_expiration(
     instance: Instance,
 ) -> None:
     """
-    Test that _perform_refresh returns InstanceMetadata with proper expiration.
+    Test that _perform_refresh returns ConnectionInfo with proper expiration.
 
     If credentials expiration is less than cert expiration,
     credentials expiration should be used.
@@ -262,7 +262,7 @@ async def test_perform_refresh_expiration(
         instance_metadata = await instance._perform_refresh()
 
     # verify instance metadata object is returned
-    assert isinstance(instance_metadata, InstanceMetadata)
+    assert isinstance(instance_metadata, ConnectionInfo)
     # verify instance metadata uses credentials expiration
     assert expiration == instance_metadata.expiration
 
@@ -277,7 +277,7 @@ async def test_connect_info(
     instance_metadata, ip_addr = await instance.connect_info(IPTypes.PUBLIC)
 
     # verify metadata and ip address
-    assert isinstance(instance_metadata, InstanceMetadata)
+    assert isinstance(instance_metadata, ConnectionInfo)
     assert ip_addr == "0.0.0.0"
     # cleanup instance
     await instance.close()
@@ -289,7 +289,7 @@ async def test_get_preferred_ip(instance: Instance) -> None:
     Test that get_preferred_ip returns proper IP address
     for both Public and Private IP addresses.
     """
-    instance_metadata: InstanceMetadata = await instance._current
+    instance_metadata: ConnectionInfo = await instance._current
 
     # test public IP as preferred IP for connection
     ip_addr = instance_metadata.get_preferred_ip(IPTypes.PUBLIC)
@@ -313,7 +313,7 @@ async def test_get_preferred_ip_CloudSQLIPTypeError(instance: Instance) -> None:
     Test that get_preferred_ip throws proper CloudSQLIPTypeError
     when missing Public or Private IP addresses.
     """
-    instance_metadata: InstanceMetadata = await instance._current
+    instance_metadata: ConnectionInfo = await instance._current
     instance_metadata.ip_addrs = {"PRIVATE": "1.1.1.1"}
     # test error when Public IP is missing
     with pytest.raises(CloudSQLIPTypeError):