Summary

The assignUserRolesInSearchDomain() mutation assigns one or more roles to one or more users within a specific search domain (repository or view). This mutation requires the MultipleViewRoleBindings feature flag to be enabled. That feature flag allows multiple simultaneous role bindings per user per search domain. To remove assigned roles, use the unassignUserRoleForSearchDomain() mutation.

Syntax

graphql
assignUserRolesInSearchDomain(
      input: AssignUserRolesInSearchDomainInput!
   ): [User!]!

The mutation accepts a single required input argument of type AssignUserRolesInSearchDomainInput!. The input requires a search domain identifier and a list of user-role assignment objects, each specifying a user and the roles to assign to that user in the domain.

The mutation returns a non-null list of non-null User objects representing the affected users. Request the id and username fields to confirm which users were updated. See the Returned Values section for all available fields.

Example

Raw
graphql
mutation {
  assignUserRolesInSearchDomain(input: 
      {searchDomainId: "abc123", 
       roleAssignments: [ 
         { userId: "def456",
           roleIds: [ "ghi789" ] } ] 
       } )
   { id, 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 {
  assignUserRolesInSearchDomain(input: 
      {searchDomainId: \"abc123\", 
       roleAssignments: [ 
         { userId: \"def456\",
           roleIds: [ \"ghi789\" ] } ] 
       } )
   { id, 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 {
  assignUserRolesInSearchDomain(input: 
      {searchDomainId: \"abc123\", 
       roleAssignments: [ 
         { userId: \"def456\",
           roleIds: [ \"ghi789\" ] } ] 
       } )
   { id, 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 { ^
  assignUserRolesInSearchDomain(input:  ^
      {searchDomainId: \"abc123\",  ^
       roleAssignments: [  ^
         { userId: \"def456\", ^
           roleIds: [ \"ghi789\" ] } ]  ^
       } ) ^
   { id, username } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  assignUserRolesInSearchDomain(input: 
      {searchDomainId: \"abc123\", 
       roleAssignments: [ 
         { userId: \"def456\",
           roleIds: [ \"ghi789\" ] } ] 
       } )
   { id, 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 {
  assignUserRolesInSearchDomain(input: 
      {searchDomainId: \"abc123\", 
       roleAssignments: [ 
         { userId: \"def456\",
           roleIds: [ \"ghi789\" ] } ] 
       } )
   { id, 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 {
  assignUserRolesInSearchDomain(input: 
      {searchDomainId: \"abc123\", 
       roleAssignments: [ 
         { userId: \"def456\",
           roleIds: [ \"ghi789\" ] } ] 
       } )
   { id, 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 {
  assignUserRolesInSearchDomain(input: 
      {searchDomainId: \"abc123\", 
       roleAssignments: [ 
         { userId: \"def456\",
           roleIds: [ \"ghi789\" ] } ] 
       } )
   { id, 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();
Example Responses
Success (HTTP Response Code 200 OK)
json
{
  "data": {
    "assignUserRolesInSearchDomain": {
      "id": "def456",
      "username": "bob"
    }
  }
}

Input Parameters

Provide the unique identifier for the target search domain and a list of user-role assignment objects. Each object specifies one user and the set of roles to assign to that user in the domain. Use the searchDomains() query to retrieve search domain identifiers.

Table: AssignUserRolesInSearchDomainInput Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
roleAssignmentsUserRoleAssignmentInputyes Short-Term A non-null list of user-role assignment objects. Each object targets one user and specifies the roles to assign to that user in the search domain. See UserRoleAssignmentInput.
searchDomainIdStringyes Short-Term The unique identifier of the search domain (repository or view) where the role assignments apply. Use the searchDomains() query to retrieve available identifiers.

Each UserRoleAssignmentInput object in the roleAssignments list accepts the following fields:

Table: UserRoleAssignmentInput Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
roleIdsStringyes Short-Term A non-null list of unique role identifiers to assign to the user. Retrieve role identifiers from the searchDomains() query under usersV2.rolesV2.roles.id.
userIdStringyes Short-Term The unique identifier of the user to assign roles to in the search domain. Retrieve user identifiers from the searchDomains() query under usersV2.id.

Returned Values

The mutation returns a non-null list of User objects for the affected users. Each object includes standard user account fields such as id, username, and email, as well as fields for permissions, group membership, and search domain access. Request id and username to confirm which users received the new role assignments.

Table: User Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
allowedOrganizationActionsOrganizationActionyes Long-Term Returns the actions the user is allowed to perform in the organization. See OrganizationAction .
allowedSystemActionsSystemActionyes Long-Term Returns the actions the user is allowed to perform in the system. See SystemAction Table.
assetIdString,yes   Id of the asset
assetTypeAssetPermissionsAssetType,yes   The type of the asset.
assetTypesAssetPermissionsAssetType],yes   List of asset types
companyString  Long-Term The name of the company for the user account.
countryCodeString  Long-Term The two-letter ISO 3166-1 Alpha-2 code for the country of residence (e.g., us).
createdAtDateTimeyes Long-Term The data and time the account was created.
displayNameStringyes Long-Term The value of the fullName if used, otherwise the username.
emailString  Long-Term The user account's email address for communications from LogScale.
externalUsernameString  Long-Term Readable username for when user stems from Falcon Stability: Long-term
firstNameString  Long-Term The user's actual first name (e.g., Bob). Don't use with fullName.
fullNameString  Long-Term The user's full name (e.g., Bob Smith). Don't use if using other name parameters.
groupSearchDomainRolesGroupSearchDomainRoleyes Long-Term The group search domain roles. See GroupSearchDomainRole.
groupsGroupyes Long-Term The groups of which the user is a member. See Group.
idStringyes Long-Term The identifier or token for the user.
isOrgRootBooleanyes Long-Term Whether the organization is granted organization ownership.
isRootBooleanyes Long-Term Whether the user account is granted root access.
lastNameString  Long-Term The user's actual last name or family name (e.g., Smith). Don't use with fullName.
limitInt,    The amount of results to return.
orderByOrderBy,    Choose the order in which the results are returned.
permissionsAssetAction]):AssetPermissionSearchResultSetyes Short-Term Permissions of the user. See UserPermissions.
phoneNumberString  Long-Term The telephone number for LogScale to use for telephone text messages.
pictureString  Long-Term File name of an image file for the account.
searchDomainIdString):[AssetActionsBySourceyes Short-Term Search domain id
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 The search domain roles assigned to the user. See SearchDomainRole.
searchDomainRolesByName(searchDomainName: String!)SearchDomainRole  Deprecateddeprecated in 1.195

The search domain roles for the user, by name. See SearchDomainRole.

This field is deprecated because when multiple roles per view is enabled, it will return only the first of possibly multiple roles matching the name for the view. Use instead searchDomainRoles or searchDomainRolesBySearchDomainName.

searchDomainRolesBySearchDomainName(searchDomainName: String!)SearchDomainRoleyes Long-Term The search domain roles assigned to the user by search domain name. See SearchDomainRole.
searchFilterString,    Filter results based on this string
skipInt,searchInRoles:Boolean):GroupResultSetTypeyes Short-Term The number of results to skip or the offset to use. For instance if implementing pagination, set skip = limit * (page - 1)
sortBySortBy,    The sort by options for assets. Asset name is default
stateCodeString  Long-Term The two-letter, ISO 3166-2 country sub-division code for the state of residence (e.g., ny).
usernameStringyes Long-Term The user name for the account.
viewNameString):[UserPermissionsyes Long-Term Exact name of the repo to find permissions for.