Skip to content
Benjamin Kiah Stroud edited this page Dec 2, 2021 · 3 revisions

Command Line Interface (CLI)

Bulkrax has a CLI for creating and updating Importers. The CLI uses the JSON API.

Enabling the CLI

The bulkrax install generator (rails g bulkrax:install ) adds two files to the local application. Both files are required for the CLI.

- bin/importer
- config/bulkrax_api.yml

Authorization

Authorization for the JSON API is via a token. The application should set the token as an environment variable called BULKRAX_API_TOKEN.

The CLI passes the token to the API in an option called --auth_token. This is required.

Help

Use the following command to view help for the CLI.

> bin/importer --help

Create an Importer

bin/importer --name "My Import" 
  --parser_klass Bulkrax::CsvParser 
  --commit "Create and Import" 
  --import_file_path /data/tmp/import.csv 
  --auth_token 12345

Update an Importer

bin/importer --importer_id 1 
  --commit "Update and Re-Import (update metadata only)" 
  --import_file_path /data/tmp/import.csv 
  --auth_token 12345

Options

--importer_id

  • ID for the Importer to Update
  • required: Update Only

--name

  • Name for the Importer
  • required: Create Only

--admin_set_id

  • AdminSet ID

--rights_statement

  • Supply a URI from the application rights statements
  • valid_values: rights statements returned by Hyrax.config.rights_statement_service_class.new.select_active_options

--override_rights_statement

  • Override any existing rights statements: 1 for yes | 0 for no
  • valid_values:
    • 0
    • 1

--import_file_path

  • Path to the import file - required for CSV and BagIt only
  • required: for Bulkrax::BagitParser and Bulkrax::CsvParser

--metadata_file_name

  • Filename used for metadata files - required for BagIt only
  • required: for Bulkrax::BagitParser Create Only

--metadata_format

  • RDF or CSV - required for BagIt only
  • required: for Bulkrax::BagitParser Create Only
  • valid_values:
    • Bulkrax::RdfEntry
    • Bulkrax::CsvEntry

--set

  • The OAI setSpec - required for OAI only
  • required: for Bulkrax::OaiParser Create Only

--collection_name

  • The OAI setName - required for required for OAI only
  • required: for Bulkrax::OaiParser Create Only

--parser_klass

  • Parser name eg. Bulkrax::CsvParser
  • required: Create Only
  • valid_values: parsers configured in config/initializers/bulkrax.rb

--limit

  • Number of records to import; blank for all

--frequency

  • ISO 8601 Durations Daily; Monthly; Yearly; Once (on save)
  • valid_values:
    • P1D
    • P1M
    • P1Y
    • PT0S

--field_mapping

  • See bulkrax/lib/bulkrax.rb for further information

--user_id

  • ID of the User creating the Importer

--base_url

  • Base URL for the Endpoint - required for OAI Only
  • required: for Bulkrax::OaiParser Create Only

--commit

  • Commit Message. Bulkrax uses commit messages to decide what action to take.
  • required: true
  • valid_values:
    • Create
    • Create and Import
    • Update Importer
    • Update and Re-Import (update metadata and replace files)
    • Update and Harvest Updated Items
    • Update and Re-Harvest All Items
    • Update and Re-Import (update metadata only)
    • Update and Import (importer has not yet been run)

--auth_token

  • Authentication token. Required for JSON requests only.
  • required: true

--port

  • Port to use in http request. Defaults to 80. May need to set to 3000 when running in the development environment