---
title: Charmhub | Deploy Gateway API Integrator using Charmhub - The Open Operator
  Collection
description: Deploy the latest version of Gateway API Integrator on any cloud.
url: https://charmhub.io/gateway-api-integrator/libraries/gateway_route
---

# Gateway API Integrator

[Canonical IS DevOps](https://charmhub.io/publisher/canonical-is-devops "View all packages from Canonical IS DevOps")

* [Canonical IS DevOps](https://charmhub.io/publisher/canonical-is-devops "View all packages from Canonical IS DevOps")

Platform:

24.04

22.04

1/stable 76fa3c34

```
juju deploy gateway-api-integrator --channel 1/stable
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

[Toggle side navigation](https://charmhub.io/gateway-api-integrator/libraries/gateway_route#drawer)

## charms.gateway\_api\_integrator.v1.gateway\_route

* [*Docstrings*Docstrings](https://charmhub.io/gateway-api-integrator/libraries/gateway_route)
  [*Code*Source code](https://charmhub.io/gateway-api-integrator/libraries/gateway_route/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.gateway_api_integrator.v1.gateway_route
    ```

    [Download gateway\_route.py](https://charmhub.io/gateway-api-integrator/libraries/gateway_route/download)
  + *Last updated* 20 Jul 2026
  + *Revision* Library version 1.3

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,
        )
```

---

Index

* [class GatewayRouteInvalidRelationDataError](https://charmhub.io/gateway-api-integrator/libraries/gateway_route#gatewayrouteinvalidrelationdataerror)
* [def valid\_fqdn(
  value
  )](https://charmhub.io/gateway-api-integrator/libraries/gateway_route#valid_fqdn)
* [class HttpsMode](https://charmhub.io/gateway-api-integrator/libraries/gateway_route#httpsmode)
* [class GatewayRouteRequirerAppData](https://charmhub.io/gateway-api-integrator/libraries/gateway_route#gatewayrouterequirerappdata)
* [class GatewayRouteProviderAppData](https://charmhub.io/gateway-api-integrator/libraries/gateway_route#gatewayrouteproviderappdata)
* [class GatewayRouteProvider](https://charmhub.io/gateway-api-integrator/libraries/gateway_route#gatewayrouteprovider)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name)](https://charmhub.io/gateway-api-integrator/libraries/gateway_route#gatewayrouteprovider-__init__)
* + [def relations(
    self)](https://charmhub.io/gateway-api-integrator/libraries/gateway_route#gatewayrouteprovider-relations)
* + [def get\_requirer\_data(
    self)](https://charmhub.io/gateway-api-integrator/libraries/gateway_route#gatewayrouteprovider-get_requirer_data)
* + [def publish\_provider\_data(
    self,
    gateway\_name,
    gateway\_model,
    https\_mode,
    gateway\_address,
    hsts\_max\_age)](https://charmhub.io/gateway-api-integrator/libraries/gateway_route#gatewayrouteprovider-publish_provider_data)
* [class GatewayRouteRequirer](https://charmhub.io/gateway-api-integrator/libraries/gateway_route#gatewayrouterequirer)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name)](https://charmhub.io/gateway-api-integrator/libraries/gateway_route#gatewayrouterequirer-__init__)
* + [def relation(
    self)](https://charmhub.io/gateway-api-integrator/libraries/gateway_route#gatewayrouterequirer-relation)
* + [def publish\_requirer\_data(
    self,
    hostname,
    additional\_hostnames)](https://charmhub.io/gateway-api-integrator/libraries/gateway_route#gatewayrouterequirer-publish_requirer_data)
* + [def get\_provider\_data(
    self)](https://charmhub.io/gateway-api-integrator/libraries/gateway_route#gatewayrouterequirer-get_provider_data)

#### 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.

hsts\_max\_age

The max-age value for the Strict-Transport-Security header.
Set only when HTTPS is enforced; None otherwise.

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

,
hsts\_max\_age
)

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.

hsts\_max\_age

The max-age for the Strict-Transport-Security header. Should
only be set when HTTPS is enforced; None otherwise.

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.
