gateway-api-integrator

Gateway API Integrator

Channel Revision Published Runs on
latest/stable 127 13 Jan 2026
Ubuntu 24.04 Ubuntu 22.04
latest/stable 14 01 Jul 2024
Ubuntu 24.04 Ubuntu 22.04
latest/edge 136 18 Feb 2026
Ubuntu 24.04 Ubuntu 22.04
latest/edge 14 27 Jun 2024
Ubuntu 24.04 Ubuntu 22.04
juju deploy gateway-api-integrator
Show information

Platform:

Ubuntu
24.04 22.04

charms.gateway_api_integrator.v0.gateway_route

gateway-route interface library.

Getting Started

To get started using the library, you just need to fetch the library using charmcraft.

cd some-charm
charmcraft fetch-lib charms.gateway_api_integrator.v0.gateway_route

In the metadata.yaml of the charm, add the following:

requires:
    gateway-route:
        interface: gateway-route
        limit: 1

Then, to initialise the library:

from charms.gateway_api_integrator.v0.gateway_route import GatewayRouteRequirer

class SomeCharm(CharmBase):
def __init__(self, *args):
    # ...

    # There are 2 ways you can use the requirer implementation:
    # 1. To initialize the requirer with parameters:
    self.gateway_route_requirer = GatewayRouteRequirer(self,
        relation_name=<required>,
        name=<optional>,
        model=<optional>,
        port=<optional>,
        hostname=<optional>,
        paths=<optional>,
    )

    # 2.To initialize the requirer with no parameters, i.e
    # self.gateway_route_requirer = GatewayRouteRequirer(self)
    # This will simply initialize the requirer class and it won't perform any action.

    # Afterwards regardless of how you initialized the requirer you can call the
    # provide_gateway_route_requirements method anywhere in your charm to update the requirer data.
    # The method takes the same number of parameters as the requirer class.
    # provide_gateway_route_requirements(name=, model=, ...)

    self.framework.observe(
        self.framework.on.config_changed, self._on_config_changed
    )
    self.framework.observe(
        self.gateway_route_requirer.on.ready, self._on_endpoints_ready
    )
    self.framework.observe(
        self.gateway_route_requirer.on.removed, self._on_endpoints_removed
    )

    def _on_config_changed(self, event: ConfigChangedEvent) -> None:
        self.gateway_route_requirer.provide_gateway_route_requirements(...)

    def _on_endpoints_ready(self, _: EventBase) -> None:
        # Handle endpoints ready event
        ...

    def _on_endpoints_removed(self, _: EventBase) -> None:
        # Handle endpoints removed event
        ...

class DataValidationError

Description

Raised when data validation fails. None

class GatewayRouteInvalidRelationDataError

Description

Raised when data validation of the gateway-route relation fails. None

def valid_fqdn(value: str)

Validate if value is a valid fqdn. TLDs are not allowed.

Arguments

value

The value to validate.

class RequirerApplicationData

Configuration model for Gateway route requirer application data.

Attributes

hostname
Optional: The hostname of this service.
paths
List of URL paths to route to this service. Defaults to an empty list.
model
The model the application is in.
name
Name of the app requesting gateway route.
port
The port number on which the service is listening.

class GatewayRouteProviderAppData

gateway-route provider databag schema.

Attributes

endpoints
The endpoints that maps to the backend.

class GatewayRouteRequirerData

gateway-route requirer data.

Attributes

relation_id
Id of the relation.
application_data
Application data.

class GatewayRouteDataAvailableEvent

GatewayRouteDataAvailableEvent custom event.

Description

This event indicates that the requirers data are available.

class GatewayRouteDataRemovedEvent

GatewayRouteDataRemovedEvent custom event.

Description

This event indicates that one of the endpoints was removed.

class GatewayRouteProviderEvents

List of events that the gateway-route requirer charm can leverage.

Attributes

data_available
This event indicates that the gateway-route endpoints are available.
data_removed
This event indicates that one of the endpoints was removed.

class GatewayRouteProvider

Gateway-route interface provider implementation.

Attributes

on
Custom events of the provider.
relation
Related applications.

Methods

GatewayRouteProvider. __init__( self , charm: CharmBase , relation_name: str , raise_on_validation_error: bool )

Initialize the GatewayRouteProvider.

Arguments

charm

The charm that is instantiating the library.

relation_name

The name of the relation.

raise_on_validation_error

Whether the library should raise GatewayRouteInvalidRelationDataError when requirer data validation fails. If this is set to True the provider charm needs to also catch and handle the thrown exception.

GatewayRouteProvider. relation( self )

Description

The list of Relation instances associated with this endpoint. None

GatewayRouteProvider. get_data( self , relation )

Fetch requirer data.

Arguments

relation

The relation instance to fetch data from.

Returns

GatewayRouteRequirerData

Validated data from the gateway-route requirer.

GatewayRouteProvider. publish_endpoints( self , endpoints , relation: Relation )

Publish to the app databag the proxied endpoints.

Arguments

endpoints

The list of proxied endpoints to publish.

relation

The relation with the requirer application.

class GatewayRouteEnpointsReadyEvent

Description

GatewayRouteEnpointsReadyEvent custom event. None

class GatewayRouteEndpointsRemovedEvent

Description

GatewayRouteEndpointsRemovedEvent custom event. None

class GatewayRouteRequirerEvents

List of events that the gateway-route requirer charm can leverage.

Attributes

ready
when the provider proxied endpoints are ready.
removed
when the provider removes or withdraws the proxied endpoints, or the relation with the provider is removed/broken.

class GatewayRouteRequirer

gateway-route interface requirer implementation.

Attributes

on
Custom events of the requirer.

Methods

GatewayRouteRequirer. __init__( self , charm: CharmBase , relation_name: str , name , model , port , hostname , paths )

Initialize the GatewayRouteRequirer.

Arguments

charm

The charm that is instantiating the library.

relation_name

The name of the relation to bind to.

name

The name of the service to route traffic to.

model

The model of the service to route traffic to.

port

The port the service is listening on.

hostname

Hostname of this service.

paths

List of URL paths to route to this service.

GatewayRouteRequirer. provide_gateway_route_requirements( self , name: str , model: str , port: int , hostname , paths )

Update gateway-route requirements data in the relation.

Arguments

name

The name of the service to route traffic to.

model

The model of the service to route traffic to.

port

The port the service is listening on.

hostname

Hostname of this service.

paths

List of URL paths to route to this service.

GatewayRouteRequirer. update_relation_data( self )

Description

Update the application data in the relation. None

GatewayRouteRequirer. get_routed_endpoints( self )

The full ingress URL to reach the current unit.

Returns

The provider URLs or an empty list if the URLs aren't available yet or are not valid.