-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathsaved_searches.go
58 lines (49 loc) · 1.53 KB
/
saved_searches.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
package client
import (
"github.com/splunk/terraform-provider-splunk/client/models"
"net/http"
"github.com/google/go-querystring/query"
)
func (client *Client) CreateSavedSearches(name, owner, app string, savedSearchObject *models.SavedSearchObject) error {
values, err := query.Values(savedSearchObject)
values.Add("name", name)
if err != nil {
return err
}
endpoint := client.BuildSplunkURL(nil, "servicesNS", owner, app, "saved", "searches")
resp, err := client.Post(endpoint, values)
if err != nil {
return err
}
defer resp.Body.Close()
return nil
}
func (client *Client) ReadSavedSearches(name, owner, app string) (*http.Response, error) {
endpoint := client.BuildSplunkURL(nil, "servicesNS", owner, app, "saved", "searches", name)
resp, err := client.Get(endpoint)
if err != nil {
return nil, err
}
return resp, nil
}
func (client *Client) UpdateSavedSearches(name string, owner string, app string, savedSearchObject *models.SavedSearchObject) error {
values, err := query.Values(&savedSearchObject)
if err != nil {
return err
}
endpoint := client.BuildSplunkURL(nil, "servicesNS", owner, app, "saved", "searches", name)
resp, err := client.Post(endpoint, values)
if err != nil {
return err
}
defer resp.Body.Close()
return nil
}
func (client *Client) DeleteSavedSearches(name, owner, app string) (*http.Response, error) {
endpoint := client.BuildSplunkURL(nil, "servicesNS", owner, app, "saved", "searches", name)
resp, err := client.Delete(endpoint)
if err != nil {
return nil, err
}
return resp, nil
}