Extensibility
Extensibility
calac41
CA Live API Creator
complements automation with provisions for extending:3
Logic
You can enhance and extend system automation for update and retrieval logic by defining rules that can invoke JavaScript.
CA Live API Creator
applies table-based logic to updates on the table and to updates to the resources that you explicitly define over the table. Underlying these extensibility services is the JavaScript object model that CA Live API Creator
creates from your schema. You specify the logic for event rules, formula rules, and validation rules in JavaScript.JavaScript provides access to the following:
- Other JavaScript or Java logic running in the Java Virtual Machine (JVM), by way of Java or JavaScript libraries.
- External services, by way of REST, Simple Object Access Protocol (SOAP), etc.
The JavaScript code that you write in API Creator runs on your servers. It has access to most of the resources on those servers, such as files and network interfaces. To limit the resources to which your code has access, install
CA Live API Creator
running in a container, such as Docker.If you have multiple TeamSpaces defined with APIs running in these TeamSpaces, the JavaScript code that you write in an API in API Creator can affect the performance of the APIs that are running in other TeamSpaces.
For more information:
- About the JavaScript object model, including persistence-enabled row objects, see Row Objects.
- About the extensibility services, see Quick Reference.
Code Insertion Points
CA Live API Creator
fires rules in an order that reflects their dependencies. This order changes as you alter rules and, therefore, affect their dependencies. By contrast, CA Live API Creator
fires events at designated points in the request-processing cycle, as illustrated in the following image:
Custom Endpoints
While you define most RESTful endpoints as resources (tables, views, and stored procedures) or functions, you can build services, perhaps unrelated to your database objects, by adding custom endpoints. For example, you can add a custom endpoint that returns JSON or HTML responses or that returns results directly to the client.
For more information about how to determine which endpoint type to define for your API, see Customize your API.
Event Handlers
CA Live API Creator
invokes event handlers before resource and logic processing begin. You can reformat the response message or the request information or you can log the requests.For more information about event handlers, see Event Handlers.
JavaScript Resources
Automated SQL operations typically retrieve resources. Instead, you can create a JavaScript resource that
CA Live API Creator
executes whenever an API user accesses the resource and returns JSON. You can materialize data using JavaScript, for example, by invoking REST services to build a request that integrates data from other systems.For more information about how to create a JavaScript resource, see Define JavaScript Resource Types.
Resource Row Event
CA Live API Creator
invokes resource row events as it retrieves rows. For example, add attributes or filter the row. You can inject new attributes or remove attributes or even make REST calls and append results.For more information about resource row events, see Resource Row Events.
Row Logic Events
CA Live API Creator
invokes event rules with the current/old rows and the current verb on POST, PUT and DELETE operations. They can operate on the row, the results of which CA Live API Creator
subjects to reactive logic.For more information:
- About how to create event rules, see Event Rule Types.
- About viewing an example of events, see Business to Business Example.
You can view an example of the JavaScript code for an event in the
Demo
API. Open the Audit Purchase Order amount changes
event.Invoke JavaScript from Reactive Logic
You specify JavaScript methods for reactive formula and validation expressions. You can access Java code from JavaScript. In the most common case, these are simple expression such as
row.price * row.quantity
. CA Live API Creator
analyzes your JavaScript for dependencies to provide proper ordering.You can build conditional logic or invoke standard functions such as date arithmetic using JavaScript. You can perform complex processing or invoke other SOA services or re-usable Java/JavaScript methods.
CA Live API Creator
analyzes the logic for dependencies which are reflected in proper execution order.For more information:
- About howCA Live API Creatorhandles ordering and creates JavaScript rows for each base table, see Declare your Logic.
- About how to create a formula rule, Formula Rule Type.
- About how to specify validation using JavaScript, see Validation Rule Type.
- About how to access Java code from JavaScript, see Logic Libraries.
Access JVM and Services
Whether you reach JavaScript by way of code insertion points, or reactive logic, you then have the flexibility to access code inside the JVM, or remotely available services.
You can also access Java code from JavaScript.
For more information about how to access Java code from JavaScript, see Logic Libraries.
The following diagram illustrates how server-side JavaScript addresses logic:

Supporting Services
The extension capabilities draw upon the following underlying API Server services:
- System variablesdefine system state, for example, for the request, logic operation, as well as useful methods.
- System classesprovide helper classes.
You can discover and use these underlying API Server services using code completion.
For more information about code completion, see Code Completion.
JavaScript Context Variables
Your code requires the following context variables that are set when
CA Live API Creator
invokes JavaScript logic:- Thereqobject. This variable provides access to the API request, such as the current user and the url parameters.For more information about this object, see The req Object.
- Row objects.A row is a JavaScript object representing the current row, with access to attributes and related data, and persistence (with logic enforcement).For more information about row objects, see Row Objects.
- ThelogicContextobject. Logic context makes visible key aspects of logic execution.For more information about this object, see The logicContext Object.
For more information about the JavaScript context variables that are set when JavaScript logic is invoked, see Quick Reference.
JavaScript System Classes
Your code requires the following JavaScript context variables to operate.
CA Live API Creator
initializes the following variables:- TheSysUtilityobject. You can invoke RESTful services from business logic or row events using the services this object provides, such as therestGet,restPut,restPost, andrestDeletemethods.For more information about this context variable, see The SysUtility Object.
- TheSysLogicobject. You also have access to logic services, such as theallocateFromTo()andInsertIntoFrom()methods.For more information about this context variable, see The SysLogic Object.
For more information:
- About a list of the system methods, see Rule Types.
- About the JavaScript context variables that are set when JavaScript logic is invoked, see Quick Reference.
- About row object behavior, see Customize your API.
Logic Libraries
JavaScript invocations typically provide the row and logic context for your programmatic access. In many cases, you will want to use libraries of existing functions, such as date routines. You can add libraries to your API.
For more information about logic libraries, see Logic Libraries.
Re-usable Rule Types
You can add new rule types to the core rules (such as formula, sum, and count, validation). You can define the parameters the rule types accept. API Creator uses extended rules by using the parameters. You can detect logic patterns and implement re-usable solutions to these using the extended rule types.
For more information about viewing an illustration of how the
InsertIntoFrom()
system method and allocation rules use this underlying technology, see allocateFromTo System Method.SQL Access
Your SQL operations are typically automated, but you can address more complex cases by overriding these defaults. You can define a Free SQL resource in API Creator.
For more information about how to define a Free SQL resource type, see Define Free SQL Resource Types.
Access SOAP Services
You can access SOAP services using Java libraries and return them as REST services in
CA Live API Creator
.For more information about viewing an example on how to expose SOAP endpoints and return them as REST responses using
CA Live API Creator
, see the LAC-SOAP2REST example on GitHub.Request Metadata
You can control processing at the request level. You can insert
@metadata
action tags to link child rows to parent rows, without the requirement for the client to supply autonum
identifiers (which they may not know) using services. You can designate that request rows can result in either an update of an existing row, or if not present, the insertion of a new row by using related services.For more information:
- About@metadataaction tags, see Complex Transaction Processing.
- About viewing an example of how to link child rows to parent rows using metadata tags, see the Business to Business Example.
- About the services you can use, such as thelogicContextobject and System Methods, see Quick Reference.
Admin Data Access
You can retrieve information about an API, such as the list of entities and resources and their attributes, rather than actual data, using the system REST endpoints.
CA Live API Creator
provides these endpoints as metadata services.For more information about how to retrieve information using these endpoints, see System REST Endpoints.
Customized Authentication
You can authorize API users using your existing security data, such as Lightweight Directory Access Protocol (LDAP), Microsoft Azure Active Directory (Azure AD), and OAuth, instead of requiring the user to reenter user lists that are maintained elsewhere. You can customize authentication by defining a custom authentication provider.
For more information about how to authenticate API users using a custom authentication provider, see Authentication Providers.