configuration
drunc.utils.configuration
Configuration utilities for DRUNC.
Classes
ConfHandler(data=None, type=ConfTypes.PyObject, oks_key=None, *args, **kwargs)
Handler for loading and parsing DRUNC configurations.
Supports multiple configuration types including JSON files, Protobuf messages, and OKS.
Initialize a ConfHandler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
object
|
The configuration data. Defaults to None. |
None
|
type
|
ConfTypes
|
The configuration type. Defaults to PyObject. |
PyObject
|
oks_key
|
OKSKey | None
|
OKS key if using OKS configuration. Defaults to None. |
None
|
*args
|
object
|
Additional positional arguments. |
()
|
**kwargs
|
object
|
Additional keyword arguments. |
{}
|
Raises:
| Type | Description |
|---|---|
DruncSetupException
|
If OKS type is used without an OKS key. |
Source code in drunc/utils/configuration.py
Methods:
copy_oks_key()
Get a copy of the OKS key if one exists.
Returns:
| Type | Description |
|---|---|
OKSKey | None
|
OKSKey | None: The OKS key, or None if not using OKS configuration. |
get_data()
get_data_authoriser()
Get the authoriser from the configuration data.
Returns:
| Name | Type | Description |
|---|---|---|
Any |
object
|
The authoriser object. |
get_data_type_name()
Get the type name of the configuration data.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The name of the data type. |
validate_and_parse_configuration_location(*args, **kwargs)
Validate and parse the configuration from the provided location.
Supports JsonFileName, OKSFileName, and PyObject types.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
object
|
Additional positional arguments. |
()
|
**kwargs
|
object
|
Additional keyword arguments. |
{}
|
Source code in drunc/utils/configuration.py
ConfTypeNotSupported(conf_type, class_name)
Bases: DruncSetupException
Exception raised when a configuration type is not supported.
Initialize the ConfTypeNotSupported exception.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conf_type
|
ConfTypes
|
The configuration type that is not supported. |
required |
class_name
|
str
|
The name of the class where this type is not supported. |
required |
Source code in drunc/utils/configuration.py
Methods:
ConfTypes
Bases: Enum
Enumeration of supported configuration types.
ConfigurationNotFound(requested_path)
Bases: DruncSetupException
Exception raised when configuration is not found.
Initialize the ConfigurationNotFound exception.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
requested_path
|
str
|
The path to the configuration that was not found. |
required |
Source code in drunc/utils/configuration.py
Methods:
OKSKey(schema_file, class_name, obj_uid, session)
Key information for accessing OKS configuration objects.
Initialize an OKSKey.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schema_file
|
str
|
The OKS schema file path. |
required |
class_name
|
str
|
The class name in the OKS schema. |
required |
obj_uid
|
str
|
The unique identifier for the object. |
required |
session
|
str
|
The session name. |
required |
Source code in drunc/utils/configuration.py
Methods:
Functions:
CLI_to_ConfTypes(scheme)
Convert a CLI scheme string to a ConfTypes enum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scheme
|
str
|
The scheme string ("file", "oksconflibs", or ""). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ConfTypes |
ConfTypes
|
The corresponding configuration type. |
Raises:
| Type | Description |
|---|---|
DruncSetupException
|
If the scheme is not recognized. |
Source code in drunc/utils/configuration.py
parse_conf_url(url)
Parse a configuration URL into scheme and type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The configuration URL (format: "scheme:filename"). |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, ConfTypes]
|
tuple[str, ConfTypes]: A tuple of (url, conf_type). |