forked from vulncheck-oss/sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
/
indices.go
39 lines (32 loc) · 897 Bytes
/
indices.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
package sdk
import (
"encoding/json"
"fmt"
)
type IndicesMeta struct {
Name string `json:"name"`
Description string `json:"description"`
Href string `json:"href"`
}
type IndicesResponse struct {
Benchmark float64 `json:"_benchmark"`
Data []IndicesMeta `json:"data"`
}
// GetIndices https://docs.vulncheck.com/api/indexes
func (c *Client) GetIndices() (responseJSON *IndicesResponse, err error) {
resp, err := c.Request("GET", "/v3/index")
if err != nil {
return nil, err
}
defer resp.Body.Close()
_ = json.NewDecoder(resp.Body).Decode(&responseJSON)
return responseJSON, nil
}
// Strings representation of the response
func (r IndicesResponse) String() string {
return fmt.Sprintf("Benchmark: %v\nData: %v\n", r.Benchmark, r.Data)
}
// GetData - Returns the data from the response
func (r IndicesResponse) GetData() []IndicesMeta {
return r.Data
}