Skip to content

MDRest4i Commands

MDRCBLCPY - Create COBOL Copybook

Creates a COBOL copybook with schemas used by MDR_DATA-GEN and MDR-DATA-INTO functions from MDRFRAME. See here for details of this command and its purpose.


MDRHTTPAPI - Create API Server

To setup your own HTTP instances for development or production purposes, then prompt the MDRHTTPAPI command. The following screen will appear:

                    MDRest4i Create SDK Server (MDRHTTPAPI)                   

Type choices, press Enter.                                                    

HTTP Server Name . . . . . . . .   MDRSTAPI      Instance Name                
HTTP Instance Root Path  . . . .   '/www/mdrstapi'                            
Port Number  . . . . . . . . . .   4546          TCP Port Number for Server   
Program ASP  . . . . . . . . . .                 Leave blank for *SYSBASE     
API Library Name/s . . . . . . .   YOURAPILIB    List of API Object Libs      
               + for more values                                              
Authority Profile  . . . . . . .   MDOWNER       Character value              
Start TCP/IP Server  . . . . . .   Y             Y, N                         

                                                                        Bottom
F3=Exit   F4=Prompt   F5=Refresh   F12=Cancel   F13=How to use this display   
F24=More keys                                                                 

Parameter Definitions:

Parameter Description
HTTP Server Name Name of the HTTP server instance
HTTP Instance Root Path Specify the value of IFS path used to store docs for this HTTP instance.
For example, if server name is MDRDEMO then the value of Server Root parameter could be: /www/mdrdemo. It is easier to name them the same for auditing and admin purposes.
Port Number Port Number for the HTTP Server (default value is 80)
Please check with your networking, infrastructure admin if allocating a port other than 80.
Also check if the port you are using is not already in use on the LPAR you are hosting the server instance being setup.
Program ASP System ASP where the MDRST instance is installed.
API Library Name/s Name the library that contains the API programs generated by MDRest4i SDK.
Authority Profile This profile used to execute the CGI APIs and system APIs used when running REST CGi programs. By Default this is set as MDOWNER which was created during the MDREST4INS installation earlier.
Start TCP/IP Server Start the new HTTP server instance. This will start the instance after it is setup by the command.
To start the server manually later use command below (Considering the Server Name as MDRSTAPI) :
STRTCPSVR SERVER(*HTTP) HTTPSVR(MDRSTAPI)

Once the command has successfully executed, you can see the HTTP server instance configuration stored in IFS path using below command (Considering the Server Root as “/www/mdrstapi):

Wrklnk '/www/mdrstapi/conf/httpd.conf'

To see the active jobs running for this server instance use this command on the IBM i:

WRKACTJOB SBS(QHTTPSVR) JOB(MDRSTAPI)

Where “MDRSTAPI” is the server name from the MDRHTTPAPI command above

Testing the API Server

Tip

If this is a first time installation, conduct these tests after the license installation.

Using a web browser, test the Helloworld REST API shipped with the MDREST4i product and found in library MDRST:

http://[your serverip or host]:[yourport]/mdrapi/mdrhello?firstName=Mike&lastName=Smith&Title=Mr

You should see the following response in the browser:

The JSON response from the helloworld API


MDRRHTTP - Maintain HTTP Servers

This command allows a user to mange the variosu aspects of IBM i Apache HTTP Server instances, created with commands MDRSDKINS, MDRHTTPAPI.

Command MDRRHTTP
MDRRHTTP                          MDRSTT14                         5.08.24    
                     MDRRHTTP - Maintain HTTP Servers             16:12:53    

  Type options, press Enter.                                                  
   2=Edit   4=Delete   5=View   6=Start   7=Stop   9=Stats   L=Logs   J=JobD  

Opt  Server Name  PortNo  Status       Started                JobD            
___  MDRSTT14     2514    *ACTIVE      2024-02-26-18.02.21    MDRSTT14        
___  MDRSTT14A    2515    *STOPPED     2024-05-28-17.16.50    MDRSTT14A       
___  STUART13     2593    *ACTIVE      2024-04-05-15.24.10    STUART13        
___  MDWEB        2566    *ACTIVE      2024-05-29-10.43.40    MDWEB           
___  MDVISRASHI   2599    *STOPPED     2024-07-22-12.50.14    MDVISRASHI              

                                                                        Bottom

 F6=Add Server     F3=Exit      F5=Refresh                                    

Options

Option Description
2=Edit This updates the data in the MDRST/MDRDHTTP table, and if requested, the server instance httpd.conf.
Edit
4=Delete Deletes the server instance. Also deletes the file server ifs folder if selected on the conformation screen.
delete
5=View Displays the server instance details
view
6=Start Start the server instance
7=Stop Stop the server instance
9=Stats If the server is active, it displays basic statistics since the the last start of the server.
stats
L=Logs Opens the ifs folder for the HTTP server instance, as defined in the httpd.conf for that instance
J=JobD Opens Work with Job Descriptions IBM i screen for the Job Description defined for that server. See the HTTPStartJobDesc MDRSTT14/MDRSTT14 directive in the httpd.conf for that server.

MDRSDKINS - Install MDRest4i SDK

Details for this command are in the SDK installation page:

MDRSDKINS


MDRSDKTEMP - Init JSON Templates

This command is used to reset the SWAGGER/OAPI templates used by the SDK when creating a new Consumer or Provider specification, back to their shipped state.


MDRSDKUPD - Updating the SDK Web Application

Warning

To run this command, the MDRest4i SDK web application must be already installed for this instance. Run command MDRSDKINS to install the SDK web application

The MDRSDKUPD command has no parameters. It only executes if the SDK has already been installed. It backs up the existing config files for the MDRest4i SDK web UI, installs the new code base, and copies back the SDK web UI config files.

The SDK web UI is backed up to IFS folder: /mdrest4i/sdkbu-mdrst

Note

The backup path is based uon the instance name for MDRest4i. If the MDRest4i instance is 'V14' for example, the backup folder for te SDK update will be: /mdrest4i/sdkbu-mdrst

To run the command:

  • ADDLIBLE MDRST
  • MDRSDKUPD command and enter

MDRSDKUSR - Add/Update SDK User

This command is an alternative to the Site Admin>manage Users option in the SDK web UI.

                    MDRest4i- Add/Update SDK User (MDRSDKUSR)                   

 Type choices, press Enter.                                                     

 User Name  . . . . . . . . . . .                 Name                          
 Name . . . . . . . . . . . . . .   'REST4i USER'                               

 Email address  . . . . . . . . .   'youremail@yourdomain.com'                  
 Domain Name  . . . . . . . . . .   CONS          Name                          
 User Class . . . . . . . . . . .   ADM                                         
 Activated  . . . . . . . . . . .   Y             Y, N
 Default Object Library . . . . .   'YOURAPILIB'______________________
 _____________________________________________________________________
                                                                     ...
 Default Source file  . . . . . .   '/QSYS.LIB/MDRST.LIB/EXAMPLE.FILE'
 _____________________________________________________________________
                                                                     ...
 Default Server URL . . . . . . .   'http://yourhost:yourport/yourlib'___
Variable Description
USERNAME A valid IBM i user name.
NAME User's actual name
EMAIL User's email address
DOMAIN Valid Values:
CONS for Console and Documenter
DOCU for MDRest4i Portal ONLY
ACTIVATED Users must be activated before they can login. Valid values are Y or N
DFTOBJL Specify the default object library to use for new OAPI specs.
DFTSRCF Specify the default source file to use for new OAPI specs.
DFTURL Specify the default testing URL to use for new OAPI specs.

MDRSTCFG - API configuration

MDRDCFG is a DB 2 table that holds the configuration details of API programs called by MDRAPI. It can be edited programmatically, by using command: MDRST/MDRSTCFG, or by MDCMS Data Group attributes.

It controls the following for each API program(Provider) called by MDRAPI:

  • URI resource name to pgm object mapping
  • Logging

To edit details in this file, invoke command MDRST/MDRSCFG

MDRSTCFG List
                       Edit MDRest4i Provider Configs                        

  2=Edit   4=Delete                                                          
                                                                    Logging  
  Opt  Root Resource                                             IFS  DTQ  PF
       /CLIENTS                                                   Y    N    N

                                                                       Bottom

F3=Exit F5=Refresh F6=Add 

Selecting 2 to edit will bring up the following screen:

MDRSTCFG Edit Screen
                                 Edit Config                             

      Root Resource:  /CLIENTS                                           

            Program:  PGM001                                             

            Library:                                                     

       Log to (Y/N):  IFS: Y                DATAQ: N               PF: N 

           Log Name:                                                     
                  IFS: /mylogs/pgm001-%F.txt                             
                DATAQ:                                                   
                   PF:                                                   

  Log Details (Y/N):       For Request               For Response        
                 Path:           Y                                       
              Headers:           Y                         Y             
                 Body:           Y                         Y             

F12=Cancel                                                               
Variable Description
Root Resource This is user friendly resource name used to invoke the API. MDRAPI will resolve this and call the Program below
Program Name of the API program called by MDRAPI
Library Library name used in the call. No value will cause MDRAPI to use *LIBL to make the call
Log to Possible values: Y or N.
There are three logging mechanisms that MDREst4i MDRFRAME provides for a REST Provider. Each option will causes MDRAPI create a log using the details in the relevant Log Name below:
IFS - Creates a log file in the IFS
DATAQ - Creates a log in a DATAQ.
Log Name IFS The format of these is as follows:
/folder/subfolder/file-%F.txt
The "%F" is substitute syntax handled by the MDRFRAME framework when creating the file. It is used to set date and time stamp values in the name. So the above example would look like this:
/folder/subfolder/file-2024-02-11.txt
for full detaisl on logging name options see LOGFILEOPTS
Log Name DATAQ Use format LIBNAME/DTAQNAME. This creates a DATAQ of the specified library/name, and writes log entries to it.
Log Name PF The format of these is LIBNAME/PFNAME. This makes a copy of MDRST/MDRLOGS into the LIBNAME/PFNAME specified, and logs requests there each time this Provider program is called
Log Details These values specify the content that will appear in the log