LiveAPICreatorCLI
A command-line tool to access CA Live API Creator REST API and Logic services. Refer to online documentation of creating and using Live API Creator REST API
Installation
git clone https://github.com/EspressoLogicCafe/liveapicreator-devops.git cd liveapicreator-devops Select one of three directories (platform: windows, linux, and macos) and copy the 'lac' and 'lacadmin' to your path where you intend to run your scripts.
Features
- Log in once per server, stay "logged in" for the lifetime of the API key
- Can call GET, POST, PUT and DELETE
- Can read/write objects from/to file or stdin (suitable for pipe work!)
Command Line Service
Usage: lac [options] [command] Commands: login [options] <url> Login to an API Server logout [options] [url] Logout from the current server, or a specific server use <alias> Use the specified server by default status Show the current server, and any defined server aliases get [options] <resource> Retrieve some data
Logon to an API Server
$lac login -u demouser -p mypassword http://localhost:8080/rest/default/demo/v1Logging in...This server licensed to: Live API CreatorLogin successful, API key will expire on: 2015-11-18T15:03:37.342Z
See which API server (if any) you are logged into
$lac status You are currently logged in to server: https://localhost:8080/rest/default/demo/v1 as user: demoDefined aliases:┌───────┬───────────────────────────────────────────────────────────┬───────┐│ Alias │ Server │ User │├───────┼───────────────────────────────────────────────────────────┼───────┤│sample │ https://localhost:8080/rest/default/sample/v1 │sample │├───────┼───────────────────────────────────────────────────────────┼───────┤│ demo │ https://localhost:8080/rest/default/demo/v1 │ demo │└───────┴───────────────────────────────────────────────────────────┴───────┘
DESCRIBE a system resource
This can return information about all tables, or one specific table, or all views/one specific view, or get information about the server or the server's license. The possible values for the resource are:
- tables
- tables/<table-name>
- views
- views/<view-name>
- license
- serverinfo
$lac describe tables DB Table---- -------------------demo customerdemo employeedemo employee_picturedemo LineItemdemo productdemo PurchaseOrderdemo purchaseorder_audit
$lac describe tables/product Name Type Size PK-------------- ------- -------- --product_number BIGINT 19 *name VARCHAR 50price DECIMAL 19icon BLOB 65535full_image BLOB 16777215
GET
Usage: get <resource> [options] Options: -h, --help output usage information -k, --pk <pk> Optional: primary key of the object to retrieve -f, --sysfilter <sysfilter> Optional: sysfilter, e.g. "less(balance:1000) or equal(name:'SomeName') -s, --sysorder <sysorder> Optional: sorting sysorder, e.g. "" -g, --userfilter <named filter> Optional: named filter, e.g. "namedFilter -t, --userorder <named order> Optional: named sorts, e.g. "namedSort([columnName])" -z, --pagesize <pagesize> Optional: up to how many rows to return per level -m, --format <format> Optional: format of output, either text , json or compactjson --truncate <length> -a, --serverAlias <serverAlias> Optional: alias of the server to use
Get a single REST endpoint (compressed format)
$lac get demo:employee demo:employee/1 employee_id:1 login:sam name:Sam Yosemitedemo:employee/2 employee_id:2 login:mlittlelamb name:Mary Little-Lambdemo:employee/3 employee_id:3 login:sconnor name:Sarah Connordemo:employee/4 employee_id:4 login:jkim name:John Kimdemo:employee/5 employee_id:5 login:bmcmanus name:Becky McManusetc...
GET a single REST endpoint (JSON format)
$lac get employee/4 -m json[ ] $lac get demo:customer --userfilter "myFilter(custname:'Alpha and Sons')" --userorder "sortByName"
POST (insert) a JSON payload
$lac post --help Usage: post <resource> [options] Options: -h, --help output usage information -j, --json <json> JSON
PUT (update) a JSON Payload
$lac put --help Usage: put <resource> [options] Options: -h, --help output usage information -j, --json <json> JSON string
note: you can replace the checksum value with "override" - but this overrides optimistic locking so use it wisely.
DELETE a REST resource
Required fields are the primary key (--pk ) and checksum (--checksum )
$lac delete --help Usage: delete <resource> [options] Options: -h, --help output usage information -k, --pk <pk> Primary key of the object to delete --checksum <checksum> Optional: checksum
Logout
$lac logoutLogout successful