/
interface.go
51 lines (44 loc) · 2.2 KB
/
interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// SPDX-License-Identifier: Apache-2.0
package hook
import (
"context"
"github.com/go-vela/types/library"
)
// HookInterface represents the Vela interface for hook
// functions with the supported Database backends.
//
//nolint:revive // ignore name stutter
type HookInterface interface {
// Hook Data Definition Language Functions
//
// https://en.wikipedia.org/wiki/Data_definition_language
// CreateHookIndexes defines a function that creates the indexes for the hooks table.
CreateHookIndexes(context.Context) error
// CreateHookTable defines a function that creates the hooks table.
CreateHookTable(context.Context, string) error
// Hook Data Manipulation Language Functions
//
// https://en.wikipedia.org/wiki/Data_manipulation_language
// CountHooks defines a function that gets the count of all hooks.
CountHooks(context.Context) (int64, error)
// CountHooksForRepo defines a function that gets the count of hooks by repo ID.
CountHooksForRepo(context.Context, *library.Repo) (int64, error)
// CreateHook defines a function that creates a new hook.
CreateHook(context.Context, *library.Hook) (*library.Hook, error)
// DeleteHook defines a function that deletes an existing hook.
DeleteHook(context.Context, *library.Hook) error
// GetHook defines a function that gets a hook by ID.
GetHook(context.Context, int64) (*library.Hook, error)
// GetHookByWebhookID defines a function that gets any hook with a matching webhook_id.
GetHookByWebhookID(context.Context, int64) (*library.Hook, error)
// GetHookForRepo defines a function that gets a hook by repo ID and number.
GetHookForRepo(context.Context, *library.Repo, int) (*library.Hook, error)
// LastHookForRepo defines a function that gets the last hook by repo ID.
LastHookForRepo(context.Context, *library.Repo) (*library.Hook, error)
// ListHooks defines a function that gets a list of all hooks.
ListHooks(context.Context) ([]*library.Hook, error)
// ListHooksForRepo defines a function that gets a list of hooks by repo ID.
ListHooksForRepo(context.Context, *library.Repo, int, int) ([]*library.Hook, int64, error)
// UpdateHook defines a function that updates an existing hook.
UpdateHook(context.Context, *library.Hook) (*library.Hook, error)
}