Skip to content

Connections

eternaltwin.connections.connections module-attribute

connections: Connections[Eternaltwin] = Connections(Eternaltwin)

Global instance holding all the synchronous connections configured with configure().

eternaltwin.connections.async_connections module-attribute

async_connections: Connections[Eternaltwin] = Connections(Eternaltwin)

Global instance holding all the asynchronous connections configured with configure().

eternaltwin.connections.Connections

Connections(client_class: Type[Client])

Bases: Generic[Client]

Holds connections to different EternalTwin API.

configure

configure(**kwargs: Any) -> None

Configure multiple clients at once.

Useful for passing in config dictionaries obtained from other sources, like Django's settings or a configuration management tool. Overwrite all existing connections.

Examples:

ETERNALTWIN_CONFIG = {
    "default": {
        'url': 'https://eternaltwin.org/api/v1/',
        'client_id': "myclient",
        'client_secret': 'mysecret',
        'state_key': HS256Key("mykey"),
        'redirect_uri': 'https://myapp.com/callback',
    },
    "test": {
        'url': 'http://localhost:50321/api/v1"',
        'client_id': "myclient",
        'client_secret': 'mysecret',
        'redirect_uri': 'https://localhost:8080/callback',
        'state_key': HS256Key("mykey"),
        'timeout': 1,
        'verify_ssl': False,
        'allow_redirects': True,
    }
}
connections.configure(**ETERNALTWIN_CONFIG)

create_connection

create_connection(alias: str, **kwargs: Any) -> Any

Create a client and register it under given alias.

get_connection

get_connection(alias: str = None) -> Client

Return the client corresponding to alias.

eternaltwin.connections.configure

configure(**kwargs: Any) -> None

Configure both the synchronous and asynchronous clients.