Skip to content
This repository was archived by the owner on Sep 2, 2024. It is now read-only.

Commit 0568995

Browse files
committed
added function management API
1 parent be17003 commit 0568995

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

function.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package backend
2+
3+
import "time"
4+
5+
type Function struct {
6+
ID string `json:"id"`
7+
FunctionName string `json:"name"`
8+
TriggerTopic string `json:"trigger"`
9+
Code string `json:"code"`
10+
Version int `json:"version"`
11+
LastUpdated time.Time `json:"lastUpdated"`
12+
LastRun time.Time `json:"lastRun"`
13+
History []RunHistory `json:"history"`
14+
}
15+
16+
type RunHistory struct {
17+
ID string `json:"id"`
18+
Version int `json:"version"`
19+
Started time.Time `json:"started"`
20+
Completed time.Time `json:"completed"`
21+
Success bool `json:"success"`
22+
Output []string `json:"output"`
23+
}
24+
25+
func AddFunction(token string, fn Function) error {
26+
return Post(token, "/fn/add", fn, nil)
27+
}
28+
29+
func ListFunctions(token string) (results []Function, err error) {
30+
err = Get(token, "/fn", &results)
31+
return
32+
}
33+
34+
func UpdateFunction(token string, fn Function) error {
35+
return Post(token, "/fn/update", fn, nil)
36+
}
37+
38+
func DeleteFunction(token, name string) error {
39+
return Get(token, "/fn/del/"+name, nil)
40+
}
41+
42+
func FunctionInfo(token, name string) (fn Function, err error) {
43+
err = Get(token, "/fn/info/"+name, &fn)
44+
return
45+
}

0 commit comments

Comments
 (0)