-
Notifications
You must be signed in to change notification settings - Fork 85
/
features.go
93 lines (79 loc) · 2.65 KB
/
features.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
package meilisearch
import (
"context"
"net/http"
)
// Type for experimental features with additional client field
type ExperimentalFeatures struct {
client *client
ExperimentalFeaturesBase
}
func (m *meilisearch) ExperimentalFeatures() *ExperimentalFeatures {
return &ExperimentalFeatures{client: m.client}
}
func (ef *ExperimentalFeatures) SetVectorStore(vectorStore bool) *ExperimentalFeatures {
ef.VectorStore = &vectorStore
return ef
}
func (ef *ExperimentalFeatures) SetLogsRoute(logsRoute bool) *ExperimentalFeatures {
ef.LogsRoute = &logsRoute
return ef
}
func (ef *ExperimentalFeatures) SetMetrics(metrics bool) *ExperimentalFeatures {
ef.Metrics = &metrics
return ef
}
func (ef *ExperimentalFeatures) SetEditDocumentsByFunction(editDocumentsByFunction bool) *ExperimentalFeatures {
ef.EditDocumentsByFunction = &editDocumentsByFunction
return ef
}
func (ef *ExperimentalFeatures) SetContainsFilter(containsFilter bool) *ExperimentalFeatures {
ef.ContainsFilter = &containsFilter
return ef
}
func (ef *ExperimentalFeatures) Get() (*ExperimentalFeaturesResult, error) {
return ef.GetWithContext(context.Background())
}
func (ef *ExperimentalFeatures) GetWithContext(ctx context.Context) (*ExperimentalFeaturesResult, error) {
resp := new(ExperimentalFeaturesResult)
req := &internalRequest{
endpoint: "/experimental-features",
method: http.MethodGet,
withRequest: nil,
withResponse: &resp,
withQueryParams: map[string]string{},
acceptedStatusCodes: []int{http.StatusOK},
functionName: "GetExperimentalFeatures",
}
if err := ef.client.executeRequest(ctx, req); err != nil {
return nil, err
}
return resp, nil
}
func (ef *ExperimentalFeatures) Update() (*ExperimentalFeaturesResult, error) {
return ef.UpdateWithContext(context.Background())
}
func (ef *ExperimentalFeatures) UpdateWithContext(ctx context.Context) (*ExperimentalFeaturesResult, error) {
request := ExperimentalFeaturesBase{
VectorStore: ef.VectorStore,
LogsRoute: ef.LogsRoute,
Metrics: ef.Metrics,
EditDocumentsByFunction: ef.EditDocumentsByFunction,
ContainsFilter: ef.ContainsFilter,
}
resp := new(ExperimentalFeaturesResult)
req := &internalRequest{
endpoint: "/experimental-features",
method: http.MethodPatch,
contentType: contentTypeJSON,
withRequest: request,
withResponse: resp,
withQueryParams: nil,
acceptedStatusCodes: []int{http.StatusOK},
functionName: "UpdateExperimentalFeatures",
}
if err := ef.client.executeRequest(ctx, req); err != nil {
return nil, err
}
return resp, nil
}