Pausing a task for the maintenance window
Pause a task to avoid partial executions and data integrity issues during a maintenance window.In this example, only one task is used for demonstration purpose. You can use your own script to loop the request to pause all the tasks that need to be paused.
Before you begin
- Generate an access token:
- For users, generate a personal access token. For further information, see Generating a Personal Access Token.
- For service accounts, generate a service account token. For further information about how to generate a service account token, see Generating a service account token. Once generated, a service account token expires after 30 minutes. If it expires, generate a new token using the POST method at the endpoint
https://api.{env}.cloud.talend.com/security/oauth/token
.
- Ensure that the user or the service account to be used to issue API calls has the
TMC_OPERATOR
role and theAUTHOR
permission for the workspace to which the task to be verified belongs.
Procedure
-
Issue the following request to pause a given task.
method: PUT endpoint: https://api.<env>.cloud.talend.com/orchestration/executables/tasks/<taskId>/pause headers: { "Content-Type": "application/json", "Authorization": "Bearer <your_personal_access_token_or_service_account_token>" } payload: { "pause" : true, "pauseContext" : "Pause during the maintenance window" }
- Set
true
to in thepause
field to pause the task. - In the
pauseContext
field, enter the message to explain the reason for which you pause the task. As the access token has been set in the previous API request used to get all scheduled task runs, if you are using Talend API Tester to issue your requests, you can use its Expression Builder to reuse theAuthorization
field of that call, for example,
For further information about this Expression Builder, see Using expressions
- Set
Results
The 202
code is returned and this pause takes effect immediately. Therefore, send the request only when the maintenance is about to start.
Resume the task when the maintenance is done.
Previous section: Checking scheduled task runs against your maintenance timetable