from invenio_records_resources.services import RecordServiceConfig as InvenioRecordServiceConfig
from invenio_records_resources.services import RecordLink, pagination_links

{% for b in python.record_service_config_bases %}
from {{ b|package_name }} import {{ b|base_name }}
{% endfor %}
{% for b in python.record_service_config_components %}
from {{ b|package_name }} import {{ b|base_name }}
{% endfor %}
from {{ python.record_class|package_name }} import {{ python.record_class|base_name }}
from {{ python.record_permissions_class|package_name }} import {{ python.record_permissions_class|base_name }}
from {{ python.record_schema_class|package_name }} import {{ python.record_schema_class|base_name }}
from {{ python.record_search_options_class|package_name }} import {{ python.record_search_options_class|base_name }}


class {{ python.record_service_config_class|base_name }}({% for b in python.record_service_config_bases %}{{ b|base_name }}, {% endfor %}InvenioRecordServiceConfig):
    """{{ python.record_class|base_name }} service config."""

    permission_policy_cls = {{ python.record_permissions_class|base_name }}
    schema = {{ python.record_schema_class|base_name }}
    search = {{ python.record_search_options_class|base_name }}
    record_cls = {{ python.record_class|base_name }}

    {% if python.record_service_config_bases %}
    components = [ *{% for b in python.record_service_config_bases[:1] %}{{ b|base_name }}.components{% endfor %}{% for c in python.record_service_config_components %}, {{ c|base_name }} {% endfor %}]
    {% else %}
    components = [ *InvenioRecordServiceConfig.components{% for c in python.record_service_config_components %}, {{ c|base_name }} {% endfor %}  ]
    {% endif %}

    model = "{{ settings.model_name }}"

    {% if python.record_service_config_generate_links %}
    @property
    def links_item(self):
        return {
            "self": RecordLink("{{ settings.collection_url }}{id}"),
        }

    links_search = pagination_links("{{ settings.collection_url }}{?args*}")
    {% endif %}

{{ settings.python.invenio_record_service_config_extra_code }}