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
 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
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
    async def get_properties(self) -> dict[str,JsonType]:
        """
        Get the current properties associated with this configuration

        Returns:
            properties
        """
        pass

    @abstractmethod
    async def set_properties(self, properties:dict[str,JsonType]):
        """
        Set the current value for the configuration's property

        Args:
            properties: the properties to set

        Notes:
            properties should be a dictionary that is JSON-serialisable
        """
        pass


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

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

        Returns:
            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 associated with this package configuration.

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

    @abstractmethod
    async def get_data_keys(self) -> list[str]:
        """
        Returns the set of keys for which data is stored in this configuration

        Returns:
            list of key names
        """
        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
109
110
111
112
113
114
115
116
117
118
119
120
@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 associated with this package configuration.

Parameters:

Name Type Description Default
key str

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

required

Returns:

Type Description
Union[bytes, None]

data or None if no data is associated with the key

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

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

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

get_data_keys() abstractmethod async

Returns the set of keys for which data is stored in this configuration

Returns:

Type Description
list[str]

list of key names

Source code in hyrrokkin_engine/configuration_service_interface.py
 99
100
101
102
103
104
105
106
107
@abstractmethod
async def get_data_keys(self) -> list[str]:
    """
    Returns the set of keys for which data is stored in this configuration

    Returns:
        list of key names
    """
    pass

get_properties() abstractmethod async

Get the current properties associated with this configuration

Returns:

Type Description
dict[str, JsonType]

properties

Source code in hyrrokkin_engine/configuration_service_interface.py
51
52
53
54
55
56
57
58
59
@abstractmethod
async def get_properties(self) -> dict[str,JsonType]:
    """
    Get the current properties associated with this configuration

    Returns:
        properties
    """
    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
122
123
124
125
126
127
128
129
130
131
@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
29
30
31
32
33
34
35
36
37
38
39
@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 associated with this package configuration.

Parameters:

Name Type Description Default
key str

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

required
data Union[bytes, None]

binary data (bytes) to be stored (or None to remove previously stored data for this key)

required
Source code in hyrrokkin_engine/configuration_service_interface.py
88
89
90
91
92
93
94
95
96
97
@abstractmethod
async def set_data(self, key: str, data: typing.Union[bytes, None]):
    """
    Set binary data associated with this package configuration.

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

set_properties(properties) abstractmethod async

Set the current value for the configuration's property

Parameters:

Name Type Description Default
properties dict[str, JsonType]

the properties to set

required
Notes

properties should be a dictionary that is JSON-serialisable

Source code in hyrrokkin_engine/configuration_service_interface.py
61
62
63
64
65
66
67
68
69
70
71
72
@abstractmethod
async def set_properties(self, properties:dict[str,JsonType]):
    """
    Set the current value for the configuration's property

    Args:
        properties: the properties to set

    Notes:
        properties should be a dictionary that is 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
41
42
43
44
45
46
47
48
49
@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"
    """