Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update labels API documentation and example requests #23589

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gillespi314
Copy link
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
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 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
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 on lines -4983 to -4985
"name": "macOS label",
"description": "Now this label only includes macOS machines",
"platform": "darwin"
Copy link
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.

@@ -4969,20 +4968,18 @@ Updates the specified label. Note: Label queries and platforms are immutable. To
| 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
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.

@@ -4969,20 +4968,18 @@ Updates the specified label. Note: Label queries and platforms are immutable. To
| 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. |
| 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
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant