mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
d5e40f329e
* Add activities generation * Add activities endpoint * Fix merge error * Fix indentation issue * Add changes file * Address PR review comments * Add mock activity func * Address codacy warings * Set foreign key but on delete set null * Make user_id set to null if deleted
35 lines
967 B
Go
35 lines
967 B
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
"github.com/fleetdm/fleet/v4/server/fleet"
|
|
"github.com/go-kit/kit/endpoint"
|
|
)
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// Get activities
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
type listActivitiesRequest struct {
|
|
ListOptions fleet.ListOptions
|
|
}
|
|
|
|
type listActivitiesResponse struct {
|
|
Activities []*fleet.Activity `json:"activities"`
|
|
Err error `json:"error,omitempty"`
|
|
}
|
|
|
|
func (r listActivitiesResponse) error() error { return r.Err }
|
|
|
|
func makeListActivitiesEndpoint(svc fleet.Service) endpoint.Endpoint {
|
|
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
|
req := request.(listActivitiesRequest)
|
|
activities, err := svc.ListActivities(ctx, req.ListOptions)
|
|
if err != nil {
|
|
return listActivitiesResponse{Err: err}, nil
|
|
}
|
|
|
|
return listActivitiesResponse{Activities: activities}, err
|
|
}
|
|
}
|