Salesforce

How to get the properties of an agent using OE Manager's REST API?

« Go Back

Information

 
TitleHow to get the properties of an agent using OE Manager's REST API?
URL NameHow-to-get-the-properties-of-an-agent-using-OE-Manager-s-REST-API
Article Number000110507
EnvironmentProduct: OpenEdge
Version: 11.7.4, 12.0
OS: All Supported Platforms
Question/Problem Description
This article provides an example to demonstrate using the ABL HttpClient libraries for fetching an Instance's properties from the OE Manager REST API for a Progress AppServer for OpenEdge (PASOE) instance.
 
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
The below code takes the following parameters:
  • Host Name in the pcHost parameter
  • Port Number in the pcPort parameter(optional) 
  • Instance name in the pcInstance parameter
Then calls the REST API to get the properties for a given instance and outputs them to a file named results.txt.
USING OpenEdge.Net.HTTP.RequestBuilder.
USING openedge.net.http.IHttpRequest.
USING openedge.net.http.IHttpResponse.
USING Progress.Json.ObjectModel.*.
USING OpenEdge.Net.HTTP.ClientBuilder.
USING OpenEdge.Net.HTTP.ResponseBuilder.
USING OpenEdge.Net.HTTP.IHttpClientLibrary.
USING OpenEdge.Net.HTTP.Lib.ClientLibraryBuilder.
USING OpenEdge.Net.HTTP.Credentials.

DEFINE INPUT  PARAMETER pcHost     AS CHARACTER   NO-UNDO.
DEFINE INPUT  PARAMETER pcPort     AS CHARACTER   NO-UNDO.
DEFINE INPUT  PARAMETER pcInstance AS CHARACTER   NO-UNDO.

DEFINE VARIABLE oResponse    AS IHttpResponse            NO-UNDO.
DEFINE VARIABLE oEntity      AS JsonObject               NO-UNDO.
DEFINE VARIABLE oCredentials AS Credentials              NO-UNDO.
DEFINE VARIABLE oRequest     AS IHttpRequest             NO-UNDO.
DEFINE VARIABLE oLib         AS IHttpClientLibrary       NO-UNDO.
DEFINE VARIABLE oProperties  AS JsonObject               NO-UNDO.

DEFINE VARIABLE cURL         AS CHARACTER                NO-UNDO.
DEFINE VARIABLE cMessage     AS CHARACTER                NO-UNDO FORMAT "x(35)".

DEFINE VARIABLE hPropsTT     AS HANDLE                   NO-UNDO.    
DEFINE VARIABLE hQuery       AS HANDLE                   NO-UNDO.
DEFINE VARIABLE hBuffer      AS HANDLE                   NO-UNDO.
DEFINE VARIABLE hColumn      AS HANDLE                   NO-UNDO.

DEFINE VARIABLE iColumn      AS INTEGER                  NO-UNDO.

cURL = "http://" + pcHost + (IF (pcPort GT "") EQ TRUE THEN ":" + pcPort ELSE "") +
       "/oemanager/applications/" + pcInstance + "/agents/properties".

// You have to login with admin rights to the tomcat manager.  If you've changed
// the password you'll need to use the modified password
oCredentials = NEW Credentials("http://localhost","tomcat","tomcat").

// Make the HTTP call
oRequest  = RequestBuilder:Get(cUrl)
                          :UsingBasicAuthentication(oCredentials)
                          :Request.
                             
oResponse = ResponseBuilder:Build():Response.
oLib      = ClientLibraryBuilder:Build():sslVerifyHost(NO):Library.

ClientBuilder:Build()
             :UsingLibrary(oLib)
             :Client:Execute(oRequest,oResponse).

// Cast the result of the call into a JsonObject. 
oEntity = CAST(oResponse:Entity,JsonObject).

// Check for error messages and return if one is encountered
cMessage = oEntity:GetCharacter("errmsg").
IF (cMessage GT "") EQ TRUE THEN DO:
    MESSAGE "Request failed with the below Error:" SKIP(1)
            cMessage
        VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
    RETURN.
END.

// The first object in the response is always named result and the 
// details of the response are children of the result object
//
// This depicts getting the result object, then creating a dynamic 
// temp-table with the result
oProperties = CAST(oEntity:GetJsonObject('result'),JsonObject).

CREATE TEMP-TABLE hPropsTT.

// Read the agents temp-table in 
hPropsTT:READ-JSON("JsonObject",oProperties,"APPEND").
hBuffer = hPropsTT:DEFAULT-BUFFER-HANDLE.

CREATE QUERY hQuery.
hQuery:SET-BUFFERS(hBuffer).
hQuery:QUERY-PREPARE("FOR EACH " + hBuffer:NAME).
hQuery:QUERY-OPEN().

OUTPUT TO results.txt.
DO WHILE hQuery:GET-NEXT():
    DO iColumn = 1 TO hBuffer:NUM-FIELDS:
        hColumn = hBuffer:BUFFER-FIELD(iColumn).
        PUT UNFORMATTED hColumn:NAME + ": " 
                        hColumn:BUFFER-VALUE CHR(10).
    END.
END.
OUTPUT CLOSE.

DELETE OBJECT hQuery   NO-ERROR.
DELETE OBJECT hPropsTT NO-ERROR.

The resulting JSON output looks like the following:
{  
   "result":{  
      "noSessionCache":"0",
      "sessionConnectProc":"",
      "agentMaxPort":"62202",
      "keyAlias":"",
      "sessionStartupProcParam":"",
      "allowRuntimeUpdates":"0",
      "flushStatsData":"0",
      "lockAllNonThreadSafeExtLib":"",
      "sessionShutdownProc":"",
      "agentStartupProcParam":"",
      "sslAlgorithms":"",
      "uuid":"http:\/\/localhost:11046\/mypasinst",
      "statusEnabled":"1",
      "collectStatsData":"0",
      "sessionStartupProc":"",
      "collectMetrics":"1",
      "sessionDisconnProc":"",
      "binaryUploadMaxSize":"0",
      "fileUploadDirectory":"",
      "sessionDeactivateProc":"",
      "workDir":"C:\\mypasinst\/work",
      "agentShutdownProc":"",
      "usingThreadSafeExtLib":"",
      "keyAliasPasswd":"",
      "sessionActivateProc":"blah.p",
      "agentStartupProc":"",
      "PROPATH":"C:\\mypasinst\/webapps\/ROOT\/WEB-INF\/openedge,C:\\mypasinst\/openedge,C:\\DLC117\/tty,C:\\DLC117\/tty\/netlib\/OpenEdge.Net.pl",
      "sessionExecutionTimeLimit":"0",
      "agentMinPort":"62002",
      "agentStartupParam":"-debugalert -errorstack -zn -catchStop 1",
      "infoVersion":"9010",
      "lockAllExtLib":"",
      "numInitialSessions":"2",
      "sessionTimeout":"180",
      "keyStorePath":"C:\\DLC117\/keys\/",
      "applications":"mypasinst"
   },
   "versionNo":1,
   "outcome":"SUCCESS",
   "versionStr":"v11.7.4 ( 2018-10-10 )",
   "errmsg":"",
   "operation":"GET AGENT PROPERTIES"
}



 
Workaround
Notes
Keyword Phrase
Last Modified Date1/4/2021 2:22 PM

Powered by