src/pds_doi_service/core/actions/reserve.py
def run(self, **kwargs):
        """
        Performs a reserve of a new DOI.

        Parameters
        ----------
        kwargs : dict
            The parsed command-line arguments for the reserve action.

        Returns
        -------
        output_label : str
            The output label, in JSON format, reflecting the status of the
            reserved input DOI's.

        Raises
        ------
        CriticalDOIException
            If any unrecoverable errors are encountered during validation of
            the input DOI's.

        """
        output_dois = []

        self.parse_arguments(kwargs)

        try:
            # Parse, complete and validate the set of provided DOI's
            dois = self._parse_input(self._input)
            dois = self._complete_dois(dois)
            dois = self._validate_dois(dois)

            for input_doi in dois:
                # Create the JSON request label to send
                io_doi_label = self._record_service.create_doi_record(input_doi, content_type=CONTENT_TYPE_JSON)

                # Submit the Reserve request
                # Determine the correct HTTP verb and URL for submission of this DOI
                method, url = self._web_client.endpoint_for_doi(input_doi, self._name)

                output_doi, o_doi_label = self._web_client.submit_content(
                    method=method, url=url, payload=io_doi_label, content_type=CONTENT_TYPE_JSON
                )

                # Log the inputs and outputs of this transaction
                transaction = self.m_transaction_builder.prepare_transaction(
                    self._submitter,
                    output_doi,
                    input_path=input_doi.input_source,
                    output_content_type=CONTENT_TYPE_JSON,
                )

                # Commit the transaction to the local database
                transaction.log()

                # Append the latest version of the Doi object to return as a label
                output_dois.append(output_doi)

        # Propagate input format exceptions, force flag should not affect
        # these being raised and certain callers (such as the API) look
        # for this exception specifically
        except InputFormatException as err:
            raise err
        # If we catch this exception, it means validation produced a warning
        # and the --force flag is not set, so log the error and exit without
        # producing an output label
        except WarningDOIException as err:
            logger.error(str(err))
            raise err
        # Convert all other errors into a CriticalDOIException to report back
        except Exception as err:
            raise CriticalDOIException(err)

        # Create the return output label containing records for all submitted DOI's
        # Note this action always returns JSON format to ensure interoperability
        # between the potential service providers
        output_label = self._record_service.create_doi_record(output_dois, content_type=CONTENT_TYPE_JSON)

        return output_label

        Performs a reserve of a new DOI.

        Parameters
        ----------
        kwargs : dict
            The parsed command-line arguments for the reserve action.

        Returns
        -------
        output_label : str
            The output label, in JSON format, reflecting the status of the
            reserved input DOI's.

        Raises
        ------
        CriticalDOIException
            If any unrecoverable errors are encountered during validation of
            the input DOI's.

        
Performs a reserve of a new DOI.
Parameters

kwargs : dict
The parsed command-line arguments for the reserve action.

Returns

output_label : str
The output label, in JSON format, reflecting the status of the
reserved input DOI's.

Raises

CriticalDOIException
If any unrecoverable errors are encountered during validation of
the input DOI's.
Performs a reserve of a new DOI . Parameters kwargs : dict The parsed command - line arguments for the reserve action . Returns output_label : str The output label in JSON format reflecting the status of the reserved input DOI ' s . Raises CriticalDOIException If any unrecoverable errors are encountered during validation of the input DOI ' s .
def run(self, **kwargs):
        output_dois = []
        self.parse_arguments(kwargs)
        try:
            dois = self._parse_input(self._input)
            dois = self._complete_dois(dois)
            dois = self._validate_dois(dois)
            for input_doi in dois:
                io_doi_label = self._record_service.create_doi_record(input_doi, content_type=CONTENT_TYPE_JSON)
                method, url = self._web_client.endpoint_for_doi(input_doi, self._name)
                output_doi, o_doi_label = self._web_client.submit_content(
                    method=method, url=url, payload=io_doi_label, content_type=CONTENT_TYPE_JSON
                )
                transaction = self.m_transaction_builder.prepare_transaction(
                    self._submitter,
                    output_doi,
                    input_path=input_doi.input_source,
                    output_content_type=CONTENT_TYPE_JSON,
                )
                transaction.log()
                output_dois.append(output_doi)
        except InputFormatException as err:
            raise err
        except WarningDOIException as err:
            logger.error(str(err))
            raise err
        except Exception as err:
            raise CriticalDOIException(err)
        output_label = self._record_service.create_doi_record(output_dois, content_type=CONTENT_TYPE_JSON)
        return output_label
def run ( self , ** kwargs ) : output_dois = [ ] self . parse_arguments ( kwargs ) try : dois = self . _parse_input ( self . _input ) dois = self . _complete_dois ( dois ) dois = self . _validate_dois ( dois ) for input_doi in dois : io_doi_label = self . _record_service . create_doi_record ( input_doi , content_type = CONTENT_TYPE_JSON ) method , url = self . _web_client . endpoint_for_doi ( input_doi , self . _name ) output_doi , o_doi_label = self . _web_client . submit_content ( method = method , url = url , payload = io_doi_label , content_type = CONTENT_TYPE_JSON ) transaction = self . m_transaction_builder . prepare_transaction ( self . _submitter , output_doi , input_path = input_doi . input_source , output_content_type = CONTENT_TYPE_JSON , ) transaction . log ( ) output_dois . append ( output_doi ) except InputFormatException as err : raise err except WarningDOIException as err : logger . error ( str ( err ) ) raise err except Exception as err : raise CriticalDOIException ( err ) output_label = self . _record_service . create_doi_record ( output_dois , content_type = CONTENT_TYPE_JSON ) return output_label
Performs a reserve of a new DOI.
Performs a reserve of a new DOI .
"""
        Performs a reserve of a new DOI.

        Parameters
        ----------
        kwargs : dict
            The parsed command-line arguments for the reserve action.

        Returns
        -------
        output_label : str
            The output label, in JSON format, reflecting the status of the
            reserved input DOI's.

        Raises
        ------
        CriticalDOIException
            If any unrecoverable errors are encountered during validation of
            the input DOI's.

        """ # Parse, complete and validate the set of provided DOI's # Create the JSON request label to send # Submit the Reserve request # Determine the correct HTTP verb and URL for submission of this DOI # Log the inputs and outputs of this transaction # Commit the transaction to the local database # Append the latest version of the Doi object to return as a label # Propagate input format exceptions, force flag should not affect # these being raised and certain callers (such as the API) look # for this exception specifically # If we catch this exception, it means validation produced a warning # and the --force flag is not set, so log the error and exit without # producing an output label # Convert all other errors into a CriticalDOIException to report back # Create the return output label containing records for all submitted DOI's # Note this action always returns JSON format to ensure interoperability # between the potential service providers
self