Description: Test a new or existing worker.
Since: 7.63.2
Security: Admin authentication is required.
Usage:POST /worker/api/v1/test/[/{workerKey}]
Produces: application/json; charset=utf-8
Header parameter: Authorization: Bearer
Parameters
Name | Datatype | Mandatory | Description |
---|---|---|---|
code | string | Yes | The worker script in TypeScript or JavaScript. |
action | enum string | Yes | Select the worker actions with which the worker is associated. |
data | object | Yes | An object that matches the action's event data. The object should match the |
stagedSecrets | string | No | The secrets to be made available during the test. If testing an existing worker, its secrets will be made available during the test. |
Query Parameters
Name | Datatype | Mandatory | Description |
---|---|---|---|
workerKey | string | No | If provided, identifies an existing worker to be tested. |
stagedSecrets | string | No | The secrets to be made available during the test. If testing an existing worker, its secrets will be made available during the test. |
projectKey | string | No | If a project admin token is used, this query parameter is required and the user must have the role project admin for the project, otherwise a HTTP error 403 is returned. |
Sample Usage
curl -X POST 'https://myserver.com/worker/api/v1/system/test' Ok
Sample Request
{ "code": string, "action": string, "data": object, // action specific payload "stagedSecrets": undefined | Secret[] }
Sample Response
{ "logs": string, // All logs generated by the worker's script appear in one line. "beforeDownload": { // The type of action. "status": DownloadStatus, // The status returned by the worker script itself. "message": string, // The message returned by the worker script. "executionStatus": “STATUS_SUCCESS” // Execution status for the worker service. } }
Secret Type
Define the secret type:
{ "key": string, // The name of the secret. "value": string // The value of the secret. }
When testing an existing worker, identified by a workerKey
, it is not possible to change the value of an existing secret.
If a staged secret is similar to an existing one, the secret should be marked for removal and then added with a new value, as in the following example.
{ "stagedSecrets": [ { “key”: “my-secret-0”, markedForRemoval: true }, { “key”: “my-secret-0”, “value”: “new-value-of-my-secret-0” } ] }
Success Response Codes:
200: OK response.
Error Response Codes:
400 The request payload is malformed.
401 Invalid credentials.
403 Insufficient permissions.
422 Error occurs when the worker service cannot encrypt a secret.
500 Error occurred during the request processing.
Sample Errors
Request Error
{ "errors": [ { "status": number, // HTTP Error status code "message": string // Reason for error } ] }
Caution
The status should be either STATUS_SUCCESS
or STATUS_FAIL
.
Execution Error
{ "message": string, // This is the message containing the error. "executionStatus": "STATUS_FAIL" }