跳转至
For the complete DHIS2 documentation index, see llms.txt.

排程

```

curl -X PATCH -d @payload.json -H "Content-Type: application/json-patch+json" "https://play.dhis2.org/dev/api/metadata/sharing"

要获取所有可用作业类型的列表,可以使用以下端点:

两个补丁应用项目端点的参数相同:

响应包含有关每个作业类型的信息,包括名称、作业类型、键、调度类型和可用参数。调度类型可以是 `CRON`,这意味着可以使用带有 `cronExpression` 字段的 cron 表达式来调度作业,或者是`FIXED_DELAY`,意味着可以使用 `delay` 字段将作业调度为以固定延迟运行.场延迟以秒为单位。

响应将类似于以下内容:

```json
{
  "jobTypes": [
    {
      "name": "Data integrity",
      "jobType": "DATA_INTEGRITY",
      "key": "dataIntegrityJob",
      "schedulingType": "CRON"
    }, {
      "name": "Resource table",
      "jobType": "RESOURCE_TABLE",
      "key": "resourceTableJob",
      "schedulingType": "CRON"
    }, {
      "name": "Continuous analytics table",
      "jobType": "CONTINUOUS_ANALYTICS_TABLE",
      "key": "continuousAnalyticsTableJob",
      "schedulingType": "FIXED_DELAY"
    }
  ]
}

工作配置{ #job-configurations }

DHIS2允许安排各种类型的作业。每种类型的作业都有不同的配置属性,可让您更好地控制作业的运行方式。此外,如果需要,您可以将同一作业配置为以不同的配置和不同的时间间隔运行。

If this is set to true, then the batch function will stop and not updating any objects if there is an error
Otherwise, if this is false then the function will try to proceed with best effort mode.

指标组 描述 类型
名称 Response
Payload formats Payload for single object type using /api/{object-type}/sharing looks like this Payload for multiple object types in one payload using api/metadata/sharing
排程 { #webapi_scheduling } Get available job types { #types } 要获取所有可用作业类型的列表,可以使用以下端点:
GET /api/jobConfigurations/jobTypes 响应包含有关每个作业类型的信息,包括名称、作业类型、键、调度类型和可用参数。调度类型可以是 CRON,这意味着可以使用带有 cronExpression 字段的 cron 表达式来调度作业,或者是FIXED_DELAY,意味着可以使用 delay 字段将作业调度为以固定延迟运行.场延迟以秒为单位。 响应将类似于以下内容:
/api/pushAnalysis//run Job Configurations Boolean

Table: Main properties

Property

名称 类型 默认 描述
A number related to date of execution which resembles the end of the period to monitor The cron expression which defines the interval for when the job should run. String (Cron expression)
jobType 创建_并_更新|创建|更新|删除 String (Enum) jobParameters

Job parameters, if applicable for job type.

名称 类型 默认 描述
empty number of tracked entities processed as a unit false 类型
默认 描述 dataValuesPageSize array of string
[] = all 项目阶段 flushMode Event analytics explain { #webapi_event_analytics_explain }
REPORT A number related to date of execution which resembles the end of the period to monitor dataValuesPageSize 应跳过的项目(ID)的可选列表

类型

名称 类型 默认 描述
empty number of tracked entities processed as a unit false 类型
默认 描述 dataValuesPageSize array of string
false number of tracked entities processed as a unit 名称 array of string

[]

名称 类型 默认 描述
默认 number of tracked entities processed as a unit pageSize int

表:SINGLE_EVENT_DATA_SYNC 作业参数

名称 类型 默认 描述
默认 number of tracked entities processed as a unit 名称 作为一组处理的事件数量。最小值为 5,最大值为 200

表格:TRACKED_ENTITY_DATA_SYNC 作业参数

| 类型 | Potential duplicate status | 仪表板资源将提供仪表板列表。请记住 仪表板对象是共享的,因此列表将受 当前已验证的用户。您可以检索有关一个的更多信息 特定的仪表板,请点击其链接,类似于: | Parameter name | |---------------|---------------|---------|--------------------------------------------------| | 默认 | number of tracked entities processed as a unit | 名称 | 作为一组处理的受追踪实体数量。最小值为 5,最大值为 200。 |

empty

| 类型 | Potential duplicate status | 仪表板资源将提供仪表板列表。请记住 仪表板对象是共享的,因此列表将受 当前已验证的用户。您可以检索有关一个的更多信息 特定的仪表板,请点击其链接,类似于: | Parameter name | |---------------|---------------|---------|--------------------------------------------------| | 默认 | number of tracked entities processed as a unit | pageSize | int |

10000

| 类型 | Potential duplicate status | 仪表板资源将提供仪表板列表。请记住 仪表板对象是共享的,因此列表将受 当前已验证的用户。您可以检索有关一个的更多信息 特定的仪表板,请点击其链接,类似于: | Parameter name | |---------------|---------------|---------|--------------------------------------------------| | Set true if job should send notifications based on validation rule groups | number of tracked entities processed as a unit | 名称 | 类型 | | Set true if job should persist validation results | number of tracked entities processed as a unit | 名称 | int | | 60 | A number related to date of execution which resembles the end of the period to monitor | dataValuesPageSize | int | | 10000 | 项目阶段 | flushMode | 名称 | | 类型 | 项目阶段 | flushMode | relativeStart |

int

| 类型 | Potential duplicate status | 仪表板资源将提供仪表板列表。请记住 仪表板对象是共享的,因此列表将受 当前已验证的用户。您可以检索有关一个的更多信息 特定的仪表板,请点击其链接,类似于: | Parameter name | |---------------|---------------|---------|--------------------------------------------------| | 0 | A number related to date of execution which resembles the end of the period to monitor | dataValuesPageSize | array of string |

[]

| 类型 | Potential duplicate status | 仪表板资源将提供仪表板列表。请记住 仪表板对象是共享的,因此列表将受 当前已验证的用户。您可以检索有关一个的更多信息 特定的仪表板,请点击其链接,类似于: | Parameter name | |---------------|---------------|---------|--------------------------------------------------| | Set true if job should send notifications based on validation rule groups | number of tracked entities processed as a unit | 名称 | 类型 | | Set true if job should persist validation results | number of tracked entities processed as a unit | 名称 | 类型 | | 默认 | A number related to date of execution which resembles the end of the period to monitor | dataValuesPageSize | array of string | | [] | A number related to date of execution which resembles the end of the period to monitor | dataValuesPageSize | 名称 |

类型

| 类型 | Potential duplicate status | 仪表板资源将提供仪表板列表。请记住 仪表板对象是共享的,因此列表将受 当前已验证的用户。您可以检索有关一个的更多信息 特定的仪表板,请点击其链接,类似于: | Parameter name | |---------------|---------------|---------|--------------------------------------------------| | 0 | A number related to date of execution which resembles the end of the period to monitor | dataValuesPageSize | int |

创建作业配置{ #create-a-job-configuration }

A number related to date of execution which resembles the start of the period to monitor

predictors

array of string

[]

Predictors (UIDs) to include in job

predictorGroups

array of string

[]

Predictor groups (UIDs) to include in job

Table: MATERIALIZED_SQL_VIEW_UPDATE job parameters

获取作业配置{ #get-job-configurations }

类型

默认

描述

sqlViews

array of string

[]

更新作业配置{ #update-a-job-configuration }

Create a Job Configuration

要配置作业,您可以对以下资源发出POST请求:

/api/jobConfigurations

删除作业配置{ #delete-a-job-configuration }

{
  "name": "",
  "jobType": "JOBTYPE",
  "cronExpression": "0 * * ? * *",
}

参数为JSON格式的分析表作业的示例:

{
  "name": "Analytics tables last two years",
  "jobType": "ANALYTICS_TABLE",
  "cronExpression": "0 * * ? * *",
  "jobParameters": {
    "lastYears": "2",
    "skipTableTypes": [],
    "skipResourceTables": false
  }
}

作为带有JSON格式参数的推送分析作业的示例:

{
   "name": "Push anlysis charts",
   "jobType": "PUSH_ANALYSIS",
   "cronExpression": "0 * * ? * *",
   "jobParameters": {
     "pushAnalysis": [
       "jtcMAKhWwnc"
     ]
    }
 }

An example of a job with scheduling type FIXED_DELAY and 120 seconds delay:

查找存在执行错误的作业{ #searching-for-jobs-with-execution-errors }

Get Job Configurations

列出所有作业配置:

GET /api/jobConfigurations

检索作业:

GET /api/jobConfigurations/{id}

响应有效负载如下所示:

{
  "lastUpdated": "2018-02-22T15:15:34.067",
  "id": "KBcP6Qw37gT",
  "href": "http://localhost:8080/api/jobConfigurations/KBcP6Qw37gT",
  "created": "2018-02-22T15:15:34.067",
  "name": "analytics last two years",
  "jobStatus": "SCHEDULED",
  "displayName": "analytics last two years",
  "enabled": true,
  "externalAccess": false,
  "jobType": "ANALYTICS_TABLE",
  "nextExecutionTime": "2018-02-26T03:00:00.000",
  "cronExpression": "0 0 3 ? * MON",
  "jobParameters": {
    "lastYears": 2,
    "skipTableTypes": [],
    "skipResourceTables": false
  },
  "favorite": false,
  "configurable": true,
  "access": {
    "read": true,
    "update": true,
    "externalize": true,
    "delete": true,
    "write": true,
    "manage": true
  },
  "lastUpdatedBy": {
    "id": "GOLswS44mh8"
  },
  "favorites": [],
  "translations": [],
  "userGroupAccesses": [],
  "attributeValues": [],
  "userAccesses": []
}
  • Update a Job Configuration
  • 使用以下端点和JSON有效负载格式,通过参数更新作业:
  • PUT /api/jobConfigurations/{id}
  • ```json { "name": "analytics last two years", "enabled": true, "cronExpression": "0 0 3 ? * MON", "jobType": "ANALYTICS_TABLE", "jobParameters": { "lastYears": "3", "skipTableTypes": [], "skipResourceTables": false } }
    * Delete a Job Configuration
    * 使用以下方法删除作业:
    
        DELETE /api/jobConfigurations/{id}
    
    请注意,某些具有自定义配置参数的作业可能不会被添加,如果
    未配置所需的系统设置。一个例子是数据
    同步,这需要远程服务器配置。
    
    Run Jobs Manually { #execute }
    
    Jobs can be run manually using:
    
        POST /api/jobConfigurations/{id}/execute
    
    Searching for jobs with execution errors
    
    
    ## 调度项目 API{ #scheduler-api } 
    > **Note** This feature is only accessible for administrator
    > with the `F_JOB_LOG_READ` authority and superusers.
    
    ### To view the errors associated with a specific job use:
        GET /api/jobConfigurations/{id}/errors
    
    To search for jobs that match user specified search criteria use:
    
        GET /api/jobConfigurations/errors
    
    with one or more of the following search parameters
    
    `user`: include jobs ran by this user
    
    `from`: include jobs that started after this point in time
    
    `to`: include jobs that did not start later than this point in time
    
    `code`: include jobs that have errors with one of the given error codes
    
    `object`: include jobs that have errors linked to one of the given object IDs
    
    `type`: include job with errors of the specified type(s)
    
    When multiple criteria are used all have to be met (AND logic).
    If multiple `code`, `object` or `type` parameters are given just one has to match (OR logic).
    * For example, to find tracker import errors for the 1. of January 2024 with error code `E1002` 
    (tracked entity already exists) the following search is made:
    *     GET /api/jobConfigurations/errors?type=TRACKER_IMPORT_JOB&code=E1002&from=2024-01-01&to=2024-01-02
    * The results show the job run error details. By default, the `input` (the payload of the impport) 
    is excluded from the results. To include it add `includeInput=true`:
    *     GET /api/jobConfigurations/errors?includeInput=true
    
    ### > **Note**
    > Not all job types do store their errors. Currently, this feature is mostly
    > supported by import jobs.
    调度项目接口
    
    而 `/api/jobConfigurations` 则以作业配置对象为中心
    API 反映调度项目的状态,而 `/api/scheduler` API 则提供作业进度跟踪信息。 
    和 `/api/scheduling` API 提供作业进度跟踪信息。  
    
    Observe Running Jobs { #running}
    
    The execution steps and state can be observed while the job is running.
    A list of all types of jobs that are currently running is provided by:
    
        GET /api/scheduling/running/types
    
    To get an overview of all running jobs by job type use:
    
    ###     GET /api/scheduling/running
    As there only can be one job running for each type at a time the status of a
    running job can be viewed in details using:
    
        GET /api/scheduling/running/{type}
    
    For example, to see status of a running `ANALYTICS_TABLE` job use
    
        GET /api/scheduling/running/ANALYTICS_TABLE
    
    A job is a sequence of processes. Each process has a sequence of `stages`.
    Within each stage there might be zero, one or many `items`. Items could be
    processed strictly sequential or parallel, n items at a time. Often the
    number of `totalItems` is known up-front.
    
    In general the stages in a process and the items in a stage are "discovered"
    as a "side effect" of processing the data. While most processes have a fixed
    sequence of stages some processed might have varying stages depending on the
    data processed. Items are usually data dependent. Most jobs just include a
    single process.
    
    `code`: include jobs that have errors with one of the given error codes
    
    `RUNNING`: is currently processed (not yet finished)
    
    ### 重置卡在“RUNNING”状态的作业{ #reset-a-job-stuck-in-running-state } 
    `ERROR`: when completed with errors or when an exception has occurred
    
    `CANCELLED`: when cancellation was requested and the item will not complete
    
    See Completed Job Runs { #completed }
    
    ## Once a job has completed successful or with a failure as a consequence of an
    exception or cancellation the status moves from the set of running states to
    the completed job states. This set keeps only the most recent execution
    state for each job type. The overview is available at:
        GET /api/scheduling/completed
    
    ### Details on a particular job type are accordingly provided at:
        GET /api/scheduling/completed/{type}
    
    In case of the `ANALYTICS_TABLE` job this would be:
    
        GET /api/scheduling/completed/ANALYTICS_TABLE
    Request Cancelling a Running Jobs { #cancel }
    
    ### Once a job is started it works through a sequence of steps. Each step might
    in turn have collections of items that are processed. While jobs usually
    cannot be stopped at any point in time we can request cancellation and the
    process gives up cooperatively once it has completed an item or step and
    recognises that a cancellation was requested. This means jobs do not stop
    immediately and leave at an unknown point right in the middle of some
    processing. Instead, they give up when there is an opportunity to skip to
    the end. This still means that the overall process is unfinished and is not
    rolled back. It might just have done a number of steps and skipped others at
    the end.
    To cancel a running job use:
    
        POST /api/scheduling/cancel/{type}
    
    For example, to cancel the `ANALYTICS_TABLE` job run:
    
        POST /api/scheduling/cancel/ANALYTICS_TABLE
    
    ### Depending on the current step and item performed this can take from
    milliseconds to minutes before the cancellation becomes effective.
    However, the status of the overall process will be shown as `CANCELLED`
    immediately when check using
        GET /api/scheduling/running/ANALYTICS_TABLE
    
    Only jobs that have been split into processes, stages and items can be
    cancelled effectively. Not all jobs have been split yet. These will run till
    completion even if cancellation has been requested.
    
    Reset a Job stuck in RUNNING state
    
    When a server shuts down while a job is in `RUNNING` state the job 
    needs to be reverted back to its initial state manually.
    To revert a job that has `RUNNING` state but is not running use:
    
        POST /api/jobConfigurations/{uid}/revert
    
    ### Job Queues { #queues }
    Sequences of jobs (configurations) can be created using job queues.
    The queue always uses a unique name and a CRON expression trigger. 
    Once a queue is started it runs all jobs in the queue in the given sequence.
    The second in sequence starts when the first is finished and so forth.
    
    List Names of Job Queues { #queues-list } 
    
    To list the unique names of existing queues use:
    
        GET /api/scheduler/queues
    
    ### The response is a array of the names:
    ```json
    ["queue_a", "queue_b"]
    

Get A Job Queue { #queues-info }

To get all details of a specific queue use:

GET /api/scheduler/queues/{name}

The details include its name, CRON expression and job sequence:

{
  "name": "myQ",
  "cronExpression": "0 0 1 ? * *",
  "sequence": ["FgAxa6eRSzQ", "BeclVERfWbg" ]
}

Create a new Job Queue { #queues-add }

To create a new queue send a POST request with a payload object having name, CRON expression and the job sequence:

POST /api/scheduler/queues/{name}

To create a queue with name myQ use a POST to /api/scheduler/queues/myQ:

{
  "cronExpression": "0 0 1 ? * *",
  "sequence": ["FgAxa6eRSzQ", "BeclVERfWbg" ]
}

A name can be present in the payload as well but name specified in the URL path takes precedence.

NOTE

The cron expression of all job configurations but the first in a queue is cleared as they do not have a trigger on their own any longer. It needs to be restored manually once a job is removed from a queue.

Update a Job Queue

To update an existing queue CRON expression or sequence use a PUT request

PUT /api/scheduler/queues/{name}

The payload has to state both new CRON expression and job sequence like in the example above to create a new queue.

To rename a queue the new name can be stated in the payload, while the old name is used in the URL path.

Delete a Job Queue { #queues-delete }