Deleting hosts with a REST API
Endpoint overview
Use the DELETE method to delete one or more existing hosts.
While running this request, at a minimum you need to specify the name or ID of the host that you want to delete. You can delete multiple hosts by specifying a comma-separated list of host names or host IDs. You can obtain the host ID by running the API for listing host details.
While deleting the hosts, you can also delete the data collectors associated with the host and the data collected by those data collectors.
In a scenario where you have duplicate host names associated with unique Agent names (Collection Station or Collection Agent), you can delete the host by specifying one of the following inputs:
- Unique ID of the host (instead of the host name).
- Name of the Agent associated with the host.
Note that while you can specify multiple host names for deleting, you cannot specify multiple Agent names to identify unique hosts for deleting.
Request URL
DELETE <protocol>://<host>:<port>/olaengine/itdaws/hostservices/hosts/<hostDetails>?agentName=<agentName>&delColl=<operation>&delData=<operation>&type=<identifierType>&version=<apiVersion>
Parameter definitions
The following parameters can be used in the request URL.
Examples
The following examples illustrate the inputs for deleting hosts by using the DELETE method.
- Example 1: Delete a single host
- Example 2: Delete multiple hosts
- Example 3: Delete hosts with duplicate names (by specifying the Agent name)
Example 1: Delete a single host
The following example illustrates the input and response for performing the following actions:
- Delete a single host, "HostA" on the "localhost" machine.
- Delete the data collector associated with the host.
- Delete the data collected using the data collector.
Request URL
DELETE http://localhost:9797/olaengine/itdaws/hostservices/hosts/HostA
"statusCode": "200",
"statusMessage": "OK",
"hosts": [{
"messages": [{
"text": "SUCCESS"
}, {
"code": "Sucessfully Deleted Host Id: 4fc3a6d2-3df0-448d-883a-59d6b7d15338 . Host Name: HostA"
}]
}],
"totalRecords": 1,
"pageSize": 0
}
Example 2: Delete multiple hosts
The following example illustrates the input and response for deleting multiple hosts by specifying the host names, "HostB" and "HostC" on the "localhost" machine:
Request URL
DELETE http://clm-pun-015982:9797/olaengine/itdaws/hostservices/hosts/HostB,HostC?type=name
"statusCode": "200",
"statusMessage": "OK",
"hosts": [{
"messages": [{
"text": "SUCCESS"
}, {
"code": "Sucessfully Deleted Host Id: 82070460-44aa-4869-9308-2aac92be6d47 . Host Name: HostB"
}]
}, {
"messages": [{
"text": "SUCCESS"
}, {
"code": "Sucessfully Deleted Host Id: 3f5bb10a-95ae-4878-84e9-e674823bb9f4 . Host Name: HostC"
}]
}],
"totalRecords": 2,
"pageSize": 0
}
Example 3: Delete hosts with duplicate names (by specifying the Agent name)
The following example illustrates the input and response for deleting a duplicate host name, "HostD" along with its associated data collector, by specifying the Agent name, "Agent1.bmc.com".
Request URL
DELETE http://localhost:9797/olaengine/itdaws/hostservices/hosts/HostD?agentName=Agent1.bmc.com&delColl=true&type=name
"statusCode": "200",
"statusMessage": "OK",
"hosts": [{
"messages": [{
"text": "SUCCESS"
}, {
"code": "Sucessfully Deleted Host Id: 68513608-ffb1-4539-b823-710236c6c401 . Host Name: HostD"
}]
}],
"totalRecords": 1,
"pageSize": 0
}
Response elements
The following sections help you understand the response elements:
- Element definitions
- Successful response sample
- Unsuccessful response sample
- Multiple status response sample
Element definitions
The endpoint response contains the following main elements:
Successful response sample
See examples.
Unsuccessful response sample
"statusCode": "400",
"statusMessage": "Bad Request",
"hosts": [{
"messages": [{
"severity": "Error",
"code": "entity.does.not.exist",
"text": "Invalid Host Name. Host Name with value host6 does not exist."
}]
}],
"totalRecords": 1,
"pageSize": 0
}
Multiple status response sample
"statusCode": "207",
"statusMessage": "Multi Status",
"hosts": [{
"messages": [{
"severity": "Error",
"code": "entity.does.not.exist",
"text": "Invalid Host Name. Host Name with value HostB does not exist."
}]
}, {
"messages": [{
"text": "SUCCESS"
}, {
"code": "Sucessfully Deleted Host Id: 75d067f6-ad83-465e-8587-25bae915fbd2 . Host Name: HostA"
}]
}],
"totalRecords": 2,
"pageSize": 0
}
HTTP status codes
The following table describes the status codes that are likely to appear while working with this endpoint.