Skip to content

OnyxConfig

Class for storing information required to connect/authenticate with Onyx.

__init__(domain, token=None, username=None, password=None)

Initialise a config.

This object stores information required to connect and authenticate with Onyx.

A domain must be provided, alongside an API token and/or the username + password.

PARAMETER DESCRIPTION
domain

Domain for connecting to Onyx.

TYPE: str

token

Token for authenticating with Onyx.

TYPE: Optional[str] DEFAULT: None

username

Username for authenticating with Onyx.

TYPE: Optional[str] DEFAULT: None

password

Password for authenticating with Onyx.

TYPE: Optional[str] DEFAULT: None

Examples:

Create a config using environment variables for the domain and an API token:

import os
from onyx import OnyxConfig, OnyxEnv

config = OnyxConfig(
    domain=os.environ[OnyxEnv.DOMAIN],
    token=os.environ[OnyxEnv.TOKEN],
)

Or using environment variables for the domain and login credentials:

import os
from onyx import OnyxConfig, OnyxEnv

config = OnyxConfig(
    domain=os.environ[OnyxEnv.DOMAIN],
    username=os.environ[OnyxEnv.USERNAME],
    password=os.environ[OnyxEnv.PASSWORD],
)