Summary

The installPackageFromZip() mutation installs a package into a view or repository from a file uploaded as multipart/form-data (form field name file). Use this mutation for a first-time package installation. To upgrade an existing package, use updatePackageFromZip(). To force a reinstall in a single call, set overwrite to true; the mutation then replaces the installed package without requiring a prior uninstall.

Syntax

graphql
installPackageFromZip(
      viewName: String!,
      overwrite: Boolean,
      queryOwnershipType: QueryOwnershipType = User
   ): InstallPackageFromZipResult!

Set viewName to the name of the view or repository where you want to install the package. Optionally set overwrite to replace an existing installation, and set queryOwnershipType to control which user owns the triggers installed by the package. See the Input Parameters section for details.

The mutation returns an InstallPackageFromZipResult object confirming the outcome. See the Returned Values section.

Example

Raw
graphql
mutation {
  installPackageFromZip (
    viewName: "humio",
    overwrite: true,
    queryOwnershipType: User
  )
  { wasSuccessful }
}
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 {
  installPackageFromZip (
    viewName: \"humio\",
    overwrite: true,
    queryOwnershipType: User
  )
  { wasSuccessful }
}"
}
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 {
  installPackageFromZip (
    viewName: \"humio\",
    overwrite: true,
    queryOwnershipType: User
  )
  { wasSuccessful }
}"
}
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 { ^
  installPackageFromZip ( ^
    viewName: \"humio\", ^
    overwrite: true, ^
    queryOwnershipType: User ^
  ) ^
  { wasSuccessful } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  installPackageFromZip (
    viewName: \"humio\",
    overwrite: true,
    queryOwnershipType: User
  )
  { wasSuccessful }
}"
}'
    "$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 {
  installPackageFromZip (
    viewName: \"humio\",
    overwrite: true,
    queryOwnershipType: User
  )
  { wasSuccessful }
}";
$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 {
  installPackageFromZip (
    viewName: \"humio\",
    overwrite: true,
    queryOwnershipType: User
  )
  { wasSuccessful }
}"
}'''

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 {
  installPackageFromZip (
    viewName: \"humio\",
    overwrite: true,
    queryOwnershipType: User
  )
  { wasSuccessful }
}"
}
);


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": {
    "installPackageFromZip": {
      "wasSuccessful": true
    }
  }
}

Input Parameters

Set viewName to the name of the view or repository where the package installs. By default, overwrite is false; the mutation fails if the package is already installed. Set it to true to replace an existing installation. The queryOwnershipType parameter controls which user owns the triggers (for example, alerts and scheduled searches) installed with the package. The owner's permissions and rate limits apply when those triggers run.

Table: Input Parameters

Parameter Type Required Default Description
This table lists all input parameters for this mutation. The queryOwnershipType parameter uses a special enum datatype; the following table describes its values.
overwrite boolean   false Whether to replace an existing package installation. Set to true to replace an installed package. When false, the mutation fails if the package is already installed.
queryOwnershipType QueryOwnershipType   User Ownership of the queries run by the triggers (for example, alerts and scheduled searches) installed with this package. When set to User, the calling user owns those triggers; their permissions and rate limits apply when the triggers run.
viewName string yes   The name of the view or repository where the package installs.

The ownership setting determines which user's data access permissions and query rate limits apply when the installed triggers execute. For example, User applies the calling user's access rights. If that user's permissions change or the account is removed, trigger behavior may be affected.

Returned Values

The mutation returns an InstallPackageFromZipResult object. This object confirms whether the installation succeeded. The following table describes the fields it contains:

Table: InstallPackageFromZipResult Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
wasSuccessfulBooleanyes Long-Term Whether package was installed successfully.