Search Hosts from Discovery

The API will search hosts and its information from the existing discovery.

Before you begin

Before attempting to searching hosts from the discovery, the user has to ensure the following:
  • Discovery should be added in AppViewX.

Request Structure

Endpoint: /ssh/search/hosts
Note: The same API has been used for the following with the additional query params:
Type: POST
Sample URL: https://<IP/HostName/TenantName>:<GWPORT>/avxapi/ssh/search/hosts?gwsource=external

To understand the elements of the sample URL, click here.

Headers:
Content-Type: application/json
Table 1. Request Parameters
Name Description
sessionId

Header

(Mandatory) Session ID received after login.

Type: String

Constraints: Required if username and password are not provided.

username

Header

(Mandatory) AppViewX login username

Type: String

Constraints: Required if sessionId is not provided.

password

Header

(Mandatory) AppViewX login password

Type: String

Constraints: Required if sessionId is not provided.

Content-Type

Header

(Mandatory) Specifies the nature of the data in the payload

Type: String

Constraints: The value of the param should be ‘application/json’.

gwsource

Query

(Mandatory) Source from which the request is triggered. (E.g. external)

Type: String

discoveryName

Query

Discovery Name. (E.g. SampleDiscovery)

If this value not given, hosts will be fetched from host inventory.

Type: String

Payload

Body

(Mandatory) Contains all the parameters to be sent in the request body for the post request

Type: Payload

Payload

Name Description
input (Optional) Input parameters to find host information from discovery

Type: Input

filter (Mandatory) Filter parameters to find host information from discovery

Type: Filter

Table 2. Input
Name Description
freeSearch (Optional) Search text to find host information from discovery

Type: String

Table 3. Filter
Name Description
sortColumn (Mandatory) Column name to be sorted.

Type: String

sortOrder (Mandatory) Order to be sorted.

Possible values: asc, desc

start

(Mandatory) Start count of the host keys to be fetched from discovery.

Type: String
max

(Mandatory) Count of the hosts to be fetched from discovery.

Type: String

Response Structure

200 OK returns string of type application/json with the following body params.

Table 4. Response Parameters
Name Description
response Contains the response attributes for the host keys

Type: response

message Success message of the action or failure description in case of error. Will be non-null for failure response

Type: String

appStatusCode Application-specific status code for the response. Will be non-null for failure response

Type: String

tags More info in case of failure response
Table 5. Response
Name Description
data

List of host information which matches the search criteria

Type: List
iTotalDisplayRecords

Total number of host available for the search criteria

Status Codes

Table 6. Status Codes and Description
HTTP Status code appStatusCode Message and Possible remediation
200 OK NA Host information retrieved successfully
401 Unauthorized AVX_GW_003 Authentication failed, reason - Invalid Credentials

Possible remediation: Ensure that valid username and password or valid sessionId is provided as the header param.

400 Bad Request AVX-VLDTN-001 Mandatory field is missing or invalid values specified - <<field name>>

Possible remediation: Check and ensure that valid value is provided for <<field name>> field in the request.

Sample Request/Response

Use Case

To search host “pe-cert-apvx-node05” in the discovery using /search/hosts API.

Request URL
https://<IP/HostName/TenantName>:<GWPORT>/avxapi/ssh/search/hosts?keysFrom=rotatedInventory&gwsource=externalhttps://<IP/HostName/TenantName>:<GWPORT>/avxapi/ssh/search/hostKeys?keysFrom=rotatedInventory&gwsource=external
Sample Request 1
{
  "input": {
    "freeSearch": "pe-cert-apvx-node05"
  },
  "filter": {
    "sortColumn": "none",
    "sortOrder": "desc",
    "start": "0",
    "max": "100"
  }
}
Sample Request 2
{
  "input": {
    "keywordSearch":{"keyname":"RotateKeys_admin_1716367184410-B0-001"}
  },
  "filter": {
    "sortColumn": "none",
    "sortOrder": "desc",
    "start": "0",
    "max": "100"
  }
}
Sample Response
{
  "response": {
    "data": [
      {
        "sshHost": {
          "credentialType": "Manual Entry",
          "fqdn": "pe-cert-apvx-node05.lab.appviewx.net.",
          "ipAddress": "192.168.60.133",
          "userName": "appviewx",
          "loginType": "password",
          "groupName": "Default_Host_Group",
          "deviceName": "pe-cert-apvx-node05",
          "port": "22",
          "accessElevation": "sudo",
          "hostName": "",
          "fingerPrint": "",
          "status": "Unresolved",
          "displayName": "192.168.60.133",
          "vendorType": "linux",
          "category": "Host",
          "keyWords": [
            "Unresolved",
            "22",
            "NA",
            "192.168.60.133",
            "pe-cert-apvx-node05",
            "appviewx",
            "Default_Host_Group",
            "Host",
            "sam"
          ],
          "groupIds": [
            "5767bcdc3465bfbf73e44726"
          ],
          "createdTime": 1716221229762,
          "adcAccess": false,
          "isClient": false,
          "isBastion": false,
          "deviceType": [
            "NA"
          ],
          "deviceStatusList": [
            {
              "title": "Network Status: Reachability Check",
              "message": "FQDN pe-cert-apvx-node05.lab.appviewx.net. resolution failed.",
              "status": "Failed",
              "timeStamp": 1716221234111
            }
          ],
          "isSudoUser": true,
          "isValidSudo": false,
          "lastSyncTime": 1716221229526,
          "sshKeysCount": 0,
          "certificatesCount": 0,
          "communicationMode": "SSH",
          "accessGroups": [
            "sam"
          ],
          "accessGroupDeviceType": "Host",
          "clientServerAccessGroups": [],
          "categoryType": "server",
          "userComplianceGroup": "Default_Key_Group",
          "inventoryAction": "manage",
          "sshSyncKeyDetail": {
            "autoCreateHPGroup": false,
            "sshSyncEnabled": false,
            "appInfraAccessGroup": [
              "sam"
            ],
            "sshScanType": "default",
            "sshScanDetails": [],
            "discoverKeyType": [
              "User Keys",
              "Host Keys"
            ],
            "fromSSHSubsystem": false
          },
          "dataCenter": "absecon",
          "accessType": "Certificate",
          "discoverySeqId": 0,
          "discoveryBatchNo": 0,
          "allowedPrincipalCount": 0,
          "sshOrigin": true,
          "update": false,
          "new": false,
          "selected": false,
          "active": true,
          "_id": "664b752d6c117a54017bc2f3"
        },
        "groups": [
          {
            "Default_Host_Group": "RW"
          }
        ],
        "displayName": "192.168.60.133",
        "fingerPrint": "",
        "permission": "RW",
        "groupPermissions": {
          "sam": "RW"
        },
        "_id": "664b752d6c117a54017bc2f3"
      }
    ],
    "iTotalDisplayRecords": 1
  },
  "message": "Host information retrieved successfully",
  "appStatusCode": null,
  "tags": {},
  "headers": null
}

Reference

Understanding the sample URL:
  • IP/HostName/TenantName: Replace with the actual IP address, hostname, or tenant name based on the specific configuration in AppViewX.
    • IP: A unique identifier assigned to each device connected to a computer network that uses the Internet Protocol for communication

      The IP address will be included in the endpoint URL for an on-prem deployment.

    • HostName: A human-readable label assigned to a device (host) on a network

      The hostname will be included in the endpoint URL for an on-prem deployment.

    • TenantName: An identifier label for a tenant given to indicate which tenant's data the API request will access/modify

      The tenant name will be included in the endpoint URL for a SaaS deployment.

  • GWPORT: AppViewX gateway port
    A gateway port refers to a network port through which data is sent and received to communicate with a gateway in an on-prem deployment.
    Note: GWPORT is not required for SaaS setups.

    Example: 31443

  • avxapi: Path parameter value (static) that is part of the endpoint's URL
  • Endpoint: Endpoint of the API, for example: /ssh/host/create
  • gwsource: Source or origin of a gateway, for example: external.

What's Next