-
Notifications
You must be signed in to change notification settings - Fork 104
/
scope_eventingmgr.go
139 lines (110 loc) · 3.6 KB
/
scope_eventingmgr.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
package gocb
// ScopeEventingFunctionManager provides methods for performing scoped eventing function management operations.
// This manager is designed to work only against Couchbase Server 7.1+.
//
// # UNCOMMITTED
//
// This API is UNCOMMITTED and may change in the future.
type ScopeEventingFunctionManager struct {
getProvider func() (eventingManagementProvider, error)
scope *Scope
}
// UpsertFunction inserts or updates an eventing function.
func (efm *ScopeEventingFunctionManager) UpsertFunction(function EventingFunction, opts *UpsertEventingFunctionOptions) error {
if opts == nil {
opts = &UpsertEventingFunctionOptions{}
}
provider, err := efm.getProvider()
if err != nil {
return err
}
return provider.UpsertFunction(efm.scope, function, opts)
}
// DropFunction drops an eventing function.
func (efm *ScopeEventingFunctionManager) DropFunction(name string, opts *DropEventingFunctionOptions) error {
if opts == nil {
opts = &DropEventingFunctionOptions{}
}
provider, err := efm.getProvider()
if err != nil {
return err
}
return provider.DropFunction(efm.scope, name, opts)
}
// DeployFunction deploys an eventing function.
func (efm *ScopeEventingFunctionManager) DeployFunction(name string, opts *DeployEventingFunctionOptions) error {
if opts == nil {
opts = &DeployEventingFunctionOptions{}
}
provider, err := efm.getProvider()
if err != nil {
return err
}
return provider.DeployFunction(efm.scope, name, opts)
}
// UndeployFunction undeploys an eventing function.
func (efm *ScopeEventingFunctionManager) UndeployFunction(name string, opts *UndeployEventingFunctionOptions) error {
if opts == nil {
opts = &UndeployEventingFunctionOptions{}
}
provider, err := efm.getProvider()
if err != nil {
return err
}
return provider.UndeployFunction(efm.scope, name, opts)
}
// GetAllFunctions fetches all the eventing functions that are in this scope.
func (efm *ScopeEventingFunctionManager) GetAllFunctions(opts *GetAllEventingFunctionsOptions) ([]EventingFunction, error) {
if opts == nil {
opts = &GetAllEventingFunctionsOptions{}
}
provider, err := efm.getProvider()
if err != nil {
return nil, err
}
return provider.GetAllFunctions(efm.scope, opts)
}
// GetFunction fetches an eventing function.
func (efm *ScopeEventingFunctionManager) GetFunction(name string, opts *GetEventingFunctionOptions) (*EventingFunction, error) {
if opts == nil {
opts = &GetEventingFunctionOptions{}
}
provider, err := efm.getProvider()
if err != nil {
return nil, err
}
return provider.GetFunction(efm.scope, name, opts)
}
// PauseFunction pauses an eventing function.
func (efm *ScopeEventingFunctionManager) PauseFunction(name string, opts *PauseEventingFunctionOptions) error {
if opts == nil {
opts = &PauseEventingFunctionOptions{}
}
provider, err := efm.getProvider()
if err != nil {
return err
}
return provider.PauseFunction(efm.scope, name, opts)
}
// ResumeFunction resumes an eventing function.
func (efm *ScopeEventingFunctionManager) ResumeFunction(name string, opts *ResumeEventingFunctionOptions) error {
if opts == nil {
opts = &ResumeEventingFunctionOptions{}
}
provider, err := efm.getProvider()
if err != nil {
return err
}
return provider.ResumeFunction(efm.scope, name, opts)
}
// FunctionsStatus fetches the current status of all eventing functions.
func (efm *ScopeEventingFunctionManager) FunctionsStatus(opts *EventingFunctionsStatusOptions) (*EventingStatus, error) {
if opts == nil {
opts = &EventingFunctionsStatusOptions{}
}
provider, err := efm.getProvider()
if err != nil {
return nil, err
}
return provider.FunctionsStatus(efm.scope, opts)
}