Skip to content

Commit 26876b4

Browse files
Merge pull request #21 from chkp-tomerassa/master
Fixed ApiQuery objects list type
2 parents 05ed01e + ed0255d commit 26876b4

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

APIFiles/APIClient.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ func (c *ApiClient) ApiQuery(command string, detailsLevel string, containerKey s
552552
if apiRes.Success && includeContainerKey == false && ok {
553553

554554
m := map[string]interface{}{}
555-
for y, x := range apiRes.data[containerKey].([]map[string]interface{}) {
555+
for y, x := range apiRes.data[containerKey].([]interface{}) {
556556

557557
m[fmt.Sprintf("%d", y)] = x
558558
}
@@ -584,14 +584,14 @@ func (c *ApiClient) genApiQuery(command string, detailsLevel string, containerKe
584584
const objLimit int = Limit
585585
var finished bool = false
586586

587-
allObjects := map[string][]map[string]interface{}{}
587+
allObjects := map[string][]interface{}{}
588588

589589
if len(containerKeys) == 0 {
590590
containerKeys = []string{"objects"}
591591
}
592592

593593
for _, key := range containerKeys {
594-
allObjects[key] = []map[string]interface{}{}
594+
allObjects[key] = []interface{}{}
595595
}
596596

597597
iterations := 0
@@ -640,7 +640,7 @@ func (c *ApiClient) genApiQuery(command string, detailsLevel string, containerKe
640640
for _, containerKey := range containerKeys {
641641

642642
for _, data := range (apiRes.data[containerKey]).([]interface{}) {
643-
allObjects[containerKey] = append(allObjects[containerKey], data.(map[string]interface{}))
643+
allObjects[containerKey] = append(allObjects[containerKey], data)
644644
}
645645
apiRes.data[containerKey] = allObjects[containerKey]
646646
i++

Examples/show_hosts.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ func ShowHosts() {
5050

5151
//fmt.Println(show_sessions_res.GetData())
5252
for _, sessionObj := range showHostsRes.GetData() {
53+
host := sessionObj.(map[string]interface{})
5354
fmt.Println("-------------\n--------------")
54-
fmt.Println(sessionObj.(map[string]interface{})["name"].(string))
55-
fmt.Println(sessionObj.(map[string]interface{})["ipv4-address"].(string))
55+
fmt.Println(host["name"].(string))
56+
fmt.Println(host["ipv4-address"].(string))
5657
}
5758

5859
}

0 commit comments

Comments
 (0)