In this use case, we use the Advanced Search APIs to find devices.

Prerequisites

Create an Advanced Search filter using the VMware Pulse IoT Center console. For information about creating an Advanced Search filter, see the VMware Pulse IoT Center User Guide.

Procedure

  1. Retrieve the Filter ID of the Advanced Search filter that you created. - GET /api/filter-definitions.
    curl -X GET https://iotc123-pulse.xyz.com/api/filter-definitions?page.number=1&page.size=1000
    {
      "filterDefinitionObjIdName": [{
        "id": "0cb97d04-60e3-46da-b46d-6ca7c2bfceab",
        "name": "G-RPI-AJ-01"
      }, {
        "id": "12dde5c4-0c96-493c-906b-a59b85ec936f",
        "name": "XYZ Test"
      }, {
        "id": "16a5dd . . . .
    
  2. Using the Filter ID, retrieve the filter query parameters - GET /api/filter-definitions/<<filterID>>.
    curl -X GET https://iotc123-pulse.xyz.com/api/filter-definitions/0cb97d04-60e3-46da-b46d-6ca7c2bfceab
    {
      "id": "0cb97d04-60e3-46da-b46d-6ca7c2bfceab",
      "name": "G-RPI-AJ-01",
      "templateId": [
        "7b275cba-4403-4951-91e9-ec6fad73506d"
      ],
      "filter": [
        {
          "keyObj": {
            "dataSource": "DEVICEMGMT_SERVICE",
            "key": "net-mac-eth0",
            "keyQualifier": "systemProperties",
            "valueType": "STRING",
            "keyType": "BOTH"
          },
          "oredOperationValuePair": [
            {
              "operator": "EQUAL_TO",
              "valueString": "b8:27:eb:c0:69:c6"
            }
          ]
        }
      ],
      "projection": [
        {
          "dataSource": "DEVICEMGMT_SERVICE",
          "key": "name",
          "keyQualifier": "device"
        },
        {
          "dataSource": "DEVICEMGMT_SERVICE",
          "key": "net-mac-eth0",
          "keyQualifier": "systemProperties"
        }
      ],
      "orgId": "d5c67393-cc8a-4c44-b320-15a4f1be46f9",
      "createdTime": "1560534152934",
      "lastUpdatedTime": "1565710386040",
      "createdBy": "ajoiner@vmware.com",
      "lastUpdatedBy": "ajoiner@vmware.com",
      "updateVersion": 2
    }
  3. Start the search process and get the Filter Results ID - POST /api/filter-results/ .
    From the result body, copy the templateid field and the full body of the filter field. Use these JSON fields to construct a device search callback. Update the valueString field in the filter with the device that you are interested in. Perform a call to start the search. You can also specify a projection if you want to retrieve other fields for the device in the final result set:
    Note: Ensure that you make a POST call.
    curl -X POST  https://iotc123-pulse.xyz.com/api/filter-results/ 
    -d '{  
       "templateId":[  
          7      b275cba-4403-4951-91e9-ec6fad73506d
       ],
       "filter":[  
          {  
             "keyObj":{  
                "dataSource":"DEVICEMGMT_SERVICE",
                "key":"net-mac-eth0",
                "keyQualifier":"systemProperties",
                "valueType":"STRING",
                "keyType":"BOTH"
             },
             "oredOperationValuePair":[  
                {  
                   "operator":"EQUAL_TO",
                   "valueString":"b8:27:eb:c0:69:c6"
                }
             ]
          }
       ]
    }'
    This call returns a filtered device list ID. Use this ID to retrieve the results.
  4. Get the result set - GET /api/filter-results/<filterResultsID>>
    Wait for a few seconds for the search to complete before retrieving the results. If you try to call too early, a warning message is displayed.
    curl -X GET   https://iotc123-pulse.xyz.com/api/filter-results/761a5e65-7253-4fda-8c35-53a44a58772d
    {  
       "aggregationTaskStatus":"FINISHED",
       "filteredDevice":[  
          {  
             "id":"16292df1-b095-4de7-bd26-2f446a09996e"
          },
          {  
             "id":"13fe6eb3-135a-402d-99ac-087ac8ecaeff"
          }
       ],
       "pageInfo":{  
          "page":1,
          "pageSize":10,
          "totalElements":"2",
          "totalPages":"1"
       }
    }