i2Rest Session Processing Program

From i2Rest
Jump to: navigation, search

As mentioned at i2Rest Server Architecture, each request to API will be routed to separate job called Session.

In most cases, Session will be running on the local IBM i server, and SBMJOB command will be used as submit session command. But it is not necessary - you can start Sessions on remote IBM i server using SBMRMTJOB command, or even on other platforms, for example with STRPCCMD or RUNRMTCMD commands. In any case, session processing program in the submitted job should communicate with i2Rest Server session gate according specific internal protocol. If you are interested in details - please contact us.

i2Rest installation contains default session processing program for SBMJOB and SBMRMTJOB commands. This program is located in installation library and has name I2REST.

Session processing program I2REST can be used in session submit command with following parameters:

Parameter Description Default value
-session REQUIRED. It should be the first parameter in parameter list
-url <session_gate_url> REQUIRED. Should contain URL of Session Gate to communicate with i2Rest Server instance

It recommended to use special value ${surl} here. i2Rest Server will substitute this special value with real URL of its Session Gate before submitting session

-uid <session_id> REQUIRED. Unique ID of this session

Session ID will be assigned to session by the server, it is required to use special value ${uid} here

-user <user_id> User ID

If passed, session job will save this user ID into character data area QTEMP/I2RESTUSR (512 bytes length). You can use some specific user profile or special value ${user} here. i2Rest Server will substitute ${user} with real User ID that tries to start new session. API processing programs can read this value and use it for their own purposes. As an option, you can pass -swap_to_user parameter (see below)

-swap_to_user Swap to user?

If passed, session job will try to swap user authority with user defined in -user parameter. The user that started i2Rest Server instance must have *USE authority to this user profile.

Not set. All session jobs will run under the authority of user that started i2Rest Server instance
-scopes <scopes> List of scopes

If passed, session job will save the list of scopes into character data area QTEMP/I2RESTSCP (512 bytes length). You can use some defined scopes list or special value ${scopes} here. i2Rest Server will substitute ${scopes} with real scopes list that was used during access token creation. API processing programs can read this value and use it for their own purposes

-init <initial_command> Can define initial command to be run in submitted session. I2REST will automatically run this command on job startup
-dcm_client_id <dcm_client_id> DCM Client Application ID for secured connections

It is required to pass this parameter whenever you want to use secured communications between Session and Session Gate.

Example:

"session_systems":
[
...
   {
      "name": "*LOCAL",
      "submit": SBMJOB JOB(I2RESTS) USER(${user})
                   CMD(CALL I2REST PARM(
                      '-session'
                      '-url' '${surl}'
                      '-uid' '${uid}'
                      '-user' '${user}'
                      '-swap_to_user'
                      '-scopes' '${scopes}'
                      '-init' 'ADDLIBLE I2REST'))
                      '-dcm_client_id' 'MYCLIENT'))"
   },
...