TrueSight API Documentation
OverviewAccountActionsAdministration
Alarms v1Alarms v2BatchingDashboards
DatasetsEventsExtended Metrics
HostgroupsGroupsMetersMetricsProduct
PluginsRelaysSourcesSynchronize Data
Tenants
Terms

PUT/v1/hostgroups/:hostgroupId

Update a Hostgroup

System Hostgroups cannot be updated

name

The name of the hostgroup

hostnames

The list of servers in the hostgroup, an empty array will match all of the hosts in your account

expression

An dynamic group expression (use either a list of groups or an express, we give higher priority to the expression)

Example request with a list of hostnames:

curl https://api.truesight.bmc.com/v1/hostgroups/:hostgroupId \
-X PUT \
-u <email>:<api-token> \
-H "Content-Type: application/json" \
-d '
{
   "name": "Database Servers",
   "hostnames": [
      "db1",
      "db2"
   ]
}'

Example request with dynamic group expression:

curl https://api.truesight.bmc.com/v1/hostgroups/:hostgroupId \
-X PUT \
-u <email>:<api-token> \
-H "Content-Type: application/json" \
-d '
{
   "name": "Database Servers",
   "expression": "{\"where\": \"'hostname' starts with 'd'\"}"
}'

Response:

[
   {
      "id": 8335,
      "name": "Database Servers",
      "hostnames": [
         "db1",
         "db2"
      ],
      "system": false
   }
]

400 Format Error response (the expression is malformed JSON):

{
   "name": "Format Error",
   "code": "ERR_BAD_FORMAT",
   "status": 400,
   "message": "Hostgroup expression is malformed JSON: Unexpected token w"
}

400 SyntaxError response (the where clause text is malformed):

{
   "name": "SyntaxError",
   "code": "ERR_BAD_FORMAT",
   "status": 400,
   "message": "Expected \"with\", comment or whitespace but \"W\" found.",
   "expected": [
      {
         "type": "literal",
         "value": "with",
         "description": "\"with\""
      },
      {
         "type": "other",
         "description": "comment"
      },
      {
         "type": "other",
         "description": "whitespace"
      }
   ],
   "found": "w",
   "offset": 37,
   "line": 1,
   "column": 38
}