Querying the List of Jobs

Function

This API is used to query the list of the current user's jobs. You can set the job ID as the ID and query jobs whose IDs are greater than or less than the ID. You can also query jobs in specific status, for example, in running status or other. By default, all jobs are queried.

The following table lists parameters involved in the API.

Table 1 Parameter description

Parameter

Description

name

Job name.

status

Status code of a job. For details, see Table 4.

cluster_id

ID of an exclusive cluster.

show_detail

Whether to return the job details.

cursor

Job ID.

next

Whether to switch to the previous or next page.

limit

Number of returned data records.

order

Query result display. Value asc indicates that the query results are displayed in ascending order, and value desc indicates that the query results are displayed in descending order.

root_job_id

Edge parent job ID, which is used to query sub-jobs of a specified edge job. If this parameter is not specified, all non-edge jobs and edge parent jobs, instead of edge sub-jobs, are queried.

URI

  • URI format

    GET /v1.0/{project_id}/jobs

  • Parameter description
    Table 2 URI parameter description

    Parameter

    Mandatory

    Description

    project_id

    Yes

    Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

Request

None

Response

  • Example response
    {
        "message_id": "CS.10001",
        "message": "Querying of the job list succeeds.",
        "current_time": 1533686888000,
        "payload": {
        "total": 1,
        "jobs": [
          {
            "job_id": 50320,
            "name": "my_job_001",
            "desc": "This is my job.",
            "username": "cs_testuser",
            "job_type": "flink_jar_job",
            "status": "job_running",
            "status_desc": "",
            "create_time": 1516952710040,
            "start_time": 1516952710740,
            "duration": 6838266,
            "user_id": "ac4eaa303639409c8ab099d55eb1538e",
            "cluster_id": 100000,
            "project_id": "5a3314075bfa49b9ae360f4ecd333695",
            "sql_body": "select * from source_table",
            "run_mode": "shared_cluster",
            "spu_number": 0,
            "parallel_number": 0,
            "job_config": {
              "checkpoint_enabled": true,
              "checkpoint_mode": "exactly_once",
              "checkpoint_interval": 0,
              "log_enabled": true,
              "obs_bucket": "obs-demo",
              "smn_topic": "cs_job_exception",
              "root_id": 0,
              "edge_group_ids": "62de1e1c-066e-48a8-a79d-f461a31b2ee1,2eb00f85-99f2-4144-bcb7-d39ff47f9002"
            },
            "jar_url": "cs-flink-jar/52818/WindowJoin.jar",
            "main_class": "org.apache.spark.examples.streaming.JavaQueueStream",
            "args": "",
            "execution_graph": "",
            "update_time": 1516952770835
          }
        ]
      }
      }
  • Parameter description
    Table 3 Response parameters

    Parameter

    Mandatory

    Type

    Description

    message_id

    No

    String

    Message type ID.

    message

    No

    String

    Message content.

    current_time

    No

    Int

    Current time, expressed by milliseconds.

    payload

    No

    None

    Information about a job list.

    total

    No

    Int

    Number of records in the query result.

    jobs

    No

    None

    Information about a job.

    job_id

    Yes

    Long

    Job ID.

    name

    No

    String

    Job name.

    desc

    No

    String

    Job description.

    username

    No

    String

    Username. This parameter is valid only when show_detail is set to true.

    job_type

    No

    String

    Job type.

    status

    No

    String

    Job status.

    status_desc

    No

    String

    Description of job status.

    create_time

    Yes

    Int

    Time when a job is created.

    start_time

    No

    Int

    Time when a job is enabled. Value 0 indicates that the job has not been enabled.

    duration

    No

    Int

    Running duration of a job, expressed by milliseconds.

    user_id

    No

    String

    ID of the user who creates the job. This parameter is valid only when show_detail is set to true.

    cluster_id

    No

    Int

    Resource ID of an exclusive cluster. Ensure that the current user has been authorized to use resources of the exclusive cluster.

    project_id

    No

    String

    ID of the project to which a job belongs. This parameter is valid only when show_detail is set to true.

    sql_body

    No

    String

    Stream SQL statement.

    run_mode

    No

    String

    Job running mode when show_detail is set to true:

    • shared_cluster: indicates that the job is running on a shared cluster.
    • exclusive_cluster: indicates that the job is running on an exclusive cluster.
    • edge_node: indicates that the job is running on an edge node.

    spu_number

    No

    Int

    Number of SPUs selected for a job.

    parallel_number

    No

    Int

    Number of parallel jobs set by a user.

    job_config

    No

    None

    Job configuration. This parameter is valid only when show_detail is set to true.

    checkpoint_enabled

    No

    boolean

    Whether to enable the automatic job snapshot function.

    • true: indicates to enable the automatic job snapshot function.
    • false: indicates to disable the automatic job snapshot function.
    • Default value: false

    checkpoint_mode

    No

    String

    Snapshot mode. The values include:

    • ExactlyOnce
    • AtLeastOnce

    checkpoint_interval

    No

    Int

    Snapshot interval, expressed by seconds.

    log_enabled

    No

    boolean

    Whether to enable the log saving function.

    obs_bucket

    No

    String

    Name of an OBS bucket.

    smn_topic

    No

    String

    If a job fails to work, CS pushes alarm information to the SMN topic.

    root_id

    No

    Int

    Parent job ID. This parameter is valid only when show_detail is set to false.

    edge_group_ids

    No

    String

    List of edge computing group IDs. Use commas (,) to separate multiple IDs. This parameter is valid only when show_detail is set to false.

    checkpoint_interval

    No

    Int

    Snapshot interval, expressed by seconds.

    jar_url

    No

    String

    OBS path of the JAR package. This parameter is valid only when show_detail is set to true.

    main_class

    No

    String

    OBS path where users are authorized to save the snapshot when checkpoint_enabled is set to true. This parameter is valid only when show_detail is set to true.

    args

    No

    String

    Job running parameter of the JAR package. This parameter is valid only when show_detail is set to true.

    execution_graph

    No

    String

    Job execution plan. This parameter is valid only when show_detail is set to true.

    update_time

    No

    Int

    Job update time. This parameter is valid only when show_detail is set to true.

Status Code

Table 4 Status code

Status Code

Description

200

Job list query succeeds.

400

The input parameters are invalid.

Error Code

For details, see Error Codes.