-
Notifications
You must be signed in to change notification settings - Fork 5
/
virtualserver.go
48 lines (45 loc) · 2.3 KB
/
virtualserver.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
40
41
42
43
44
45
46
47
48
package illumioapi
import (
"fmt"
"strings"
)
// VirtualServer represents a VirtualServer in the PCE
type VirtualServer struct {
Href string `json:"href,omitempty"`
Name string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
DiscoveredVirtualServer *Href `json:"discovered_virtual_server,omitempty"`
DvsName string `json:"dvs_name,omitempty"`
DvsIdentifier string `json:"dvs_identifier,omitempty"`
Labels *[]Label `json:"labels,omitempty"`
Service *Service `json:"service,omitempty"`
Providers *ConsumerOrProvider `json:"providers,omitempty"`
Mode string `json:"mode,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
CreatedBy *Href `json:"created_by,omitempty"`
DeletedAt string `json:"deleted_at,omitempty"`
DeletedBy *Href `json:"deleted_by,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
UpdatedBy *Href `json:"updated_by,omitempty"`
}
// GetVirtualServers returns a slice of IP lists from the PCE. pStatus must be "draft" or "active".
// queryParameters can be used for filtering in the form of ["parameter"]="value".
// The first API call to the PCE does not use the async option.
// If the slice length is >=500, it re-runs with async.
func (p *PCE) GetVirtualServers(queryParameters map[string]string, pStatus string) (api APIResponse, err error) {
// Validate pStatus
pStatus = strings.ToLower(pStatus)
if pStatus != "active" && pStatus != "draft" {
return api, fmt.Errorf("invalid pStatus")
}
api, err = p.GetCollection("sec_policy/"+pStatus+"/virtual_servers", false, queryParameters, &p.VirtualServersSlice)
if len(p.VirtualServersSlice) >= 500 {
api, err = p.GetCollection("sec_policy/"+pStatus+"/virtual_servers", true, queryParameters, &p.VirtualServersSlice)
}
p.VirtualServers = make(map[string]VirtualServer)
for _, v := range p.VirtualServersSlice {
p.VirtualServers[v.Href] = v
p.VirtualServers[v.Name] = v
}
return api, err
}