fleet/server/service/api_endpoints.go
Juan Fernandez 1bc32467a7
Implement GET /api/v1/fleet/rest_api (#42883)
**Related issue:** Resolves #42883 

Added a new premium GET /api/_version_/fleet/rest_api endpoint that
returns the contents of the embedded `api_endpoints.yml` artifact.
2026-04-10 11:12:38 -04:00

34 lines
1,014 B
Go

package service
import (
"context"
"github.com/fleetdm/fleet/v4/server/fleet"
)
//////////////////////////////////////////////////////////////////////////////////
// List API endpoints
//////////////////////////////////////////////////////////////////////////////////
type listAPIEndpointsRequest struct{}
type listAPIEndpointsResponse struct {
APIEndpoints []fleet.APIEndpoint `json:"api_endpoints"`
Err error `json:"error,omitempty"`
}
func (r listAPIEndpointsResponse) Error() error { return r.Err }
func listAPIEndpointsEndpoint(ctx context.Context, request any, svc fleet.Service) (fleet.Errorer, error) {
endpoints, err := svc.ListAPIEndpoints(ctx)
return listAPIEndpointsResponse{
APIEndpoints: endpoints,
Err: err,
}, nil
}
func (svc *Service) ListAPIEndpoints(ctx context.Context) ([]fleet.APIEndpoint, error) {
// skipauth: No authorization check, this is a premium feature only
svc.authz.SkipAuthorization(ctx)
return nil, fleet.ErrMissingLicense
}