Summary

The testUploadFileAction() mutation tests an upload file action by running it against mock event data. Validate that the action correctly uploads a file to its configured destination before creating a permanent action with createUploadFileAction(). The test accepts a mock trigger name; the referenced trigger does not need to exist. The mutation does not save any action to the system.

Syntax

graphql
testUploadFileAction(
      input: TestUploadFileAction!
   ): TestResult!

The input argument accepts a TestUploadFileAction object, which is required and non-nullable. The required fields are viewName, name, fileName, triggerName, and eventData. Supply triggerName as a mock value; the referenced trigger does not need to exist. The optional fields updateMode, keyColumns, and keyColumnsIgnoreCase control how the file upload handles duplicate rows. See the Input Parameters section for all fields and descriptions.

The mutation returns a non-nullable TestResult object that indicates whether the test succeeded and includes a descriptive message. See the Returned Values section for details.

Example

Raw
graphql
mutation {
  testUploadFileAction( input: 
    { viewName: "humio",
      name: "tug",
      fileName: "my-file.csv",
      triggerName: "incoming",
      eventData: "[{\"#type\":\"kv\"}]",
      } )
  { success }
}
Mac OS or Linux (curl)
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "mutation {
  testUploadFileAction( input: 
    { viewName: \"humio\",
      name: \"tug\",
      fileName: \"my-file.csv\",
      triggerName: \"incoming\",
      eventData: \"[{\\"#type\\":\\"kv\\"}]\",
      } )
  { success }
}"
}
EOF
Mac OS or Linux (curl) One-line
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "mutation {
  testUploadFileAction( input: 
    { viewName: \"humio\",
      name: \"tug\",
      fileName: \"my-file.csv\",
      triggerName: \"incoming\",
      eventData: \"[{\\"#type\\":\\"kv\\"}]\",
      } )
  { success }
}"
}
EOF
Windows Cmd and curl
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql ^
    -H "Authorization: Bearer $TOKEN" ^
    -H "Content-Type: application/json" ^
    -d @'{"query" : "mutation { ^
  testUploadFileAction( input:  ^
    { viewName: \"humio\", ^
      name: \"tug\", ^
      fileName: \"my-file.csv\", ^
      triggerName: \"incoming\", ^
      eventData: \"[{\\"#type\\":\\"kv\\"}]\", ^
      } ) ^
  { success } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  testUploadFileAction( input: 
    { viewName: \"humio\",
      name: \"tug\",
      fileName: \"my-file.csv\",
      triggerName: \"incoming\",
      eventData: \"[{\\"#type\\":\\"kv\\"}]\",
      } )
  { success }
}"
}'
    "$YOUR_LOGSCALE_URL/graphql"
Perl
perl
#!/usr/bin/perl

use HTTP::Request;
use LWP;

my $TOKEN = "TOKEN";

my $uri = '$YOUR_LOGSCALE_URL/graphql';

my $query = "mutation {
  testUploadFileAction( input: 
    { viewName: \"humio\",
      name: \"tug\",
      fileName: \"my-file.csv\",
      triggerName: \"incoming\",
      eventData: \"[{\\"#type\\":\\"kv\\"}]\",
      } )
  { success }
}";
$query =~ s/\n/ /g;
my $json = sprintf('{"query" : "%s"}',$query);
my $req = HTTP::Request->new("POST", $uri );

$req->header("Authorization" => "Bearer $TOKEN");
$req->header("Content-Type" => "application/json");

$req->content( $json );

my $lwp = LWP::UserAgent->new;

my $result = $lwp->request( $req );

print $result->{"_content"},"\n";
Python
python
#! /usr/local/bin/python3

import requests

url = '$YOUR_LOGSCALE_URL/graphql'
mydata = r'''{"query" : "mutation {
  testUploadFileAction( input: 
    { viewName: \"humio\",
      name: \"tug\",
      fileName: \"my-file.csv\",
      triggerName: \"incoming\",
      eventData: \"[{\\"#type\\":\\"kv\\"}]\",
      } )
  { success }
}"
}'''

resp = requests.post(url,
                     data = mydata,
                     headers = {
   "Authorization" : "Bearer $TOKEN",
   "Content-Type" : "application/json"
}
)

print(resp.text)
Node.js
javascript
const https = require('https');

const data = JSON.stringify(
    {"query" : "mutation {
  testUploadFileAction( input: 
    { viewName: \"humio\",
      name: \"tug\",
      fileName: \"my-file.csv\",
      triggerName: \"incoming\",
      eventData: \"[{\\"#type\\":\\"kv\\"}]\",
      } )
  { success }
}"
}
);


const options = {
  hostname: '$YOUR_LOGSCALE_URL',
  path: 'graphql',
  port: 443,
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Content-Length': data.length,
    Authorization: 'BEARER ' + process.env.TOKEN,
    'User-Agent': 'Node',
  },
};

const req = https.request(options, (res) => {
  let data = '';
  console.log(`statusCode: ${res.statusCode}`);

  res.on('data', (d) => {
    data += d;
  });
  res.on('end', () => {
    console.log(JSON.parse(data).data);
  });
});

req.on('error', (error) => {
  console.error(error);
});

req.write(data);
req.end();
Example Responses
Success (HTTP Response Code 200 OK)
json
{
  "data": {
    "testUploadFileAction": {
      "success": true
    }
  }
}

Input Parameters

The TestUploadFileAction input type requires viewName, name, fileName, triggerName, and eventData. Supply triggerName as a mock value; the referenced trigger does not need to exist. Supply eventData as a JSON object for a single event or a JSON array of objects for multiple events to make the test more realistic. The optional fields updateMode, keyColumns, and keyColumnsIgnoreCase control row-update behavior when the destination file already exists.

Table: TestUploadFileAction Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
eventDataStringyes Long-Term JSON data representing one or more events. One event can be supplied as a JSON object. Multiple events must be supplied as a list of JSON objects.
fileNameStringyes Long-Term The file name for the uploaded file.
keyColumnsStringyes   Key columns to use to update the file. This only allowed when `updateMode` is set to `update`, in which case it is mandatory. If new rows match existing rows in these columns, the existing row will be updated. If not, new rows will be appended.
keyColumnsIgnoreCaseBoolean    Whether to match key columns case insensitively or not. Should only be set when `updateMode` is `Update`, in which case it is mandatory.
nameStringyes Long-Term The name of the action.
triggerNameStringyes Long-Term The name of the action. This is a mock value, the trigger doesn't have to exist.
updateModeUpdateMode    The mode for the file update.
viewNameStringyes Long-Term The name of the view of the action.

Returned Values

The mutation returns a TestResult object indicating whether the test succeeded and providing a descriptive message. Review this result to confirm your configuration is correct before creating a permanent action.

Table: TestResult Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
messageStringyes Long-Term A message explaining the test result.
successBooleanyes Long-Term True if the test was a success, false otherwise.