-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom_functions.go
99 lines (81 loc) · 2.56 KB
/
custom_functions.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
package harper
type CustomFunctionStatusResponse struct {
IsEnabled bool `json:"is_enabled"`
Port int `json:"port"`
Directory string `json:"directory"`
}
type PackageCustomFunctionProjectResponse struct {
Project string `json:"project"`
Payload string `json:"payload"`
File string `json:"file"`
}
func (c *Client) CustomFunctionStatus() (*CustomFunctionStatusResponse, error) {
var response CustomFunctionStatusResponse
err := c.opRequest(operation{
Operation: OP_CUSTOM_FUNCTIONS_STATUS,
}, &response)
return &response, err
}
func (c *Client) GetCustomFunctions() (map[string]interface{}, error) {
var response map[string]interface{}
err := c.opRequest(operation{
Operation: OP_GET_CUSTOM_FUNCTIONS,
}, &response)
return response, err
}
func (c *Client) GetCustomFunction(project, type_, file string) (*MessageResponse, error) {
var response MessageResponse
err := c.opRequest(operation{
Operation: OP_GET_CUSTOM_FUNCTION,
Project: project,
Type: type_,
File: file,
}, &response)
return &response, err
}
func (c *Client) SetCustomFunction(project, type_, file, functionContent string) (*MessageResponse, error) {
var response MessageResponse
err := c.opRequest(operation{
Operation: OP_SET_CUSTOM_FUNCTION,
Project: project,
Type: type_,
File: file,
FunctionContent: functionContent,
}, &response)
return &response, err
}
func (c *Client) DropCustomFunction(project, type_, file string) (*MessageResponse, error) {
var response MessageResponse
err := c.opRequest(operation{
Operation: OP_DROP_CUSTOM_FUNCTION,
Project: project,
Type: type_,
File: file,
}, &response)
return &response, err
}
func (c *Client) AddCustomFunctionProject(project string) (*MessageResponse, error) {
var response MessageResponse
err := c.opRequest(operation{
Operation: OP_ADD_CUSTOM_FUNCTION_PROJECT,
Project: project,
}, &response)
return &response, err
}
func (c *Client) DropCustomFunctionProject(project string) (*MessageResponse, error) {
var response MessageResponse
err := c.opRequest(operation{
Operation: OP_DROP_CUSTOM_FUNCTION_PROJECT,
Project: project,
}, &response)
return &response, err
}
func (c *Client) PackageCustomFunctionProject(project string, skipNodeModules bool) (*PackageCustomFunctionProjectResponse, error) {
var response PackageCustomFunctionProjectResponse
err := c.opRequest(operation{
Operation: OP_PACKAGE_CUSTOM_FUNCTION_PROJECT,
Project: project,
SkipNodeModules: skipNodeModules,
}, &response)
return &response, err
}