# Path: invenio_pidstore/models.py
# PID_STATUS_TITLES = {
#     'NEW': _('New'),
#     'RESERVED': _('Reserved'),
#     'REGISTERED': _('Registered'),
#     'REDIRECTED': _('Redirected'),
#     'DELETED': _('Deleted'),
# }
#     NEW = 'N'
#     RESERVED = 'K'
#     REGISTERED = 'R'
#     REDIRECTED = 'M'
#     DELETED = 'D'
# class PIDStatus(Enum):
# class PersistentIdentifier(db.Model, Timestamp):
# class Redirect(db.Model, Timestamp):
# class RecordIdentifier(db.Model):
#     def __init__(self, value):
#     def __eq__(self, other):
#     def __str__(self):
#     def title(self):
#     def create(cls, pid_type, pid_value, pid_provider=None,
#                status=PIDStatus.NEW, object_type=None, object_uuid=None,):
#     def get(cls, pid_type, pid_value, pid_provider=None):
#     def get_by_object(cls, pid_type, object_type, object_uuid):
#     def has_object(self):
#     def get_assigned_object(self, object_type=None):
#     def assign(self, object_type, object_uuid, overwrite=False):
#     def unassign(self):
#     def get_redirect(self):
#     def redirect(self, pid):
#     def reserve(self):
#     def register(self):
#     def delete(self):
#     def sync_status(self, status):
#     def is_redirected(self):
#     def is_registered(self):
#     def is_deleted(self):
#     def is_new(self):
#     def is_reserved(self):
#     def __repr__(self):
#     def next(cls):
#     def max(cls):
#     def _set_sequence(cls, val):
#     def insert(cls, val):
# 
# 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


from datacite import DataCiteMDSClient
from datacite.errors import DataCiteError, DataCiteGoneError, \
    DataCiteNoContentError, DataCiteNotFoundError, HttpError
from flask import current_app
from ..models import PIDStatus, logger
from .base import BaseProvider
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2015-2019 CERN.
# Copyright (C) 2019 Northwestern University.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""DataCite PID provider."""

from __future__ import absolute_import




class DataCiteProvider(BaseProvider):
    """DOI provider using DataCite API."""

    pid_type = 'doi'
    """Default persistent identifier type."""

    pid_provider = 'datacite'
    """Persistent identifier provider name."""


# Path: invenio_pidstore/models.py
# PID_STATUS_TITLES = {
#     'NEW': _('New'),
#     'RESERVED': _('Reserved'),
#     'REGISTERED': _('Registered'),
#     'REDIRECTED': _('Redirected'),
#     'DELETED': _('Deleted'),
# }
#     NEW = 'N'
#     RESERVED = 'K'
#     REGISTERED = 'R'
#     REDIRECTED = 'M'
#     DELETED = 'D'
# class PIDStatus(Enum):
# class PersistentIdentifier(db.Model, Timestamp):
# class Redirect(db.Model, Timestamp):
# class RecordIdentifier(db.Model):
#     def __init__(self, value):
#     def __eq__(self, other):
#     def __str__(self):
#     def title(self):
#     def create(cls, pid_type, pid_value, pid_provider=None,
#                status=PIDStatus.NEW, object_type=None, object_uuid=None,):
#     def get(cls, pid_type, pid_value, pid_provider=None):
#     def get_by_object(cls, pid_type, object_type, object_uuid):
#     def has_object(self):
#     def get_assigned_object(self, object_type=None):
#     def assign(self, object_type, object_uuid, overwrite=False):
#     def unassign(self):
#     def get_redirect(self):
#     def redirect(self, pid):
#     def reserve(self):
#     def register(self):
#     def delete(self):
#     def sync_status(self, status):
#     def is_redirected(self):
#     def is_registered(self):
#     def is_deleted(self):
#     def is_new(self):
#     def is_reserved(self):
#     def __repr__(self):
#     def next(cls):
#     def max(cls):
#     def _set_sequence(cls, val):
#     def insert(cls, val):
# 
# 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/datacite.py
from datacite import DataCiteMDSClient
from datacite.errors import DataCiteError, DataCiteGoneError, \
    DataCiteNoContentError, DataCiteNotFoundError, HttpError
from flask import current_app
from ..models import PIDStatus, logger
from .base import BaseProvider

# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2015-2019 CERN.
# Copyright (C) 2019 Northwestern University.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""DataCite PID provider."""

from __future__ import absolute_import




class DataCiteProvider(BaseProvider):
    """DOI provider using DataCite API."""

    pid_type = 'doi'
    """Default persistent identifier type."""

    pid_provider = 'datacite'
    """Persistent identifier provider name."""


    default_status = PIDStatus.NEW