-
Notifications
You must be signed in to change notification settings - Fork 1
/
service.go
49 lines (42 loc) · 1.04 KB
/
service.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
package scimgroup
import (
"github.com/zscaler/zscaler-sdk-go/v2/zpa"
)
type (
SortOrder string
SortField string
)
const (
ASCSortOrder SortOrder = "ASC"
DESCSortOrder = "DESC"
IDSortField SortField = "id"
NameSortField = "name"
CreationTimeSortField = "creationTime"
ModifiedTimeSortField = "modifiedTime"
)
type Service struct {
Client *zpa.Client
sortOrder SortOrder
sortBy SortField
}
func New(c *zpa.Client) *Service {
return &Service{
Client: c,
sortOrder: ASCSortOrder,
sortBy: NameSortField,
}
}
func (service *Service) WithSort(sortBy SortField, sortOrder SortOrder) *Service {
c := Service{
Client: service.Client,
sortOrder: service.sortOrder,
sortBy: service.sortBy,
}
if sortBy == IDSortField || sortBy == NameSortField || sortBy == CreationTimeSortField || sortBy == ModifiedTimeSortField {
c.sortBy = sortBy
}
if sortOrder == ASCSortOrder || sortOrder == DESCSortOrder {
c.sortOrder = sortOrder
}
return &c
}