A custom Density Clustering tool is used as an example to give you a quick understanding of how to use Processing Automation Service through the REST API.

Asynchronous execution of Processing Automation Service tools via REST API

  1. From the iserver service management page, go to the Info page of the Processing Automation Service, Click http://localhost:8090/iserver/services/geoprocessing/restjsr to enter Processing Automation Service, see the list of tools under the Processing Automation Service root resource, and find the custom tool TownCluster tool under Model tool.

    If you need to view the resource page of the Publish Model, you can directly select the model in the model list of the modeling page, and click the right mouse button to select Open Resource Page in the pop-up menu.

 

  1. View the description of the TownCluster tool, set the tool ID and the parameter ID, and generate a token in the iServer (refer to: Obtain Token )。

Figure Description of the TownCluster tool

According to the published tool ID (sps.WorkflowProcessFactory.models:towncluster), the parameter ID of the tool, the parameter value to be set, and the generated token, the build asynchronously executes the Processing Automation Service tool POST request URI as follows:

http://172.16.16.8:8090/iserver/services/geoprocessing/restjsr/gp/v2/sps.WorkflowProcessFactory.models:towncluster/jobs? token=OCtW1D34XoGM2xmxSUWfoTrWNbNlgfuVoQi8w4Tqejfh_7apnBAe6pt4zPWw1ClHtC4_LHNomodhp2vHMN8G-A..

Construct the following POST request parameters according to the parameter ID of the published tool and the parameter value to be set (because reserved parameters are checked in Publish Model, only the parameters to be adjusted can be set here, and the remaining parameters are reserved when published). In addition, in order to ensure the security of the data transmission process, the sensitive information in the data connection info can be encrypted by adding the "secretKey" key parameter in the request body. When obtaining the Result Info of the task later, you also need to add the secret key parameter for decryption. If the secret keys used for encryption and decryption are the same, the original text is returned directly; otherwise, the encrypted Connection Info is returned. :

{

"parameter": {

"densitycluster-savedFields":["County","NAME"],

"densitycluster-eps":"15.0 Kilometer",

"saveas-dataConnInfo":"--host=172.16.112.9 --port=5432 --database=postgis --user=postgres --passwd=●●●●●●● --dataset=Town_15km --dbType=PGGIS --providerType=jdbc"

},

"secretKey":"1234567890qwerty",

"environments":

{

"master":"spark://172.16.16.8:7077",

"appName":"Geoprocessing",

"settings":["spark.cores.max=8","spark.driver.host=192.168.17.43","spark.executor.memory=32g"]

}

}

Perform a POST request to the URI of the published custom Density Clustering tool in the Model Builder

The task status information returned in JSON format is as follows:

{"jobID":"gp-20200902-162021-B96D5","status":"started"}

 

  1. With an asynchronously executed POST request, you can get the Processing Automation Service task ID for this execution (GP-20200902-162021-B96D5) in the status information returned. Based on this task ID and the Processing Automation Service tool ID, you can view the relevant task information and results via GET request.

http://172.16.16.8:8090/iserver/services/geoprocessing/restjsr/gp/v2/sps.WorkflowProcessFactory.models:towncluster/jobs/ gp-20200902-162021-B96D5.rjson? token=OCtW1D34XoGM2xmxSUWfoTrWNbNlgfuVoQi8w4Tqejfh_7apnBAe6pt4zPWw1ClHtC4_LHNomodhp2vHMN8G-A..

The resulting Processing Automation Service task information is as follows:

{

"jobID": "gp-20200902-162021-B96D5",

"processID": "sps.WorkflowProcessFactory.models:towncluster",

"messages": {

"result": "{"saveas-isSuccessful":"--host=nm6X2rjKIcH9fgv7VOdlNg== --port=5432 --database=postgis --user=dOG1xePrLDVeMPzoGsSiPA== --passwd=1kVkKc0xVXTU89C081Kb9w== --dataset=Town_15km --dbtype=PGGIS --providerType=jdbc"}",

"processMethodStatus": {

"Read Vector Data": "FINISHED",

"Density Clustering": "FINISHED",

"Save Vector Data": "FINISHED"

},

    "parameter": "{"densitycluster-savedFields":["County","NAME"],"densitycluster-eps":"15.0 Kilometer","saveas-dataConnInfo":"--providerType=dsf --path=/home/dsfdata"}"

},

"processTitle": "TownCluster",

"state": {

"formatStartTime": "2020-09-02 16:20:21",

"errorStackTrace": null,

"success": true,

"startTime": 1599034821996,

"formatEndTime": "2020-09-02 16:20:22",

"endTime": 1599034822335,

"runState": "FINISHED",

"errorMsg": null,

"elapsedTime": 0

}

}

http://172.16.16.8:8090/iserver/services/geoprocessing/restjsr/gp/v2/sps.WorkflowProcessFactory.models:towncluster/jobs/ gp-20200902-162021-B96D5/results?token=OCtW1D34XoGM2xmxSUWfoTrWNbNlgfuVoQi8w4Tqejfh_7apnBAe6pt4zPWw1ClHtC4_LHNomodhp2vHMN8G-A..&secretKey=1234567890qwerty

The result Processing Automation Service task results are as follows:

{"saveas-isSuccessful":"--host=172.16.112.9 --port=5432 --database=postgis --user=postgres --passwd=●●●●●●● --dataset=Town_15km --dbType=PGGIS --providerType=jdbc"}

Synchronous execution of Processing Automation Service tools via REST API

  1. From the iserver service management page, go to the Info page of the Processing Automation Service, Click http://localhost:8090/iserver/services/geoprocessing/restjsr to enter Processing Automation Service, see the list of tools under the Processing Automation Service root resource, and find the Custom ToolTown Cluster under Custom Tool.
  2. View the description of the Town Cluster tool to determine the tool ID, the parameter ID to be set, and so on. According to the tool ID (SPS. Workflow ProcessFactory. Models: towncluster), the tool parameter ID, and the parameter value to be set, the GET request URI of the synchronous execution Geo-Processing Automation (GPA) tool is constructed as follows:

http://172.16.16.8:8090/iserver/services/geoprocessing/restjsr/gp/v2/sps.WorkflowProcessFactory.models:towncluster/execute?parameter={"densitycluster-savedFields":"['M_unite','place_name']","saveas-dataConnInfo":"--providerType=hbase --hbase.zookeepers=172.16.16.8:2181 --hbase.catalog=demo --dataset=Town_15km","densitycluster-eps":"15.0 Kilometer"}&environment=[{"type":"BDT_Spark_Environment","master":"spark://172.16.16.8:7077","appName":"Geoprocessing","settings":["spark.cores.max=8","spark.driver.host=192.168.17.43","spark.executor.memory=32g"]}]&token=OCtW1D34XoGM2xmxSUWfoTrWNbNlgfuVoQi8w4Tqejfh_7apnBAe6pt4zPWw1ClHtC4_LHNomodhp2vHMN8G-A..

Performing a GET request on the URI of the published custom Density Clustering tool in the Model Builder allows you to perform a Density Clustering analysis of the towns in the region. The resulting Processing Automation Service task results are as follows:

{"saveas-isSuccessful":"--providerType=dsf --path=/home/dsfdata"}

The request URI for synchronous execution of the Processing Automation Service tool is format-sensitive. Avoid using extra spaces and line breaks in the URI. Copy the URI to the browser for validation. If some special characters in the parameter need to be encoded, the encoding tool can be used for processing.

 

For an introduction to the REST API, refer to geoprocessing .

Please refer to:

 Through iServer The REST API uses