REST API Reference > Data Integration REST API > CodeTask
  

CodeTask

Use the code task API to submit Spark code written in Scala to an advanced cluster. You can use the CodeTask resource to create, start, and cancel a code task job. You can also access session logs, view job details and job status of a code task.
Consider the following guidelines when you use the code task resource:
Note: If you use a tool such as Postman that automatically includes the HTTP version, do not enter the HTTP version in the URL. If the HTTP version appears twice in the URL, the request fails.
Complete the following tasks to submit Scala code in a JAR file and manage and monitor code task jobs:

Create a code task

Use the CodeTask resource to create a code task. The response includes the code task ID that you can use in subsequent API calls.

POST request

Use the following URI to create a code task:
POST <server URL>/disnext/api/v1/CodeTask
Use the following fields in the POST request:
Field
Type
Required / Optional
Description
codeTaskName
String
Required
Name of the code task.
runtimeEnvironmentName
String
Optional
Runtime environment used for the code task.
Either the runtimeEnvironmentName or the agentGroupId is required. If both are provided, then the agentGroupId is used.
codeExecutionParameters
Parameters in the code task.
agentGroupId
String
Required
Runtime environment that contains the Secure Agent used to run the code task.
Either the runtimeEnvironmentName or the agentGroupId is required. If both are provided, then the agentGroupId is used.
overrideTaskTimeout
Long
Optional
Overrides the code task timeout value for this execution. A value of -1 signifies no timeout.
logLevel
String
Optional
Log level for session logs, agent job log, Spark driver, and executor logs. Valid values are: none, terse, normal, verboseInitialization, or verboseData.
The default value is normal.
sparkMainClass
String
Required
Entry point of the Spark application. For example:
org.apache.spark.examples.company.SparkExampleApp
sparkMainClassArgs
List <String>
Optional
Ordered arguments sent to the Spark application main class. For example:
--appTypeSPARK_PI_FILES_JARS--
classesToLoadcom.company.test.SparkTest1Class
sparkPrimaryResource
String
Required
Scala JAR file that contains the code task.
sparkJars
List <String>
Optional
The directory and file name of the JAR file that is uploaded to the cluster and added to the Spark driver and executor classpaths.
sparkFiles
List <String>
Optional
The directory and file name of the Spark file that is uploaded to the cluster and available under the current working directory.
advancedCustomProperties
String
Optional
Spark properties or other custom properties that Data Integration uses. For example:
"{\"spark.driver.memory\": \"2G\", \"spark.executor.instances\": \"4\"}"

POST response

The following variable is set from the response attributes:
Name
Response Value
Note
CODE_TASK_ID
codeTaskId
Used in the start and view code task resources.

POST request example

Use the following sample as a reference to create a code task:
POST <server URL>/disnext/api/v1/CodeTask
Content-Type: application/json
Accept: application/json
IDS-SESSION-ID:{{IDS_SESSION_ID}}
{
"codeTaskName" : "CODETASK_API",
"runtimeEnvironmentName" : "{{RTE_NAME}}",
"codeExecutionParameters" : {
"agentGroupId": "{{AGENT_GROUP_ID}}",
"logLevel": "normal",
"sparkMainClass": "org.apache.spark.examples.infa.sparkdirect.SparkDirectExampleApp",
"sparkMainClassArgs": ["6"],
"sparkPrimaryResource": "spark-examples_2.12-3.0.0.jar",
"sparkJars": [],
"sparkFiles": [],
"advancedCustomProperties": "{\"spark.driver.memory\": \"1G\", \"spark.executor.memory\": \"1G\", \"spark.kubernetes.driverEnv.SPARK_DIRECT_TASK_SLEEP\": \"600\", \"spark.kubernetes.driverEnv.SPARK_DIRECT_APP_TYPE\": \"SPARK_PI\", \"spark.kubernetes.driverEnv.SPARK_DIRECT_KMS_ENCRYPTED_PROPS\": \"spark.sparkdirect.kms.prop\", \"spark.sparkdirect.kms.prop\": \"5pkOjS0HILDwSaW6eyxtiwB3g2TBYayjKLRFSSyxn5M=0p6v3eCvrtFkw6K78Buwal\", \"advanced.custom.property\": \"infa.spark.local=false\"}"
}
}

POST response example

A successful POST response returns a summary, the code task ID, and the code task name similar to the following example:
{
"summary": "Code Task created successfully",
"codeTaskId": 3,
"codeTaskName": "CODETASK_API"
}

Start a code task

Use this POST request to start the code task job. The response includes the code task job ID that you can use in subsequent API calls.

POST request

To start a code task, use the task ID. The code task ID is included in the response when you create a code task. For more information, see Create a code task .
Use the following URI to start a code task:
POST <server URL>/disnext/api/v1/CodeTask/Start
Use the following field in the POST request:
Field
Type
Required / Optional
Description
codeTaskId
String
Required
The code task ID from the create resource.

POST response

The following variable is set from the response attributes:
Name
Response Value
Note
CODE_TASK_JOB_ID
jobId
Used to cancel the code task job, or to get job status, session logs, or Spark task status.

POST request example

Use this sample as a reference to start a code task.
POST <server URL>/disnext/api/v1/CodeTask/Start
Content-Type: application/json
Accept: application/json
IDS-SESSION-ID:{{IDS_SESSION_ID}}
{
"codeTaskId" : {{CODE_TASK_ID}}
}

POST response example

A successful POST response returns the code task job ID and other information, similar to the following example:
{
"summary": "Code Task started successfully",
"jobId": "8zcuMdImeshidZ4XVExs20",
"codeTaskInstanceName": "Demo-2",
"sparkCodeTaskResponseBody": {
"agentGroupId": "01000025000000000003",
"clusterConfigId": "Default",
"logLevel": "normal",
"startRunTime": "2022-04-04T20:23:57.154+00:00",
"submitTime": "2022-04-04T20:23:57.095+00:00"
}
}

View a code task

Use this GET request to view the code task configuration parameters.

GET request

To request the parameters of a code task, use the task ID. The code task ID is included in the response when you create a code task. For more information, see Create a code task .
Use the following URI to get the code task parameters:
GET <server URL>/disnext/api/v1/CodeTask/<Code task ID>

GET response

Returns the code task object for the requested task ID.
Returns the error object if errors occurred.
The following table describes the parameters in the response:
Field
Type
Description
codeTaskName
String
Name of the code task.
codeTaskId
Numeric
The code task identifier.
agentGroupId
String
Runtime environment that contains the Secure Agent used to run the code task.
overrideTaskTimeout
String
Overrides the code task timeout value for this execution. A value of -1 signifies no timeout.
logLevel
String
Log level for session logs, agent job log, Spark driver, and executor logs. Valid values are: none, terse, normal, verboseInitialization, or verboseData.
The default value is normal.
sparkMainClass
String
Entry point of the Spark application. For example:
org.apache.spark.examples.company.SparkExampleApp
sparkMainClassArgs
List<String>
Ordered arguments sent to the Spark application main class. For example:
--appTypeSPARK_PI_FILES_JARS--
classesToLoadcom.company.test.SparkTest1Class
sparkPrimaryResource
String
Scala JAR file that contains the code task.
sparkJars
List <String>
The directory and file name of the JAR file that is uploaded to the cluster and added to the Spark driver and executor classpaths.
sparkFiles
List <String>
The directory and file name of the Spark file that is uploaded to the cluster and available under the current working directory.
advancedCustomProperties
String
Spark properties or other custom properties that Data Integration uses.

GET request example

Use this sample as a reference to get the code task parameters.
GET <server URL>/disnext/api/v1/CodeTask/<Code task ID>
Content-Type: application/json
Accept: application/json
IDS-SESSION-ID:{{IDS_SESSION_ID}}

GET response example

A successful GET response returns the code task parameters, similar to the following example:
{
"codeTaskName": "CODETASK_API",
"codeTaskId": 3,
"agentGroupId": "01000025000000000003",
"overrideTaskTimeout": null,
"logLevel": "normal",
"sparkMainClass": "org.apache.spark.examples.infa.sparkdirect.SparkDirectExampleApp",
"sparkMainClassArgs": ["6"],
"sparkPrimaryResource": "spark-examples_2.12-3.0.0.jar",
"sparkJars": [],
"sparkFiles": [],
"advancedCustomProperties": "{\"spark.driver.memory\": \"1G\", \"spark.executor.memory\": \"1G\", \"spark.kubernetes.driverEnv.SPARK_DIRECT_TASK_SLEEP\": \"600\", \"spark.kubernetes.driverEnv.SPARK_DIRECT_APP_TYPE\": \"SPARK_PI\", \"spark.kubernetes.driverEnv.SPARK_DIRECT_KMS_ENCRYPTED_PROPS\": \"spark.sparkdirect.kms.prop\", \"spark.sparkdirect.kms.prop\": \"5pkOjS0HILDwSaW6eyxtiwB3g2TBYayjKLRFSSyxn5M=0p6v3eCvrtFkw6K78Buwal\", \"advanced.custom.property\": \"infa.spark.local=false\"}"
}

Status of a code task

Use this GET request to check the code task job status.

GET request

To request the status of a code task job, use the code task job ID. The code task job ID is included in the response when you start a code task. For more information, see Start a code task.
Use the following URI to get the code task job status parameters:
GET <server URL>/disnext/api/v1/CodeTask/JobStatus/<Code task job ID>

GET response

Returns the code task object for the requested job ID.
Returns the error object if errors occurred.
The following table describes the parameters in the response:
Field
Type
Description
codeTaskName
String
Name of the code task.
codeTaskId
Numeric
The code task identifier.
agentGroupId
String
Runtime environment that contains the Secure Agent used to run the code task.
executionState
String
The state of the job: QUEUED, RUNNING, SUCCEEDED, FAILED, CANCELLED Job status. A job can have one of the following statuses:
  • - Starting. The job is starting.
  • - Running. The job is either queued or running.
  • - Success. The job completed successfully.
  • - Failed. The job did not complete because it encountered errors.
sessionLogUrl
String
URL of the session log file.
assignedServerlessComputeUnits
Double
Number of serverless compute units per hour that the task requested.
You can view the number of requested compute units if the task runs in a serverless runtime environment.
consumedServerlessComputeUnits
Double
Total number of serverless compute units that the task consumed.
You can view the number of consumed compute units if the task runs in a serverless runtime environment.
firstErrorMessage
String
Error message, if any, that is associated with the job.

GET request example

Use this sample as a reference to get the code task job status.
GET <server URL>/disnext/api/v1/CodeTask/JobStatus/<Code task job ID>
Content-Type: application/json
Accept: application/json
IDS-SESSION-ID:{{IDS_SESSION_ID}}

GET response example

A successful GET response returns the code task job status, similar to the following example:
{
"status": "RUNNING",
"startTime": "2022-04-04T20:23:57.000",
"updateTime": "2022-04-04T20:23:58.000",
"endTime": null,
"instanceName": "Demo-2",
"assetName": "Demo",
"runId": 2,
"orgId": "kuJVH54wm6gfhVj4QEdboY",
"startedBy": "coder@examplecompany.com",
"runtimeEnvId": "01000025000000000003",
"codeTaskId": 2,
"errorMessage": "",
"sessionLogUrl": "logservice/api/v1/jobs/8zcuMdImeshidZ4XVExs20/logs",
"agentJobLogUrl": null,
"advancedLogLocation": null,
"advancedLogDownloadUrl": null
}
An error status GET response returns the code task job status, similar to the following example:
{
"status": "FAILED",
"startTime": "2022-03-10T17:23:29.000",
"updateTime": "2022-03-10T17:23:34.000",
"endTime": "2022-03-10T17:23:34.000",
"instanceName": "Demo-2",
"assetName": "Demo",
"runId": 2,
"orgId": "4nuRA6NIsI6lvUBYamL76P",
"startedBy": "coder@examplecompany.com",
"runtimeEnvId": "01000025000000000003",
"codeTaskId": 477,
"errorMessage": "WES_internal_error_Failed to start cluster for [01000025000000000003]. Error reported while starting cluster [404 {\"code\":\"CONFIG.NOT_FOUND_id\",\"message\":\"Internal error. Cannot find an advanced configuration with ID 01000025000000000003. Contact Informatica Global Customer Support.\",\"debugMessage\":\"Internal error. Cannot find an advanced configurati[truncated]. For more information about the failure, check the application log.If the problem persists, contact Informatica Global Customer Support.",
"sessionLogUrl": "logservice/api/v1//jobs/6pqqt9KTgi3l9jyVnAajei/logs",
"agentJobLogUrl": null,
"advancedLogLocation": null,
"advancedLogDownloadUrl": null
}

Cancel a code task

Use this PUT request to cancel the code task job.

PUT request

To cancel a code task job, use the code task job ID. The code task job ID is included in the response when you start a code task. For more information, see Start a code task.
Use the following URI to cancel a code task job:
PUT <server URL>/disnext/api/v1/CodeTask/Cancel
Use the following field in the PUT request:
Field
Type
Required / Optional
Description
jobId
String
Required
The code task job ID from the start resource.

PUT response

Returns the code task cancellation state for the requested job ID.
Returns the error object if errors occurred.

PUT request example

Use this sample as a reference to cancel a code task job.
PUT <server URL>/disnext/api/v1/CodeTask/Cancel
Content-Type: application/json
Accept: application/json
IDS-SESSION-ID:{{IDS_SESSION_ID}}
{
"jobId" : {{CODE_TASK_JOB_ID}}
}

PUT response example

A successful PUT response returns the code task job cancellation information, similar to the following example:
{
"state": "Code Task marked for cancellation.",
"jobId": "6pqqt9KTgi3l9jyVnAajei"
}

Session logs for a code task

Use the jobs resource to access the code task session logs.

GET request

To access the session logs of a code task, use the code task job ID. The code task job ID is included in the response when you start a code task. For more information, see Start a code task.
Use the following URI to get code task session logs:

GET <server URL>/logservice/api/v1/jobs/<Code task job ID>/logs
You can use the Postman Send and Download option.

GET response

Returns a link to the code task ZIP file for the requested job ID.
Returns the error object if errors occurred.

GET request example

Use this sample as a reference to access code task session logs.
GET <server URL>/logservice/api/v1/jobs/<Code task job ID>/logs
Content-Type: application/json
Accept: application/json
IDS-SESSION-ID:{{IDS_SESSION_ID}}

Spark task results for a code task

Use the jobs resource to access the Spark task results for the code task.

GET request

To access the Spark task results of a code task, use the code task job ID. The code task job ID is included in the response when you start a code task. For more information, see Start a code task.
Use the following URI to access code task Spark task results:

GET <server URL>/logservice/api/v1/jobs/<Code task job ID>/callback

GET response

Returns the code task Spark task details for the requested job ID.
Returns the error object if errors occurred.

GET request example

Use this sample as a reference to access code task Spark task results.
GET <server URL>/logservice/api/v1/jobs/<Code task job ID>/callback
Content-Type: application/json
Accept: application/json
IDS-SESSION-ID:{{IDS_SESSION_ID}}

GET response example

A successful GET response returns the code task Spark task results, similar to the following example:
{

"jobId": "73LJ52V0tiNjC2HFb2YggK",

"callbackBody": "{\"taskId\": \"73LJ52V0tiNjC2HFb2YggK\", \"executionId\": \"73LJ52V0tiNjC2HFb2YggK\", \"sessionLogUrl\": \"logservice/api/v1/jobs/73LJ52V0tiNjC2HFb2YggK/logs\", \"executionState\": \"RUNNING\"}"

}