Skip to content

Configuration service api

Configuration Services API

When a hyrrokkin package configuration instance is created, the constructor is passed a configuration services instance which implements the following methods

ConfigurationServiceInterface

Source code in hyrrokkin_engine/configuration_service_interface.py
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
class ConfigurationServiceInterface:

    @abstractmethod
    def resolve_resource(self, resource_path:str) -> str:
        """
        Resolve a relative resource path based on the location of the package schema

        Args:
            resource_path: the file path to resolve

        Returns:
            resolved path as a string containing a URL
        """

    @abstractmethod
    def set_status(self, status_message: str = "", level: typing.Literal["info", "warning", "error"] = "info"):
        """
        Set an info status message for the packahe configuration.

        Args:
            status_message: a short descriptive message or empty string (to clear the status)
            level: whether the message is "info", "warning" or "error"
        """

    @abstractmethod
    def get_property(self, property_name:str, default_value=None):
        """
        Get the current value for configuration's property

        :param property_name: the name of the property
        :param default_value: a default value to return if the named property is not defined on the configuration
        :return: property value
        """
        pass

    @abstractmethod
    def set_property(self, property_name:str, property_value):
        """
        Set the current value for the configuration's property

        :param property_name: the name of the property
        :param property_value: the property value

        :notes: property values MUST be JSON-serialisable
        """
        pass

    @abstractmethod
    async def get_data(self, key: str) -> typing.Union[bytes, None]:
        """
        Get binary data (bytes) associated with this package configuration.

        :param key: a key to locate the data (can only contain alphanumeric characters and underscores)

        :return: data or None if no data is associated with the key
        """
        pass

    @abstractmethod
    async def set_data(self, key: str, data: typing.Union[bytes, None]):
        """
        Set binary data (bytes) associated with this package configuration.

        :param key: a key to locate the data (can only contain alphanumeric characters and underscores)
        :param data: binary data (bytes) to be stored (or None to remove previously stored data for this key)
        """
        pass

    @abstractmethod
    def get_configuration(self, package_id:str) -> typing.Union[None,"hyrrokkin_engine.ConfigurationInterface"]:
        """
        Obtain a configuration object if defined for the specified package.

        Args:
            package_id: the id of the package configuration to obtain

        Returns:
            a configuration object or None
        """
        pass

    @abstractmethod
    def request_open_client(self, client_name: str, session_id: str):
        """
        Called to request that a client of this configuration be opened

        Args:
            client_name: the type of client to load
            session_id: specify which session to send the request to (defaults to all sessions)
        """
        pass

get_configuration(package_id) abstractmethod

Obtain a configuration object if defined for the specified package.

Parameters:

Name Type Description Default
package_id str

the id of the package configuration to obtain

required

Returns:

Type Description
Union[None, ConfigurationInterface]

a configuration object or None

Source code in hyrrokkin_engine/configuration_service_interface.py
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
@abstractmethod
def get_configuration(self, package_id:str) -> typing.Union[None,"hyrrokkin_engine.ConfigurationInterface"]:
    """
    Obtain a configuration object if defined for the specified package.

    Args:
        package_id: the id of the package configuration to obtain

    Returns:
        a configuration object or None
    """
    pass

get_data(key) abstractmethod async

Get binary data (bytes) associated with this package configuration.

:param key: a key to locate the data (can only contain alphanumeric characters and underscores)

:return: data or None if no data is associated with the key

Source code in hyrrokkin_engine/configuration_service_interface.py
71
72
73
74
75
76
77
78
79
80
@abstractmethod
async def get_data(self, key: str) -> typing.Union[bytes, None]:
    """
    Get binary data (bytes) associated with this package configuration.

    :param key: a key to locate the data (can only contain alphanumeric characters and underscores)

    :return: data or None if no data is associated with the key
    """
    pass

get_property(property_name, default_value=None) abstractmethod

Get the current value for configuration's property

:param property_name: the name of the property :param default_value: a default value to return if the named property is not defined on the configuration :return: property value

Source code in hyrrokkin_engine/configuration_service_interface.py
48
49
50
51
52
53
54
55
56
57
@abstractmethod
def get_property(self, property_name:str, default_value=None):
    """
    Get the current value for configuration's property

    :param property_name: the name of the property
    :param default_value: a default value to return if the named property is not defined on the configuration
    :return: property value
    """
    pass

request_open_client(client_name, session_id) abstractmethod

Called to request that a client of this configuration be opened

Parameters:

Name Type Description Default
client_name str

the type of client to load

required
session_id str

specify which session to send the request to (defaults to all sessions)

required
Source code in hyrrokkin_engine/configuration_service_interface.py
105
106
107
108
109
110
111
112
113
114
@abstractmethod
def request_open_client(self, client_name: str, session_id: str):
    """
    Called to request that a client of this configuration be opened

    Args:
        client_name: the type of client to load
        session_id: specify which session to send the request to (defaults to all sessions)
    """
    pass

resolve_resource(resource_path) abstractmethod

Resolve a relative resource path based on the location of the package schema

Parameters:

Name Type Description Default
resource_path str

the file path to resolve

required

Returns:

Type Description
str

resolved path as a string containing a URL

Source code in hyrrokkin_engine/configuration_service_interface.py
26
27
28
29
30
31
32
33
34
35
36
@abstractmethod
def resolve_resource(self, resource_path:str) -> str:
    """
    Resolve a relative resource path based on the location of the package schema

    Args:
        resource_path: the file path to resolve

    Returns:
        resolved path as a string containing a URL
    """

set_data(key, data) abstractmethod async

Set binary data (bytes) associated with this package configuration.

:param key: a key to locate the data (can only contain alphanumeric characters and underscores) :param data: binary data (bytes) to be stored (or None to remove previously stored data for this key)

Source code in hyrrokkin_engine/configuration_service_interface.py
82
83
84
85
86
87
88
89
90
@abstractmethod
async def set_data(self, key: str, data: typing.Union[bytes, None]):
    """
    Set binary data (bytes) associated with this package configuration.

    :param key: a key to locate the data (can only contain alphanumeric characters and underscores)
    :param data: binary data (bytes) to be stored (or None to remove previously stored data for this key)
    """
    pass

set_property(property_name, property_value) abstractmethod

Set the current value for the configuration's property

:param property_name: the name of the property :param property_value: the property value

:notes: property values MUST be JSON-serialisable

Source code in hyrrokkin_engine/configuration_service_interface.py
59
60
61
62
63
64
65
66
67
68
69
@abstractmethod
def set_property(self, property_name:str, property_value):
    """
    Set the current value for the configuration's property

    :param property_name: the name of the property
    :param property_value: the property value

    :notes: property values MUST be JSON-serialisable
    """
    pass

set_status(status_message='', level='info') abstractmethod

Set an info status message for the packahe configuration.

Parameters:

Name Type Description Default
status_message str

a short descriptive message or empty string (to clear the status)

''
level Literal['info', 'warning', 'error']

whether the message is "info", "warning" or "error"

'info'
Source code in hyrrokkin_engine/configuration_service_interface.py
38
39
40
41
42
43
44
45
46
@abstractmethod
def set_status(self, status_message: str = "", level: typing.Literal["info", "warning", "error"] = "info"):
    """
    Set an info status message for the packahe configuration.

    Args:
        status_message: a short descriptive message or empty string (to clear the status)
        level: whether the message is "info", "warning" or "error"
    """