To allow programmers to write RPG programs which will act as API we had to create Aperio Backend layer. This is a simple new library (IAF100AP) which should be included in RPG projects. This new library plays two roles in the API landscape:
The typical installation of Aperio Backend (IAF100AP) is to just put it on IBM i and set up the system so that this new library is available during compilation and runtime of RPG programs . Library IAF100AP must be on the library list.
To standardize communication between API Bridge and IBM i we established IADF (Iptor API Data format). We agreed that RPG programs will communicate with API Bridge in a special way. It will exchange JSON strings. Incoming JSON string has the following structure:
{
"control":{...},
"params:"{...}
}
It contains two sections (objects):
example:
{
"control":{
"program": "MGRR001",
"openCrossRef": true,
"limit": 15
},
"params": {
"warehouse": "BRI",
"item": "TEST-ITEM01"
}
}
The example above showss how the incoming json may look like if you want to run MGRR001 RPG program with parameters Warehouse=BRI and item=TEST-ITEM01. It also tells that response should be limited to 15 rows only, and Aperio should open cross reference files before calling MGRR001.
The response from RPG program is also standardized and transferred to API Bridge as json:
{
"control":{...},
"data":{...},
"messages":[...],
"error":{...}
}
It contains up to 4 sections (objects).
To help programmer to write RPG program and to keep standard communication with API Bridge, a set of procedures were prepared in Aperio backend. Here You can find the reference list of these procedures.
The instalation routine you can find here.
The configuration can be divided into 3 sections:
Mainly Aperio Backend is delivered as one library (IAF100AP). The easiest way to configure Aperio is to just restore this library and place in the library list. In DC1 we achieve it by using Additional products. Aperio Backend library contains set or programs/service-programs which are used do develop RPG API. Additionally, Aperio Backend keeps information about RPG API programs. This information is kept in files. If your environment is simple, you don’t need to do more about it. But in case you have on the same machine (IBM i) a Production company, a Test company and Development company then you probably need to differentiate information about API. Some API are available on development and some only on production. More complex situation is when in the same IBM i you have many customers (multitenant instalation). Then definitely there is a need to differentiate Aperio data. In this case, when Aperio Backend is initialized you can decide to initialize extra library for Aperio Backend Data. For example: CUSTADTA. Then this library must be placed above IAF100AP on the library list.
Library list on IBM i for customer A
...
CUSTADATA
IAF100AP
Library list on IBM i for customer B
...
CUSTBDATA
IAF100AP
Libraries CUSTADATA and CUSTBDATA will contain (metadata, control, config and notification) data, where IAF100AP will contain Aperio Backend programs. If you log in to customer environment company you should see correct library list. Additionaly if you see screen for command WRKAPIMTH then press F8 - you should see that the framework is located in IAF100AP and the data is located in sepearte library.
In prevous chapter it was described that Aperio data can be kept in a separate library. Depending if you want to differentiate configuration per companies/customers or you want to keep it simple the same for all tenants, you can choose model with one or many libraries. To see which library is used to store the config information, type WRKAPIMTH on IBM i command line (5250) adn then press F8. See where the config is located. To maintain config type use command WRKAPIMTH and press F7. There are two sections:
The detailed information about Aperio backend config you can find here. The detail information about exit point you can find here.
This chapter describes how to configure API Bridge to reflect library list on IBM i. The “environment” section of the configuration of API Bridge sets the initial library list. In simple installation at the end of the initial library list there is IAF100AP (see bellow).
Simple example of API Bridge configuration
{
"environment": {
"libraryList":"A120ENV,DEV121AS,DEV121AP,A120AP,IAF100AP",
"serviceProgram": "IAFS0001",
"initMethod": "environment.init",
"parameters": {
"environmentBaseLibrary":"A120ENV",
"environmentId":"DEV121A"
}
},
...
}
What are more complex situations?
In case if on one IBM i you have multiple companies for one customer, and Aperio Backend data has separate libraries per company. Then the best solution is to put Aperio Backend Data library associated to production also on the initial library list.
Example: Customer has 3 companies:
In this case the best would be to put SUCTDATAPR on the initial library list for API Bridge
{
"environment": {
"libraryList":"A120ENV,DEV121AS,DEV121AP,A120AP,CUSTDATAPR,IAF100AP",
"serviceProgram": "IAFS0001",
"initMethod": "environment.init",
"parameters": {
"environmentBaseLibrary":"A120ENV",
"environmentId":"DEV121A"
}
},
...
}
There is also a possibility to put only IAF100AP on the initial library list without customer specific data library. In this case, you have to make sure that you have the definition of the following APIs in IAF100AP. To check it, go to 5250 and remove customer specific data library from the library list (leave only IAF100AP) and run command WRKAPIMTH. Press F8 and make sure your current metadata is located in IAF100AP. Then make sure that the following APIs are defined in IAF100AP library. If something is missing you can add it manually. These methods/programs are important to initialize job on IBM i.
API method | SQ | Program |
---|---|---|
environment.init | 9 | MGRR0108 |
environmentCompanies.get | 9 | MGRR0100 |
api.init | 99 | IAFR0227 |
apiCommonParameters.get | 99 | IAFR0240 |
apiFrameworkStatistics.get | 99 | IAFR0213 |
apiMetadataInfo.get | 99 | IAFR0214 |
apiMethod.get | 99 | IAFR0229 |
apiMethodAttributeTypes.get | 99 | IAFR0237 |
apiMethods.get | 99 | IAFR0228 |
apiSettings.get | 99 | IAFR0215 |
apiSubsets.get | 99 | IAFR0238 |
apiUserProfile.get | 99 | IAFR0246 |
appNotification.add | 99 | IAFR0221 |
appNotification.delete | 99 | IAFR0220 |
appNotification.get | 99 | IAFR0219 |
appNotification.update | 99 | IAFR0222 |
appNotifications.get | 99 | IAFR0218 |
appNotificationServer.add | 99 | IAFR0225 |
appNotificationServer.delete | 99 | IAFR0226 |
appNotificationServers.get | 99 | IAFR0224 |
appNotificationServers.notify | 99 | IAFR0223 |
extApiService.add | 99 | IAFR0241 |
extApiService.delete | 99 | IAFR0243 |
extApiService.get | 99 | IAFR0244 |
extApiService.update | 99 | IAFR0242 |
extApiServices.get | 99 | IAFR0245 |
systemSettings.get | 99 | IAFR0216 |