artefactual-labs / cul-spectrum

Concordia University Library Python client for the Spectrum REST API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CUL Spectrum

About

CUL Spectrum implements a Python CLI client for the Concordia University Library Spectrum REST API.

Install

Clone this repo, change into the cloned directory, and install:

cd cul-spectrum
pip install .

Usage

CUL Spectrum currently only implements a client for the set_uuid endpoint.

To add a single AIP:

spectrum set-uuid --uuid=f904e936-a347-4211-82b7-e2a3c4da8cb2 --name=example1

You will be prompted for the Spectrum server URL and authorization token.

Environment variables

To avoid being prompted for the server URL and authorization token on each spectrum invocation, you can set environment variables for these values:

export SPECTRUM_URL=https://example.com/cgi/archivematica
export SPECTRUM_TOKEN=secret123

Input options

You can add a single AIP to Spectrum by specifying the --uuid and --name options:

spectrum set-uuid --uuid=f904e936-a347-4211-82b7-e2a3c4da8cb2 --name=example1

Warning: spectrum does no validation of the UUID and name values or formats.

You can also provide input data for multiple AIPs in CSV format by using the --csv-file option:

spectrum set-uuid --csv-file=../cul_spectrum_test.csv

The CSV file must include a uuid column and either a name column (for a bare AIP name, e.g. "test1"), or a current_path column (for a storage server path, e.g. "3db3/fc8b/0e60/46a2/89fb/2243/1315/b2f9/test1-3bd3fc8b-0e60-46a2-89fb-22431315b2f9.7z").

Output options

CUL Spectrum's default output format is CSV:

$ spectrum set-uuid --uuid=f904e936-a347-4211-82b7-e2a3c4da8cb2 --name=example1
http_status,http_body
200 OK,"{""id"": ""1579""}"

CUL Spectrum also supports JSON output with the --out-format option:

$ spectrum set-uuid --uuid=f904e936-a347-4211-82b7-e2a3c4da8cb2 --name=example1 --out-format=json
{
    "http_status": "200 OK",
    "http_body": "{\"id\": \"1012\"}"
}

To write spectrum's output to a file you can use stdout redirection:

$ spectrum set-uuid --uuid=f904e936-a347-4211-82b7-e2a3c4da8cb2 --name=example1 > results.csv

Development

Testing

To run all tests with tox:

tox

Or run tests directly with pytest:

pip install -r requirements/test.txt
pytest

Credits

This package was created with Cookiecutter and Artefactual's fork of the audreyr/cookiecutter-pypackage project template.

About

Concordia University Library Python client for the Spectrum REST API

License:Other


Languages

Language:Python 94.3%Language:Makefile 5.7%