-
Notifications
You must be signed in to change notification settings - Fork 1
/
zpa_scim_group.go
65 lines (57 loc) · 2.01 KB
/
zpa_scim_group.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
58
59
60
61
62
63
64
65
package scimgroup
import (
"fmt"
"net/http"
"strings"
"github.com/zscaler/zscaler-sdk-go/zpa/services/common"
)
const (
userConfig = "/userconfig/v1/customers/"
scimGroupEndpoint = "/scimgroup"
idpId = "/idpId"
)
type ScimGroup struct {
CreationTime int64 `json:"creationTime,omitempty"`
ID int64 `json:"id,omitempty"`
IdpGroupID string `json:"idpGroupId,omitempty"`
IdpID int64 `json:"idpId,omitempty"`
IdpName string `json:"idpName,omitempty"`
ModifiedTime int64 `json:"modifiedTime,omitempty"`
Name string `json:"name,omitempty"`
}
func (service *Service) Get(scimGroupID string) (*ScimGroup, *http.Response, error) {
v := new(ScimGroup)
relativeURL := fmt.Sprintf("%s/%s", userConfig+service.Client.Config.CustomerID+scimGroupEndpoint, scimGroupID)
resp, err := service.Client.NewRequestDo("GET", relativeURL, nil, nil, v)
if err != nil {
return nil, nil, err
}
return v, resp, nil
}
func (service *Service) GetByName(scimName, IdpId string) (*ScimGroup, *http.Response, error) {
var v struct {
List []ScimGroup `json:"list"`
}
relativeURL := fmt.Sprintf("%s/%s", userConfig+service.Client.Config.CustomerID+scimGroupEndpoint+idpId, IdpId)
resp, err := service.Client.NewRequestDo("GET", relativeURL, common.Pagination{PageSize: common.DefaultPageSize, Search: scimName}, nil, &v)
if err != nil {
return nil, nil, err
}
for _, scim := range v.List {
if strings.EqualFold(scim.Name, scimName) {
return &scim, resp, nil
}
}
return nil, resp, fmt.Errorf("no scim named '%s' was found", scimName)
}
func (service *Service) GetAllByIdpId(IdpId string) ([]ScimGroup, *http.Response, error) {
var v struct {
List []ScimGroup `json:"list"`
}
relativeURL := fmt.Sprintf("%s/%s", userConfig+service.Client.Config.CustomerID+scimGroupEndpoint+idpId, IdpId)
resp, err := service.Client.NewRequestDo("GET", relativeURL, common.Pagination{PageSize: common.DefaultPageSize}, nil, &v)
if err != nil {
return nil, nil, err
}
return v.List, resp, nil
}