Deduplication

This example deduplicates all files in a case.

Example Scripts

1
2
3
4
5
6
items=$current_case.searchUnsorted('')
start=Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
dedupedItems=$utilities.getItemUtility().deduplicate(items);
elapsed=Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond) - start
responseBody = { "elapsed" => elapsed, "count" => dedupedItems.length() }
response.setBody(responseBody)
1
2
3
4
5
6
7
items=$current_case.searchUnsorted('');
start = Date.now();
dedupedItems=$utilities.getItemUtility().deduplicate(items);
end = Date.now();
elapsed = parseInt(end - start)
responseBody = { "elapsed": elapsed, "count": dedupedItems.length };
response.setBody(responseBody)
1
2
3
4
5
6
7
8
9
import time

items=current_case.searchUnsorted('');
start = int(time.time() * 1000)
dedupedItems=utilities.getItemUtility().deduplicate(items);
end = int(time.time() * 1000)
elapsed = (end - start)*1000
responseBody = { "elapsed": elapsed, "count": len(dedupedItems) };
response.setBody(responseBody)

Synchronous Examples

Example Request

curl --location --request PUT 'http://localhost:8080/nuix-restful-service/svc/v1/cases/{caseId}/userScripts' \
--header 'Authorization: Bearer YOUR_BEARER_TOKEN' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data-raw '{
  "fileName": "deduplicate.rb",
  "language": "RUBY",
  "async": false
}'
wget --no-check-certificate --quiet \
  --method PUT \
  --timeout=0 \
  --header 'Authorization: Bearer YOUR_BEARER_TOKEN' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --body-data '{
  "fileName": "deduplicate.rb",
  "language": "RUBY",
  "async": false
}' \
   'http://localhost:8080/nuix-restful-service/svc/v1/cases/{caseId}/userScripts'

Example Response

{
    "elapsed": 323, 
    "count": 443
}

Asynchronous Examples

Example Request

curl --location --request PUT 'http://localhost:8080/nuix-restful-service/svc/v2/cases/{caseId}/userScripts' \
--header 'Authorization: Bearer YOUR_BEARER_TOKEN' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--data '{
"fileName": "deduplicate.rb",
"language": "RUBY",
"async": false
}'
wget --no-check-certificate --quiet \
  --method PUT \
  --timeout=0 \
  --header 'Authorization: Bearer YOUR_BEARER_TOKEN' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --body-data '{
  "fileName": "deduplicate.rb",
  "language": "RUBY",
  "async": false
}' \
   'http://localhost:8080/nuix-restful-service/svc/v2/cases/{caseId}/userScripts'

Example Response

{
    "functionKey": "b874da78-0efe-426c-b6ea-5562e5926896", 
    "location": "http://localhost:8080/nuix-restful-service/svc/v1/asyncFunctions/b874da78-0efe-426c-b6ea-5562e5926896"
}

You can retrieve the results of the function by polling the asyncFunctions endpoint.

Example Request

curl --location 'http://localhost:8080/nuix-restful-service/svc/v1/asyncFunctions/b874da78-0efe-426c-b6ea-5562e5926896' \
--header 'Authorization: Bearer YOUR_BEARER_TOKEN'
wget --no-check-certificate --quiet \
  --method GET \
  --timeout=0 \
  --header 'Authorization: Bearer YOUR_BEARER_TOKEN' \
   'http://localhost:8080/nuix-restful-service/svc/v1/asyncFunctions/b874da78-0efe-426c-b6ea-5562e5926896'

Example Response

{
    "done": true,
    "cancelled": false,
    "result": {
        "status": 200,
        "headers": {
            "Content-Type": [
                "application/json"
            ]
        },
        "fileName": null,
        "result": null,
        "output": "",
        "body": {
            "elapsed": 26,
            "count": 447
        }
    },
    "token": "YOUR_BEARER_TOKEN",
    "functionKey": "b874da78-0efe-426c-b6ea-5562e5926896",
    "progress": 0,
    "total": 1,
    "percentComplete": 0.0000,
    "updatedOn": 1709234413275,
    "status": "COMPLETE",
    "statusId": null,
    "requestTime": 1709234413273,
    "startTime": 1709234413275,
    "finishTime": 1709234419373,
    "caseId": "49a6410465624ac8ae613d5c7645f096",
    "caseName": "dedupe",
    "hasSuccessfullyCompleted": true,
    "friendlyName": "User Script Function V2",
    "caseLocation": "/cases/dedupe",
    "requestor": "YOUR_USERNAME>",
    "licenseShortName": null,
    "action": "CaseQueuedAsyncUserScriptFunctionV2",
    "options": {
        "name": "67572f0d-a97a-4653-870c-d584e5695ddc",
        "description": null,
        "absoluteFilePath": "/user-scripts/deduplicate.rb",
        "relativeOutputDirectory": "script_output"
    },
    "participatingInCaseFunctionQueue": true,
    "processedBy": "nuix-restful-server-1",
    "error": null
}