Skip to content

Commit

Permalink
Add read-only-uris flag
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomirp committed Feb 26, 2025
1 parent 94b0f67 commit 39034e3
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions lib/charms/data_platform_libs/v0/data_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def _on_topic_requested(self, event: TopicRequestedEvent):

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 41
LIBPATCH = 42

PYDEPS = ["ops>=2.0.0"]

Expand Down Expand Up @@ -1700,7 +1700,7 @@ def set_tls_ca(self, relation_id: int, tls_ca: str) -> None:
class RequirerData(Data):
"""Requirer-side of the relation."""

SECRET_FIELDS = ["username", "password", "tls", "tls-ca", "uris"]
SECRET_FIELDS = ["username", "password", "tls", "tls-ca", "uris", "read-only-uris"]

def __init__(
self,
Expand Down Expand Up @@ -2749,6 +2749,19 @@ def uris(self) -> Optional[str]:

return self.relation.data[self.relation.app].get("uris")

@property
def read_only_uris(self) -> Optional[str]:
"""Returns the readonly connection URIs."""
if not self.relation.app:
return None

if self.secrets_enabled:
secret = self._get_secret("user")
if secret:
return secret.get("read-only-uris")

return self.relation.data[self.relation.app].get("read-only-uris")

@property
def version(self) -> Optional[str]:
"""Returns the version of the database.
Expand Down Expand Up @@ -2855,6 +2868,15 @@ def set_uris(self, relation_id: int, uris: str) -> None:
"""
self.update_relation_data(relation_id, {"uris": uris})

def set_read_only_uris(self, relation_id: int, uris: str) -> None:
"""Set the database readonly connection URIs in the application relation databag.
Args:
relation_id: the identifier for a particular relation.
uris: connection URIs.
"""
self.update_relation_data(relation_id, {"read-only-uris": uris})

def set_version(self, relation_id: int, version: str) -> None:
"""Set the database version in the application relation databag.
Expand Down

0 comments on commit 39034e3

Please sign in to comment.