Difference between revisions of "Management API config"

From i2Rest
Jump to: navigation, search
Line 1: Line 1:
=Request authorization=
 
 
[[Management_APIs|Management APIs]] includes functions that can be used to do some management stuff - change runtime parameters, query current status of server instance, etc. OAuth2 token with management_functions scope is required for any management Api call.
 
[[Management_APIs|Management APIs]] includes functions that can be used to do some management stuff - change runtime parameters, query current status of server instance, etc. OAuth2 token with management_functions scope is required for any management Api call.
  
 
;Step 1
 
;Step 1
:Create text file named I2RESTECHO.PCML anywhere on IFS, for example "/tmp/PCML/i2restecho.pcml". Copy and paste following code. It represents a description for the sample program I2RESTECHO, that is included into i2Rest Server installation for demonstration purposes:
+
:Register two users on IBM i.
<pre>
 
<pcml version="1.0">
 
 
 
  <program name="echo" path="/QSYS.LIB/%LIBL%.LIB/I2RESTECHO.PGM">
 
      <data name="echo" usage="inputoutput" type="char" length="10" trim="both"/>
 
  </program>
 
 
 
</pcml>
 
</pre>
 
 
 
 
;Step 2
 
;Step 2
:Contact your system administrator for your IBM i server host name (or IP) and ''two'' available ports for "main" and "management" gates of your first i2Rest Server instance. Create file config.json (you can name it with any name and put it into any available IFS folder). Enter following text, replace host_name, ports and pcml_file with appropriate values.<bt>
+
:Contact your system administrator for your IBM i server host name (or IP) and ''two'' available ports for "main" and "management" gates of your first i2Rest Server instance. Create file config.json (you can name it with any name and put it into any available IFS folder). Enter following text, replace host_name, ports, user (must be a regestered IBM i user) and client (must be a regestered IBM i user) with appropriate values.<bt>
 
[[I2Rest_quick_config|Basic configuration]] management API variant (differences are highlighted in <span style="background:#00FFFF;">blue</span>):
 
[[I2Rest_quick_config|Basic configuration]] management API variant (differences are highlighted in <span style="background:#00FFFF;">blue</span>):
  
Line 37: Line 26:
 
       }
 
       }
 
     ],
 
     ],
     "pcmls":
+
     <span style="background:#00FFFF;">
    [
 
      {
 
          "pcml_mount"        : "echo",
 
          "pcml_file"          : "<span style="color:red;"><complete name of i2restecho.pcml on IFS (for example /tmp/PCML/i2restecho.pcml)></span>",
 
          "valid_in_anonymous" : true
 
      }
 
    ]<span style="background:#00FFFF;">,
 
 
     "OAuth2":
 
     "OAuth2":
 
     {
 
     {
Line 65: Line 47:
 
==Мanagement API call==
 
==Мanagement API call==
 
So, what you have to do before we can test Мanagement API call to i2Rest Server:
 
So, what you have to do before we can test Мanagement API call to i2Rest Server:
:a) Register two users on IBM i - one for a "сlient" parameter and one for a "user" parameter.
+
:a)  
 
:b) Fill the [[I2Rest_Advanced_Setup#Oauth2_obj_template|OAuth2 object template]] above with IBM i users values. Then add the snippet to your [[I2Rest_quick_config|basic server configuration]](with or without ssl protection) and put your new *.json anywhere on IBM i IFS.
 
:b) Fill the [[I2Rest_Advanced_Setup#Oauth2_obj_template|OAuth2 object template]] above with IBM i users values. Then add the snippet to your [[I2Rest_quick_config|basic server configuration]](with or without ssl protection) and put your new *.json anywhere on IBM i IFS.
 
:c) Restart server to apply your new configuration *.json.     
 
:c) Restart server to apply your new configuration *.json.     
 
Now let's test the configuration obtaining [[Auth_profile_SoapUI|Oauth2 token with SoapUI]], and than proceed to [[Manage_API_SoapUI|Management api authorized call]].
 
Now let's test the configuration obtaining [[Auth_profile_SoapUI|Oauth2 token with SoapUI]], and than proceed to [[Manage_API_SoapUI|Management api authorized call]].

Revision as of 17:26, 29 June 2020

Management APIs includes functions that can be used to do some management stuff - change runtime parameters, query current status of server instance, etc. OAuth2 token with management_functions scope is required for any management Api call.

Step 1
Register two users on IBM i.
Step 2
Contact your system administrator for your IBM i server host name (or IP) and two available ports for "main" and "management" gates of your first i2Rest Server instance. Create file config.json (you can name it with any name and put it into any available IFS folder). Enter following text, replace host_name, ports, user (must be a regestered IBM i user) and client (must be a regestered IBM i user) with appropriate values.<bt>

Basic configuration management API variant (differences are highlighted in blue):

{
   "gates":
   {
      "main"       : {"url":"http://<host_name>[:port] (for example api.i2rest.com:1234)"},
      "management" : {"url":"http://<host_name>[:port] (for example api.i2rest.com:4321)"}
   },
   "session_systems":
   [
      {  "name"   : "*ANONYMOUS", 
         "submit" : "SBMJOB JOB(I2RESTA)                \
                            USER(${user})               \
                            CMD(CALL I2REST             \
                               PARM('-session'          \
                                    '-url' '${surl}'    \
                                    '-uid' '${uid}'     \
                                    '-user' '${user}')) \
                            INLLIBL(I2REST)"
      }
   ],
   
   "OAuth2":
   {
     "scopes": {"management_functions" : {"description":"i2Rest management APIs call"}
     },
     "users":
     {
        "USRX":{"description":"John Johnes","valid_clients":{"TSTCLNT":{"scopes":["management_functions"]}}}
     },
     "clients":
     {
        "TSTCLNT":{"redirect_uri":"<main gate URL>/oauth2/redirect", 
                   "description":"Test client", 
                   "valid_scopes":["management_functions"],
                   "valid_grant_types":["authorization_code"]}
     },
     "tokens": {"type":"token"},"codes":{"type":"code"}
   } 
}

Мanagement API call

So, what you have to do before we can test Мanagement API call to i2Rest Server:

a)
b) Fill the OAuth2 object template above with IBM i users values. Then add the snippet to your basic server configuration(with or without ssl protection) and put your new *.json anywhere on IBM i IFS.
c) Restart server to apply your new configuration *.json.

Now let's test the configuration obtaining Oauth2 token with SoapUI, and than proceed to Management api authorized call.