GLAuth Utils
- Identity Charmers
Channel | Revision | Published | Runs on |
---|---|---|---|
latest/edge | 21 | 20 Oct 2024 |
juju deploy glauth-utils --channel edge
Deploy universal operators easily with Juju, the Universal Operator Lifecycle Manager.
Platform:
charms.glauth_utils.v0.glauth_auxiliary
-
- Last updated 12 Jan 2024
- Revision Library version 0.1
Juju Charm Library for the glauth_auxiliary
Juju Interface.
This juju charm library contains the Provider and Requirer classes for handling
the glauth_auxiliary
interface.
Requirer Charm
The requirer charm is expected to:
- Listen to the custom juju event
AuxiliaryReadyEvent
to consume the auxiliary data from the integration - Listen to the custom juju event
AuxiliaryUnavailableEvent
to handle the situation when the auxiliary integration is broken
from charms.glauth_utils.v0.glauth_auxiliary import (
AuxiliaryRequirer,
AuxiliaryReadyEvent,
)
class RequirerCharm(CharmBase):
# Auxiliary requirer charm that integrates with an auxiliary provider charm.
def __init__(self, *args):
super().__init__(*args)
self.auxiliary_requirer = AuxiliaryRequirer(self)
self.framework.observe(
self.auxiliary_requirer.on.auxiliary_ready,
self._on_auxiliary_ready,
)
self.framework.observe(
self.auxiliary_requirer.on.auxiliary_unavailable,
self._on_auxiliary_unavailable,
)
def _on_auxiliary_ready(self, event: AuxiliaryReadyEvent) -> None:
# Consume the auxiliary data
auxiliary_data = self.auxiliary_requirer.consume_auxiliary_relation_data(
event.relation.id,
)
def _on_auxiliary_unavailable(self, event: AuxiliaryUnavailableEvent) -> None:
# Handle the situation where the auxiliary integration is broken
...
As shown above, the library offers custom juju event to handle the specific situation, which are listed below:
- auxiliary_ready: event emitted when the auxiliary data is ready for requirer charm to use.
- auxiliary_unavailable: event emitted when the auxiliary integration is broken.
Additionally, the requirer charmed operator needs to declare the auxiliary
interface in the metadata.yaml
:
requires:
glauth-auxiliary:
interface: glauth_auxiliary
limit: 1
Provider Charm
The provider charm is expected to:
- Listen to the custom juju event
AuxiliaryRequestedEvent
to provide the auxiliary data in the integration
from charms.glauth_utils.v0.glauth_auxiliary import (
AuxiliaryProvider,
AuxiliaryRequestedEvent,
)
class ProviderCharm(CharmBase):
# Auxiliary provider charm.
def __init__(self, *args):
super().__init__(*args)
self.auxiliary_provider = AuxiliaryProvider(self)
self.framework.observe(
self.auxiliary_provider.on.auxiliary_requested,
self._on_auxiliary_requested,
)
def _on_auxiliary_requested(self, event: AuxiliaryRequestedEvent) -> None:
# Prepare the auxiliary data
auxiliary_data = ...
# Update the integration data
self.auxiliary_provider.update_relation_app_data(
relation.id,
auxiliary_data,
)
As shown above, the library offers custom juju event to handle the specific situation, which are listed below:
- auxiliary_requested: event emitted when the requirer charm integrates with the provider charm
Index
def leader_unit(func: Callable)
Methods
leader_unit. wrapper( obj )
class AuxiliaryData
class AuxiliaryRequestedEvent
Description
An event emitted when the auxiliary integration is built. None
class AuxiliaryReadyEvent
Description
An event emitted when the auxiliary data is ready. None
class AuxiliaryUnavailableEvent
Description
An event emitted when the auxiliary integration is unavailable. None
class AuxiliaryProviderEvents
class AuxiliaryRequirerEvents
class AuxiliaryProvider
Methods
AuxiliaryProvider. __init__( self , charm: CharmBase , relation_name: str )
AuxiliaryProvider. update_relation_app_data( data: AuxiliaryData , relation_id )
Description
An API for the provider charm to provide the auxiliary data. None
class AuxiliaryRequirer
Methods
AuxiliaryRequirer. __init__( self , charm: CharmBase , relation_name: str )
AuxiliaryRequirer. consume_auxiliary_relation_data( relation_id )
Description
An API for the requirer charm to consume the auxiliary data. None