-
Notifications
You must be signed in to change notification settings - Fork 1
/
search.go
32 lines (29 loc) · 1.05 KB
/
search.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
package umbrella
import (
"fmt"
"net/url"
"time"
)
// SearchResults contains a list of matches when performning a pattern search.
type SearchResults struct {
Expression string `json:"expression"` // Query Regex
TotalResults int `json:"totalResults"` // Number of results
MoreDataAvailable bool `json:"moreDataAvailable"` // True if TotalResults > Limit
Limit int `json:"limit"` // Query result limit
Matches []struct {
Name string `json:"name"` // Domain name
FirstSeen int64 `json:"firstSeen"`
FirstSeenISO time.Time `json:"firstSeenISO"`
SecurityCategories []string `json:"securityCategories"`
} `json:"matches"`
}
// Search performs a pattern search.
func (c Investigate) Search(expression string, opts QueryOptions) (SearchResults, error) {
u := &url.URL{
Path: fmt.Sprintf("search/%s", expression),
RawQuery: url.Values(opts).Encode(),
}
var out SearchResults
err := c.Get(c.BaseURL.ResolveReference(u).String(), &out)
return out, err
}