Setting up the Admin CLI

The anzo CLI is an advanced administration tool for managing Anzo. It is primarily used for migrations and deployments. To script user interface operations or control Anzo with the CLI, please contact Cambridge Semantics.

This topic provides instructions for configuring the admin command line interface, anzo, and viewing the help menu. The anzo client is in the <install_path>/Client directory.

Adding the CLI to the Anzo Service User PATH

Follow the instructions below to configure the PATH environment variable to include the Client directory so that you call the anzo CLI from anywhere.

  1. If necessary, run the following command to become the Anzo service user:
    sudo su - <anzo_user_name>

    For example:

    sudo su - anzo
  2. Open ~/.bash_profile in a text editor.
  3. Change the PATH to the following value:
    PATH=$PATH:$HOME/.local/bin:$HOME/bin:Anzo_install_path/Client

    For example:

    PATH=$PATH:$HOME/.local/bin:$HOME/bin:/opt/Anzo/Client
  4. Save and close the file, and then run the following command:
    source ~/.bash_profile
  5. Type anzo to verify that you can access the CLI. For example:

    [anzo@anzo-server ~]$ anzo
    Anzo Command Line Client.
    Copyright (c) 2017 - 2019 Cambridge Semantics Inc and others.
    All rights reserved.
    Version: 4.4.0.r201910171220
    Type anzo help for usage

Configuring the CLI

Follow the instructions below to configure a settings file that specifies the default Anzo CLI configuration values for parameters such as host, port, user, and password. Specifying these details in the settings file eliminates the need to include those options in subsequent commands.

To create and populate the settings file, settings.trig, in your home directory, run the following command:

anzo setup <options>

Where options include the following choices:

-beep , --beep                   beep when command is completed
-ds , --datasource <datasource>  URI of the datasource to query, if other than primary datasource.
                                 Option not available for dataset queries.
-h , --host <hostname>           anzo server hostname
-http , --http                   Use http connection to server.
-p , --port <int>                anzo server port
-pause , --pause-exit            Wait for a user key entry before an abnormal exit.
-ssl , --use-ssl                 Use SSL for connection.
-t , --timeout <timeout>         override the default 30 second timeout for operations
-timer , --timer                 Print out the total operation time
-trace , --show-trace            Show stack trace for errors.
-trust , --trust-all             Trust all certificates including invalid ones
-u , --user <string>             username to connect with
-w , --password <string>         user's password
-x , --exclude-prefixes          Do not use prefixes defined in user settings to expand options,
                                 arguments, or to write RDF.
-z , --settings <file>           override the default settings file location

For example:

anzo setup -h localhost -p 61616 -u sysadmin -w @nz0

Anzo creates the settings.trig file in the ~/user/.anzo directory. You can edit the file as needed. The installation also includes a sample settings file, settings_example.trig, in the Client directory. You can view the sample file for reference. For example:

### standard prefixes
@prefix foaf      : <http://xmlns.com/foaf/0.1/> .
@prefix rdfs      : <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dc        : <http://purl.org/dc/elements/1.1/> .
@prefix xsd       : <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf       : <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#### anzo prefixes:
@prefix cli : <http://openanzo.org/cli/> .
@prefix system : <http://openanzo.org/ontologies/2008/07/System#> .
@prefix anzo : <http://openanzo.org/ontologies/2008/07/Anzo#> .
@prefix ld : <http://cambridgesemantics.com/ontologies/2009/05/LinkedData#> .
@prefix anzowt : <http://cambridgesemantics.com/ontologies/2009/05/AnzoWebToolkit#> .
@prefix reg : <http://cambridgesemantics.com/registries/> .
@prefix ontserv : <http://cambridgesemantics.com/semanticServices/OntologyService#> .
@prefix ldserv : <http://cambridgesemantics.com/semanticServices/LinkedData#> .
cli:config {
  cli:config
#       system:user "" ;
#       system:password "" ;
  system:timeout  "0";
  system:useSsl "false";
  system:port "61616";
  system:keystoreFile "${ANZO_CLI_HOME}/../Common/ssl/client.ks";
  system:keystoreType "JCEKS";
  system:keystorePassword "p@ssw0rd";
  system:truststoreFile "${ANZO_CLI_HOME}/../Common/ssl/client.ts";
  system:truststoreType "JCEKS";
  system:truststorePassword "p@ssw0rd";
  .
}

Viewing the CLI Help Menu

The CLI help menu lists all of the available subcommands. To view the subcommands, run anzo help.

usage: anzo <subcommand> [options] [args]
Anzo Command Line Client.
Type 'anzo help <subcommand>' for help with a specific subcommand.
Available subcommands:
acls              Ensure the graphs in a dataset inherit their ACLs from the dataset
analyze           Provides several flavors of analysis for Anzo request/response logs
call              Calls an anzo semantic service and prints the service response to the console
collapse          Collapse all URI arguments to prefixed URIs (CURIEs) using user defined prefixes
collapseGraph     In specified graph(s), collapse object properties with only one literal value
                  into a datatype property
convert           Converts between the various RDF file formats
count             Counts the statements in an RDF file
create            Creates named graphs in the repository from the provided RDF
csv               Export instances of an ontology class with all of their property values
deploy            Import, export, or delete a linked data set and related components
deregister	  Deregister given resource from appropriate registries based on rdf:type of resource 
expand            Expands all prefixed URI (CURIE) arguments to expanded URIs using
                  user defined prefix map
find              Retrieves statements from the server via simple pattern find
gen               Generates code for the ontologies as supplied by the input RDF or arguments
get               Retrieves named graphs from the server
graph2lds         Creates a Linked Data Set from the statements in a graph(s)
import            Imports statements into the repository, creating graphs in the repository as needed
inspectOntology   Inspects a dataset for an ontology
link              Link an excel workbook using a layout
load              Loads file based linked datasets
loadXML           Imports xml as statements into a graph in the repository as needed
ls		  List resources from appropriate registries based on type of resource
play              Play back a sequence of recorded requests
query             Executes a SPARQL query against the repository or a local RDF file
rdfformats        Show available rdf formats
register          Register given resource to appropriate registries based on rdf:type of resource.
		  Supported types:[
			http://cambridgesemantics.com/ontologies/2009/05/LinkedData#LinkedDataSet
			http://cambridgesemantics.com/ontologies/2009/05/LinkedData#LinkedDataCollection
			http://cambridgesemantics.com/ontologies/2009/05/LinkedData#LinkedDataCollectionInstance
			http://www.w3.org/2002/07/owl#Ontology
			http://openanzo.org/ontologies/2008/07/SemanticService#SemanticService
			http://cambridgesemantics.com/ontologies/2009/05/Spreadsheets#LinkedWorkbook
			http://cambridgesemantics.com/ontologies/2009/05/AnzoWebToolkit#Component
			http://cambridgesemantics.com/ontologies/Graphmarts#Graphmart
			http://cambridgesemantics.com/ontologies/Graphmarts#Step
			http://cambridgesemantics.com/ontologies/Graphmarts#Layer
			http://cambridgesemantics.com/ontologies/Graphmarts#View
			]
remove            Removes named graphs from the repository
replace           Replaces named graphs in the repository with the provided RDF
reset             Resets the repository, replacing all contents of repository with rdf provided
retrieve          Retrieves content from the binary store and saves it in a local file
setup             Set up settings.trig file
sortedConvert     Converts between the various RDF file formats
store             Stores a local file in the Anzo server's binary store
union             Unions RDF from the arguments and optionally from STDIN as well
update            Updates existing graphs in the repository
uploadBundle      Upload bundle to server
uploadCertificate Upload trusted certificate to server
watch             Listens for changes to a graph and prints them out
xray		  Export system tables into trig file


URI arguments to commands may either be fully qualified URIs ("http://...") or prefixed URIs ("dc:title").
The prefix mapping is defined in the users settings file.
User settings are loaded from a user's "~/.anzo/settings.trig" file.
See documentation for details.

To view the help for a specific subcommand, run anzo help command_name. For example, the following command displays help for the find command:

[user@anzo Client]# ./anzo help find
usage: anzo find [options] [NAMED-GRAPH-URI...]
Retrieves statements from the server via simple pattern find.
-beep , --beep                      beep when command is completed
-ds , --datasource <datasource>     URI of the datasource to query, if other than primary datasource.
                                    Option not available for dataset queries.
-f , --output-file <file>           write the find results to a file
-h , --host <hostname>              anzo server hostname
-http , --http                      Use http connection to server.
-lang , --literal-language <string> The literal language
-lit , --literal-object <string>    The literal object of find pattern
-n , --count                        Outputs only the total number of matching statements
-o , --output-format <rdf-Format>   Override the default RDF format associated with the RDF output(s)
-p , --port <int>                   anzo server port
-pause , --pause-exit               Wait for a user key entry before an abnormal exit.
-pred , --predicate <URI>           The predicate of find pattern
-pretty , --pretty-print            PrettyPrint output (currently only json)
-ssl , --use-ssl                    Use SSL for connection.
-sub , --subject <subject>          The subject of find pattern
-t , --timeout <timeout>            override the default 30 second timeout for operations
-timer , --timer                    Print out the total operation time
-trace , --show-trace               Show stack trace for errors.
-trust , --trust-all                Trust all certificates including invalid ones
-type , --literal-datatype <URI>    The literal datatype
-u , --user <string>                username to connect with
-uri , --uri-object <URI>           The uri object of find pattern
-w , --password <string>            user's password
-x , --exclude-prefixes             Do not use prefixes defined in user settings to expand options,
                                    arguments, or to write RDF.
-z , --settings <file>              override the default settings file location

'help rdfformats' for list of available RDF formats.
Filename arguments default to the file format matching their filename extension.
STDIN and STDOUT default to 'trig'.