Summary

The updatePackageFromZip() mutation updates an installed package in a view or repository using a zip file uploaded as multipart/form-data (form field name file). Use this mutation when you have a newer version of a package to apply to an existing installation. To install a package for the first time, use installPackageFromZip() instead.

Syntax

graphql
updatePackageFromZip(
      viewName: String!,
      conflictResolutions: [ConflictResolutionConfiguration!]!,
      queryOwnershipType: QueryOwnershipType = User
   ): BooleanResultType!

Provide the name of the target view or repository in viewName. Supply conflict resolution rules in conflictResolutions. Optionally set queryOwnershipType to control query execution ownership for triggers such as alerts and scheduled searches installed by the package. The mutation returns a BooleanResultType! confirming success.

Input parameters

Provide the name of the target view or repository, the conflict resolution rules for any asset naming collisions, and optionally the query ownership type for triggers installed by the package. The following tables describe the special datatypes for conflictResolutions and queryOwnershipType.

Table: Input parameters and datatypes

Parameter Type Required Default Description
This table lists all input parameters for this mutation. The conflictResolutions and queryOwnershipType parameters use special datatypes; the following tables describe their values.
conflictResolutions [ConflictResolutionConfiguration] yes   How to handle conflicts when package assets already exist in the target view. See the ConflictResolutionConfiguration table following this one.
queryOwnershipType QueryOwnershipType     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. See the QueryOwnershipType table following this one.
viewName String yes   The name of the view or repository that contains the installed package.

The ConflictResolutionConfiguration datatype requires the name of the asset and its type (for example, dashboard or aggregate alert). It also requires a resolution strategy to apply when the asset already exists. See the table below for all parameters and links to sub-parameters:

Table: ConflictResolutionConfiguration Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
conflictResolutionMergeStrategyyes Long-Term How conflicts are resolved. See MergeStrategy .
entityNameStringyes Long-Term The name of the entity.
entityTypeAssetTypeyes Long-Term The type of entity. See AssetType .

The QueryOwnershipType enum controls whether queries execute on behalf of the calling user or the organization. See the table below for details:

Example

Raw
graphql
mutation {
  updatePackageFromZip(
       viewName: "humio",
       conflictResolutions: [ { entityType: Dashboard, 
                                entityName: "Errors",
                                conflictResolution: Ours },
                              { entityType: Dashboard, 
                                entityName: "Hosts",
                                conflictResolution: Ours }],
       queryOwnershipType: Organization
  )
  { result }
}
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 {
  updatePackageFromZip(
       viewName: \"humio\",
       conflictResolutions: [ { entityType: Dashboard, 
                                entityName: \"Errors\",
                                conflictResolution: Ours },
                              { entityType: Dashboard, 
                                entityName: \"Hosts\",
                                conflictResolution: Ours }],
       queryOwnershipType: Organization
  )
  { result }
}"
}
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 {
  updatePackageFromZip(
       viewName: \"humio\",
       conflictResolutions: [ { entityType: Dashboard, 
                                entityName: \"Errors\",
                                conflictResolution: Ours },
                              { entityType: Dashboard, 
                                entityName: \"Hosts\",
                                conflictResolution: Ours }],
       queryOwnershipType: Organization
  )
  { result }
}"
}
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 { ^
  updatePackageFromZip( ^
       viewName: \"humio\", ^
       conflictResolutions: [ { entityType: Dashboard,  ^
                                entityName: \"Errors\", ^
                                conflictResolution: Ours }, ^
                              { entityType: Dashboard,  ^
                                entityName: \"Hosts\", ^
                                conflictResolution: Ours }], ^
       queryOwnershipType: Organization ^
  ) ^
  { result } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  updatePackageFromZip(
       viewName: \"humio\",
       conflictResolutions: [ { entityType: Dashboard, 
                                entityName: \"Errors\",
                                conflictResolution: Ours },
                              { entityType: Dashboard, 
                                entityName: \"Hosts\",
                                conflictResolution: Ours }],
       queryOwnershipType: Organization
  )
  { result }
}"
}'
    "$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 {
  updatePackageFromZip(
       viewName: \"humio\",
       conflictResolutions: [ { entityType: Dashboard, 
                                entityName: \"Errors\",
                                conflictResolution: Ours },
                              { entityType: Dashboard, 
                                entityName: \"Hosts\",
                                conflictResolution: Ours }],
       queryOwnershipType: Organization
  )
  { result }
}";
$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 {
  updatePackageFromZip(
       viewName: \"humio\",
       conflictResolutions: [ { entityType: Dashboard, 
                                entityName: \"Errors\",
                                conflictResolution: Ours },
                              { entityType: Dashboard, 
                                entityName: \"Hosts\",
                                conflictResolution: Ours }],
       queryOwnershipType: Organization
  )
  { result }
}"
}'''

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 {
  updatePackageFromZip(
       viewName: \"humio\",
       conflictResolutions: [ { entityType: Dashboard, 
                                entityName: \"Errors\",
                                conflictResolution: Ours },
                              { entityType: Dashboard, 
                                entityName: \"Hosts\",
                                conflictResolution: Ours }],
       queryOwnershipType: Organization
  )
  { result }
}"
}
);


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": {
    "updatePackageFromZip": {
      "result": true
    }
  }
}

Returned values

The mutation returns a BooleanResultType! indicating whether the update succeeded. The table below describes the fields in this type:

Table: BooleanResultType Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
resultBooleanyes Long-Term Whether the mutation was performed successfully.