-
Notifications
You must be signed in to change notification settings - Fork 1
/
applicationservicesgroup.go
43 lines (36 loc) · 1.34 KB
/
applicationservicesgroup.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
package applicationservicesgroup
import (
"fmt"
"strings"
"github.com/zscaler/zscaler-sdk-go/zia/services/common"
)
const (
appServicesGroupLiteEndpoint = "/appServiceGroups/lite"
)
type ApplicationServicesGroupLite struct {
ID int `json:"id"`
Name string `json:"name,omitempty"`
NameL10nTag bool `json:"nameL10nTag"`
}
func (service *Service) Get(serviceGroupID int) (*ApplicationServicesGroupLite, error) {
var appServicesGroupLite ApplicationServicesGroupLite
err := service.Client.Read(fmt.Sprintf("%s/%d", appServicesGroupLiteEndpoint, serviceGroupID), &appServicesGroupLite)
if err != nil {
return nil, err
}
service.Client.Logger.Printf("[DEBUG]Returning application services group from Get: %d", appServicesGroupLite.ID)
return &appServicesGroupLite, nil
}
func (service *Service) GetByName(serviceGroupName string) (*ApplicationServicesGroupLite, error) {
var appServicesGroupLite []ApplicationServicesGroupLite
err := common.ReadAllPages(service.Client, appServicesGroupLiteEndpoint, &appServicesGroupLite)
if err != nil {
return nil, err
}
for _, appServicesGroupLite := range appServicesGroupLite {
if strings.EqualFold(appServicesGroupLite.Name, serviceGroupName) {
return &appServicesGroupLite, nil
}
}
return nil, fmt.Errorf("no application services group found with name: %s", serviceGroupName)
}