The group() GraphQL query is used to specify a group.

For more information on user groups, see the Manage Groups documentation page.

Syntax

Below is the syntax for the group() query field:

graphql
group(
     groupId: string!
  ): Group!

To be able to get information on a particular group, with this query you have to provide the unique identifier for the group.

For the return value Group, you'll need to specify at least one of its parameters (see the Returned Datatypes section below). Here's an example which specifies two values:

Raw
graphql
query{
  group(groupId: "BHdJstvjgDUjXg10KrbjiybpSbOHIw1b") {
    displayName, userCount
  }
}
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{
  group(groupId: \"BHdJstvjgDUjXg10KrbjiybpSbOHIw1b\") {
    displayName, userCount
  }
}"
}
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{
  group(groupId: \"BHdJstvjgDUjXg10KrbjiybpSbOHIw1b\") {
    displayName, userCount
  }
}"
}
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{ ^
  group(groupId: \"BHdJstvjgDUjXg10KrbjiybpSbOHIw1b\") { ^
    displayName, userCount ^
  } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "query{
  group(groupId: \"BHdJstvjgDUjXg10KrbjiybpSbOHIw1b\") {
    displayName, userCount
  }
}"
}'
    "$YOUR_LOGSCALE_URL/graphql"
Perl
perl
#!/usr/bin/perl

use HTTP::Request;
use LWP;

my $INGEST_TOKEN = "TOKEN";

my $uri = '$YOUR_LOGSCALE_URL/graphql';

my $json = '{"query" : "query{
  group(groupId: \"BHdJstvjgDUjXg10KrbjiybpSbOHIw1b\") {
    displayName, userCount
  }
}"
}';
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{
  group(groupId: \"BHdJstvjgDUjXg10KrbjiybpSbOHIw1b\") {
    displayName, userCount
  }
}"
}'''

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{
  group(groupId: \"BHdJstvjgDUjXg10KrbjiybpSbOHIw1b\") {
    displayName, userCount
  }
}"
}
);


const options = {
  hostname: '$YOUR_LOGSCALE_URL/graphql',
  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": {
    "group": {
      "displayName": "chiefs",
      "userCount": 3
    }
  }
}

This example requests first the display name of the group, then number of users in the group. See the next section for a table containing more values you can request.

Returned Datatypes

The returned datatype group() has its own parameters. Below is a list of them along with their datatypes and a description of each:

Table: Group

ParameterTypeRequiredDefaultDescription
Some arguments may be required, as indicated in the Required column. For some fields, this column indicates that a result will always be returned for this column.
assetPermissionsmultipleyes Get asset permissions assigned to the group for the specific asset. The datatype consists of (assetId: string!, assetType: AssetPermissionsAssetType!, searchDomainId: string): AssetPermissionsForGroup!. See AssetPermissionsAssetType and AssetPermissionsForGroup.
defaultQueryPrefixstring  The default prefix for queries.
defaultRoleRole  The default role associated with the group. See Role.
defaultSearchDomainCountintegeryes The default search domain count.
displayNamestringyes The display name of the group.
idstringyes The identifier of the group.
lookupNamestring  The look-up name for the group.
organizationRoles[GroupOrganizationRole]yes The roles of the organization associated with the group. See GroupOrganizationRole.
permissionTypePermissionType  Indicates which level of permissions the group contains. See PermissionType.
queryPrefixes[QueryPrefixes]yes The query prefixes for the group. queryPrefixes(onlyIncludeRestrictiveQueryPrefixes: boolean, onlyForRoleWithId: string): [QueryPrefixes!]! See QueryPrefixes.
roles[SearchDomainRole]yes The roles for the group See SearchDomainRole.
searchAssetPermissionsmultipleyes Search for asset permissions for the group. This is a preview and subject to change. The datatype consists of (searchFilter: string, skip: integer, limit: integer, orderBy: OrderBy, sortBy: SortBy, assetTypes: [AssetPermissionsAssetType!], searchDomainIds: [string!], permissions: [AssetPermissionInputEnum!], includeUnassignedAssets: boolean): AssetPermissionSearchResultSet!. See AssetPermissionsAssetType AssetPermissionInputEnum, and AssetPermissionSearchResultSet.
searchDomainCountintegeryes The number of search domains for the group.
searchDomainRolesmultipleyes The search domain roles assigned to the group. The multiple datatype consists of (searchDomainId: string): [SearchDomainRole]. (seeSearchDomainRole).
searchDomainRolesByNamemultipleyes The search domain roles assigned to the group, by name. The multiple datatype consists of (searchDomainName: string): SearchDomainRole. See SearchDomainRole.
searchDomainRolesBySearchDomainNamestringyes The domain roles by search domain name. The datatype consists of (searchDomainName: string!): [SearchDomainRole!]. See SearchDomainRole.
searchUsersmultipleyes Used to search the list of users in the group. The datatype consists of (searchFilter: string, skip: integer, limit: integer, sortBy: OrderByUserField, orderBy: OrderBy): UserResultSetType!. See OrderByUserField, OrderBy, UserResultSetType.
systemRoles[GroupSystemRole]yes The system roles of the group (see GroupSystemRole Table).
userCountintegeryes The number of users that are part of the group.
users[User]yes The list of users in the group. See User.