SAML Integrator

  • By Canonical IS DevOps
Channel Revision Published Runs on
latest/stable 48 02 Apr 2024
Ubuntu 22.04
latest/edge 50 03 May 2024
Ubuntu 22.04
juju deploy saml-integrator
Show information

Platform:

Ubuntu
22.04

charms.saml_integrator.v0.smtp_integrator

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 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 import SmtpDataAvailableEvent, 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 TransportSecurity

Represent the transport security values.

Attributes

NONE
none
STARTTLS
starttls
TLS
tls

class AuthType

Represent the auth type values.

Attributes

NONE
none
NOT_PROVIDED
not_provided
PLAIN
plain

class SmtpRelationData

Represent the relation data.

Attributes

host
The hostname or IP address of the outgoing SMTP relay.
port
The port of the outgoing SMTP relay.
user
The SMTP AUTH user to use for the outgoing SMTP relay.
password
The SMTP AUTH password to use for the outgoing SMTP relay.
password_id
The secret ID where the SMTP AUTH password for the SMTP relay is stored.
auth_type
The type used to authenticate with the SMTP relay.
transport_security
The security protocol to use for the outgoing SMTP relay.
domain
The domain used by the sent emails from SMTP relay.

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

host
The hostname or IP address of the outgoing SMTP relay.
port
The port of the outgoing SMTP relay.
user
The SMTP AUTH user to use for the outgoing SMTP relay.
password
The SMTP AUTH password to use for the outgoing SMTP relay.
password_id
The secret ID where the SMTP AUTH password for the SMTP relay is stored.
auth_type
The type used to authenticate with the SMTP relay.
transport_security
The security protocol to use for the outgoing SMTP relay.
domain
The domain used by the sent emails from SMTP relay.

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

class SmtpRequiresEvents

SMTP events.

Attributes

smtp_data_available
the SmtpDataAvailableEvent.

Description

This class defines the events that a SMTP requirer can emit.

class SmtpRequires

Requirer side of the SMTP relation.

Attributes

on
events the provider can emit.

Methods

SmtpRequires. __init__( self , charm , relation_name: str )

Construct.

Arguments

charm

the provider charm.

relation_name

the relation name.

class SmtpProvides

Provider side of the SMTP relation.

Attributes

relations
list of charm relations.

Methods

SmtpProvides. __init__( self , charm , relation_name: str )

Construct.

Arguments

charm

the provider charm.

relation_name

the relation name.

SmtpProvides. relations( self )

The list of Relation instances associated with this relation_name.

Returns

List of relations to this charm.

SmtpProvides. update_relation_data( self , relation , smtp_data: SmtpRelationData )

Update the relation data.

Arguments

relation

the relation for which to update the data.

smtp_data

a SmtpRelationData instance wrapping the data to be updated.