Skip to content

Commit

Permalink
Merge pull request #40 from datadrivers/release/v0.14.4
Browse files Browse the repository at this point in the history
Add method LDAPChangeOrder to Client interface
  • Loading branch information
Nosmoht committed Jul 7, 2020
2 parents 06fe0cb + 9667fec commit 25df677
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ type Client interface {
ContentType() string
ContentTypeJSON()
ContentTypeTextPlain()
LDAPList() ([]LDAP, error)
LDAPChangeOrder([]string) error
LDAPCreate(LDAP) error
LDAPDelete(string) error
LDAPList() ([]LDAP, error)
LDAPRead(string) (*LDAP, error)
LDAPUpdate(string, LDAP) error
PrivilegeCreate(Privilege) error
Expand Down
18 changes: 18 additions & 0 deletions ldap.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ type LDAP struct {
UserSubtree bool `json:"userSubtree,omitempty"`
}

func (c *client) LDAPChangeOrder(order []string) error {
ioReader, err := jsonMarshalInterfaceToIOReader(order)
if err != nil {
return err
}

body, resp, err := c.Post(fmt.Sprintf("%s/change-order", ldapAPIEndpoint), ioReader)
if err != nil {
return err
}

if resp.StatusCode != http.StatusNoContent {
return fmt.Errorf("could not change LDAP order: HTTP: %d, %v", resp.StatusCode, string(body))
}

return nil
}

func (c *client) LDAPList() ([]LDAP, error) {
body, resp, err := c.Get(ldapAPIEndpoint, nil)
if err != nil {
Expand Down

0 comments on commit 25df677

Please sign in to comment.