Skip to content

previewRuleTarget

QUERYpreviewRuleTarget

AI Defense Policy GraphQL API · Queries

Preview which applications match target conditions with a given action. For policy authoring — works with unsaved rules. Single-rule variant: warnings do not consider any other rules. For a cross-rule aware preview, use previewRuleTargets. Single rule in isolation: advisories are not narrowed for rules above it and effectiveCount is null. Use previewRuleTargets for sequence-aware advisories.

Arguments

Argument Type Description
conditions [TargetConditionInput!]!
action PolicyAction!

Returns

RuleTargetPreview!

Request samples

curl -X POST "https://api.taegis.sophos.com/graphql" -H "Authorization: Bearer <access-token>" -H "X-Tenant-ID: <tenant-id>" -H "Content-Type: application/json" -d "{
  \"query\": \"query PreviewRuleTarget(\$conditions: [TargetConditionInput!]!, \$action: PolicyAction!) { previewRuleTarget(conditions: \$conditions, action: \$action) { matchedCount effectiveCount topApps { id name riskLevel } riskCounts { level count } warnings enforcementImpact { webControlDomains } } }\",
  \"variables\": {
    \"conditions\": [
      {
        \"dimension\": \"<dimension>\",
        \"operator\": \"IN\",
        \"values\": [
          \"<values>\"
        ]
      }
    ],
    \"action\": \"BLOCK\"
  }
}"

import requests

response = requests.post(
    "https://api.taegis.sophos.com/graphql",
    headers={
        "Authorization": "Bearer <access-token>",
        "X-Tenant-ID": "<tenant-id>",
        "Content-Type": "application/json",
    },
    json={   'query': 'query PreviewRuleTarget($conditions: [TargetConditionInput!]!, '
             '$action: PolicyAction!) { previewRuleTarget(conditions: '
             '$conditions, action: $action) { matchedCount effectiveCount '
             'topApps { id name riskLevel } riskCounts { level count } '
             'warnings enforcementImpact { webControlDomains } } }',
    'variables': {   'conditions': [   {   'dimension': '<dimension>',
                                           'operator': 'IN',
                                           'values': ['<values>']}],
                     'action': 'BLOCK'}},
)
print(response.json())

$headers = @{
    "Authorization" = "Bearer <access-token>"
    "X-Tenant-ID" = "<tenant-id>"
    "Content-Type" = "application/json"
}
$body = '{
  "query": "query PreviewRuleTarget($conditions: [TargetConditionInput!]!, $action: PolicyAction!) { previewRuleTarget(conditions: $conditions, action: $action) { matchedCount effectiveCount topApps { id name riskLevel } riskCounts { level count } warnings enforcementImpact { webControlDomains } } }",
  "variables": {
    "conditions": [
      {
        "dimension": "<dimension>",
        "operator": "IN",
        "values": [
          "<values>"
        ]
      }
    ],
    "action": "BLOCK"
  }
}'
Invoke-RestMethod -Method POST -Uri "https://api.taegis.sophos.com/graphql" -Headers $headers -Body $body -ContentType "application/json"

package main

import (
    "fmt"
    "io"
    "net/http"
    "strings"
)

func main() {
    req, err := http.NewRequest("POST", "https://api.taegis.sophos.com/graphql", strings.NewReader(`{
  "query": "query PreviewRuleTarget($conditions: [TargetConditionInput!]!, $action: PolicyAction!) { previewRuleTarget(conditions: $conditions, action: $action) { matchedCount effectiveCount topApps { id name riskLevel } riskCounts { level count } warnings enforcementImpact { webControlDomains } } }",
  "variables": {
    "conditions": [
      {
        "dimension": "<dimension>",
        "operator": "IN",
        "values": [
          "<values>"
        ]
      }
    ],
    "action": "BLOCK"
  }
}`))
    if err != nil {
        panic(err)
    }
    req.Header.Set("Authorization", "Bearer <access-token>")
    req.Header.Set("X-Tenant-ID", "<tenant-id>")
    req.Header.Set("Content-Type", "application/json")

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}

const response = await fetch("https://api.taegis.sophos.com/graphql", {
  method: "POST",
  headers: {
    "Authorization": "Bearer <access-token>",
    "X-Tenant-ID": "<tenant-id>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
  "query": "query PreviewRuleTarget($conditions: [TargetConditionInput!]!, $action: PolicyAction!) { previewRuleTarget(conditions: $conditions, action: $action) { matchedCount effectiveCount topApps { id name riskLevel } riskCounts { level count } warnings enforcementImpact { webControlDomains } } }",
  "variables": {
    "conditions": [
      {
        "dimension": "<dimension>",
        "operator": "IN",
        "values": [
          "<values>"
        ]
      }
    ],
    "action": "BLOCK"
  }
}),
});
const data = await response.json();
console.log(data);