github.com/influxdata/influxdb/v2@v2.7.6/mock/notification_endpoint_service.go (about) 1 package mock 2 3 import ( 4 "context" 5 6 "github.com/influxdata/influxdb/v2" 7 "github.com/influxdata/influxdb/v2/kit/platform" 8 ) 9 10 var _ influxdb.NotificationEndpointService = &NotificationEndpointService{} 11 12 // NotificationEndpointService represents a service for managing notification rule data. 13 type NotificationEndpointService struct { 14 *OrganizationService 15 *UserResourceMappingService 16 FindNotificationEndpointByIDF func(ctx context.Context, id platform.ID) (influxdb.NotificationEndpoint, error) 17 FindNotificationEndpointByIDCalls SafeCount 18 FindNotificationEndpointsF func(ctx context.Context, filter influxdb.NotificationEndpointFilter, opt ...influxdb.FindOptions) ([]influxdb.NotificationEndpoint, int, error) 19 FindNotificationEndpointsCalls SafeCount 20 CreateNotificationEndpointF func(ctx context.Context, nr influxdb.NotificationEndpoint, userID platform.ID) error 21 CreateNotificationEndpointCalls SafeCount 22 UpdateNotificationEndpointF func(ctx context.Context, id platform.ID, nr influxdb.NotificationEndpoint, userID platform.ID) (influxdb.NotificationEndpoint, error) 23 UpdateNotificationEndpointCalls SafeCount 24 PatchNotificationEndpointF func(ctx context.Context, id platform.ID, upd influxdb.NotificationEndpointUpdate) (influxdb.NotificationEndpoint, error) 25 PatchNotificationEndpointCalls SafeCount 26 DeleteNotificationEndpointF func(ctx context.Context, id platform.ID) ([]influxdb.SecretField, platform.ID, error) 27 DeleteNotificationEndpointCalls SafeCount 28 } 29 30 func NewNotificationEndpointService() *NotificationEndpointService { 31 return &NotificationEndpointService{ 32 OrganizationService: NewOrganizationService(), 33 UserResourceMappingService: NewUserResourceMappingService(), 34 FindNotificationEndpointByIDF: func(ctx context.Context, id platform.ID) (influxdb.NotificationEndpoint, error) { 35 return nil, nil 36 }, 37 FindNotificationEndpointsF: func(ctx context.Context, filter influxdb.NotificationEndpointFilter, opt ...influxdb.FindOptions) ([]influxdb.NotificationEndpoint, int, error) { 38 return nil, 0, nil 39 }, 40 CreateNotificationEndpointF: func(ctx context.Context, nr influxdb.NotificationEndpoint, userID platform.ID) error { 41 return nil 42 }, 43 UpdateNotificationEndpointF: func(ctx context.Context, id platform.ID, nr influxdb.NotificationEndpoint, userID platform.ID) (influxdb.NotificationEndpoint, error) { 44 return nil, nil 45 }, 46 PatchNotificationEndpointF: func(ctx context.Context, id platform.ID, upd influxdb.NotificationEndpointUpdate) (influxdb.NotificationEndpoint, error) { 47 return nil, nil 48 }, 49 DeleteNotificationEndpointF: func(ctx context.Context, id platform.ID) ([]influxdb.SecretField, platform.ID, error) { 50 return nil, 0, nil 51 }, 52 } 53 } 54 55 // FindNotificationEndpointByID returns a single telegraf config by ID. 56 func (s *NotificationEndpointService) FindNotificationEndpointByID(ctx context.Context, id platform.ID) (influxdb.NotificationEndpoint, error) { 57 defer s.FindNotificationEndpointByIDCalls.IncrFn()() 58 return s.FindNotificationEndpointByIDF(ctx, id) 59 } 60 61 // FindNotificationEndpoints returns a list of notification rules that match filter and the total count of matching notification rules. 62 // Additional options provide pagination & sorting. 63 func (s *NotificationEndpointService) FindNotificationEndpoints(ctx context.Context, filter influxdb.NotificationEndpointFilter, opt ...influxdb.FindOptions) ([]influxdb.NotificationEndpoint, int, error) { 64 defer s.FindNotificationEndpointsCalls.IncrFn()() 65 return s.FindNotificationEndpointsF(ctx, filter, opt...) 66 } 67 68 // CreateNotificationEndpoint creates a new notification rule and sets ID with the new identifier. 69 func (s *NotificationEndpointService) CreateNotificationEndpoint(ctx context.Context, nr influxdb.NotificationEndpoint, userID platform.ID) error { 70 defer s.CreateNotificationEndpointCalls.IncrFn()() 71 return s.CreateNotificationEndpointF(ctx, nr, userID) 72 } 73 74 // UpdateNotificationEndpoint updates a single notification rule. 75 // Returns the new notification rule after update. 76 func (s *NotificationEndpointService) UpdateNotificationEndpoint(ctx context.Context, id platform.ID, nr influxdb.NotificationEndpoint, userID platform.ID) (influxdb.NotificationEndpoint, error) { 77 defer s.UpdateNotificationEndpointCalls.IncrFn()() 78 return s.UpdateNotificationEndpointF(ctx, id, nr, userID) 79 } 80 81 // PatchNotificationEndpoint updates a single notification rule with changeset. 82 // Returns the new notification rule after update. 83 func (s *NotificationEndpointService) PatchNotificationEndpoint(ctx context.Context, id platform.ID, upd influxdb.NotificationEndpointUpdate) (influxdb.NotificationEndpoint, error) { 84 defer s.PatchNotificationEndpointCalls.IncrFn()() 85 return s.PatchNotificationEndpointF(ctx, id, upd) 86 } 87 88 // DeleteNotificationEndpoint removes a notification rule by ID. 89 func (s *NotificationEndpointService) DeleteNotificationEndpoint(ctx context.Context, id platform.ID) ([]influxdb.SecretField, platform.ID, error) { 90 defer s.DeleteNotificationEndpointCalls.IncrFn()() 91 return s.DeleteNotificationEndpointF(ctx, id) 92 }