/
view.go
48 lines (40 loc) · 1.43 KB
/
view.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
package bloblang
import (
"encoding/json"
"github.com/benthosdev/benthos/v4/internal/bloblang/query"
)
// FunctionView describes a particular function belonging to a Bloblang
// environment.
type FunctionView struct {
spec query.FunctionSpec
}
// Description provides an overview of the function.
func (v *FunctionView) Description() string {
return v.spec.Description
}
// FormatJSON returns a byte slice of the function configuration formatted as a
// JSON object. The schema of this method is undocumented and is not intended
// for general use.
//
// Experimental: This method is not intended for general use and could have its
// signature and/or behaviour changed outside of major version bumps.
func (v *FunctionView) FormatJSON() ([]byte, error) {
return json.Marshal(v.spec)
}
// MethodView describes a particular method belonging to a Bloblang environment.
type MethodView struct {
spec query.MethodSpec
}
// Description provides an overview of the method.
func (v *MethodView) Description() string {
return v.spec.Description
}
// FormatJSON returns a byte slice of the method configuration formatted as a
// JSON object. The schema of this method is undocumented and is not intended
// for general use.
//
// Experimental: This method is not intended for general use and could have its
// signature and/or behaviour changed outside of major version bumps.
func (v *MethodView) FormatJSON() ([]byte, error) {
return json.Marshal(v.spec)
}