Docs‎ > ‎Live API Overview‎ > ‎

Node Admin CLI

Because all Live API Creator APIs are REST APIs, any REST-compatible tool and language can use them. For instance, you can use curl or your web browser. But these tools are a bit tedious: you have to manually set HTTP headers and remember the ID of various objects.

API Creator provides two command-line tools to make this easier: liveapicreator-cli and liveapicreator-admin-cli. Use these command-line interfaces (CLIs) to administer Live API Creator administration services and APIs. 

The Admin CLI is documented on the NPM page, here.

Advanced users will no doubt realize that it is, in fact, entirely possible to administer an API service using liveapicreator-cli -- that is true, but the liveapicreator-admin-cli makes it quite a bit easier.

Install Node

The Admin CLI requires Node. Install node from here.

Windows - Add Node to Path

If this NodeJS is not in your PATH, you will need to fix that, otherwise you'll have to specify the full path to the executable.  Set your path as follows (click the image to enlarge):
  1. Open Control Panel, filter for Env.
  2. Open Environment Variables by clicking the link.
  3. Open Environmental Variables.
  4. Select Path.
    1. If there is no PATH variable in your list of User variables then create a New one. 
    2. Edit the PATH variable, add the location of the directory to the Variable Value field, and click OK.
C:\Program Files\nodejs\

Important! Changes to the variable do not take effect on current launches Command Windows.

File Permissions

Note: On Windows (and sometimes Mac), npm install creates an executable called liveapicreatoradmin in your <node_modules>/.bin directory

Installation

Install the Admin CLI by entering the following into terminal (also see here):

npm install liveapicreator-admin-cli -g

MAC users may need to use the sudo command:

sudo npm install liveapicreator-admin-cli -g

Command Line Service

Note: lacadmin is provided as an alias for liveapicreatoradmin; this is automatic, using the npm install, above. 

Similar to most CLI tools, lacadmin provides help:


$ liveapicreatoradmin --help

  Usage: liveapicreatoradmin [options] [command]

  Commands:

    login [options] <url>  -alias [alias name]                       Login to an API Creator server using an alias name (multiple connections can be active)
    logout [options] [url] -alias [alias name]                       Logout from the current server, or an alias specific server 
    use <alias name>                                                 Use the specified login aliasserver by default
    status                                                           Show the current server, and any defined server aliases
    project <list|create|update|delete|use|import|export>            Administer API Projects
    datasources <list|create|update|delete|import|export>            Administer datasources (database connections) within a project.
    resource <list|create|delete|import|export>                      Administer resources within a project.
    rule  <list|create|delete|import|export>                         Administer rules within a project.
    authprovider <list|create|delete|import|export>                  Administer authentication providers for an account.
    libraries <list|create|update|delete|import|export|linkProject>  Administer user libraries for an account and link to project.
    apioptions <list|update|import|export>                           Administer API project options for an API Project.
namedsort [options] <list|create|update|delete|import|export>          Administer Named Sorts for the active API Project.
namedfilter [options] <list|create|delete|update|import|export>        Administer Named filter for the active API Project.
token [options] <list|export|import>                                   Administer Auth Tokens for current project.
role [options] <list|export|import>                                    Administer Roles for current project.
user [options] <list|export|import>                                    Administer Users for current project.
topic [options] <list|export|import>                                   Administer Topics for current project.
event [options] <list|export|import>                                   Administer Request & Response Events for current project.
handler [options] <list|export|import>                                 Administer Custom Endpoints (Handlers) for current project.
apiversion [options] <list|export|import>                              Administer API Versions for Resources for current project.
relationship [options] <list|export|import>                            Administer Relationships (Virtual Keys) for current project.
snapshot [options] <list|start>                                        List or start a project snapshot (backup) for current project.
Options: -h, --help output usage information -V, --version output the version number

Sample Export Script

You can combine each command to export parts of your system into components that can later be used in source control and then promoted to different servers.

#! /bin/bash echo 'Export Script for Northwind Jetty B2b' mkdir nw
Echo 'Connect to local server' liveapicreatoradmin logout -a local liveapicreatoradmin login -u admin -p Password1 http://localhost:8080 -a localnw liveapicreatoradmin use localnw Echo 'List Project, find and use project by name and then export as json file' liveapicreatoradmin project list liveapicreatoradmin project use --url_name nwindb2b liveapicreatoradmin project export --url_name nwindb2b --file nw/nwind.json Echo 'List the current API Settings and export all settings as json file' liveapicreatoradmin apioptions list liveapicreatoradmin apioptions export --file nw/nw_settings.json Echo 'List all Data Sources for current project and then export active project named nw to json file' liveapicreatoradmin datasource list liveapicreatoradmin datasource export --prefix nw --file nw/derby_ds.json Echo 'List all Libraries and export by name' liveapicreatoradmin libraries list liveapicreatoradmin libraries export --name RESTAuthSecurityProviderCreate --file nw/auth_libraries.json
Echo 'List all Auth Providers and export by Name to json file' liveapicreatoradmin authprovider list liveapicreatoradmin authprovider export --name RESTAuthSecurityProviderCreate --file nw/nw_authprovider.json
Echo 'List all Rules - using verbose will export each individual rule, then export all rules for this project to json file' liveapicreatoradmin rule list --verbose liveapicreatoradmin rule export --file nw/rules.json Echo 'List all Resources and export them all to json file' liveapicreatoradmin resource list liveapicreatoradmin resource export --file nw/resources.json Echo 'Locgout and close connections' liveapicreatoradmin logout -a localnw

Import

#! /bin/bash Echo 'import Script for Northwind Jetty to new Server' Echo 'Logon to local Jetty server (if WAR file use http://localhost:8080/APIServer) ' liveapicreatoradmin login -u admin -p Password1 http://localhost:8080 -a localqa liveapicreatoradmin use localqa Echo 'Libraries - need to import these before import of JSON project' Echo 'We can create the Library and use an existing JS library.' #liveapicreatoradmin libraries create --name RestAuthProviderJS --comments 'RESTAuthProvider js Demo' --shortName restauth --libtype javascript --ver 1.0 --file nw/RESTAuthSecurityProvider.js liveapicreatoradmin libraries import --file nw/auth_libraries.json liveapicreatoradmin libraries list Echo ' Projects - this is the default NorthWind JSON project' liveapicreatoradmin project import --file nw/nwind.json liveapicreatoradmin project list Echo 'API Settings [Optional]' liveapicreatoradmin apioptions list liveapicreatoradmin apioptions import --file nw/nw_settings.json Echo ' Data Sources [optional] for other databases - set the password' liveapicreatoradmin datasource list Echo 'liveapicreatoradmin datasource update --prefix nw --password password1 -- Jetty does not use pw Echo 'Auth Providers - lets create a new one and link it to the current project' liveapicreatoradmin authprovider list #liveapicreatoradmin authprovider create --name RESTAuthSecurityProviderCreate --createFunction LDAPAuthProviderCreate --paramMap logonApiKey=Lvnq9CYXN5oYoiToWGkN,loginBaseURL=http://localhost:8080/rest/default/nwind/v1/nw%3AEmployees,loginGroupURL=http://localhost:8080/rest/default/nwind/v1/nw%3ARegion --comments Uses NW Employees for REST Validation liveapicreatoradmin authprovider import --file nw/nw_authprovider.json liveapicreatoradmin authprovider linkProject --name RESTAuthSecurityProviderCreateJS Echo 'Rules [optional] project import contains all rules' liveapicreatoradmin rule list --verbose # 'liveapicreatoradmin rule import --file nw/rules.json Echo 'Resources [optional] - project import contains all resources' liveapicreatoradmin resource list #'liveapicreatoradmin resource import --file nw/resources.json Echo 'close connections' liveapicreatoradmin logout -a localqa



Subpages (1): DevOps