Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 848e2d1

Browse files
committed
Issue #30 - Add Additional Query Params for Ip Intel Index
1 parent 926e79b commit 848e2d1

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

index.go

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
)
99

1010
type IndexQueryParameters struct {
11+
// INDEX RELATED
1112
Cve string `json:"cve"`
1213
Alias string `json:"alias"`
1314
Iava string `json:"iava"`
@@ -20,13 +21,20 @@ type IndexQueryParameters struct {
2021
MispId string `json:"misp_id"`
2122
Ransomware string `json:"ransomware"`
2223
Botnet string `json:"botnet"`
23-
Limit int `json:"limit"`
24-
Sort string `json:"sort"`
25-
Order string `json:"order"`
26-
Page int `json:"page"`
27-
Cursor string `json:"cursor"`
28-
NextCursor string `json:"next_cursor"`
29-
PrevCursor string `json:"prev_cursor"` // this may not exist
24+
Hostname string `json:"hostname"`
25+
ID string `json:"id"`
26+
Country string `json:"country"`
27+
CountryCode string `json:"country_code"`
28+
Asn string `json:"asn"`
29+
30+
// PAGINATION RELATED
31+
Limit int `json:"limit"`
32+
Sort string `json:"sort"`
33+
Order string `json:"order"`
34+
Page int `json:"page"`
35+
Cursor string `json:"cursor"`
36+
NextCursor string `json:"next_cursor"`
37+
PrevCursor string `json:"prev_cursor"` // this may not exist
3038
}
3139

3240
type IndexMeta struct {
@@ -58,6 +66,7 @@ type IndexResponse struct {
5866
// add method to set query parameters
5967
func setIndexQueryParameters(query url.Values, queryParameters ...IndexQueryParameters) {
6068
for _, queryParameter := range queryParameters {
69+
// INDEX RELATED
6170
if queryParameter.Cve != "" {
6271
query.Add("cve", queryParameter.Cve)
6372
}
@@ -94,6 +103,19 @@ func setIndexQueryParameters(query url.Values, queryParameters ...IndexQueryPara
94103
if queryParameter.Botnet != "" {
95104
query.Add("botnet", queryParameter.Botnet)
96105
}
106+
if queryParameter.Hostname != "" {
107+
query.Add("hostname", queryParameter.Hostname)
108+
}
109+
if queryParameter.ID != "" {
110+
query.Add("id", queryParameter.ID)
111+
}
112+
if queryParameter.Country != "" {
113+
query.Add("country", queryParameter.Country)
114+
}
115+
if queryParameter.CountryCode != "" {
116+
query.Add("country_code", queryParameter.CountryCode)
117+
}
118+
// PAGINATION RELATED
97119
if queryParameter.Limit != 0 {
98120
query.Add("limit", fmt.Sprintf("%d", queryParameter.Limit))
99121
}

0 commit comments

Comments
 (0)