sborl - Schema-based Operator Relation Libraries
This library provides a base for creating relation endpoint libraries for use with charmed operators and Juju. It tries to make creating Pythonic implementations of a relation interface protocol straightforward and approachable, while encouraging good patterns such as using schema-based interface protocol validation, providing helpers for testing charms using your library, and surfacing problems with relations in a clean way.
Example
An example endpoint class and usage might look like:
class RandomURLRequirer(sborl.relation.EndpointWrapper):
INTERFACE = "random-url"
ROLE = "requires"
SCHEMA = Path(__file__) / "schema.yaml"
LIMIT = 1
@property
def url(self):
if not self.is_ready():
return None
relation = self.relations[0]
return self.unwrap(relation)[relation.app]["url"]
class MyCharm(ops.charm.CharmBase):
def __init__(self, *args):
super().__init__(*args)
self.random_url = RandomURLRequirer(charm=self, endpoint="random-url-provider")
self.framework.observe(self.random_url.on.ready, self._log_url)
def _log_url(self, event):
log.info(f"Got random URL: {self.random_url.url}")
Metadata
Release files for sborl 0.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sborl-0.0.8.tar.gz | 7.9 kB | Details |
Release files / sborl-0.0.8.tar.gz
| Download URL | sborl-0.0.8.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
89ad7da15424e70cfea366664942b5431096734664a6f8ddedffd78c8932738d
|
|
BLAKE2b-256 checksum How to use checksums |
ca932fe1ef81ef0b4245895ac3a6ffc9dc3685745f02a7576a4a68f40068c957
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12
|