/
ucpLdap.go
45 lines (34 loc) · 859 Bytes
/
ucpLdap.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
package ucp
import (
"encoding/json"
"fmt"
"github.com/joeabbey/diver/pkg/ucp/types"
)
//GetLDAPInfo - returns all information about the LDAP configuration
func (c *Client) GetLDAPInfo() (*ucptypes.LDAPConfig, error) {
url := fmt.Sprintf("%s/enzi/v0/config/auth/ldap", c.UCPURL)
response, err := c.getRequest(url, nil)
if err != nil {
return nil, err
}
var l ucptypes.LDAPConfig
err = json.Unmarshal(response, &l)
if err != nil {
return nil, err
}
return &l, nil
}
//SetLDAPInfo - returns all information about the LDAP configuration
func (c *Client) SetLDAPInfo(cfg *ucptypes.LDAPConfig) error {
url := fmt.Sprintf("%s/enzi/v0/config/auth/ldap", c.UCPURL)
b, err := json.Marshal(cfg)
if err != nil {
return err
}
response, err := c.putRequest(url, b)
if err != nil {
ParseUCPError(response)
return err
}
return nil
}