Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-2749

API hosts query return 50 out of 114 hosts

    XMLWordPrintable

    Details

    • Type: Knowledge acquisition
    • Status: Done
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: 3.10.2
    • Fix Version/s: None
    • Component/s: Built-in functions
    • Labels:
      None
    • Environment:
      CentOS 7.3/6.9

      Description

      By default the API only returns 50 hosts at a time. How can I get more than 50 results in a single query response?

      sudo curl -k --user admin https://"cfehubip"/api/host?context-include

      Answer

      Supply the count parameter to the query which sets the number of results to return in a single page.

      https://docs.cfengine.com/docs/3.10/reference-enterprise-api-ref-host.html#list-hosts

      [root@hub ~]# curl -k -u admin:admin https://localhost/api/host?count=1
      {
        "data": [
          {
            "firstseen": "1515593644",
            "hostname": "host001",
            "id": "SHA=e694a3ea2a5c6ce1d098a9871cf6df8459a314c4b8a7d3dcd4f01f27b17cbf08",
            "lastreport": "1515593754"
          }
        ],
        "meta": {
          "count": 1,
          "page": 1,
          "timestamp": 1515593771,
          "total": 2
        }
      }
      

       

       

        Attachments

          Activity

            People

            • Assignee:
              a10042 Nick Anderson
              Reporter:
              mikkelna Nathan Mikkelsen
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Summary Panel