-
Notifications
You must be signed in to change notification settings - Fork 190
/
tests_helper.go
35 lines (28 loc) · 932 Bytes
/
tests_helper.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
package services
import (
"context"
"github.com/opensearch-project/opensearch-go/opensearchapi"
"strings"
)
func CreateIndex(clusterClient *OsClusterClient, indexName string, mapping *strings.Reader) (int, error) {
req := opensearchapi.IndicesCreateRequest{
Index: indexName,
Body: mapping,
}
do, err := req.Do(context.Background(), clusterClient.client)
return do.StatusCode, err
}
func UpdateIndexSettings(clusterClient *OsClusterClient, indexName string, mapping *strings.Reader) {
req := opensearchapi.IndicesPutSettingsRequest{
Index: []string{indexName},
Body: mapping,
}
_, err := req.Do(context.Background(), clusterClient.client)
if err != nil {
return
}
}
func DeleteIndex(clusterClient *OsClusterClient, indexName string) (int, error) {
res, err := opensearchapi.IndicesDeleteRequest{Index: []string{indexName}}.Do(context.Background(), clusterClient.client)
return res.StatusCode, err
}