resources/segments/jobs/assignments
Assign selected segments to jobs.
NOTE: This method works with Standard projects only. Codyt is NOT supported.
URL
(POST) /api/resources/segments/jobs/assignments
PARAMETERS
The request BODY contains a JSON object with these properties:
action | The action to perform:
Note: If no change was applied for a segment, the segment is counted in the “noop” result parameter. | string, Mandatory |
scope | Defines the scope of segments to select. See Scope (Object) | object, Mandatory |
query | Defines an optional filter on the segments within the scope. See Search and filter segments for how to construct this object. | object?, Optional |
jobIds | A list of Standard job IDs. All these jobs will be assigned to the segments selected from the scope and query. | int[], Mandatory |
status | Optional, default is 0 (no status). The segment’s text status specific to a job ID. It is a value from this enumeration: Text Status (Enumeration) | int, Optional |
maxSegments | Specify the maximum number of segments that should be updated. By default this is 1000. Jobs with too many segments may not be practical. Note: If a selected segment was not changed (such as when all jobs are already assigned), it will be skipped and counted under the “noop” result parameter. Ultimately, the system attempts to change as many filtered segments as you specify in maxSegments. | int, Optional |
callbackurl | Specify a URL which will be called upon success or failure of operation. This makes polling for operation status unnecessary. See Callbacks (with asynchronous operations) | Optional |
EXAMPLES
Assign segments:
{
"scope":{ "type": "Project", "projectid": 7182 },
"query": { "ctx": ["labels"] },
"maxSegments": 10,
"action": "Assign",
"jobIds": [3343, 3665],
"status": 0
}
Unassign segments:
{
"scope":{ "type": "Project", "projectid": 7182 },
"query": { },
"maxSegments": 20,
"action": "Unassign",
"jobIds": [3343, 3342],
}
Set status
{
"scope":{ "type": "Project", "projectid": 7182 },
"query": { },
"maxSegments": 3,
"action": "SetStatus",
"jobIds": [3342],
"status": 2
}
RESULTS
This method is an asynchronous operation: Your request is queued and will execute as soon as possible.
Asynchronous operations - How to:
The API method immediately returns a JSON object that includes the ID of the operation (look for the requestId
property).
However, the operation has not yet been executed. You will need to await the operation’s termination to obtain results.
Waiting can be done in two ways: Polling: Regularly check the operation’s status. Webhook Call: Wait for a callback using the callbackurl
parameter in your request. We strongly recommend the latter approach. For more details, please refer to the documentation: Asynchronous operations
The JSON results, obtained with polling or with a callback, include the operation status as well as any results specific to the API method. Below is an example of successful termination:
{
"trm": {
"requestid": 13432,
"isbatch": false,
"status": "Finished",
"statusText": "Finished!"
},
"custom": {
"updated": 48,
"noop": 0,
"failures": 0
}
}
Check the status of trm/status
. In case of success it should say “Finished”.
The node custom/files
lists each submitted file with these properties:
updated: Total segments that were updated.
noop: Total segments that were filtered but did not need to be updated. They were thus skipped.
failures: Total segments that could not be assigned for technical reasons.