Gateway API Integrator

Platform:

Ubuntu
24.04 22.04
Channel Revision Published Runs on
latest/stable 151 08 Apr 2026
Ubuntu 24.04 Ubuntu 22.04
latest/stable 14 01 Jul 2024
Ubuntu 24.04 Ubuntu 22.04
latest/edge 158 16 Jun 2026
Ubuntu 24.04 Ubuntu 22.04
latest/edge 14 27 Jun 2024
Ubuntu 24.04 Ubuntu 22.04
1/edge 161 Yesterday
Ubuntu 24.04
juju deploy gateway-api-integrator

charms.gateway_api_integrator.v1.gateway_route

gateway-route interface library v1.

This library implements the gateway-route interface.

The requirer publishes hostname information. The provider publishes gateway resource details (gateway name, model/namespace, HTTPS mode) so the requirer can reference the correct Gateway resource.

With the v1 interface, the requirer is expected to create and manage its own HTTP/TCP/UDP route resources referencing the provider's Gateway.

Getting Started

Fetch the library:

charmcraft fetch-lib charms.gateway_api_integrator.v1.gateway_route
Requirer usage

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

requires:
    gateway-route:
        interface: gateway-route
from charms.gateway_api_integrator.v1.gateway_route import (
    GATEWAY_ROUTE_RELATION_NAME,
    GatewayRouteRequirer,
    GatewayRouteProviderAppData,
)

class IngressConfiguratorCharm(CharmBase):
    def __init__(self, *args):
        super().__init__(*args)
        self.gateway_route = GatewayRouteRequirer(self)
        self.framework.observe(
            self.on[GATEWAY_ROUTE_RELATION_NAME].relation_changed, self._on_gateway_route_changed
        )
        self.framework.observe(
            self.on[GATEWAY_ROUTE_RELATION_NAME].relation_broken, self._on_gateway_route_changed
        )

    def _on_gateway_route_changed(self, event):
        provider_data = self.gateway_route.get_provider_data()
        if provider_data:
            # Use provider_data.gateway_name, provider_data.gateway_model, provider_data.https_mode
            ...
Provider usage

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

provides:
    gateway-route:
        interface: gateway-route
from charms.gateway_api_integrator.v1.gateway_route import (
    GATEWAY_ROUTE_RELATION_NAME,
    GatewayRouteProvider,
    HttpsMode,
    GatewayRouteRequirerAppData,
)

class GatewayAPIIntegratorCharm(CharmBase):
    def __init__(self, *args):
        super().__init__(*args)
        self.gateway_route = GatewayRouteProvider(self)
        self.framework.observe(
            self.on[GATEWAY_ROUTE_RELATION_NAME].relation_changed, self._on_gateway_route_changed
        )
        self.framework.observe(
            self.on[GATEWAY_ROUTE_RELATION_NAME].relation_broken, self._on_gateway_route_changed
        )

    def _on_gateway_route_changed(self, event):
        requirer_data = self.gateway_route.get_requirer_data()
        # requirer_data is a dict[int, GatewayRouteRequirerAppData]
        # Use data.hostname, data.additional_hostnames
        # Publish provider data to all valid relations
        self.gateway_route.publish_provider_data(
            gateway_name=self.app.name,
            gateway_model=self.model.name,
            https_mode=HttpsMode.ENFORCED,
        )

class GatewayRouteInvalidRelationDataError

Description

Raised when relation data validation for gateway-route fails. None

def valid_fqdn(value: str)

Validate if value is a valid FQDN (TLDs alone are not allowed).

Arguments

value

The value to validate.

class HttpsMode

HTTPS mode for the gateway.

Description

Attrs: DISABLED: TLS is not configured; only HTTP listener exists. ENABLED: TLS is configured; both HTTP and HTTPS listeners exist. ENFORCED: TLS is configured and enforce-https is true; HTTP redirects to HTTPS.

class GatewayRouteRequirerAppData

Requirer application databag schema.

Attributes

hostname
The hostname for the service.
additional_hostnames
Additional hostnames for the service.

Description

The requirer provides hostname information so the provider can configure TLS certificates and DNS records.

class GatewayRouteProviderAppData

Provider application databag schema.

Attributes

gateway_name
The name of the Gateway resource managed by the provider.
gateway_model
The Juju model (K8s namespace) where the Gateway resource lives.
https_mode
The HTTPS mode indicating how the provider handles TLS.
gateway_address
The gateway LB address. Provided so requirers without a configured hostname can reference the gateway by IP.

Description

The provider publishes gateway resource details so the requirer can construct HTTPRoute resources referencing the correct Gateway.

class GatewayRouteProvider

Gateway-route interface provider implementation.

Description

The provider reads hostname data from requirers and publishes gateway resource information back.

Methods

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

Initialize the GatewayRouteProvider.

Arguments

charm

The charm instance using this library.

relation_name

The name of the relation endpoint.

GatewayRouteProvider. relations( self )

Description

All relations for this endpoint. None

GatewayRouteProvider. get_requirer_data( self )

Fetch requirer data from all relations.

Returns

Dictionary mapping relation ID to validated requirer data.

Description

Also stores the valid relations for use by publish_provider_data.

GatewayRouteProvider. publish_provider_data( self , gateway_name: str , gateway_model: str , https_mode: HttpsMode , gateway_address )

Publish gateway information to requirers with valid data.

Arguments

gateway_name

The name of the Gateway resource.

gateway_model

The Juju model (K8s namespace) of the Gateway resource.

https_mode

The HTTPS mode for the gateway.

gateway_address

The gateway LB address, used when no hostname is configured.

Description

Only publishes to relations previously validated by get_requirer_data.

class GatewayRouteRequirer

Gateway-route interface requirer implementation.

Description

The requirer provides hostname information and reads back gateway resource details from the provider.

Methods

GatewayRouteRequirer. __init__( self , charm: CharmBase , relation_name: str )

Initialize the GatewayRouteRequirer.

Arguments

charm

The charm instance using this library.

relation_name

The name of the relation endpoint.

GatewayRouteRequirer. relation( self )

Description

The relation instance for this endpoint. None

GatewayRouteRequirer. publish_requirer_data( self , hostname: str , additional_hostnames )

Publish hostname data to the provider.

Arguments

hostname

The hostname for the service.

additional_hostnames

Additional hostnames for the service.

GatewayRouteRequirer. get_provider_data( self )

Fetch provider application data from the relation.

Returns

Validated provider data or None if not yet available.