-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathresource_api.go
More file actions
49 lines (43 loc) · 1.27 KB
/
resource_api.go
File metadata and controls
49 lines (43 loc) · 1.27 KB
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
package api
import (
"github.com/SecurityDo/ingext_api/client"
"github.com/SecurityDo/ingext_api/model"
)
// PlatformService provides helpers for calling platform_* endpoints.
type ResourceService struct {
client *client.IngextClient
}
func NewResourceService(client *client.IngextClient) *ResourceService {
return &ResourceService{client: client}
}
func (s *ResourceService) call(function string, payload interface{}, out interface{}) error {
return ApiCall(s.client, function, payload, out)
}
type ResourceSearchRequest struct {
Options *model.LakeFacetSearchOption `json:"options"`
Customer string `json:"customer"`
Resource string `json:"resource"`
}
func (s *ResourceService) Search(resourceType string, customer string) (resp *model.LakeSearchResponse, err error) {
request := &ResourceSearchRequest{
Options: &model.LakeFacetSearchOption{
FetchLimit: 1000,
Facets: &model.FacetsOption{
Facets: []*model.FacetEntry{
{
Title: "Groups",
Field: "@office365User.groups",
Size: 20,
},
},
},
},
Customer: customer,
Resource: resourceType,
}
//var resp model.LakeSearchResponse
if err := s.call("resource_search", request, &resp); err != nil {
return nil, err
}
return resp, nil
}