Summary

The groupsAndUsersWithPermissionsOnAsset() GraphQL query returns all groups and users that have permissions on a specific asset in a given view or repository, with optional pagination and filtering.

Syntax

graphql
groupsAndUsersWithPermissionsOnAsset(
      searchDomainName: String!,
      assetType: AssetPermissionsAssetType!,
      assetId: String!,
      searchFilter: String,
      groupsOrUsersFilters: [GroupsOrUsersFilter!],
      limit: Int = 50,
      skip: Int = 0,
      orderBy: OrderBy = ASC,
      includeEmptyPermissionSet: Boolean! = false
   ): UserOrGroupAssetPermissionSearchResultSet!

Provide searchDomainName, assetType, assetId, and includeEmptyPermissionSet (required — set to true to include principals with no current access; defaults to false). Optionally filter by searchFilter (text match), groupsOrUsersFilters (restrict to users or groups), orderBy (default ASC), limit (default 50), and skip (default 0 — use limit * (page - 1) for pagination). See Input Parameters and Returned Values for details.

Example

Raw
graphql
query {
	groupsAndUsersWithPermissionsOnAsset(
    searchDomainName: "humio",
    assetType: SavedQuery,
    assetId: "1S2bN2y5JwrzP6wEHHAQtL7bicF8mS0Y",
    groupsOrUsersFilters: Users,
    includeEmptyPermissionSet: false
  )
  { totalResults  }
}
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" : "query {
	groupsAndUsersWithPermissionsOnAsset(
    searchDomainName: \"humio\",
    assetType: SavedQuery,
    assetId: \"1S2bN2y5JwrzP6wEHHAQtL7bicF8mS0Y\",
    groupsOrUsersFilters: Users,
    includeEmptyPermissionSet: false
  )
  { totalResults  }
}"
}
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" : "query {
	groupsAndUsersWithPermissionsOnAsset(
    searchDomainName: \"humio\",
    assetType: SavedQuery,
    assetId: \"1S2bN2y5JwrzP6wEHHAQtL7bicF8mS0Y\",
    groupsOrUsersFilters: Users,
    includeEmptyPermissionSet: false
  )
  { totalResults  }
}"
}
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" : "query { ^
	groupsAndUsersWithPermissionsOnAsset( ^
    searchDomainName: \"humio\", ^
    assetType: SavedQuery, ^
    assetId: \"1S2bN2y5JwrzP6wEHHAQtL7bicF8mS0Y\", ^
    groupsOrUsersFilters: Users, ^
    includeEmptyPermissionSet: false ^
  ) ^
  { totalResults  } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "query {
	groupsAndUsersWithPermissionsOnAsset(
    searchDomainName: \"humio\",
    assetType: SavedQuery,
    assetId: \"1S2bN2y5JwrzP6wEHHAQtL7bicF8mS0Y\",
    groupsOrUsersFilters: Users,
    includeEmptyPermissionSet: false
  )
  { totalResults  }
}"
}'
    "$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 = "query {
	groupsAndUsersWithPermissionsOnAsset(
    searchDomainName: \"humio\",
    assetType: SavedQuery,
    assetId: \"1S2bN2y5JwrzP6wEHHAQtL7bicF8mS0Y\",
    groupsOrUsersFilters: Users,
    includeEmptyPermissionSet: false
  )
  { totalResults  }
}";
$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" : "query {
	groupsAndUsersWithPermissionsOnAsset(
    searchDomainName: \"humio\",
    assetType: SavedQuery,
    assetId: \"1S2bN2y5JwrzP6wEHHAQtL7bicF8mS0Y\",
    groupsOrUsersFilters: Users,
    includeEmptyPermissionSet: false
  )
  { totalResults  }
}"
}'''

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" : "query {
	groupsAndUsersWithPermissionsOnAsset(
    searchDomainName: \"humio\",
    assetType: SavedQuery,
    assetId: \"1S2bN2y5JwrzP6wEHHAQtL7bicF8mS0Y\",
    groupsOrUsersFilters: Users,
    includeEmptyPermissionSet: false
  )
  { totalResults  }
}"
}
);


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": {
    "groupsAndUsersWithPermissionsOnAsset": {
      "totalResults": 0
    }
  }
}

Input Parameters

Provide searchDomainName, assetType, assetId, and includeEmptyPermissionSet (required, defaults to false). All remaining parameters are optional.

Table: Input Parameters & Datatypes

Parameter Type Required Default Description
This table contains all input parameters for this query. Since some of the parameters use special datatypes, additional tables for them are included below.
assetId String yes   The unique identifier of the asset. For files, use the name of the file.
assetType AssetPermissionsAssetType yes   The type of the asset. See table below.
groupsOrUsersFilters [GroupsOrUsersFilter]     Whether to include only users, only groups — or both. See table below.
includeEmptyPermissionSet Boolean yes   Whether to include users and groups that currently do not have access to the asset.
limit Int   50 The amount of results to return.
orderBy OrderBy   ASC How to order results.
searchDomainName String yes   The name of the view or repository where the asset belongs.
searchFilter String     Filter results based on this string.
skip Int   0 The number of results to skip, or the offset to use.

The AssetPermissionsAssetType enum restricts the search to principals with access to a specific asset type.

Table: AssetPermissionsAssetType

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
Action      
AggregateAlert      
Dashboard      
File      
FilterAlert      
LegacyAlert      
PersistedAggregation    added in 1.259 
SavedQuery      
ScheduledReport      
ScheduledSearch      

The GroupsOrUsersFilter enum restricts results to users only, groups only, or both.

Table: GroupsOrUsersFilter Enum Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
Groups      
Users      

The OrderBy enum controls whether results are returned in ascending or descending alphanumeric order.

Returned Values

Returns a non-nullable UserOrGroupAssetPermissionSearchResultSet object with two fields: totalResults (total matching principals before pagination) and results (a list of UserOrGroupTypeAndPermissions objects, each with userOrGroup — the matching user or group — and assetPermissions — the list of AssetAction values permitted on the asset). The available fields are listed here:

Table: UserOrGroupAssetPermissionSearchResultSet Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
resultsUserOrGroupTypeAndPermissionsyes Short-Term The paginated result set
totalResultsIntyes Short-Term The total number of matching results