Summary

The assignPermissionsForResources() mutation assigns one or more permissions to users or groups for specific resources in LogScale, such as dashboards or saved queries. To inspect existing permissions before assigning new ones, run the groupsAndUsersWithPermissionsOnAsset() query first.

Syntax

graphql
assignPermissionsForResources(
      input: [PermissionAssignmentInputType!]!
   ): [UserOrGroup!]!

The input argument accepts a non-null list of PermissionAssignmentInputType objects. Each object identifies the user or group and specifies the permissions to assign for a target resource. To retrieve actor and resource identifiers, run the groupsAndUsersWithPermissionsOnAsset() query. The Input Parameters section describes each field.

The mutation returns a non-null list of UserOrGroup values, each representing a user or group affected by the assignment. UserOrGroup is a union of the Group and User types. The Returned Values section lists the available fields for each type.

Example

Raw
graphql
mutation {
   assignPermissionsForResources(input: [
    {actor: { actorId: "abc123", actorType: User }, 
              resource: "searchdomain/def456", 
              permissionSet: {permissionSetType: RoleId, 
              values: [ "ghi789" ] } } ] ) 
   {... on User {username} }
}
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 {
   assignPermissionsForResources(input: [
    {actor: { actorId: \"abc123\", actorType: User }, 
              resource: \"searchdomain/def456\", 
              permissionSet: {permissionSetType: RoleId, 
              values: [ \"ghi789\" ] } } ] ) 
   {... on User {username} }
}"
}
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 {
   assignPermissionsForResources(input: [
    {actor: { actorId: \"abc123\", actorType: User }, 
              resource: \"searchdomain/def456\", 
              permissionSet: {permissionSetType: RoleId, 
              values: [ \"ghi789\" ] } } ] ) 
   {... on User {username} }
}"
}
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 { ^
   assignPermissionsForResources(input: [ ^
    {actor: { actorId: \"abc123\", actorType: User },  ^
              resource: \"searchdomain/def456\",  ^
              permissionSet: {permissionSetType: RoleId,  ^
              values: [ \"ghi789\" ] } } ] )  ^
   {... on User {username} } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
   assignPermissionsForResources(input: [
    {actor: { actorId: \"abc123\", actorType: User }, 
              resource: \"searchdomain/def456\", 
              permissionSet: {permissionSetType: RoleId, 
              values: [ \"ghi789\" ] } } ] ) 
   {... on User {username} }
}"
}'
    "$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 {
   assignPermissionsForResources(input: [
    {actor: { actorId: \"abc123\", actorType: User }, 
              resource: \"searchdomain/def456\", 
              permissionSet: {permissionSetType: RoleId, 
              values: [ \"ghi789\" ] } } ] ) 
   {... on User {username} }
}";
$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 {
   assignPermissionsForResources(input: [
    {actor: { actorId: \"abc123\", actorType: User }, 
              resource: \"searchdomain/def456\", 
              permissionSet: {permissionSetType: RoleId, 
              values: [ \"ghi789\" ] } } ] ) 
   {... on User {username} }
}"
}'''

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 {
   assignPermissionsForResources(input: [
    {actor: { actorId: \"abc123\", actorType: User }, 
              resource: \"searchdomain/def456\", 
              permissionSet: {permissionSetType: RoleId, 
              values: [ \"ghi789\" ] } } ] ) 
   {... on User {username} }
}"
}
);


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();

Input Parameters

Each object in the input list must identify the user or group and specify the permissions to assign for the target resource. To retrieve identifiers for existing users or groups, run the groupsAndUsersWithPermissionsOnAsset() query.

Table: PermissionAssignmentInputType Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
actorActorInputyes   The user or group to assign permissions to
permissionSetPermissionSetInputyes   The set of permissions the given actor will gain for the resource
queryPrefixString    The query prefix. This field is only valid for view role assignments for groups.
resourceStringyes   Path of the resource for which the permissions are assigned. Can be either a search domain or a specific asset in a search domain. Examples: - A search domain with ID "123": "searchdomain/123" - A dashboard with ID "321" in a search domain with ID "123": "searchdomain/123/dashboard/321"

Returned Values

The mutation returns a non-null list of UserOrGroup values. This is a union between two datatypes: Group and User. The following tables describe the fields available for each type.

Table: Group Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
assetIdString,yes   Id of the asset
assetTypeAssetPermissionsAssetType,searchDomainId:String):GroupAssetActionsBySourceyes Short-Term The type of the asset.
assetTypesAssetPermissionsAssetType],yes   List of asset types
defaultQueryPrefixString  Long-Term  
defaultRoleRole  Long-Term  
defaultSearchDomainCountIntyes Long-Term  
displayNameStringyes Long-Term  
idStringyes Long-Term  
limitInt,    The amount of results to return.
lookupNameString  Long-Term  
orderByOrderBy):UserResultSetTypeyes Long-Term Choose the order in which the results are returned.
organizationRolesGroupOrganizationRoleyes Long-Term  
permissionTypePermissionType  Long-Term  
permissionsAssetAction]):AssetPermissionSearchResultSetyes Short-Term Include Read, Update and/or Delete permission assignments. The filter will accept all assets if the argument Null or the empty list.
rolesSearchDomainRoleyes Long-Term  
searchDomainCountIntyes Long-Term  
searchDomainIdsString],yes   List of search domain id's to search within. Null or empty list is interpreted as all search domains
searchDomainRoles(searchDomainId: String)SearchDomainRoleyes Long-Term  
searchDomainRolesByName(searchDomainName: String!)SearchDomainRole   deprecated in 1.195 
searchDomainRolesBySearchDomainName(searchDomainName: String!)SearchDomainRoleyes Long-Term  
searchFilterString,    Filter results based on this string
skipInt,    The number of results to skip or the offset to use. For instance if implementing pagination, set skip = limit * (page - 1)
sortByOrderByUserField,    The value to sort the result set by.
systemRolesGroupSystemRoleyes Long-Term  
userCountIntyes Long-Term  
usersUseryes Long-Term Â