List resources
resources returns your organization's resources one page at a time. The caller needs the
resource.read permission.
query ListResources($first: Int, $after: String, $filter: JSONObject, $sort: ResourceSort) {
resources(first: $first, after: $after, filter: $filter, sort: $sort) {
data {
id
name
description
resource_type
enabled
risk_level
tags
}
pageInfo {
hasNextPage
nextCursor
}
}
}
Variables for the first page of enabled resources with a risk level of 3 or more, by name:
{
"first": 2,
"filter": { "enabled": true, "risk_level": { "$gte": 3 } },
"sort": { "column": "name", "direction": "ASC" }
}
The response is one page and a cursor:
{
"data": {
"resources": {
"data": [
{
"id": "019d1f36-c27d-7276-b4f4-59953442554f",
"name": "Ledger Admin",
"description": "Administrator access to the finance ledger",
"resource_type": "ASSIGNABLE_ITEM",
"enabled": true,
"risk_level": 4,
"tags": ["finance"]
},
{
"id": "019d1f36-c9a1-7d05-9a41-0c6f0f0f2a11",
"name": "Payroll Reports",
"description": null,
"resource_type": "ASSIGNABLE_ITEM",
"enabled": true,
"risk_level": 3,
"tags": ["finance", "hr"]
}
],
"pageInfo": {
"hasNextPage": true,
"nextCursor": "UGF5cm9sbCBSZXBvcnRz"
}
}
}
}
Read the next page
Send the same operation with the same filter and sort, and after set to the nextCursor you
received:
{
"first": 2,
"after": "UGF5cm9sbCBSZXBvcnRz",
"filter": { "enabled": true, "risk_level": { "$gte": 3 } },
"sort": { "column": "name", "direction": "ASC" }
}
Keep going until hasNextPage is false. A cursor is an opaque string that belongs to one filter
and sort: don't build one, and don't reuse it after changing either.
Without first, a page holds 50 resources. first can be at most 500.
Filter and sort
filter uses the syntax in How to use the API. You can
filter resources on name, description, tags, risk_level, resource_type, enabled,
fulfiller_type, owner_type, owner_reference_id, created_at and updated_at. A filter on
another field is refused. resource_type is ASSIGNABLE_ITEM, TASK or BUNDLE.
sort.column can be name, risk_level, resource_type, enabled, created_at, updated_at or
id. Without sort, or with a column that is not in that list, resources come back by name,
ascending.
Count resources
The page has no total, and the number of items in data is only the size of that page. To count the
resources that match a filter, ask resourceStats:
query CountResources($filter: JSONObject) {
resourceStats(filter: $filter, groupBy: RISK_LEVEL) {
total
groups {
key
count
}
}
}
Variables:
{ "filter": { "enabled": true } }
{
"data": {
"resourceStats": {
"total": 42,
"groups": [
{ "key": "1", "count": 19 },
{ "key": "2", "count": 12 },
{ "key": "3", "count": 8 },
{ "key": "4", "count": 3 }
]
}
}
}
groupBy is optional and takes RISK_LEVEL, ENABLED, OWNER_TYPE or FULFILLER_TYPE. Each
group's key is the grouped value as a string.
To list who holds a resource, use resourceAssignments(resourceId: ...), which pages the same way
with at most 100 assignments a page.