from typing import List


class LabelProvider:
    """
    label provider interface that should be implemented by label provider developers
    """

    def __init__(self, root_folder, configuration):
        """
        prepare everything needed to provide labels

        :param root_folder: relative path to label folder
        :param configuration: object parsed from configuration.json
        """
        raise NotImplementedError

    def close(self):
        """
        is called everytime a label provider is not used anymore

        :return:
        """
        raise NotImplementedError

    def get_labels(self) -> List[dict]:
        """
        return all available labels

        :return:
        """
        raise NotImplementedError

    @staticmethod
    def create_label(reference: str, name: str,
                     parent_reference: str = None, hierarchy_level: str = None):
        """
        create a label result

        :param reference: label reference string
        :param name: label name
        :param parent_reference: parent's reference string
        :param hierarchy_level: hierarchy level name
        :return:
        """
        return {
            'reference': reference,
            'name': name,
            'parent': parent_reference,
            'hierarchy_level': hierarchy_level
        }
