Bulk Actions

Overview

Bulk actions are a common extension point within Enterprise Tester, exposed as features of the grid (normally a button, or selection field and button combination).

Bulk actions can be invoked asynchronously by issuing a POST request to the backgroundtasks collection resource, with the configuration information including the command being invoked passed in the Parameters collection, as show in the example below:

{
  "Type": "bulkaction",
  "Parameters": {
    "commandName": "BulkCopy",
    "scenarioName": "BulkCopyScriptsScenario",
    "targetId": "ab1bd3c3-f30b-43b2-82e2-a07e0133511c",
    "targetType": "TestScriptPackage",
    "targetPackageId": "ab1bd3c3-f30b-43b2-82e2-a07e0133511c",
    "sourcePackageId": "4016f35b-817f-459e-8533-9fc8015335c8",
    "projectId": "c651ed19-5375-475a-a539-9f6401467130",
    "selections":[
        {"Id":"0a02cb6d-4afa-463c-a6df-9fe400b7d8fc","Type":"TestScript"},
        {"Id":"0a675d09-78cd-463e-a600-9fc80153481b","Type":"TestScript"}
    ],
    "retainStructure":true
  }
}

If we pull apart the above request we can see that we are:

Available commands

CSV Export command

The CSV Export command is an example of an action which has a payload (an exported file) which you can download after completing the action - first, here is an example of a CSV export task being created:

{
  "Type": "bulkaction",
  "Parameters": {
    "scenarioName": "CSV",
    "encoding": "UTF8",
    "delimiter": "comma",
    "onlyVisibleColumns": false,
    "includeHeader": true,
    "includeSteps": true,
    "includeStepsResults": true,
    "query": "Name ~ export",
    "exportAll": true,
    "commandName": "Export"
  }
}

As a result of creating this task, the response will indicate where the task updates can be fetched from via GET using the "Self" URL:

{   
  "Complete": false,
  "TotalElements": 0,
  "ProcessedElements": 0,
  "StartedAt": "2012-07-03T12:16:30Z",
  "ProgressInPercent": 0.0,
  "Id": "bulkaction_Export_CSV_56065c63-cdf7-4285-ab10-321646317be8",
  "Message": null,
  "Self": "http://localhost:29840/api/backgroundtask/bulkaction_Export_CSV_56065c63-cdf7-4285-ab10-321646317be8"
}

When the task has completed, fetching the task will include in it's response details of the where you can then download the exported file from (indicated in the "exportedfile" link).

{
  "Complete": true,
  "StartedAt": "2012-07-03T12:16:30Z",
  "FinishedAt": "2012-07-03T12:16:30Z",
  "ProgressInPercent": 1.0,
  "Id": "bulkaction_Export_CSV_56065c63-cdf7-4285-ab10-321646317be8",
  "Message": "Completed",
  "TotalTimeToExecute": "0s",
  "FileName": "export-Entities-2012-07-04-121630am.csv",
  "ContentType": "text/csv",
  "Encoding": "UTF8",
  "Self": "http://localhost:29840/api/backgroundtask/bulkaction_Export_CSV_56065c63-cdf7-4285-ab10-321646317be8",
  "Links": [
    {
      "Href": "http://localhost:29840/api/exportfile/export-Entities-2012-07-04-121630am.csv",
      "Rel": "exportedfile"
    }
  ]
}