Metadata-Version: 2.3
Name: invenio-pidstore-extra
Version: 0.5.1
Summary: Module that adds URN minting by DNB epicur service.
Project-URL: Homepage, https://github.com/ulbmuenster/invenio-pidstore-extra
Author-email: University of Münster <forschungsdaten@uni-muenster.de>
License: MIT
Keywords: dnb,invenio,rdm,urn
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.12
Requires-Dist: arrow>=1.3.0
Requires-Dist: flask>=3.1.0
Requires-Dist: idutils>=1.4.2
Requires-Dist: invenio-app>=3.0.0
Requires-Dist: invenio-pidstore>=2.0.0
Requires-Dist: invenio-rdm-records>=17.0.2
Requires-Dist: invenio-search>=3.0.0
Requires-Dist: isort==8.0.1
Requires-Dist: opensearch-dsl>=2.1.0
Provides-Extra: tests
Requires-Dist: check-manifest; extra == 'tests'
Requires-Dist: pytest-black-ng>=0.4.0; extra == 'tests'
Requires-Dist: pytest-cov==6.1.1; extra == 'tests'
Requires-Dist: pytest-docstyle==2.0.1; extra == 'tests'
Requires-Dist: pytest-env==1.1.5; extra == 'tests'
Requires-Dist: pytest-invenio>=3.3.0; extra == 'tests'
Requires-Dist: pytest-isort==4.0.0; extra == 'tests'
Requires-Dist: pytest-mock>=3.12.0; extra == 'tests'
Requires-Dist: pytest==8.3.5; extra == 'tests'
Requires-Dist: sphinx>=4.5.0; extra == 'tests'
Description-Content-Type: text/x-rst

..
    Copyright (C) 2024-2025 University of Münster.

    invenio-pidstore-extra is free software; you can redistribute it and/or
    modify it under the terms of the MIT License; see LICENSE file for more
    details.

=======================
 invenio-pidstore-extra
=======================

Module that adds URN minting by DNB epicur service.

InvenioRDM supports DOI minting with Datacite out of the box. This module adds support for URN minting by using the
URN API published by German National Library (DNB).

Configuration
=============

After adding the module to your InvenioRDM instance you need to add the following snippet to your `invenio.cfg`.
Make sure you have registered at the DNB and set the config variables below to the correct values!

When putting this to production, set `PIDSTORE_EXTRA_TEST_MODE = False`!

.. code-block:: python

    PIDSTORE_EXTRA_DNB_SANDBOX_URI = "http://127.0.0.1:8000/"

    PIDSTORE_EXTRA_DNB_ENABLED = True
    PIDSTORE_EXTRA_DNB_USERNAME = "username"
    PIDSTORE_EXTRA_DNB_PASSWORD = "password"
    PIDSTORE_EXTRA_DNB_ID_PREFIX = "urn:nbn:de:hbz:6"
    PIDSTORE_EXTRA_FORMAT = "{prefix}-{id}"
    PIDSTORE_EXTRA_TEST_MODE = True

    #
    # Persistent identifiers configuration
    #
    from invenio_rdm_records.config import RDM_PERSISTENT_IDENTIFIER_PROVIDERS as DEFAULT_PERSISTENT_IDENTIFIER_PROVIDERS
    from invenio_pidstore_extra import providers

    RDM_PERSISTENT_IDENTIFIER_PROVIDERS = DEFAULT_PERSISTENT_IDENTIFIER_PROVIDERS + [
        providers.DnbUrnProvider(
          "urn",
          client=providers.DNBUrnClient("dnb", PIDSTORE_EXTRA_DNB_ID_PREFIX, PIDSTORE_EXTRA_DNB_USERNAME, PIDSTORE_EXTRA_DNB_PASSWORD, PIDSTORE_EXTRA_FORMAT),
          label=_("URN"),
        ),
    ]

    from invenio_rdm_records.config import RDM_PERSISTENT_IDENTIFIERS as DEFAULT_PERSISTENT_IDENTIFIERS

    RDM_PERSISTENT_IDENTIFIERS = {
        **DEFAULT_PERSISTENT_IDENTIFIERS,
        "urn": {
          "providers": ["urn"],
          "required": True,
          "label": _("URN"),
          "is_enabled": providers.DnbUrnProvider.is_enabled,
        },
    }

    from invenio_pidstore_extra.services.components import URNRelationsComponent
    from invenio_rdm_records.services.components import DefaultRecordsComponents

    RDM_RECORDS_SERVICE_COMPONENTS = DefaultRecordsComponents + [URNRelationsComponent]

Development
===========

The flask app `invenio_pidstore_extra.dnb-sandbox.py` contains a very simple implementation of the DNB api to allow testing the URN support when the DNB sandbox is not available or just no user has been provided. You can start it with calling

.. code-block:: console

   python invenio_pidstore_extra/dnb-sandbox.py --port 8000 --namespace urn:nbn:de:hbz:6- --namespace urn:nbn:de:test:

The `--namespace` option can be repeated to accept multiple namespace prefixes.
