Reference: Gateway examples for Connect

Tanium Gateway provides a GraphQL API integration point for Tanium solutions, including Connect. Connect queries and mutations require Connect to retrieve information about connections and connection runs, and to start or stop connection runs.

For additional Gateway example syntax, see Reference: Filter syntax and Reference: Gateway examples.

Connect v1 REST API replacement

The Connect GraphQL APIs are at stability index 1.2 - Experimental (Release Candidate). For the best results, if a GraphQL API provides functionality, use that instead of the corresponding legacy Connect REST API. Connect REST APIs not listed in the table do not have comparable functionality in Tanium Gateway, or are otherwise not used in favor of other Connect REST APIs.

Table 1. Gateway GraphQL API replacements for Connect v1 REST API endpoints

Connect v1 REST API endpoint

Gateway GraphQL API replacement

Notes

DELETE v1/connections/:id

n/a

Delete a connection by ID

GET v1/connectionruns (legacy)

query.connectRuns

Get connection runs

GET v1/connections (legacy)

query.connectConnections

Get connections

GET v1/connections/:id (legacy)

query.connectConnection

Get a connection by ID

GET v1/connections/:id/runs/:connectionrunid (legacy)

query.connectRun

Get a connection run by ID

GET v1/connections/:id/runs/:connectionrunid/download

n/a

Get the log data for a connection run

POST v1/connections/:id/runs (legacy)

mutation.connectConnectionStart

Start a connection run

POST v1/connections/:id/stop (legacy)

mutation.connectConnectionStop

Stop an in-progress connection run

POST v1/import

n/a

Create or modify a connection

Get Connect connection by ID

The following query requires Connect 5.20 or later and retrieves a connection that matches the ID.

JSON
query exampleGetSingleConnection($id: ID!) {
  connectConnection(ref: {id: $id}) {
    id
    currentRun {
      id
      connectionID
      status
      createdTime
      updatedTime
    }
    description
    displayName
    pastRuns {
      edges {
        node {
          id
          connectionID
          status
          createdTime
          updatedTime
        }
      }
    }
  }
}

Include an ID variable in the QUERY VARIABLES panel or in your variables dictionary:

JSON
{
  "id": "123"
}

Example response:

JSON
{
  "data": {
    "connectConnection": {
      "id": "123",
      "currentRun": null,
      "description": "Example connection description",
      "displayName": "Example connection name",
      "pastRuns": {
        "edges": [
          {
            "node": {
              "id": "234",
              "connectionID": "23",
              "status": "Finished",
              "createdTime": "2023-08-15T16:45:00.574Z",
              "updatedTime": "2023-08-15T16:45:03.689Z"
            }
          },
          {
            "node": {
              "id": "345",
              "connectionID": "23",
              "status": "Finished",
              "createdTime": "2023-08-15T15:45:00.575Z",
              "updatedTime": "2023-08-15T15:45:03.567Z"
            }
          }
        ]
      }
    }
  }
}

Get Connect connection run by ID

The following query requires Connect 5.20 or later and retrieves a connection run that matches the ID.

JSON
query exampleGetSingleConnectionRun($id: ID!) {
  connectRun(ref: {id: $id}) {
    id
    connectionID
    status
    createdTime
    updatedTime
  }
}

Include an ID variable in the QUERY VARIABLES panel or in your variables dictionary:

JSON
{
  "id": "123"
}

Example response:

JSON
{
  "data": {
    "connectRun": {
      "id": "123",
      "connectionID": "234",
      "status": "Finished",
      "createdTime": "2023-08-15T07:01:21.824Z",
      "updatedTime": "2023-08-15T07:01:30.912Z"
    }
  }
}

Get multiple Connect connection runs

The following query requires Connect 5.20 or later and retrieves the first 2 connection runs.

JSON
query exampleGetConnectionRuns($first: Int) {
  connectRuns(first: $first) {
    edges {
      node {
        id
        connectionID
        status
        createdTime
        updatedTime
      }
    }
    pageInfo {
      hasPreviousPage
      hasNextPage
      startCursor
      endCursor
    }
    totalRecords
  }
}

Include a pagination variable in the QUERY VARIABLES panel or in your variables dictionary:

JSON
{
  "first": 2
}

Example response:

JSON
{
  "data": {
    "connectRuns": {
      "edges": [
        {
          "node": {
            "id": "1",
            "connectionID": "123",
            "status": "Finished",
            "createdTime": "2023-08-15T07:01:21.824Z",
            "updatedTime": "2023-08-15T07:01:30.912Z"
          }
        },
        {
          "node": {
            "id": "2",
            "connectionID": "234",
            "status": "Finished",
            "createdTime": "2023-08-15T07:01:19.678Z",
            "updatedTime": "2023-08-15T07:01:23.757Z"
          }
        }
      ],
      "pageInfo": {
        "hasPreviousPage": false,
        "hasNextPage": true,
        "startCursor": "MA==",
        "endCursor": "MQ=="
      },
      "totalRecords": 504
    }
  }
}

Get multiple Connect connections

The following query requires Connect 5.20 or later and retrieves the first 2 connections.

JSON
query exampleGetConnections($first: Int) {
  connectConnections(first: $first) {
    edges {
      node {
        id
        currentRun {
          id
          connectionID
          status
          createdTime
          updatedTime
        }
        description
        displayName
        pastRuns {
          edges {
            node {
              id
              connectionID
              status
              createdTime
              updatedTime
            }
          }
        }
      }
    }
    pageInfo {
      hasNextPage
      hasPreviousPage
      startCursor
      endCursor
    }
    totalRecords
  }
}

Include a pagination variable in the QUERY VARIABLES panel or in your variables dictionary:

JSON
{
  "first": 2
}

Example response:

JSON
{
  "data": {
    "connectConnections": {
      "edges": [
        {
          "node": {
            "id": "23",
            "currentRun": null,
            "description": "Example connection description",
            "displayName": "Example connection name",
            "pastRuns": {
              "edges": [
                {
                  "node": {
                    "id": "234",
                    "connectionID": "23",
                    "status": "Finished",
                    "createdTime": "2023-08-15T16:45:00.574Z",
                    "updatedTime": "2023-08-15T16:45:03.689Z"
                  }
                },
                {
                  "node": {
                    "id": "345",
                    "connectionID": "23",
                    "status": "Finished",
                    "createdTime": "2023-08-15T15:45:00.575Z",
                    "updatedTime": "2023-08-15T15:45:03.567Z"
                  }
                }
              ]
            }
          }
        },
        {
          "node": {
            "id": "13",
            "currentRun": null,
            "description": "Example connection description 2",
            "displayName": "Example connection name 2",
            "pastRuns": {
              "edges": []
            }
          }
        }
      ],
      "pageInfo": {
        "hasNextPage": true,
        "hasPreviousPage": false,
        "startCursor": "MA==",
        "endCursor": "MQ=="
      },
      "totalRecords": 23
    }
  }
}

Get multiple Connect connections by ID

The following query requires Connect 5.45 or later and retrieves the connections that match either ID 1234 or 5678.

JSON
query exampleGetMultipleConnectionsByIDs($first_id: ID!, $second_id: ID!) {
  connectConnections(filter: {ids: [$first_id, $second_id]}) {
    totalRecords
    edges {
      node {
        id
        displayName
      }
    }
  }
}

Include the ID variables in the QUERY VARIABLES panel or in your variables dictionary:

JSON
{
  "first_id": 1234,
  "second_id": 5678
}

Example response:

JSON
{
  "data": {
    "connectConnections": {
      "totalRecords": 2,
      "edges": [
        {
          "node": {
            "id": "1234",
            "displayName": "Example connection 1"
          }
        },
        {
          "node": {
            "id": "5678",
            "displayName": "Example connection 2"
          }
        }
      ]
    }
  }
}

Get multiple Connect connections by description

The following query requires Connect 5.45 or later and retrieves connections that contain Example in the description.

JSON
query exampleGetConnectionsByDescription($target_description: String) {
  connectConnections(filter: {description: $target_description}) {
    totalRecords
    edges {
      node {
        id
        displayName
        description
      }
    }
  }
}

Include the description variable in the QUERY VARIABLES panel or in your variables dictionary:

JSON
{
  "target_description": "Example"
}

Example response:

JSON
{
  "data": {
    "connectConnections": {
      "totalRecords": 3,
      "edges": [
        {
          "node": {
            "id": "1234",
            "displayName": "Example connection 1",
            "description": "An example description"
          }
        },
        {
          "node": {
            "id": "567",
            "displayName": "Example connection 2",
            "description": "Example description"
          }
        },
        {
          "node": {
            "id": "8901",
            "displayName": "Example connection 3",
            "description": "A description that contains example"
          }
        }
      ]
    }
  }
}

Get Connect connection by ID and displayName

The following query requires Connect 5.45 or later and retrieves the connection that matches ID 1234 and contains Example Connection in the displayName field.

JSON
query exampleGetConnectionByIDAndDisplayName($target_id: ID!, $target_display_name: String) {
  connectConnections(filter: { ids: [$target_id], displayName: $target_display_name }) {
    totalRecords
    edges {
      node {
        id
        displayName
      }
    }
  }
}

Include the ID and display name variables in the QUERY VARIABLES panel or in your variables dictionary:

JSON
{
  "target_id": 1234,
  "target_display_name": "Example Connection"
}

Example response:

JSON
{
  "data": {
    "connectConnections": {
      "totalRecords": 1,
      "edges": [
        {
          "node": {
            "id": "1234",
            "displayName": "Example Connection"
          }
        }
      ]
    }
  }
}

Start a Connect connection run

The following mutation requires Connect 5.20 or later and starts a connection run from a connection that matches the connection ID.

JSON
mutation exampleStartConnection($connectionID: ID!) {
  connectConnectionStart(input: {connectionID: $connectionID}) {
    run {
      id
      connectionID
      status
      createdTime
      updatedTime
    }
    error {
      message
      retryable
      timedOut
    }
  }
}

Include an ID variable in the QUERY VARIABLES panel or in your variables dictionary:

JSON
{
  "connectionID": "123"
}

Example response:

JSON
{
  "data": {
    "connectConnectionStart": {
      "run": {
        "id": "12345",
        "connectionID": "123",
        "status": "Starting",
        "createdTime": "2023-08-15T18:16:54.509Z",
        "updatedTime": "2023-08-15T18:16:54.512Z"
      },
      "error": null
    }
  }
}

Stop a Connect connection run

The following mutation requires Connect 5.20 or later and stops an in-progress connection run. This mutation has no effect on connection runs that are already stopped.

JSON
mutation exampleStopConnection($connectRunID: ID!) {
  connectConnectionStop(input: {connectRunID: $connectRunID}) {
    run {
      id
      connectionID
      status
      createdTime
      updatedTime
    }
    error {
      message
      retryable
      timedOut
    }
  }
}

Include an ID variable in the QUERY VARIABLES panel or in your variables dictionary:

JSON
{
  "connectRunID": "123"
}

Example response:

JSON
{
  "data": {
    "connectConnectionStop": {
      "run": {
        "id": "123",
        "connectionID": "234",
        "status": "Running",
        "createdTime": "2023-08-15T18:36:29.739Z",
        "updatedTime": "2023-08-15T18:36:32.235Z"
      },
      "error": null
    }
  }
}