Skip to content

Commit

Permalink
Merge pull request #2 from ConradKurth/user-support
Browse files Browse the repository at this point in the history
Adding in support for more user management calls
  • Loading branch information
mohandutt134 authored Oct 6, 2018
2 parents a1597dd + f56b902 commit 16e6a48
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
20 changes: 20 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,26 @@ func (c *DefaultClient) ListUsers() ([]User, error) {
return users, err
}

func (c *DefaultClient) InviteUser(u User) error {
params := defaultParams()
var out interface{}
return c.execute("POST", "/users/invite.json", params, &out)
}

func (c *DefaultClient) UpdateUser(u User) error {
params := defaultParams()
var out interface{}
path := fmt.Sprintf("/users/%v.json", u.ID)
return c.execute("PUT", path, params, &out)
}

func (c *DefaultClient) DeleteUser(u User) error {
params := defaultParams()
var out interface{}
path := fmt.Sprintf("/users/%v.json", u.ID)
return c.execute("DELETE", path, params, &out)
}

func (c *DefaultClient) ListLogDestinations() ([]LogDestination, error) {
lds := []LogDestination{}
params := defaultParams()
Expand Down
14 changes: 12 additions & 2 deletions header.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import "net"

type Client interface {
ListUsers() ([]User, error)
InviteUser(User) error
UpdateUser(User) error
DeleteUser(User) error

ListLogDestinations() ([]LogDestination, error)
RegisterSystem(s InputSystem) (OutputSystem, error)
GetSystem(id string) (*OutputSystem, error)
Expand Down Expand Up @@ -52,8 +56,14 @@ type LogDestination struct {
}

type User struct {
Email string `json:"email"`
ID int `json:"id"`
Email string `json:"email"`
ID int `json:"id"`
ReadOnly int `json:"read_only"`
ManageMembers int `json:"manage_members"`
ManageBilling int `json:"manage_billing"`
PurgeLogs int `json:"purge_logs"`
CanAccessAllGroups int `json:"can_access_all_groups"`
GroupIDs []int `json:"group_ids"`
}

type InputSystem struct {
Expand Down

0 comments on commit 16e6a48

Please sign in to comment.