Skip to main content
Common Reference

The tapi Command

Version availability

Available in 7.0.0 and later.

The tapi command is designed to act as an interface to the Tungsten REST APIv2.

Usage
tapi [options] [API_call_path]
Feature change in v8.0.0

tapi only supports APIv2 calls at present. Using APIv8 can be enabled by issuing the --apiver 8 option on all tapi calls, although at present this is only experimental.

The original goal of this script was to provide a way to test and exercise the API which then grew to include additional functionality and convenience options.

tapi Generic Options

OptionDescriptionVersionProduct
--debug
Aliases: -d
CTTR
--help
Aliases: -h
CTTR
--quiet
Aliases: -q
CTTR
--service
Aliases: -s
Specify a service name. Used with --run, --getpolicy, --setpolicy and the --policy NRPE plugin.CTTR
--verbose
Aliases: -v
CTTR
OptionDescriptionVersionProduct
--curlSpecify where to find curl executable (default: curl).CTTR
--getSet the curl request to GET.CTTR
--hostSpecify the host name to connect to.
Default: 127.0.0.1
CTTR
--nossl
Aliases: --http
Specify NON-SSL/http-only connection.
Default: https
CTTR
--password
Aliases: -p
Specify auth password.CTTR
--portSpecify the port number to connect to.
Default: 8090
CTTR
--postSet the curl request to POST.CTTR
--putSet the curl request to PUT.CTTR
--requestSpecify the curl request method.
Default: none | Valid: GET, POST, PUT
CTTR
--user
Aliases: -u
Specify auth user.CTTR
OptionDescriptionVersionProduct
--critical
Aliases: -c
Specify the critical threshold value in seconds; used with --latency.CTTR
--latencyCheck the replicator for latency as an NRPE plugin.CTTR
--onlineCheck the manager to see if the datasource is online as an NRPE plugin.CT
--per-replica-perfdata
Aliases: --allperf
When --per-replica-perfdata is specified with --perf, each service is listed separately; used with --latency.CTTR
--perf
Aliases: --perfdata
Display additional performance data; used with --latency.CTTR
--policyCheck the manager to see if the cluster is in {autopolidy} policy mode as an NRPE plugin.CT
--progressCheck the replicator to see that it is making progress over time as an NRPE plugin.CTTR
--servicesCheck the host for running services (Manager, Connector and Replicator) as an NRPE plugin.CTTR
--wait
Aliases: -w
Specify the time to wait in seconds during the --progress test.
Default: 1
CTTR
--warn
Aliases: -w
Specify the warning threshold value in seconds; used with --latency.CTTR
--zabbix
Aliases: -z
Use Zabbix-style exit messages which are the same as the exit code, unlike NRPE which outputs a string starting with OK, WARNING or CRITICAL.CTTR
OptionDescriptionVersionProduct
--createConnect to the specified host and port, then call the createAdminUser path with a special body to instantiate the user. Must supply --create-user and --create-password.CTTR
--create-passSets the password for the APIv2 admin user created using the --create flag. --createand --create-user must also be suppliedCTTR
--create-userSets the user name for the APIv2 admin user created using the --create flag. --createand --create-pass must also be suppliedCTTR
--getdsDisplay the main Manager dataservice name.CT
--getmainDisplay the main Replicator service name.CTTR
--getpolicyGet the current local policy. If --service [svcname] is specified, then the policy will be displayed for that service.CT
--getportsDisplay the API default port for each component.CTTR
--getsubsDisplay the Replicator sub-service(s).CTTR
--includeServiceNameOutput service names.CTTR
--no-connectorsAppend '?no-connectors=1' to all API calls to disable the Manager internal status calls to the Connectors.CT
--setautoSet the current policy to AUTOMATIC.CT
--setmaintSet the current policy to MAINTENANCE.CT
--setmapGenerate and POST payload to Connector to instantiate the service. Must supply: --service, --node,--role, --state, --resource, --iscomposite, --driver.8.0.0CTTR
--setpolicySet the current local policy. If --service [svcname] is specified, then the policy will be set for that service.
Valid: auto, a, maint, m
CT
--topologyDisplay the main Manager topology.CT
OptionDescriptionVersionProduct
--connector
Aliases: -C
Specify the connector path.CT
--filter
Aliases: -F
Specify [string] to limit the call path (typically used with --listapi.CTTR
--manager
Aliases: -M
Specify the manager path.CT
--replicator
Aliases: -R
Specify the replicator path.CTTR
OptionDescriptionVersionProduct
--all-aervicesOperate on all available services. Used with --run.CTTR
--apiverBy default, all commands will use APIv2, this option can be used to switch to experiemntal APIv8 by passing --apiver 8.8.0.0CTTR
--follow
Aliases: -f--descend
If the resulting payload type is URIsPayload then call every key in the payload as a sub-item of the original path.CTTR
--listapi
Aliases: -L
List all available REST API calls by unique key.CTTR
--run
Aliases: -r--alias
Specify an API call name by unique key. Use --listapi to see all keys/aliases.CTTR
OptionDescriptionVersionProduct
--affinityDisplay only the affinity-specific values from the /connector/configuration/module/connector path.CT
--allstatsDisplay all statistics cluster-wide using the Manager API.CT
--clusterstatus
Aliases: --cs
Use the manager/cluster/status path.CT
--connectorstatusUse the /connector/configuration/module/connector path.CT
--mgrstatsDisplay Manager statistics cluster-wide using the Manager API.CT
--routersDisplay Connector statistics cluster-wide using the Manager API.CT
--statusUse the manager/status path.CT
--trstatsDisplay Replicator statistics cluster-wide using the Manager API.CT
OptionDescriptionVersionProduct
--backuptimeoutSpecify the backup timeout in seconds.CTTR
--mysqldumpUse the mysqldump backup agent.CTTR
--restoretimeoutSpecify the restore timeout in seconds.CTTR
--restoreuriSpecify the restore URI.CTTR
--storageagentSpecify the storage agent.CTTR
--xtrabackupUse the xtrabackup backup.CTTR
--xtrabackupFullUse the xtrabackupFull backup agent.CTTR
--xtrabackupIncrementalUse the xtrabackupIncremental backup agent.CTTR

There are many cli options which invoke the various functions of the tapi script.

With no options specified, the tapi script will construct a curl command to query the Tungsten Manager API (default https://127.0.0.1:8090) using the [API_call_path] provided on the command line.

Basic Example

Running tapi -M status would result in something like the following:

shell> tapi -M status
Executing: curl -s --user tungsten:secret --insecure --request GET 'https://127.0.0.1:8090/api/v2/manager/status'
{"payloadType":"StatusPayload","payloadVersion":"1","payload":{"dataServiceName":"east","dataSourceName":"db1-demo.continuent.com",
"startTime":"2021-03-25T16:47:50.523 UTC","uptimeSeconds":1909,"state":"ONLINE","isCoordinator":true,"isWitness":false,
"managerPID":4052,"parentPID":4031,"policyMode":"MAINTENANCE","coordinator":"db1-demo.continuent.com"}}

If both --user and --password are defined, curl will use them in the call.

If either or both --user and --password are missing, tapi will attempt to derive the values using the tpm command.

Simple Admin Command Examples

tapi --getds
tapi --topology
tapi --setmaint
tapi --setauto

tapi --setpolicy maintenance
tapi --setpolicy m
tapi --setpolicy automatic
tapi --setpolicy a

Simple Replicator Command Examples

tapi --getmain
tapi --getsubs

Running API Command Examples

Show all available API calls in four columns: component, unique key, request type, request path:

tapi -R --listapi

Show all available API calls filtered by Manager (-M), Replicator (-R) or Connector (-C):

tapi --listapi -M
tapi --listapi -R
tapi --listapi -C

Execute an API call by unique key per component:

tapi -R --listapi
tapi -R --run ping
tapi -R -v --run offline (like `trepctl offline`)
tapi -R -v --run online (like `trepctl online`)

Backup and Restore Examples

tapi -v -R --run backup --mysqldump
tapi -v -R --run backup --xtrabackupFull
tapi -v -R -j --run restore
tapi -v -R -j --run task d28465a2-6023-47c4-9a4c-20f93514db75

Advanced Connector Provisioning Examples

Applies to: ct

Using a JSON Payload (MySQL Example)

shell> vi ~/DataServicesMapPayload.txt
{
"payloadType": "DataServicesMapPayload",
"payload": {
"alpha": {
"db1": {
"dataServiceName": "alpha",
"name": "db1",
"isAvailable": true,
"role": "master",
"host": "db1",
"state": "ONLINE",
"url": "jdbc:mysql:thin://db2-demo.continuent.com:13306/
{DBNAME}?jdbcCompliantTruncation=false&zeroDateTimeBehavior=convertToNull&;
tinyInt1isBit=false&allowMultiQueries=true&yearIsDateType=false",
"isComposite": false,
"driver": "org.drizzle.jdbc.DrizzleDriver"
}
}
}
}
shell> tapi -C -r setServicesmap --file ~/DataServicesMapPayload.txt

Using a JSON Payload (PostgreSQL Example)

shell> vi ~/DataServicesMapPayload.txt

{
"payloadType": "DataServicesMapPayload",
"payload": {
"ddg": {
"u4": {
"dataServiceName": "ddg",
"name": "u4",
"isAvailable": true,
"role": "master",
"host": "u4",
"state": "ONLINE",
"url": "jdbc:postgresql://u4:5432/${DBNAME}",
"isComposite": false,
"driver": "org.postgresql.Driver"
}
}
}
}
shell> tapi -C -r setServicesmap --file ~/DataServicesMapPayload.txt

Using Command Line Arguments (MySQL Example)

tapi --setmap --service alpha --node db1 --role master --state ONLINE --resource 'jdbc:mysql:thin://db2-demo.continuent.com:13306/
{DBNAME&}?jdbcCompliantTruncation=false&zeroDateTimeBehavior=convertToNull&tinyInt1isBit=false&allowMultiQueries=true&yearIsDateType=false'
--iscomposite false --driver org.drizzle.jdbc.DrizzleDriver

Using Command Line Arguments (PostgreSQL Example)

tapi --setmap --service alpha --node db1 --role master --state ONLINE --resource 'jdbc:postgresql://u4:5432/{DBNAME}' --iscomposite false
--driver org.postgresql.Driver