Below are a few basic REST API examples:
List nodes:
curl -i -u Admin:admin -X GET "http://172.16.31.20:8019/rest/v1/nodes"
List remote queue managers:
curl -i -u Admin:admin -X GET "http://172.16.31.20:8019/rest/v1/remote-qmgrs"
Add a remote QMGR:
curl -i -u Admin:admin -X POST "http://172.16.31.20:8019/rest/v1/remote-qmgrs" -H "Content-Type: application/json" -d "{\"managerName\":\"MQM\",\"nodeName\":\"DOCKER\",\"qmgrName\":\"TQM53\",\"general\":{\"connectUser\":\"nastel\",\"connectPassword\":\"Nastel@12345678\"},\"communication\":{\"connectionName\":\"172.16.31.121(1434)\",\"cmdQName\":\"SYSTEM.ADMIN.COMMAND.QUEUE\",\"channelName\":\"NAVIGATOR.SVRCONN\",\"cmdConvert\":\"No\"}}"
In this example we are adding a queue manager named TQM53, and a connection manager instance DOCKER.
Delete remote queue manager:
curl -i -u Admin:admin -X DELETE "http://172.16.31.20:8019/rest/v1/remote-qmgrs/DOCKER/TQM2"
In this example we are deleting a queue manager named TQM2 from the connection manager instance DOCKER.
REST API with Oauth2
Below is information on how to setup and utilize REST API with Oauth2.
Setup
- Enable OAuth2 Authentication in the workgroup server properties as seen below:
- Request a token. You will get two tokens, the access_token and refresh_token. You need to send access_token in the curl header. Send a command like the following to request a token:
curl -k -X POST "http://172.16.31.20:8019/auth/token" -H "accept: */*" -H "Content-Type: application/json" -d "{\"client_id\":\"nastel\",\"client_secret\":\"nastel\",\"grant_type\":\"password\",\"username\":\"Administrator\",\"password\":\"venkat123\"}"
In this example the username is "Administrator" and the password is "venkat123" (located at the end of the json string). The response appears as follows:{"scope":"","token_type":"Bearer","expires_in":1800,"access_token":"eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNUU0iLCJzdWIiOiJBZG1pbmlzdHJhdG9yIiwianRpIjoiYjUyMWNkOGMtNTQxMC00NmFiLWJhOTMtMzE0ZWJlMGFlN2ZlIiwiaWF0IjoxNjEyODQ1OTU2LCJleHAiOjE2MTI4NDc3NTYsInJlZnJlc2hUb2tlbklkIjoiOWYxNDhiMzktOWFmOC00NWJiLTg1MzEtNjFmZjExY2ZhZjc1In0.PAAnLbtjLeljC0Eh9-6nnS6jGeJYbBoRP0orAv4nPQ8","refresh_token":"eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNUU0iLCJzdWIiOiJBZG1pbmlzdHJhdG9yIiwianRpIjoiOWYxNDhiMzktOWFmOC00NWJiLTg1MzEtNjFmZjExY2ZhZjc1IiwiaWF0IjoxNjEyODQ1OTU2LCJleHAiOjE2MTM3MDk5NTYsImNsaWVudElkIjoibmFzdGVsIiwiY2xpZW50U2VjdXJlIjoibmFzdGVsIn0.a4P8grwUiTAA1b-oz-0d_lJqukVEceblkJ4olho-ytQ"}
Use this token in future commands.
List WGS attributes
curl -X GET "http://172.16.31.20:8019/rest/v1/" -H "accept: application/json" -H "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNUU0iLCJzdWIiOiJBZG1pbmlzdHJhdG9yIiwianRpIjoiYjUyMWNkOGMtNTQxMC00NmFiLWJhOTMtMzE0ZWJlMGFlN2ZlIiwiaWF0IjoxNjEyODQ1OTU2LCJleHAiOjE2MTI4NDc3NTYsInJlZnJlc2hUb2tlbklkIjoiOWYxNDhiMzktOWFmOC00NWJiLTg1MzEtNjFmZjExY2ZhZjc1In0.PAAnLbtjLeljC0Eh9-6nnS6jGeJYbBoRP0orAv4nPQ8"
Response:
{
“version” : “10.1.5.10”,
“serviceName” : “WGS”,
“appName” : “WGS”,
“managerName” : “MQM”,
“apwmqDbInfo” : “DBMS: MySQL APWMQ_DB_VERSION: 20 (Expected: 20)”,
“permitsDbInfo” : “DBMS: MySQL PERMV3_DB_VERSION: 28 (Expected: 28)”,
“servicesURL” : “http://172.16.31.20:8019/rest/v1/services”,
“swaggerUiURL” : “http://172.16.31.20:8019/rest/v1/api-docs”
}
List basic node information for ISERIES
curl -X GET “http://172.16.31.20:8019/rest/v1/nodes/{ISERIES}” -H “accept: application/json” -H “Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNUU0iLCJzdWIiOiJBZG1pbmlzdHJhdG9yIiwianRpIjoiYjUyMWNkOGMtNTQxMC00NmFiLWJhOTMtMzE0ZWJlMGFlN2ZlIiwiaWF0IjoxNjEyODQ1OTU2LCJleHAiOjE2MTI4NDc3NTYsInJlZnJlc2hUb2tlbklkIjoiOWYxNDhiMzktOWFmOC00NWJiLTg1MzEtNjFmZjExY2ZhZjc1In0.PAAnLbtjLeljC0Eh9-6nnS6jGeJYbBoRP0orAv4nPQ8”
Response:
{
"managerName" : "MQM",
"name" : "ISERIES",
"type" : "Local Agent"
}
List detailed node information for ISERIES
curl -X GET "http://172.16.31.20:8019/rest/v1/nodes/ISERIES?attributes=%2A" -H "accept: application/json" -H "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNUU0iLCJzdWIiOiJBZG1pbmlzdHJhdG9yIiwianRpIjoiYjUyMWNkOGMtNTQxMC00NmFiLWJhOTMtMzE0ZWJlMGFlN2ZlIiwiaWF0IjoxNjEyODQ1OTU2LCJleHAiOjE2MTI4NDc3NTYsInJlZnJlc2hUb2tlbklkIjoiOWYxNDhiMzktOWFmOC00NWJiLTg1MzEtNjFmZjExY2ZhZjc1In0.PAAnLbtjLeljC0Eh9-6nnS6jGeJYbBoRP0orAv4nPQ8"
Response:
{
"managerName" : "MQM",
"name" : "ISERIES",
"type" : "Local Agent",
"identity" : {
"useDns" : "No",
"hostName" : "",
"netAddress" : "129.40.95.121",
"portNumber" : 5010,
"version" : "6.7.0003",
"platform" : "OS/400",
"description" : ""
},
"discovery" : {
"heartBeat" : 1,
"discoveryInterval" : 720,
"refreshInterval" : 30,
"commandTimeout" : 90,
"pendingCommandLimit" : 5000,
"useNewRefresh" : "On",
"nameListDiscover" : "Off",
"ping" : 0,
"dnsName" : ""
},
"extended" : {
"traceAgent" : "Disabled",
"uidToUpper" : "Off",
"maxWaitTime" : 0,
"tcpQueueLimit" : 0,
"tcpRetryCount" : 0,
"bufferSize" : 0,
"tcpNoDelay" : "Off",
"reuseAddr" : "Off"
},
"mask" : {
"qmgr" : "*",
"aliasQueue" : "*",
"localQueue" : "*",
"modelQueue" : "*",
"remoteQueue" : "*",
"channel" : "*",
"client" : "*",
"listener" : "*",
"process" : "*",
"service" : "*",
"nameList" : "*",
"authInfo" : "*",
"clusterQMgr" : "*",
"topic" : "*",
"subscription" : "*"
},
"qmgr" : {
"logMethod" : null,
"logPath" : "",
"primaryLogs" : 0,
"secondaryLogs" : 0,
"logFileSize" : 0,
"logBufferSize" : 0
},
"state" : {
"lastUpdated" : 1611613707000,
"objectState" : "Unknown",
"managed" : "Enabled",
"authorization" : "Off",
"eventCounter" : 0,
"lastAction" : 10129,
"lastEventTime" : 0,
"osInformation" : "",
"cpuCount" : 4,
"mipsCount" : 0
},
"jobs" : {
"totalJobCount" : 0,
"scheduledJobCount" : 0,
"canceledJobCount" : 0,
"successJobCount" : 0,
"failedJobCount" : 0,
"readyJobCount" : 0,
"pendingJobCount" : 0,
"jobIds" : [ ]
},
"customProperties" : { }
}