API design: API endpoint for updating a host's manual labels (#16979)

API design for: 
- #16767

---------

Co-authored-by: Rachael Shaw <r@rachael.wtf>
This commit is contained in:
Marko Lisica
2024-04-25 15:53:01 -05:00
committed by GitHub
co-authored by Rachael Shaw
parent 3886a322fd
commit a0a8579b56
+60
View File
@@ -1865,6 +1865,8 @@ None.
- [Wipe host](#wipe-host)
- [Get host's past activity](#get-hosts-past-activity)
- [Get host's upcoming activity](#get-hosts-upcoming-activity)
- [Add labels to host](#add-labels-to-host)
- [Remove labels from host](#remove-labels-from-host)
- [Live query one host (ad-hoc)](#live-query-one-host-ad-hoc)
- [Live query host by identifier (ad-hoc)](#live-query-host-by-identifier-ad-hoc)
@@ -4037,6 +4039,64 @@ To wipe a macOS or Windows host, the host must have MDM turned on. To lock a Lin
}
```
### Add labels to host
Adds manual labels to a host.
`POST /api/v1/fleet/hosts/:id/labels`
#### Parameters
| Name | Type | In | Description |
| ---- | ------- | ---- | ---------------------------- |
| labels | list | body | The list of label names to add to the host. |
#### Example
`POST /api/v1/fleet/hosts/12/labels`
##### Request body
```json
{
"labels": ["label1", "label2"]
}
```
##### Default response
`Status: 200`
### Remove labels from host
Removes manual labels from a host.
`DELETE /api/v1/fleet/hosts/:id/labels`
#### Parameters
| Name | Type | In | Description |
| ---- | ------- | ---- | ---------------------------- |
| labels | list | body | The list of label names to delete from the host. |
#### Example
`DELETE /api/v1/fleet/hosts/12/labels`
##### Request body
```json
{
"labels": ["label3", "label4"]
}
```
##### Default response
`Status: 200`
### Live query one host (ad-hoc)
Runs an ad-hoc live query against the specified host and responds with the results.