Command line interface

CLI scripts can be used perform all actions available in the UI

LinkedDataHub CLI wraps the HTTP API into a set of shell scripts with convenient parameters. The scripts should run on any Unix-based system. They can be used for testing, automation, scheduled execution and such. It is usually much quicker to perform actions using CLI rather than the user interface, as well as easier to reproduce.

Some scripts correspond to a single request to LinkedDataHub, others combine others into tasks with multiple interdependent requests, such as the CSV import.

You will need to supply a .pem file of your WebID certificate as well as its password as script arguments, among others.

The CLI scripts live in the bin folder and need to be added to the $PATH environmental variable. For example:

export PATH="$(find bin -type d -exec realpath {} \; | tr '
' ':')$PATH"

They also use the Jena's CLI commands internally, so make sure to have them on $PATH before running the scripts.

Parameters

Common parameters used by most scripts include:

-f
--cert-pem-file
.pem file with the WebID certificate of the agent
-p
--cert-password
Password of the WebID certificate
-b
--base
Base URI of the application
--proxy
The host this request will be proxied through (optional)
It can be used with port 5443 for which the client certificate authentication is always enabled, for example --proxy https://localhost:5443/

Other parameters are script-specific.

Usage

A usage message with parameters of a script is printed when the scripted is run without any arguments. There can be named parameters and default parameters, both of those can be optional. For example:

$ add-select.sh
Creates a SPARQL SELECT query.

Usage:  add-select.sh options

Options:
  -f, --cert-pem-file CERT_FILE        .pem file with the WebID certificate of the agent
  -p, --cert-password CERT_PASSWORD    Password of the WebID certificate
  -b, --base BASE_URI                  Base URI of the application
  --proxy PROXY_URL                    The host this request will be proxied through (optional)

  --title TITLE                        Title of the chart
  --description DESCRIPTION            Description of the chart (optional)
  --uri URI                            URI of the query (optional)

  --query-file ABS_PATH                Absolute path to the text file with the SPARQL query string
  --service SERVICE_URI                URI of the SPARQL service specific to this query (optional)

The optional parameters are marked with (Optional). In this case there is no default argument, but some scripts require document (named graph) URI as the default parameter, e.g. ontology document URL.

This is how an add-select.sh invocation would look like:

add-select.sh \
  -b "$base" \
  -f ./ssl/owner/cert.pem \
  -p "$owner_cert_password" \
  --proxy "$proxy" \
  --title "Select concepts" \
  --query-file "$pwd/queries/select-concepts.rq"

Scripts

Currently supported:

Purpose Script
Low-level (Graph Store Protocol)
GET request get.sh
POST request post.sh
PUT request put.sh
PATCH request patch.sh
DELETE request delete.sh
Documents
Create container document create-container.sh
Create item document create-item.sh
Content
Append object block (instance of ldh:Object) to document content/add-object-block.sh
Append XHTML block (instance of ldh:XHTML) to document content/add-xhtml-block.sh
Remove block from document content/remove-block.sh
Instances of system classes
Append service (instance of ldh:GenericService) to document add-generic-service.sh
Append result set chart (instance of ldh:ResultSetChart) to document add-result-set-chart.sh
Append SELECT query (instance of sp:Select) to document add-select.sh
Append SPARQL view (instance of ldh:View) to document add-view.sh
Imports
Create file add-file.sh
Create CONSTRUCT query add-construct.sh
Create CSV import imports/add-csv-import.sh
Import CSV data imports/import-csv.sh
Create RDF import imports/add-rdf-import.sh
Import RDF data imports/import-rdf.sh
Administration
Add owl:import to ontology admin/add-ontology-import.sh
Clear and reload ontology admin/clear-ontology.sh
Access control
Add agent to group admin/acl/add-agent-to-group.sh
Create authorization admin/acl/create-authorization.sh
Create group admin/acl/create-group.sh
Make application publicly readable to any agent admin/acl/make-public.sh
Ontologies
Add class admin/ontologies/add-class.sh
Add CONSTRUCT query admin/ontologies/add-construct.sh
Create ontology admin/ontologies/create-ontology.sh
Add property constraint admin/ontologies/add-property-constraint.sh
Add restriction admin/ontologies/add-restriction.sh
Add SELECT query admin/ontologies/add-select.sh
Import ontology admin/ontologies/import-ontology.sh
Packages
Install package admin/packages/install-package.sh
Uninstall package admin/packages/uninstall-package.sh

Usage example:

add-file.sh \
  -b "https://localhost:4443/" \
  -f ./ssl/owner/cert.pem \
  -p "$owner_cert_password" \
  --title "Friends" \
  --file friends.csv \
  --content-type text/csv

See also the data import user guides.

Find the CLI scripts on GitHub or check out the demo apps that use them.