-
Notifications
You must be signed in to change notification settings - Fork 1
/
dlp_icap_server.go
57 lines (46 loc) · 1.43 KB
/
dlp_icap_server.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
49
50
51
52
53
54
55
56
57
package dlp_icap_servers
import (
"fmt"
"strings"
"github.com/zscaler/zscaler-sdk-go/zia/services/common"
)
const (
dlpIcapServersEndpoint = "/icapServers"
)
type DLPICAPServers struct {
// The unique identifier for a DLP server.
ID int `json:"id"`
// The DLP server name.
Name string `json:"name,omitempty"`
// The DLP server URL.
URL string `json:"url,omitempty"`
// The DLP server status
Status string `json:"status,omitempty"`
}
func (service *Service) Get(icapServerID int) (*DLPICAPServers, error) {
var icapServers DLPICAPServers
err := service.Client.Read(fmt.Sprintf("%s/%d", dlpIcapServersEndpoint, icapServerID), &icapServers)
if err != nil {
return nil, err
}
service.Client.Logger.Printf("[DEBUG]Returning dlp icap server from Get: %d", icapServers.ID)
return &icapServers, nil
}
func (service *Service) GetByName(icapServerName string) (*DLPICAPServers, error) {
var icapServers []DLPICAPServers
err := common.ReadAllPages(service.Client, dlpIcapServersEndpoint, &icapServers)
if err != nil {
return nil, err
}
for _, icap := range icapServers {
if strings.EqualFold(icap.Name, icapServerName) {
return &icap, nil
}
}
return nil, fmt.Errorf("no dlp icap server found with name: %s", icapServerName)
}
func (service *Service) GetAll() ([]DLPICAPServers, error) {
var icapServers []DLPICAPServers
err := common.ReadAllPages(service.Client, dlpIcapServersEndpoint, &icapServers)
return icapServers, err
}