-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmetadata.go
54 lines (44 loc) · 1.5 KB
/
metadata.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
package couchbase
import (
"github.com/project-flogo/core/data/coerce"
)
type Settings struct {
Username string `md:"username"` // Cluster username
Password string `md:"password"` // Cluster password
BucketName string `md:"bucketName,required"` // The bucket name
BucketPassword string `md:"bucketPassword"` // The bucket password
Server string `md:"server,required"` // The Couchbase server (e.g. couchbase://127.0.0.1)
Method string `md:"method,required,allowed(Insert,Upsert,Remove,Get)"` // The method type (Insert, Upsert, Remove or Get); (default: *Insert*)
Expiry int `md:"expiry,required"` // The document expiry (default: 0)
}
type Input struct {
Key string `md:"key,required"` // The document key identifier
Data string `md:"data"` // The document data (when the method is get this field is ignored)
}
type Output struct {
Data interface{} `md:"data"` // The result of the method invocation
}
func (i *Input) ToMap() map[string]interface{} {
return map[string]interface{}{
"key": i.Key,
"data": i.Data,
}
}
func (i *Input) FromMap(values map[string]interface{}) error {
var err error
i.Key, err = coerce.ToString(values["key"])
if err != nil {
return err
}
i.Data, err = coerce.ToString(values["data"])
return err
}
func (o *Output) ToMap() map[string]interface{} {
return map[string]interface{}{
"data": o.Data,
}
}
func (o *Output) FromMap(values map[string]interface{}) error {
o.Data, _ = values["data"]
return nil
}