API Creation by Command Line

API Creation by Command Line
lac31
You can interact with your API using the
CA Live API Creator
 Admin command line interface (Admin CLI),
liveapicreatoradmin
(or the alias 
lacadmin
). You can script the creation and deployment of you APIs using the Admin CLI.
For example, you can:
  • Promote a development project to production.
  • Move source control system artifacts into production.
Your scripts can deal with other elements of your DevOps environment.
For more information about the Admin CLI, including how to install the Admin CLI, how to access the Admin CLI help, and viewing a sample export and import script, see the npm site.
The following script creates the Business to Business (B2B) sample:
(Windows version):
REM import Script for Northwind-B2B Jetty
echo on
REM Logon to local Jetty server (if using a WAR file use http://localhost:8080/APIServer)
call liveapicreatoradmin logout -a local
call liveapicreatoradmin login -u admin -p Password1 http://localhost:8080/ -a local
call liveapicreatoradmin use local
call liveapicreatoradmin status
 
REM Import the Northwind B2B Project, and 'use' it in subsequent commands
call liveapicreatoradmin project import --file Northwind-B2B.json
call liveapicreatoradmin project use --url_name nwindb2b
call iveapicreatoradmin project update --authprovider 1000
 
REM Create the AuthProvider library.
call liveapicreatoradmin libraries create --name RESTAuthSecurityProviderCreate project --short_name restauth --libtype javascript --ver 1.0 --linkProject --file RESTAuthSecurityProvider.js --comments RESTAuthProvider js Demo
 
REM Create a new library (postResourceTo.js), and link it to the current project
call liveapicreatoradmin libraries create --name postResourceToJS --short_name postjs --linkProject --libtype javascript --ver 1.0 --file postResourceTo.js --comments postResourceTo
call liveapicreatoradmin libraries list
 
REM Data Sources [optional] for other databases - set the password
call liveapicreatoradmin datasource list
REM call liveapicreatoradmin datasource update --prefix nw --password password1 -- Jetty does not use pw
 
REM Auth Providers - link Auth Provider to the current project, using the library loaded above
call liveapicreatoradmin authprovider list
call liveapicreatoradmin authprovider create --name RESTAuthSecurityProviderCreateJS --createFunction RESTAuthSecurityProviderCreate --paramMap logonApiKey=Bzn8jVyfOTiIpW6UQCgy,loginBaseURL=http://localhost:8080/rest/default/nwindb2b/v1/nw%3AEmployees,loginGroupURL=http://localhost:8080/rest/default/nwindb2b/v1/nw%3ARegion --comments 'Uses NW Employees for REST Validation'
call liveapicreatoradmin authprovider linkProject --name RESTAuthSecurityProviderCreateJS
 
REM Import the Pavlov API project
call liveapicreatoradmin project import --file PavlovAPI.json
call liveapicreatoradmin project list
call liveapicreatoradmin project update -authprovider 1000
 
REM close connections
call liveapicreatoradmin logout -a local
(Mac version):
#! /bin/bash
# import Script for Northwind-B2B Jetty#
# Logon to local Jetty server (if using a WAR file use http://localhost:8080/APIServer)
liveapicreatoradmin logout -a local
liveapicreatoradmin login -u admin -p Password1 http://localhost:8080/ -a local
liveapicreatoradmin use local
liveapicreatoradmin status
 
# Import the Northwind B2B Project, and 'use' it in subsequent commands
liveapicreatoradmin project import --file Northwind-B2B.json
liveapicreatoradmin project use --url_name nwindb2b
 
# Create the AuthProvider library.
liveapicreatoradmin libraries create --name RESTAuthSecurityProviderCreate project --short_name restauth --libtype javascript --ver 1.0 --linkProject --file RESTAuthSecurityProvider.js --comments RESTAuthProvider js Demo
 
# Create a new library (postResourceTo.js), and link it to the current project
liveapicreatoradmin libraries create --name postResourceToJS --short_name postjs --linkProject --libtype javascript --ver 1.0 --file postResourceTo.js --comments postResourceTo
liveapicreatoradmin libraries list
 
# Data Sources [optional] for other databases - set the password
liveapicreatoradmin datasource list#
liveapicreatoradmin datasource update --prefix nw --password password1 -- Jetty does not use pw
 
# Auth Providers - link Auth Provider to the current project, using the library loaded above
liveapicreatoradmin authprovider list
liveapicreatoradmin authprovider create --name RESTAuthSecurityProviderCreateJS --createFunction RESTAuthSecurityProviderCreate --paramMap logonApiKey=Bzn8jVyfOTiIpW6UQCgy,loginBaseURL=http://localhost:8080/rest/default/nwindb2b/v1/nw%3AEmployees,loginGroupURL=http://localhost:8080/rest/default/nwindb2b/v1/nw%3ARegion --comments 'Uses NW Employees for REST Validation'
liveapicreatoradmin authprovider linkProject --name RESTAuthSecurityProviderCreateJS
 
# Import the Pavlov API project
liveapicreatoradmin project import --file PavlovAPI.json
liveapicreatoradmin project list
 
# close connections
liveapicreatoradmin logout -a local
For more information: