Summary

The assignOrganizationRoleToGroup() mutation assigns an organization role to a group in LogScale. Organization roles define the organization-level permissions that members of the group inherit. Call this mutation after creating a group to grant it access to organization-level features and administration capabilities.

Syntax

graphql
assignOrganizationRoleToGroup(
      input: AssignOrganizationRoleToGroupInput!
   ): AssignOrganizationRoleToGroupMutation!

The mutation takes a single required input argument of type AssignOrganizationRoleToGroupInput!. Provide the unique identifier of the group and the unique identifier of the organization role to assign. Use the organization() query to retrieve these identifiers before calling this mutation.

The mutation returns a non-null AssignOrganizationRoleToGroupMutation! object containing the updated group with its assigned organization role. See the Returned Values section for the full field list.

Example

Raw
graphql
mutation {
  assignOrganizationRoleToGroup(input: 
            {groupId: "abc123", 
             roleId: "def456"} )
       { group { role {id, displayName, organizationPermissions} } }
}
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 {
  assignOrganizationRoleToGroup(input: 
            {groupId: \"abc123\", 
             roleId: \"def456\"} )
       { group { role {id, displayName, organizationPermissions} } }
}"
}
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 {
  assignOrganizationRoleToGroup(input: 
            {groupId: \"abc123\", 
             roleId: \"def456\"} )
       { group { role {id, displayName, organizationPermissions} } }
}"
}
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 { ^
  assignOrganizationRoleToGroup(input:  ^
            {groupId: \"abc123\",  ^
             roleId: \"def456\"} ) ^
       { group { role {id, displayName, organizationPermissions} } } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  assignOrganizationRoleToGroup(input: 
            {groupId: \"abc123\", 
             roleId: \"def456\"} )
       { group { role {id, displayName, organizationPermissions} } }
}"
}'
    "$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 {
  assignOrganizationRoleToGroup(input: 
            {groupId: \"abc123\", 
             roleId: \"def456\"} )
       { group { role {id, displayName, organizationPermissions} } }
}";
$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 {
  assignOrganizationRoleToGroup(input: 
            {groupId: \"abc123\", 
             roleId: \"def456\"} )
       { group { role {id, displayName, organizationPermissions} } }
}"
}'''

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 {
  assignOrganizationRoleToGroup(input: 
            {groupId: \"abc123\", 
             roleId: \"def456\"} )
       { group { role {id, displayName, organizationPermissions} } }
}"
}
);


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": {
    "assignOrganizationRoleToGroup": {
      "group": {
        "role": {
          "id": "abc123",
          "displayName": "Maintainer",
          "organizationPermissions": [
            "ChangeSecurityPolicies",
            "ManageUsers",
            "ChangeOrganizationPermissions",
            "ChangeSessions",
            "ChangeAllViewOrRepositoryPermissions"
          ]
        }
      }
    }
  }
}

Input Parameters

Provide the group ID and the role ID to associate. Use the organization() query to look up valid group and role IDs before calling this mutation.

Table: AssignOrganizationRoleToGroupInput Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
groupIdStringyes Long-Term The unique identifier of the group.
roleIdStringyes Long-Term The unique identifier of the role.

Returned Values

The mutation returns an AssignOrganizationRoleToGroupMutation! object containing the updated group association. Request the group.role field to confirm the assigned role. The role field returns a Role object that includes the role identifier, display name, and the list of organization permissions the role grants.

Table: AssignOrganizationRoleToGroupMutation Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
groupGroupOrganizationRoleyes Long-Term The group to which to assign organization role. See GroupOrganizationRole.

The AssignOrganizationRoleToGroupMutation type includes a group field that returns a GroupOrganizationRole object. The following table describes the fields available on that sub-type.

Table: GroupOrganizationRole Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
roleRoleyes Long-Term The organization role of the group. See Role.

The GroupOrganizationRole type includes a role field that returns a Role object. The following table describes the fields available on that sub-type.

Table: Role Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
descriptionString  Long-Term A description of the role.
displayNameStringyes Long-Term The display name of the role.
groupsGroupyes Long-Term The groups related to the role. See Group.
groupsCountIntyes Long-Term The number of groups related to the role.
idStringyes Long-Term The unique identifier for the role.
limitInt,    The amount of results to return.
organizationManagementPermissionsOrganizationManagementPermissionyes Long-Term The organization management permissions given to the role. See OrganizationManagementPermission.
organizationPermissionsOrganizationPermissionyes Long-Term The organization permissions given to the role. See OrganizationPermission.
readonlyDefaultRoleReadonlyDefaultRole  Short-Term The read-only default role. This parameter is a preview and subject to change. See ReadonlyDefaultRole.
skipInt):GroupResultSetTypeyes Long-Term The number of results to skip or the offset to use. For instance if implementing pagination, set skip = limit * (page - 1)
systemPermissionsSystemPermissionyes Long-Term The system permissions given to the role. See SystemPermission.
usersUseryes Long-Term A list of users assigned the role. See User.
usersCountIntyes Long-Term The number of users assigned the role.
viewPermissionsPermissionyes Long-Term The view permissions given to the role. See Permission.