-
Notifications
You must be signed in to change notification settings - Fork 468
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
Implement separate "device policies" API for checking Desktop notifications #5685
Comments
@lucasmrod would you mind thinking through this with me to make sure we're on the same page? First thing that comes to mind is to add a new public method to
edit: I was just confused about ^, but I would still be helpful to hear you thoughts about adding a new |
we discussed in a call with @lucasmrod , we're going to:
|
Introducing a separate
+1, can be tackled at a later iteration. |
This adds a new device authenticated endpoint, `/api/_version_/fleet/device/{token}/policies` to retrieve the device policies. An example request / response looks like: ```bash curl https://localhost:8080/api/latest/fleet/device/1804e808-171f-4dda-9bec-f695b2f2371a/policies ``` ```json { "policies": [ { "id": 3, "name": "Antivirus healthy (Linux)", "query": "SELECT score FROM (SELECT case when COUNT(*) = 2 then 1 ELSE 0 END AS score FROM processes WHERE (name = 'clamd') OR (name = 'freshclam')) WHERE score == 1;", "description": "Checks that both ClamAV's daemon and its updater service (freshclam) are running.", "author_id": 1, "author_name": "Admin", "author_email": "[email protected]", "team_id": null, "resolution": "Ensure ClamAV and Freshclam are installed and running.", "platform": "darwin,windows,linux", "created_at": "2022-05-23T20:53:36Z", "updated_at": "2022-05-23T20:53:36Z", "response": "fail" } ] } ``` Related to [#5685](#5685), in another changeset I will be adding "client" endpoints so we can consume this endpoint from Fleet Desktop
This adds a new API client named DeviceClient to server/service, meant to consume device endpoints and be used from Fleet Desktop. Some of the logic to make requests and parse responses was very repetitive, so I introduced a private baseClient type and moved some of the logic of the existent Client there. Related to #5685 and #5697
As discussed in #5579 (comment), this should be completed before bringing Desktop out of beta.
Currently defined
/device
endpoints:fleet/server/service/handler.go
Lines 391 to 396 in d84d600
We need to add one to fetch the host's policies (+ their results, similar to how they are returned in the
/api/_version_/fleet/device/{token}
endpoint).NOTE(lucas): We should expose this endpoint to be used by Go code (the Fleet Desktop tray application is made in Go:
orbit/cmd/desktop/desktop.go
). Should be similar to what we have forfleetctl
in theserver/service/client_*.go
files.Why? @sharvilshah had to copy the types to be able to make requests and parse the responses: e.g.
fleet/orbit/cmd/desktop/desktop.go
Lines 22 to 49 in 8e5cedf
The text was updated successfully, but these errors were encountered: