Skip to main content

Retrieve Active Assets

This article provides an example demonstrating how to execute a GraphQL query via the Brinqa API to retrieve specific assets based on your selected criteria. While this example focuses on a specific set of attributes, you can tailor the query to include the attributes that fit your needs. For more details on the GraphiQL explorer, see how to use the GraphiQL explorer.

To query for active assets in the GraphiQL Explorer, follow these steps:

  1. Log in to your Brinqa Platform as a System Administrator.

  2. Navigate to Administration admin button > System > GraphQL Explorer.

  3. Click GraphiQL Explorer icon Show GraphiQL Explorer to display or switch to the GraphiQL Explorer.

  4. Click assets to display the options and fields for assets.

  5. To specify a filter, select the filter option and provide a condition such as status=active or complianceStatus=Non compliant.

  6. To specify the number of records to be returned, select the limit option and type a number. The default number is 10.

  7. To include specific fields in your query, select them from the available fields. For example, you can select complianceStatus, displayName, firstSeen, id, lastUpdated, and status. If needed, click the field again to remove it from the query.

tip

For a brief description of each field, refer to the Docs GraphiQL Documentation Explorer icon menu within the GraphQL Explorer. You can use the search function to find specific attributes, or browse the list to get a brief description of each field.

  1. After you've selected all the desired fields, click Execute query or press Ctrl-Enter to run the query.

The right pane displays the results. You can modify the query by changing the filter conditions and the limit, or by selecting different fields to include in the response.

Assets query

After you've verified that the query is fetching the desired data, you can either copy the query itself or click GraphiQL Code Exporter icon Show GraphiQL Code Exporter to obtain the cURL command.

Here's the cURL command corresponding to the query in the screenshot. It sends a POST request to the Brinqa GraphQL endpoint with specific headers, such as Content-Type and Authorization, to ensure proper handling of the JSON content and authentication:

curl 'https://<BrinqaPlatformName>.brinqa.net/graphql/caasm' \
--compressed \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <your-access-token>" \
-H "Accept: application/json" \
-H "Accept-Encoding: gzip, deflate" \
--data '{
"query": "query MyQuery { assets(filter: \"status=active\", limit: 10) { id complianceStatus displayName firstSeen lastUpdated status }}",
"variables": null,
"operationName": "MyQuery"
}'
note

Replace <BrinqaPlatformName> with the actual name of your Brinqa Platform and replace <your-access-token> with your access token.

The result of this query is a JSON object containing an array of active assets. Each asset item consists of the fields you have selected in your query. The provided result is a snapshot of the assets that meet the criteria specified in the query:

{
"data": {
"assets": [
{
"complianceStatus": "Compliant",
"displayName": "Lina Hybarger",
"firstSeen": "2023-07-31T19:31:12.561Z",
"id": "1686091182456995840",
"lastUpdated": "2023-08-08T19:07:06.024Z",
"status": "Active"
},
{
"complianceStatus": "Compliant",
"displayName": "Teodoro Gaboury",
"firstSeen": "2023-07-31T19:31:13.917Z",
"id": "1686091182456995842",
"lastUpdated": "2023-08-08T19:07:06.024Z",
"status": "Active"
},
// ... other assets ...
]
}
}