Synapse
- Canonical IS DevOps
Channel | Revision | Published | Runs on |
---|---|---|---|
latest/stable | 426 | 20 Sep 2024 | |
latest/edge | 481 | 19 Nov 2024 | |
1/stable | 303 | 30 Jul 2024 | |
1/edge | 345 | 31 Jul 2024 |
juju deploy synapse
Deploy Kubernetes operators easily with Juju, the Universal Operator Lifecycle Manager. Need a Kubernetes cluster? Install MicroK8s to create a full CNCF-certified Kubernetes system in under 60 seconds.
Platform:
charms.synapse.v0.matrix_auth
-
- Last updated 07 Oct 2024
- Revision Library version 0.3
Library to manage the plugin integrations with the Synapse charm.
This library contains the Requires and Provides classes for handling the integration
between an application and a charm providing the matrix_plugin
integration.
Requirer Charm
from charms.synapse.v0.matrix_auth import MatrixAuthRequires
class MatrixAuthRequirerCharm(ops.CharmBase):
def __init__(self, *args):
super().__init__(*args)
self.plugin_auth = MatrixAuthRequires(self)
self.framework.observe(self.matrix_auth.on.matrix_auth_request_processed, self._handler)
...
def _handler(self, events: MatrixAuthRequestProcessed) -> None:
...
As shown above, the library provides a custom event to handle the scenario in which a matrix authentication (homeserver and shared secret) has been added or updated.
The MatrixAuthRequires provides an update_relation_data
method to update the relation data by
passing a MatrixAuthRequirerData
data object, requesting a new authentication.
Provider Charm
Following the previous example, this is an example of the provider charm.
from charms.synapse.v0.matrix_auth import MatrixAuthProvides
class MatrixAuthProviderCharm(ops.CharmBase):
def __init__(self, *args):
super().__init__(*args)
self.plugin_auth = MatrixAuthProvides(self)
...
The MatrixAuthProvides object wraps the list of relations into a relations
property
and provides an update_relation_data
method to update the relation data by passing
a MatrixAuthRelationData
data object.
class MatrixAuthProviderCharm(ops.CharmBase):
...
def _on_config_changed(self, _) -> None:
for relation in self.model.relations[self.plugin_auth.relation_name]:
self.plugin_auth.update_relation_data(relation, self._get_matrix_auth_data())
Index
class MatrixAuthProviderData
Represent the MatrixAuth provider data.
Attributes
Methods
Store the Matrix shared secret as a Juju secret.
Arguments
the Juju model
relation to grant access to the secrets to.
Retrieve the shared secret corresponding to the shared_secret_id.
Arguments
the Juju model.
the secret ID for the shared secret.
Returns
the shared secret or None if not found.
MatrixAuthProviderData. to_relation_data( self , model , relation )
Convert an instance of MatrixAuthProviderData to the relation representation.
Arguments
the Juju model.
relation to grant access to the secrets to.
Returns
Dict containing the representation.
MatrixAuthProviderData. from_relation( cls , model , relation )
Initialize a new instance of the MatrixAuthProviderData class from the relation.
Arguments
the relation.
Returns
A MatrixAuthProviderData instance.
class MatrixAuthRequirerData
Represent the MatrixAuth requirer data.
Attributes
Methods
MatrixAuthRequirerData. set_registration_id( self , model , relation )
Store the app registration as a Juju secret.
Arguments
the Juju model
relation to grant access to the secrets to.
MatrixAuthRequirerData. get_registration( cls , model , registration_secret_id )
Retrieve the registration corresponding to the registration_secret_id.
Arguments
the Juju model.
the secret ID for the registration.
Returns
the registration or None if not found.
MatrixAuthRequirerData. to_relation_data( self , model , relation )
Convert an instance of MatrixAuthRequirerData to the relation representation.
Arguments
the Juju model.
relation to grant access to the secrets to.
Returns
Dict containing the representation.
MatrixAuthRequirerData. from_relation( cls , model , relation )
Get a MatrixAuthRequirerData from the relation data.
Arguments
the Juju model.
the relation.
Returns
the relation data and the processed entries for it.
class MatrixAuthRequestProcessed
Description
MatrixAuth event emitted when a new request is processed. None
Methods
MatrixAuthRequestProcessed. get_matrix_auth_provider_relation_data( self )
Get a MatrixAuthProviderData for the relation data.
Returns
the MatrixAuthProviderData for the relation data.
class MatrixAuthRequestReceived
Description
MatrixAuth event emitted when a new request is made. None
class MatrixAuthRequiresEvents
MatrixAuth requirer events.
Attributes
Description
This class defines the events that a MatrixAuth requirer can emit.
class MatrixAuthProvidesEvents
MatrixAuth provider events.
Attributes
Description
This class defines the events that a MatrixAuth provider can emit.
class MatrixAuthProvides
Provider side of the MatrixAuth relation.
Attributes
Methods
MatrixAuthProvides. __init__( self , charm , relation_name: str )
Construct.
Arguments
the provider charm.
the relation name.
MatrixAuthProvides. get_remote_relation_data( self )
Retrieve the remote relation data.
Returns
the relation data.
MatrixAuthProvides. update_relation_data( self , relation , matrix_auth_provider_data: MatrixAuthProviderData )
Update the relation data.
Arguments
the relation for which to update the data.
a MatrixAuthProviderData instance wrapping the data to be updated.
class MatrixAuthRequires
Requirer side of the MatrixAuth requires relation.
Attributes
Methods
MatrixAuthRequires. __init__( self , charm , relation_name: str )
Construct.
Arguments
the provider charm.
the relation name.
MatrixAuthRequires. get_remote_relation_data( self )
Retrieve the remote relation data.
Returns
the relation data.
MatrixAuthRequires. update_relation_data( self , relation , matrix_auth_requirer_data: MatrixAuthRequirerData )
Update the relation data.
Arguments
the relation for which to update the data.
MatrixAuthRequirerData wrapping the data to be updated.