# Path: invenio_pidstore/models.py
# class PIDStatus(Enum):
#     """Constants for possible status of any given PID."""
# 
#     __order__ = 'NEW RESERVED REGISTERED REDIRECTED DELETED'
# 
#     NEW = 'N'
#     """PID has *not* yet been registered with the service provider."""
# 
#     RESERVED = 'K'
#     """PID reserved in the service provider but not yet fully registered."""
# 
#     REGISTERED = 'R'
#     """PID has been registered with the service provider."""
# 
#     REDIRECTED = 'M'
#     """PID has been redirected to another persistent identifier."""
# 
#     DELETED = 'D'
#     """PID has been deleted/inactivated with the service provider.
# 
#     This should happen very rarely, and must be kept track of, as the PID
#     should not be reused for something else.
#     """
# 
#     def __init__(self, value):
#         """Hack."""
# 
#     def __eq__(self, other):
#         """Equality test."""
#         return self.value == other
# 
#     def __str__(self):
#         """Return its value."""
#         return self.value
# 
#     @property
#     def title(self):
#         """Return human readable title."""
#         return PID_STATUS_TITLES[self.name]
# 
# Path: invenio_pidstore/providers/base.py
# class BaseProvider(object):
#     """Abstract class for persistent identifier provider classes."""
# 
#     pid_type = None
#     """Default persistent identifier type."""
# 
#     pid_provider = None
#     """Persistent identifier provider name."""
# 
#     default_status = PIDStatus.NEW
#     """Default status for newly created PIDs by this provider."""
# 
#     @classmethod
#     def create(cls, pid_type=None, pid_value=None, object_type=None,
#                object_uuid=None, status=None, **kwargs):
#         """Create a new instance for the given type and pid.
# 
#         :param pid_type: Persistent identifier type. (Default: None).
#         :param pid_value: Persistent identifier value. (Default: None).
#         :param status: Current PID status.
#             (Default: :attr:`invenio_pidstore.models.PIDStatus.NEW`)
#         :param object_type: The object type is a string that identify its type.
#             (Default: None).
#         :param object_uuid: The object UUID. (Default: None).
#         :returns: A :class:`invenio_pidstore.providers.base.BaseProvider`
#             instance.
#         """
#         assert pid_value
#         assert pid_type or cls.pid_type
# 
#         pid = PersistentIdentifier.create(
#             pid_type or cls.pid_type,
#             pid_value,
#             pid_provider=cls.pid_provider,
#             object_type=object_type,
#             object_uuid=object_uuid,
#             status=status or cls.default_status,
#         )
#         return cls(pid, **kwargs)
# 
#     @classmethod
#     def get(cls, pid_value, pid_type=None, **kwargs):
#         """Get a persistent identifier for this provider.
# 
#         :param pid_type: Persistent identifier type. (Default: configured
#             :attr:`invenio_pidstore.providers.base.BaseProvider.pid_type`)
#         :param pid_value: Persistent identifier value.
#         :param kwargs: See
#             :meth:`invenio_pidstore.providers.base.BaseProvider` required
#             initialization properties.
#         :returns: A :class:`invenio_pidstore.providers.base.BaseProvider`
#             instance.
#         """
#         return cls(
#             PersistentIdentifier.get(pid_type or cls.pid_type, pid_value,
#                                      pid_provider=cls.pid_provider),
#             **kwargs)
# 
#     def __init__(self, pid, **kwargs):
#         """Initialize provider using persistent identifier.
# 
#         :param pid: A :class:`invenio_pidstore.models.PersistentIdentifier`
#             instance.
#         """
#         self.pid = pid
#         assert pid.pid_provider == self.pid_provider
# 
#     def reserve(self):
#         """Reserve a persistent identifier.
# 
#         This might or might not be useful depending on the service of the
#         provider.
# 
#         See: :meth:`invenio_pidstore.models.PersistentIdentifier.reserve`.
#         """
#         return self.pid.reserve()
# 
#     def register(self):
#         """Register a persistent identifier.
# 
#         See: :meth:`invenio_pidstore.models.PersistentIdentifier.register`.
#         """
#         return self.pid.register()
# 
#     def update(self):
#         """Update information about the persistent identifier."""
#         pass
# 
#     def delete(self):
#         """Delete a persistent identifier.
# 
#         See: :meth:`invenio_pidstore.models.PersistentIdentifier.delete`.
#         """
#         return self.pid.delete()
# 
#     def sync_status(self):
#         """Synchronize PIDstatus with remote service provider."""
#         pass


import copy
from base32_lib import base32
from flask import current_app
from ..models import PIDStatus
from .base import BaseProvider
from __future__ import absolute_import




class RecordIdProviderV2(BaseProvider):
    """Record identifier provider V2.

    This is the recommended record id provider.

    It generates a random alphanumeric string as opposed to an increasing
    integer (:class:`invenio_pidstore.providers.recordid.RecordIdProvider`).
    """

    pid_type = 'recid'
    """Type of persistent identifier."""

    pid_provider = None
    """Provider name.

    The provider name is not recorded in the PID since the provider does not
    provide any additional features besides creation of record ids.
    """

    default_status_with_obj = PIDStatus.REGISTERED
    """Record IDs are by default registered immediately.

    Default: :attr:`invenio_pidstore.models.PIDStatus.REGISTERED`
    """


# Path: invenio_pidstore/models.py
# class PIDStatus(Enum):
#     """Constants for possible status of any given PID."""
# 
#     __order__ = 'NEW RESERVED REGISTERED REDIRECTED DELETED'
# 
#     NEW = 'N'
#     """PID has *not* yet been registered with the service provider."""
# 
#     RESERVED = 'K'
#     """PID reserved in the service provider but not yet fully registered."""
# 
#     REGISTERED = 'R'
#     """PID has been registered with the service provider."""
# 
#     REDIRECTED = 'M'
#     """PID has been redirected to another persistent identifier."""
# 
#     DELETED = 'D'
#     """PID has been deleted/inactivated with the service provider.
# 
#     This should happen very rarely, and must be kept track of, as the PID
#     should not be reused for something else.
#     """
# 
#     def __init__(self, value):
#         """Hack."""
# 
#     def __eq__(self, other):
#         """Equality test."""
#         return self.value == other
# 
#     def __str__(self):
#         """Return its value."""
#         return self.value
# 
#     @property
#     def title(self):
#         """Return human readable title."""
#         return PID_STATUS_TITLES[self.name]
# 
# Path: invenio_pidstore/providers/base.py
# class BaseProvider(object):
#     """Abstract class for persistent identifier provider classes."""
# 
#     pid_type = None
#     """Default persistent identifier type."""
# 
#     pid_provider = None
#     """Persistent identifier provider name."""
# 
#     default_status = PIDStatus.NEW
#     """Default status for newly created PIDs by this provider."""
# 
#     @classmethod
#     def create(cls, pid_type=None, pid_value=None, object_type=None,
#                object_uuid=None, status=None, **kwargs):
#         """Create a new instance for the given type and pid.
# 
#         :param pid_type: Persistent identifier type. (Default: None).
#         :param pid_value: Persistent identifier value. (Default: None).
#         :param status: Current PID status.
#             (Default: :attr:`invenio_pidstore.models.PIDStatus.NEW`)
#         :param object_type: The object type is a string that identify its type.
#             (Default: None).
#         :param object_uuid: The object UUID. (Default: None).
#         :returns: A :class:`invenio_pidstore.providers.base.BaseProvider`
#             instance.
#         """
#         assert pid_value
#         assert pid_type or cls.pid_type
# 
#         pid = PersistentIdentifier.create(
#             pid_type or cls.pid_type,
#             pid_value,
#             pid_provider=cls.pid_provider,
#             object_type=object_type,
#             object_uuid=object_uuid,
#             status=status or cls.default_status,
#         )
#         return cls(pid, **kwargs)
# 
#     @classmethod
#     def get(cls, pid_value, pid_type=None, **kwargs):
#         """Get a persistent identifier for this provider.
# 
#         :param pid_type: Persistent identifier type. (Default: configured
#             :attr:`invenio_pidstore.providers.base.BaseProvider.pid_type`)
#         :param pid_value: Persistent identifier value.
#         :param kwargs: See
#             :meth:`invenio_pidstore.providers.base.BaseProvider` required
#             initialization properties.
#         :returns: A :class:`invenio_pidstore.providers.base.BaseProvider`
#             instance.
#         """
#         return cls(
#             PersistentIdentifier.get(pid_type or cls.pid_type, pid_value,
#                                      pid_provider=cls.pid_provider),
#             **kwargs)
# 
#     def __init__(self, pid, **kwargs):
#         """Initialize provider using persistent identifier.
# 
#         :param pid: A :class:`invenio_pidstore.models.PersistentIdentifier`
#             instance.
#         """
#         self.pid = pid
#         assert pid.pid_provider == self.pid_provider
# 
#     def reserve(self):
#         """Reserve a persistent identifier.
# 
#         This might or might not be useful depending on the service of the
#         provider.
# 
#         See: :meth:`invenio_pidstore.models.PersistentIdentifier.reserve`.
#         """
#         return self.pid.reserve()
# 
#     def register(self):
#         """Register a persistent identifier.
# 
#         See: :meth:`invenio_pidstore.models.PersistentIdentifier.register`.
#         """
#         return self.pid.register()
# 
#     def update(self):
#         """Update information about the persistent identifier."""
#         pass
# 
#     def delete(self):
#         """Delete a persistent identifier.
# 
#         See: :meth:`invenio_pidstore.models.PersistentIdentifier.delete`.
#         """
#         return self.pid.delete()
# 
#     def sync_status(self):
#         """Synchronize PIDstatus with remote service provider."""
#         pass


# Path: invenio_pidstore/providers/recordid_v2.py
import copy
from base32_lib import base32
from flask import current_app
from ..models import PIDStatus
from .base import BaseProvider

from __future__ import absolute_import




class RecordIdProviderV2(BaseProvider):
    """Record identifier provider V2.

    This is the recommended record id provider.

    It generates a random alphanumeric string as opposed to an increasing
    integer (:class:`invenio_pidstore.providers.recordid.RecordIdProvider`).
    """

    pid_type = 'recid'
    """Type of persistent identifier."""

    pid_provider = None
    """Provider name.

    The provider name is not recorded in the PID since the provider does not
    provide any additional features besides creation of record ids.
    """

    default_status_with_obj = PIDStatus.REGISTERED
    """Record IDs are by default registered immediately.

    Default: :attr:`invenio_pidstore.models.PIDStatus.REGISTERED`
    """


    default_status = PIDStatus.RESERVED