The groupsPage() GraphQL query returns all of the defined groups in an organization. This field is not yet available. It's described here as a preview and is used for new pagination pattern.

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

Syntax

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

graphql
groupsPage(
     search: string
     pageSize: integer!
     pageNumber: integer!
   ): GroupsPage!

In the syntax here you can see there are three possible inputs — two required, as indicated by the exlamation points. The return datatype is more complicated. It's easier to understand if you look closely at the example below. The given and returned data, though, are described in the sections that follow the example.

Raw
graphql
query{
  groupsPage(
    pageSize: 10
    pageNumber: 1
  ) {
    page {
      id, displayName, userCount
    }
    pageInfo {
      number
      totalNumberOfRows
      total
    }
  }
}
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{
  groupsPage(
    pageSize: 10
    pageNumber: 1
  ) {
    page {
      id, displayName, userCount
    }
    pageInfo {
      number
      totalNumberOfRows
      total
    }
  }
}"
}
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{
  groupsPage(
    pageSize: 10
    pageNumber: 1
  ) {
    page {
      id, displayName, userCount
    }
    pageInfo {
      number
      totalNumberOfRows
      total
    }
  }
}"
}
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{ ^
  groupsPage( ^
    pageSize: 10 ^
    pageNumber: 1 ^
  ) { ^
    page { ^
      id, displayName, userCount ^
    } ^
    pageInfo { ^
      number ^
      totalNumberOfRows ^
      total ^
    } ^
  } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "query{
  groupsPage(
    pageSize: 10
    pageNumber: 1
  ) {
    page {
      id, displayName, userCount
    }
    pageInfo {
      number
      totalNumberOfRows
      total
    }
  }
}"
}'
    "$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{
  groupsPage(
    pageSize: 10
    pageNumber: 1
  ) {
    page {
      id, displayName, userCount
    }
    pageInfo {
      number
      totalNumberOfRows
      total
    }
  }
}"
}';
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{
  groupsPage(
    pageSize: 10
    pageNumber: 1
  ) {
    page {
      id, displayName, userCount
    }
    pageInfo {
      number
      totalNumberOfRows
      total
    }
  }
}"
}'''

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{
  groupsPage(
    pageSize: 10
    pageNumber: 1
  ) {
    page {
      id, displayName, userCount
    }
    pageInfo {
      number
      totalNumberOfRows
      total
    }
  }
}"
}
);


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": {
    "groupsPage": {
      "page": [
        {
          "id": "BHdJstvjgDUjXg10KrbjiybpSbOHIw1b",
          "displayName": "chiefs",
          "userCount": 3
        },
        {
          "id": "frkEfzhGfwirpfrtLJ6QSW6ZoLqy5ZDI",
          "displayName": "peons",
          "userCount": 1
        }
      ],
      "pageInfo": {
        "number": 1,
        "totalNumberOfRows": 2,
        "total": 2
      }
    }
  }
}

For the GroupPage (see Returned Datatypes below), you have to enter page with the fields you want returned. Those parameters come from the Group datatype. As for pageInfo, all three of the parameters are required and returned.

Given Datatypes

The given parameters are described in the table below:

Table: Mix of input for groupsPage

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.
Table last updated: Sep 6, 2024
searchstring  Text on which to search the groups in the organization.
pageSizeinteger 50The number of records to return per page.
pageNumberinteger 0Used to specify which page of results to return.

Returned Datatypes

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

Table: GroupPage

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.
Table last updated: Sep 25, 2024
page[Group]yes A list of groups. See Group.
pageInfoPageTypeyes Information about the group page. See PageType.