Forum Discussion

yaquaholic's avatar
yaquaholic
Icon for Contributor II rankContributor II
15 days ago

GraphQL query problem

I'm trying to use GQL to extract detail about our event policies, as the API give very little detail.
And as we have a SL hosted system, DB access is only available to us via the Web UI. 

I've been building the query up, but I'm getting lost on the eventPolicySuppressions.
Here's the code:

query Event_Policies {
  eventPolicy(id:4075) {
    id
    name
    editedBy {id user}
    dateEdited
    severity { id name }
    enabled
    source {name}
    regularExpression1
    regularExpression2
    regularExpressionSearch
    autoClearedEvents { id name editedBy {user} }
    eventPolicySuppressions { entity {__typename}}
  }
}

I only seem to be able to get the entity {_typename} (which is "device") or the entityType ("entityType": "device") as a result. There don't appear to be any other options being offered from the UI suggestions.

Does anyone know how I can get the eventPolicySuppressions device or device groups information?

Thanks,
Richard

 

  • Hi Richard,

    You need to use an inline fragment to get more details. You can do something like the below to get more of what you want for each type, device or devicegroup, and add additional fields from there. Hope that helps!

    query Event_Policies {
      eventPolicy(id: 4075) {
        id
        name
        editedBy {
          id
          user
        }
        dateEdited
        severity {
          id
          name
        }
        enabled
        source {
          name
        }
        regularExpression1
        regularExpression2
        regularExpressionSearch
        autoClearedEvents {
          id
          name
          editedBy {
            user
          }
        }
        eventPolicySuppressions {
          entity {
            __typename
            ... on DeviceGroup {
              groups {
                id
              }
            }
            ... on Device {
              id
            }
          }
        }
      }
    }

     

  • Hi Richard,

    You need to use an inline fragment to get more details. You can do something like the below to get more of what you want for each type, device or devicegroup, and add additional fields from there. Hope that helps!

    query Event_Policies {
      eventPolicy(id: 4075) {
        id
        name
        editedBy {
          id
          user
        }
        dateEdited
        severity {
          id
          name
        }
        enabled
        source {
          name
        }
        regularExpression1
        regularExpression2
        regularExpressionSearch
        autoClearedEvents {
          id
          name
          editedBy {
            user
          }
        }
        eventPolicySuppressions {
          entity {
            __typename
            ... on DeviceGroup {
              groups {
                id
              }
            }
            ... on Device {
              id
            }
          }
        }
      }
    }