This repository has been archived by the owner on Jun 1, 2023. It is now read-only.
/
ldap_setting.go
53 lines (45 loc) · 1.6 KB
/
ldap_setting.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
package client
import (
"context"
"fmt"
"github.com/suzuki-shunsuke/go-graylog"
)
// GetLDAPSetting returns the LDAP setting.
func (client *Client) GetLDAPSetting() (*graylog.LDAPSetting, *ErrorInfo, error) {
return client.GetLDAPSettingContext(context.Background())
}
// GetLDAPSettingContext returns the LDAP setting with a context.
func (client *Client) GetLDAPSettingContext(ctx context.Context) (
*graylog.LDAPSetting, *ErrorInfo, error,
) {
// GET /system/ldap/settings Get the LDAP configuration if it is configured
ls := &graylog.LDAPSetting{}
ei, err := client.callGet(
ctx, client.Endpoints().LDAPSetting(), nil, ls)
return ls, ei, err
}
// UpdateLDAPSetting updates the LDAP setting.
func (client *Client) UpdateLDAPSetting(ldapSetting *graylog.LDAPSetting) (
*ErrorInfo, error,
) {
return client.UpdateLDAPSettingContext(context.Background(), ldapSetting)
}
// UpdateLDAPSettingContext updates the LDAP setting with a context.
func (client *Client) UpdateLDAPSettingContext(
ctx context.Context, prms *graylog.LDAPSetting,
) (*ErrorInfo, error) {
if prms == nil {
return nil, fmt.Errorf("ldap setting is nil")
}
return client.callPut(ctx, client.Endpoints().LDAPSetting(), prms, nil)
}
// DeleteLDAPSetting deletes the LDAP setting.
func (client *Client) DeleteLDAPSetting() (*ErrorInfo, error) {
return client.DeleteLDAPSettingContext(context.Background())
}
// DeleteLDAPSettingContext deletes the LDAP setting with a context.
func (client *Client) DeleteLDAPSettingContext(
ctx context.Context,
) (*ErrorInfo, error) {
return client.callDelete(ctx, client.Endpoints().LDAPSetting(), nil, nil)
}