-
Notifications
You must be signed in to change notification settings - Fork 1
/
zpa_saml_attribute.go
57 lines (50 loc) · 1.77 KB
/
zpa_saml_attribute.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 samlattribute
import (
"fmt"
"net/http"
"github.com/zscaler/zscaler-sdk-go/zpa/services/common"
)
const (
mgmtConfig = "/mgmtconfig/v2/admin/customers/"
mgmtConfigV1 = "/mgmtconfig/v1/admin/customers/"
samlAttributeEndpoint = "/samlAttribute"
)
type SamlAttribute struct {
CreationTime string `json:"creationTime,omitempty"`
ID string `json:"id,omitempty"`
IdpID string `json:"idpId,omitempty"`
IdpName string `json:"idpName,omitempty"`
ModifiedBy string `json:"modifiedBy,omitempty"`
ModifiedTime string `json:"modifiedTime,omitempty"`
Name string `json:"name,omitempty"`
SamlName string `json:"samlName,omitempty"`
UserAttribute bool `json:"userAttribute,omitempty"`
}
func (service *Service) Get(samlAttributeID string) (*SamlAttribute, *http.Response, error) {
v := new(SamlAttribute)
relativeURL := fmt.Sprintf("%s/%s", mgmtConfigV1+service.Client.Config.CustomerID+samlAttributeEndpoint, samlAttributeID)
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(samlAttrName string) (*SamlAttribute, *http.Response, error) {
var v struct {
List []SamlAttribute `json:"list"`
}
relativeURL := fmt.Sprintf(mgmtConfig + service.Client.Config.CustomerID + samlAttributeEndpoint)
resp, err := service.Client.NewRequestDo("GET", relativeURL, common.Pagination{
PageSize: common.DefaultPageSize,
Search: samlAttrName,
}, nil, &v)
if err != nil {
return nil, nil, err
}
for _, samlAttribute := range v.List {
if samlAttribute.Name == samlAttrName {
return &samlAttribute, resp, nil
}
}
return nil, resp, fmt.Errorf("no saml attribute named '%s' was found", samlAttrName)
}