SMTP Integrator
- Canonical IS DevOps
Channel | Revision | Published | Runs on |
---|---|---|---|
latest/stable | 45 | 19 Aug 2024 | |
latest/edge | 52 | 07 Oct 2024 |
juju deploy smtp-integrator
Deploy universal operators easily with Juju, the Universal Operator Lifecycle Manager.
Platform:
charms.smtp_integrator.v0.smtp
-
- Last updated 25 Sep 2024
- Revision Library version 0.12
Library to manage the integration with the SMTP Integrator charm.
This library contains the Requires and Provides classes for handling the integration
between an application and a charm providing the smtp
and smtp-legacy
integrations.
If the requirer charm supports secrets, the preferred approach is to use the smtp
relation to leverage them.
This library also contains a SmtpRelationData
class to wrap the SMTP data that will
be shared via the integration.
Requirer Charm
from charms.smtp_integrator.v0.smtp import SmtpDataAvailableEvent, SmtpRequires
class SmtpRequirerCharm(ops.CharmBase):
def __init__(self, *args):
super().__init__(*args)
self.smtp = smtp.SmtpRequires(self)
self.framework.observe(self.smtp.on.smtp_data_available, self._handler)
...
def _handler(self, events: SmtpDataAvailableEvent) -> None:
...
As shown above, the library provides a custom event to handle the scenario in which new SMTP data has been added or updated.
Provider Charm
Following the previous example, this is an example of the provider charm.
from charms.smtp_integrator.v0.smtp import SmtpProvides
class SmtpProviderCharm(ops.CharmBase):
def __init__(self, *args):
super().__init__(*args)
self.smtp = SmtpProvides(self)
...
The SmtpProvides 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 SmtpRelationData
data object.
class SmtpProviderCharm(ops.CharmBase):
...
def _on_config_changed(self, _) -> None:
for relation in self.model.relations[self.smtp.relation_name]:
self.smtp.update_relation_data(relation, self._get_smtp_data())
Index
class TransportSecurity
Represent the transport security values.
Attributes
class AuthType
Represent the auth type values.
Attributes
class SmtpRelationData
Represent the relation data.
Attributes
Methods
SmtpRelationData. to_relation_data( self )
Convert an instance of SmtpRelationData to the relation representation.
Returns
Dict containing the representation.
class SmtpDataAvailableEvent
Smtp event emitted when relation data has changed.
Attributes
Methods
SmtpDataAvailableEvent. host( self )
Description
Fetch the SMTP host from the relation. None
SmtpDataAvailableEvent. port( self )
Description
Fetch the SMTP port from the relation. None
SmtpDataAvailableEvent. user( self )
Description
Fetch the SMTP user from the relation. None
SmtpDataAvailableEvent. password( self )
Description
Fetch the SMTP password from the relation. None
SmtpDataAvailableEvent. password_id( self )
Description
Fetch the SMTP password from the relation. None
SmtpDataAvailableEvent. auth_type( self )
Description
Fetch the SMTP auth type from the relation. None
SmtpDataAvailableEvent. transport_security( self )
Description
Fetch the SMTP transport security protocol from the relation. None
SmtpDataAvailableEvent. domain( self )
Description
Fetch the SMTP domain from the relation. None
SmtpDataAvailableEvent. skip_ssl_verify( self )
Description
Fetch the skip_ssl_verify flag from the relation. None
class SmtpRequiresEvents
SMTP events.
Attributes
Description
This class defines the events that a SMTP requirer can emit.
class SmtpRequires
Requirer side of the SMTP relation.
Attributes
Methods
SmtpRequires. __init__( self , charm , relation_name: str )
Construct.
Arguments
the provider charm.
the relation name.
SmtpRequires. get_relation_data( self )
Retrieve the relation data.
Returns
the relation data.
class SmtpProvides
Description
Provider side of the SMTP relation. None
Methods
SmtpProvides. __init__( self , charm , relation_name: str )
Construct.
Arguments
the provider charm.
the relation name.
SmtpProvides. update_relation_data( self , relation , smtp_data: SmtpRelationData )
Update the relation data.
Arguments
the relation for which to update the data.
a SmtpRelationData instance wrapping the data to be updated.