-
Notifications
You must be signed in to change notification settings - Fork 14
/
saved_objects.go
60 lines (49 loc) · 1.61 KB
/
saved_objects.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
package kibana
const savedObjectsPath = "/api/saved_objects/"
type SavedObjectRequest struct {
Type string `json:"type" url:"type"`
Fields []string `json:"fields" url:"fields"`
PerPage int `json:"per_page" url:"per_page"`
}
type SavedObjectRequestBuilder struct {
objectType string
fields []string
perPage int
}
type SavedObjectsClient interface {
GetByType(request *SavedObjectRequest) (*SavedObjectResponse, error)
}
type SavedObjectResponse struct {
Page int `json:"page"`
PerPage int `json:"per_page"`
Total int `json:"total"`
SavedObjects []*SavedObject `json:"saved_objects"`
}
type SavedObject struct {
Id string `json:"id"`
Type string `json:"type"`
Version version `json:"version"`
Attributes map[string]interface{} `json:"attributes"`
}
func NewSavedObjectRequestBuilder() *SavedObjectRequestBuilder {
return &SavedObjectRequestBuilder{perPage: 20}
}
func (builder *SavedObjectRequestBuilder) WithType(objectType string) *SavedObjectRequestBuilder {
builder.objectType = objectType
return builder
}
func (builder *SavedObjectRequestBuilder) WithFields(fields []string) *SavedObjectRequestBuilder {
builder.fields = fields
return builder
}
func (builder *SavedObjectRequestBuilder) WithPerPage(perPage int) *SavedObjectRequestBuilder {
builder.perPage = perPage
return builder
}
func (builder *SavedObjectRequestBuilder) Build() *SavedObjectRequest {
return &SavedObjectRequest{
Fields: builder.fields,
Type: builder.objectType,
PerPage: builder.perPage,
}
}