This tutorial will guide you in creating and uploading a check which utilizes ADR .to pull data from the Apica ADR Rest API Plugin, which
The ADR check you will create pulls a username and password to perform a dummy login to https://the-internet.herokuapp.com/login. The credentials are listed right on the page of the site, which makes clear it is intended for test purposes only. The site stores no data and needs no personalized credentials whatsoever. However, it gives a “success” message upon successful login with the dummy credentials which is all we need.
The .prxdat for the script can be found herezip file and inline script which can be used when following this tutorial is attached:
View file | ||
---|---|---|
|
...
|
View file | ||
---|---|---|
|
Step | Screenshot/Notes |
---|---|
Step 1 |
Go to “Personal Settings” in your ZT instance and add the following details to “Apica Table Server API Configuration”. Make sure the checkbox next to the box heading is checked:
This setting will use HTTP to connect to {hostname}.apica.local. Use the hostname of the server on which ADR is installed. The table you will be pulling from is, of course, hosted on this server.
: Populate ADR |
With the |
Necessary DataYou will need a login to the ADR instance if you want to populate the ADR instance with your own tables/data. |
For purposes of the demo, you can use the test table specified in the script using the |
API plugin. | |
Step |
2: |
There are various ways to CRUD (create/read/update/delete) to ADR, including but not limited to utilization of the ADR REST API script and/or inline script usage. The easiest way to start is with inline script usage so that is what we implemented in the test script.
Create a script using an inline script or the ZT REST API plugin if you need to utilize the API for usage beyond what the inline scripts allow.
Note |
---|
ZT REST API plugin implementation is an advanced implementation which should be performed by Professional Services. The REST API plugin provides functionality beyond what the inline scripts offer |
Info |
---|
ADR REST API plugin implementation will not be covered here as it is beyond the scope of this article. |
You can find a guide to inline scripts in the Inline Script editor of ZT itself and also in the ADR user manual. You can find the inline script we used here:
View file | ||
---|---|---|
|
Step 4: Compile the script to allow communication with ADR
Compile the script as usual and make sure “Apply Apica Table Server API configuration from Personal Settings” is checked.
Step 5: Create the check with specialized settings
Specify the .class name within the check settings:
This will allow the check to run the pre-compiled .class file (with the ATS Server settings specified)
You will need additional settings, such as “-ats-server-name”, specified if you are using the REST API plugin. See the documentation which was bundled with ADR for more details.
Note |
---|
You MUST select a location for the check which has access to the ADR server you specified earlier! As such, a script which utilizes ADR must be run on a private agent which can successfully connect to your ADR server. Otherwise the check will not run. |
Step 6: Provide the .class file to Apica for Uploading
Submit a request to Support mentioning the purpose of the .class file and have them upload the .class file into your checkAdd the REST API Plugin to Your ScriptFirst, you must add the ADRRestApiPlugin.class to your Plugins directory and then pull it into your script using the “Add Plug-in” button in the Var Handler. Before you upload the plugin, you must specify table name, API call to be used, etc. These will be converted into variables within the Var Finder as User Input Variables. Adding the parameters as User Input Variables is helpful because it allows users to change parameters at runtime as needed. There will be an option to export the output of the API call as a variable. You must do this! The API Plugin simply executes an API call and returns the JSON as an output variable so you must save the output as “jsonResponse” or similar. | |||
Step 3: Add an Inline Script to Process Data Returned From ADR CallNext, you need to create and add an inline script which will process the data returned from the REST API plugin. We’ve included the inline script we used here. The inline script simply pulls the username and password stored in the table and sets the username and password to those returned values. Add the inline script via the “Add Inline Script” button above and configure the input/output variables to take the jsonResponse variable as the input and return the username and password variables as the output. See screenshot 1 to the right. Assign the username and password variables you extracted to the “username” and “password” variables in the script. See screenshot 2 to the right.
| |||
Step 4: Create the Check With Specialized SettingsYou will need to upload the .zip file and then specify any arguments you pass in as user input in “additional arguments”. These are the user inputs in the test check linked above:
If you decide to set these user inputs (e.g. -ats_command as “standalone variables” rather than “user input fields” within the script, and thus hard-code the values, you will not need to pass them via additional options. |
After following these steps you should be able to run your ADR check successfully!