Skip to content

Commit 25df677

Browse files
authored
Merge pull request #40 from datadrivers/release/v0.14.4
Add method LDAPChangeOrder to Client interface
2 parents 06fe0cb + 9667fec commit 25df677

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

client.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ type Client interface {
3333
ContentType() string
3434
ContentTypeJSON()
3535
ContentTypeTextPlain()
36-
LDAPList() ([]LDAP, error)
36+
LDAPChangeOrder([]string) error
3737
LDAPCreate(LDAP) error
3838
LDAPDelete(string) error
39+
LDAPList() ([]LDAP, error)
3940
LDAPRead(string) (*LDAP, error)
4041
LDAPUpdate(string, LDAP) error
4142
PrivilegeCreate(Privilege) error

ldap.go

+18
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,24 @@ type LDAP struct {
4545
UserSubtree bool `json:"userSubtree,omitempty"`
4646
}
4747

48+
func (c *client) LDAPChangeOrder(order []string) error {
49+
ioReader, err := jsonMarshalInterfaceToIOReader(order)
50+
if err != nil {
51+
return err
52+
}
53+
54+
body, resp, err := c.Post(fmt.Sprintf("%s/change-order", ldapAPIEndpoint), ioReader)
55+
if err != nil {
56+
return err
57+
}
58+
59+
if resp.StatusCode != http.StatusNoContent {
60+
return fmt.Errorf("could not change LDAP order: HTTP: %d, %v", resp.StatusCode, string(body))
61+
}
62+
63+
return nil
64+
}
65+
4866
func (c *client) LDAPList() ([]LDAP, error) {
4967
body, resp, err := c.Get(ldapAPIEndpoint, nil)
5068
if err != nil {

0 commit comments

Comments
 (0)