-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcmd_search.go
35 lines (28 loc) · 931 Bytes
/
cmd_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
33
34
35
package main
import (
common "github.com/apiheat/akamai-cli-common/v4"
service "github.com/apiheat/go-edgegrid/v6/service/netlistv2"
"github.com/urfave/cli/v2"
)
// cmdSearchNetLists is used by cli to execute search across lists based on item
func cmdSearchNetLists(c *cli.Context) error {
return searchNetLists(c)
}
// searchNetLists execute client API call to search for lists based on item
func searchNetLists(c *cli.Context) error {
//TODO: fix
// common.VerifyArgumentByName(c, "searchPattern")
listNetListOptsv2 := service.ListNetworkListsOptionsv2{}
listNetListOptsv2.Search = c.String("searchPattern")
if c.String("listType") == "ANY" {
listNetListOptsv2.TypeOflist = ""
} else {
listNetListOptsv2.TypeOflist = c.String("listType")
}
netListsRes, netlistErr := apiClient.ListNetworkLists(listNetListOptsv2)
if netlistErr != nil {
return netlistErr
}
common.OutputJSON(netListsRes)
return nil
}