A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.cfengine.com/latest/api-enterprise-api-ref-inventory.html below:

Inventory API - CFEngine 3.26 Docs

Inventory API allows to access inventory reports and attributes dictionary.

Inventory reports

URI: https://hub.cfengine.com/api/inventory

Method: POST

Parameters:

code

curl -k --user <username>:<password> \
  -X POST \
  https://hub.cfengine.com/api/inventory \
  -H 'content-type: application/json' \
  -d '{
        "sort":"Host name",
        "filter":{
           "Host name":{
              "matches":["value1","value"],
              "not_contain":"value2"
           }
        },
        "select":[
           "Host name",
           "OS type",
           "IPv4 addresses",
           "CFEngine version",
           "Ports listening"
        ],
        "hostContextExclude":[
           "policy_server"
        ]
      }
'

Example Request Body:

code

{
   "sort":"Host name",
   "filter":{
      "Host name":{
         "matches":"value1",
         "=":"value2"
      }
   },
   "select":[
      "Host name",
      "OS type",
      "IPv4 addresses",
      "CFEngine version",
      "Ports listening"
   ],
   "hostContextExclude":[
      "policy_server"
   ]
}

Example response:

code

{
  "data": [
    {
      "header": [
        {
          "columnName": "Host name",
          "columnType": "STRING"
        },
        {
          "columnName": "OS type",
          "columnType": "STRING"
        },
        {
          "columnName": "IPv4 addresses",
          "columnType": "STRING"
        },
        {
          "columnName": "CFEngine version",
          "columnType": "STRING"
        },
        {
          "columnName": "Ports listening",
          "columnType": "STRING"
        }
      ],
      "queryTimeMs": 30,
      "rowCount": 2,
      "rows": [
        [
          "host1.cfengine.com",
          "linux",
          "128.30.23.33",
          "3.10.0",
          "22, 25, 80, 443, 5308, 9000"
        ],
        [
          "host2.cfengine.com",
          "linux",
          "184.45.1.75",
          "3.10.0",
          null
        ]
      ]
    }
  ],
  "meta": {
    "count": 1,
    "page": 1,
    "timestamp": 1496222472,
    "total": 1
  }
}

Example Request Body with includeAdditionally set to true:

code

{
    "sort": "Host name",
    "filter": {
        "OS": {
            "matches": "non-existing OS"
        }
    },
    "hostFilter": {
        "includes": {
            "includeAdditionally": true,
            "entries": {
                "hostname": [
                    "ubuntu-bionic"
                ]
            }
        }
    },
    "select": [
        "Host name",
        "OS"
    ]
}

Example response:

As you can see, despite the OS filter should return zero hosts, we had one additionally included by the host in the Host filter.

code

{
    "data": [
        {
            "header": [
                {
                    "columnName": "Host name",
                    "columnType": "STRING"
                },
                {
                    "columnName": "OS",
                    "columnType": "STRING"
                }
            ],
            "queryTimeMs": 21,
            "rowCount": 1,
            "rows": [
                [
                    "ubuntu-bionic",
                    "Ubuntu 18"
                ]
            ]
        }
    ],
    "meta": {
        "count": 1,
        "page": 1,
        "timestamp": 1712141765,
        "total": 1
    }
}
List of inventory attributes

URI: https://hub.cfengine.com/api/inventory/attributes-dictionary

Method: GET

Shows list of all inventory attributes available in the system.

See more details: * Custom inventory

CURL request example curl -k --user admin:admin -X GET https://hub.cfengine.com/api/inventory/attributes-dictionary

Example response:

code

[
  {
    "id": 2,
    "attribute_name": "BIOS vendor",
    "category": "Hardware",
    "readonly": 1,
    "type": "string",
    "convert_function": null,
    "keyname": "default.cfe_autorun_inventory_dmidecode.dmi[bios-vendor]"
  },
  {
    "id": 3,
    "attribute_name": "BIOS version",
    "category": "Hardware",
    "readonly": 1,
    "type": "string",
    "convert_function": null,
    "keyname": "default.cfe_autorun_inventory_dmidecode.dmi[bios-version]"
  }
]
Edit inventory attribute

URI: https://hub.cfengine.com/api/inventory/attributes-dictionary/:id

Method: PATCH

Set inventory attribute type (int/string..). This is needed for applying filtering in correct format. Only readonly - 0 attribute can be edited

Parameters:

CURL request example curl -k --user admin:admin -X PATCH https://hub.cfengine.com/api/inventory/attributes-dictionary/260 -H 'content-type: application/json' -d '{ "category":"Hardware", "type": "int" }'

Example Request Body:

code

{
 "category":"Hardware",
 "type": "int"
}

Example response:

code

{
  "id": 1,
  "attribute_name": "Architecture",
  "category": "Hardware",
  "readonly": 0,
  "type": "slist",
  "convert_function": "cf_clearSlist"
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4