Summary

The searchDomainAssets() GraphQL query fetches the list of assets found in one or more search domains.

Syntax

graphql
searchDomainAssets(
      searchDomainNames: [String!]!,
      assetTypes: [AssetPermissionsAssetType!],
      searchFilter: String,
      limit: Int = 50,
      skip: Int = 0,
      orderBy: OrderBy = ASC
   ): SearchDomainAssetsResultSet!

Provide any text on which to search domain assets, a list of search domain names, asset types, ordering, and the number of results to skip and return. See the Input Parameters section for details.

Returns a nullable SearchDomainAssetsResultSet object. See the Returned Values section for more on what may be returned.

Example

Raw
graphql
query {
	searchDomainAssets(
    searchDomainNames: [ "humio" ]
    assetTypes: [],
    skip: 2,
    limit: 2
    orderBy: DESC  
  )
  { totalResults, results { name, assetType, id }  }
}
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 {
	searchDomainAssets(
    searchDomainNames: [ \"humio\" ]
    assetTypes: [],
    skip: 2,
    limit: 2
    orderBy: DESC  
  )
  { totalResults, results { name, assetType, id }  }
}"
}
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 {
	searchDomainAssets(
    searchDomainNames: [ \"humio\" ]
    assetTypes: [],
    skip: 2,
    limit: 2
    orderBy: DESC  
  )
  { totalResults, results { name, assetType, id }  }
}"
}
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 { ^
	searchDomainAssets( ^
    searchDomainNames: [ \"humio\" ] ^
    assetTypes: [], ^
    skip: 2, ^
    limit: 2 ^
    orderBy: DESC   ^
  ) ^
  { totalResults, results { name, assetType, id }  } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "query {
	searchDomainAssets(
    searchDomainNames: [ \"humio\" ]
    assetTypes: [],
    skip: 2,
    limit: 2
    orderBy: DESC  
  )
  { totalResults, results { name, assetType, id }  }
}"
}'
    "$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 = "query {
	searchDomainAssets(
    searchDomainNames: [ \"humio\" ]
    assetTypes: [],
    skip: 2,
    limit: 2
    orderBy: DESC  
  )
  { totalResults, results { name, assetType, id }  }
}";
$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" : "query {
	searchDomainAssets(
    searchDomainNames: [ \"humio\" ]
    assetTypes: [],
    skip: 2,
    limit: 2
    orderBy: DESC  
  )
  { totalResults, results { name, assetType, id }  }
}"
}'''

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 {
	searchDomainAssets(
    searchDomainNames: [ \"humio\" ]
    assetTypes: [],
    skip: 2,
    limit: 2
    orderBy: DESC  
  )
  { totalResults, results { name, assetType, id }  }
}"
}
);


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": {
    "searchDomainAssets": {
      "totalResults": 37,
      "results": [
        {
          "name": "parseHumioText",
          "assetType": "SavedQuery",
          "id": "abc123"
        },
        {
          "name": "my-webhook-action",
          "assetType": "Action",
          "id": "def456"
        }
      ]
    }
  }
}

Input Parameters

Provide any text on which to search domain assets, a list of search domain names, any particular asset types that are of interest (see the second table below), how to order results (see third), and the number of results to skip and how many to return.

Table: Input Parameters & Datatypes

Parameter Type Required Default Description
This table contains all input parameters for this query. Since some of the parameters use special datatypes, additional tables for them are included below.
assetTypes [AssetPermissionsAssetType]     The types of assets to include. If empty, all asset types are included. See table below.
limit Int   50 The maximum number of results to return.
orderBy OrderBy   ASC How to order results. See table below.
searchDomainNames [String!]!     A list of repository and view names.
searchFilter String     Any text on which to filter results.
skip Int   0 The number of results to skip, or offset to use.

This special datatype will allow you to limit the search for domains to those with access to certain types of assets.

The other input datatype is a simple one. You can return results based on whether they are in ascending or descending order, alphanumerically.

Returned Values

Returns a nullable SearchDomainAssetsResultSet object. The table below lists all fields:

Table: SearchDomainAssetsResultSet Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
resultsSearchDomainAssetyes Short-Term The paginated result set.
totalResultsIntyes Short-Term The total number of matching results.

The SearchDomainAssetsResultSet type contains SearchDomainAsset objects. For reference, the SearchDomainAsset datatype table is included here:

Table: SearchDomainAsset Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
assetTypeAssetPermissionsAssetTypeyes Short-Term The type of the asset.
idStringyes Short-Term The id of the asset.
nameStringyes Short-Term The name of the asset.
resourceStringyes Short-Term The resource string representation of this asset. Can be used for assigning asset permissions for this asset
searchDomainIdStringyes Short-Term The id of the search domain.
searchDomainNameStringyes Short-Term The name of the search domain.