Skip to content

Implement separate "device policies" API for checking Desktop notifications #5685

@zwass

Description

@zwass

As discussed in #5579 (comment), this should be completed before bringing Desktop out of beta.

Currently defined /device endpoints:

// device-authenticated endpoints
de := newDeviceAuthenticatedEndpointer(svc, logger, opts, r, apiVersions...)
de.GET("/api/_version_/fleet/device/{token}", getDeviceHostEndpoint, getDeviceHostRequest{})
de.POST("/api/_version_/fleet/device/{token}/refetch", refetchDeviceHostEndpoint, refetchDeviceHostRequest{})
de.GET("/api/_version_/fleet/device/{token}/device_mapping", listDeviceHostDeviceMappingEndpoint, listDeviceHostDeviceMappingRequest{})
de.GET("/api/_version_/fleet/device/{token}/macadmins", getDeviceMacadminsDataEndpoint, getDeviceMacadminsDataRequest{})

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 for fleetctl in the server/service/client_*.go files.
Why? @sharvilshah had to copy the types to be able to make requests and parse the responses: e.g.

type Response struct {
Host struct {
Policies []struct {
ID int `json:"id"`
Name string `json:"name"`
Query string `json:"query"`
Description string `json:"description"`
AuthorID int `json:"author_id"`
AuthorName string `json:"author_name"`
AuthorEmail string `json:"author_email"`
TeamID interface{} `json:"team_id"`
Resolution string `json:"resolution"`
Platform string `json:"platform"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Response string `json:"response"`
} `json:"policies"`
Status string `json:"status"`
DisplayText string `json:"display_text"`
} `json:"host"`
License struct {
Tier string `json:"tier"`
Organization string `json:"organization"`
DeviceCount int `json:"device_count"`
Expiration time.Time `json:"expiration"`
Note string `json:"note"`
} `json:"license"`
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions