Skip to content

Update labels API documentation and example requests#23589

Closed
gillespi314 wants to merge 1 commit intomainfrom
sg-labels-api-docs
Closed

Update labels API documentation and example requests#23589
gillespi314 wants to merge 1 commit intomainfrom
sg-labels-api-docs

Conversation

@gillespi314
Copy link
Copy Markdown
Contributor

  • Adds note regarding to clarify existing API behavior when updating the list of hosts associated with a manual label based on this recent Slack thread
  • Updates request/response examples to illustrate builtin and manual labels

Copy link
Copy Markdown
Contributor Author

@gillespi314 gillespi314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rachaelshaw, I took a stab at some incremental updates to the labels API documentation based on some things that came up during my on call rotation.

I believe you took some notes/action items for yourself related to some of this in Slack so feel free to tweak this PR however makes the most sense for you :)

I tried to get the most mileage out of the two existing examples by using the create label example to illustrate dynamic labels and the modify example to illustrate manual labels. But I think it would be even better to have a set of examples for creating and modifying a dynamic label and another set of examples for creating and modifying a manual label.

Comment thread docs/REST API/rest-api.md
Comment on lines +4930 to +4933
"name": "macOS hosts (x86_64)",
"description": "Filters macOS hosts with x86_64 architecture",
"query": "SELECT 1 FROM os_version WHERE platform = 'darwin' AND instr(arch, 'x86_64')",
"platform": "darwin"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old example was a little confusing because there is a builtin label for Ubuntu hosts so I tried to craft an example of a dynamic label that felt more useful in practice.

Comment thread docs/REST API/rest-api.md
Comment on lines -4983 to -4985
"name": "macOS label",
"description": "Now this label only includes macOS machines",
"platform": "darwin"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bad example because the platform cannot be modified for existing labels so I revised this to be an example of how the list of hosts can be modified a manual label.

Comment thread docs/REST API/rest-api.md
| id | integer | path | **Required**. The label's id. |
| name | string | body | The label's name. |
| description | string | body | The label's description. |
| hosts | array | body | If updating a manual label: the list of host identifiers (`hardware_serial`, `uuid`, `osquery_host_id`, `hostname`, or `name`) the label will apply to. |
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revised to remove osquery_host_id and name based on this Slack thread.

Comment thread docs/REST API/rest-api.md
| name | string | body | The label's name. |
| description | string | body | The label's description. |
| hosts | array | body | If updating a manual label: the list of host identifiers (`hardware_serial`, `uuid`, `osquery_host_id`, `hostname`, or `name`) the label will apply to. |
| hosts | array | body | If updating a manual label: the list of host identifiers (`hardware_serial`, `uuid`, or `hostname`) the label will apply to. **Note: The provided list fully replaces the previous list.** |
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this note to clarify existing behavior that the new list fully replaces the previous list based on this Slack thread.

@rachaelshaw
Copy link
Copy Markdown
Member

@gillespi314 Sorry this dropped off my radar! Some questions about this API just resurfaced, so I'll pick up from this branch if the merge conflicts aren't too bad and get these changes in. (Going to go ahead and close this to avoid dragging down PR open time, since this was left in draft for so long.)

rachaelshaw added a commit that referenced this pull request Apr 11, 2025
Improvements/fixes for manual label documentation.

Follow-up from this old draft PR:
#23589

---------

Co-authored-by: gillespi314 <73313222+gillespi314@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants