ElasticJob-Cloud provides RESTful APIs such as application publishing and job registration, which can be operated by curl.

Request URL prefix is /api

Authentication API

Get AccessToken

url: login

Method: POST

Content type: application/json

Parameter list:

Property nameTypeRequired or notDefault valueDescription
usernameStringYesAPI authentication username
passwordStringYesAPI authentication password

Response parameter:

Property nameTypeDescription
accessTokenStringAPI authentication token

Example:

  1. curl -H "Content-Type: application/json" -X POST http://elasticjob_cloud_host:8899/api/login -d '{"username": "root", "password": "pwd"}'

Response body:

  1. {"accessToken":"some_token"}

Application API

Publish application

url: app

Method: POST

Parameter type: application/json

Parameter list:

Property nameTypeRequired or notDefault valueDescription
appNameStringYesJob application name
appURLStringYesPath of job application
cpuCountdoubleNo1The number of CPUs required for the job application to start
memoryMBdoubleNo128MB of memory required to start the job application
bootstrapScriptStringYesBoot script
appCacheEnablebooleanNotrueWhether to read the application from the cache every time the job is executed
eventTraceSamplingCountintNo0 (no sampling)Number of resident job event sampling rate statistics

Detailed parameter description:

appName:

It is the unique identifier of ElasticJob-Cloud’s job application.

appURL:

A path that can be accessed through the network must be provided.

bootstrapScript:

Example: bin\start.sh

appCacheEnable:

Disabled, every time the task is executed, the application will be downloaded from the application repository to the local.

eventTraceSamplingCount:

To avoid excessive data volume, you can configure the sampling rate for frequently scheduled resident jobs, that is, every N times the job is executed, the job execution and tracking related data will be recorded.

Example:

  1. curl -l -H "Content-type: application/json" -X POST -d '{"appName":"my_app","appURL":"http://app_host:8080/my-job.tar.gz","cpuCount":0.1,"memoryMB":64.0,"bootstrapScript":"bin/start.sh","appCacheEnable":true,"eventTraceSamplingCount":0}' http://elastic_job_cloud_host:8899/api/app

Modify application configuration

url: app

Method: PUT

Parameter type: application/json

Parameter list:

Property nameTypeRequired or notDefault valueDescription
appNameStringYesJob application name
appCacheEnablebooleanYestrueWhether to read the application from the cache every time the job is executed
eventTraceSamplingCountintNo0 (no sampling)Number of resident job event sampling rate statistics

Example:

  1. curl -l -H "Content-type: application/json" -X PUT -d '{"appName":"my_app","appCacheEnable":true}' http://elastic_job_cloud_host:8899/api/app

Job API

Register job

url: job/register

Method: POST

Parameter type: application/json

Parameter list:

Property nameTypeRequired or notDefault valueDescription
appNameStringYesJob application name
cpuCountdoubleYesThe number of CPUs required for a single chip operation, the minimum value is 0.001
memoryMBdoubleYesThe memory MB required for a single chip operation, the minimum is 1
jobExecutionTypeEnumYesJob execution type. TRANSIENT is a transient operation, DAEMON is a resident operation
jobNameStringYesJob name
cronStringNocron expression, used to configure job trigger time
shardingTotalCountintYesTotal number of job shards
shardingItemParametersStringNoCustom sharding parameters
jobParameterStringNoJob custom parameters
failoverbooleanNofalseWhether to enable failover
misfirebooleanNofalseWhether to enable missed tasks to re-execute
jobExecutorServiceHandlerTypebooleanNofalseJob thread pool processing strategy
jobErrorHandlerTypebooleanNofalseJob error handling strategy
descriptionStringNoJob description information
propsPropertiesNoJob property configuration information

Use the script type instantaneous job to upload the script directly to appURL without tar package. If there is only a single script file, no compression is required. If it is a complex script application, you can still upload a tar package and support various common compression formats.

Example:

  1. curl -l -H "Content-type: application/json" -X POST -d '{"appName":"my_app","cpuCount":0.1,"memoryMB":64.0,"jobExecutionType":"TRANSIENT","jobName":"my_job","cron":"0/5 * * * * ?","shardingTotalCount":5,"failover":true,"misfire":true}' http://elastic_job_cloud_host:8899/api/job/register

update job configuration

url: job/update

Method: PUT

Parameter type: application/json

Parameters: same as registration job

Example:

  1. curl -l -H "Content-type: application/json" -X PUT -d '{"appName":"my_app","jobName":"my_job","cpuCount":0.1,"memoryMB":64.0,"jobExecutionType":"TRANSIENT","cron":"0/5 * * * * ?","shardingTotalCount":5,"failover":true,"misfire":true}' http://elastic_job_cloud_host:8899/api/job/update

Deregister Job

url: job/deregister

Method: DELETE

Parameter type: application/json

Parameters: Job name

Example:

  1. curl -l -H "Content-type: application/json" -X DELETE -d 'my_job' http://elastic_job_cloud_host:8899/api/job/deregister

Trigger job

url: job/trigger

Method: POST

Parameter type: application/json

Parameters: Job name

Description: Event-driven, triggering jobs by calling API instead of timing. Currently only valid for transient operations.

Example:

  1. curl -l -H "Content-type: application/json" -X POST -d 'my_job' http://elastic_job_cloud_host:8899/api/job/trigger