Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating field names for 'Group' and added a new 'Edit' interface #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/scottlamb/luxor/protocol"
"golang.org/x/net/context"
"io/ioutil"
"net/http"
"time"

"github.com/scottlamb/luxor/protocol"
"golang.org/x/net/context"
)

// *Controller implements protocol.Controller
Expand Down Expand Up @@ -172,6 +173,14 @@ func (c *Controller) GroupListRename(ctx context.Context, req *protocol.GroupLis
return resp, protocol.ErrorForStatus(resp.Status)
}

func (c *Controller) GroupListEdit(ctx context.Context, req *protocol.GroupListEditRequest) (*protocol.GroupListEditResponse, error) {
resp := &protocol.GroupListEditResponse{}
if err := c.request(ctx, "GroupListEdit", req, resp); err != nil {
return nil, err
}
return resp, protocol.ErrorForStatus(resp.Status)
}

func (c *Controller) GroupListReorder(ctx context.Context, req *protocol.GroupListReorderRequest) (*protocol.GroupListReorderResponse, error) {
resp := &protocol.GroupListReorderResponse{}
if err := c.request(ctx, "GroupListReorder", req, resp); err != nil {
Expand Down
27 changes: 24 additions & 3 deletions protocol/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ package protocol
import (
"errors"
"fmt"

"golang.org/x/net/context"
)

Expand Down Expand Up @@ -88,6 +89,9 @@ type Controller interface {
// GroupListRename renames a group.
GroupListRename(ctx context.Context, request *GroupListRenameRequest) (response *GroupListRenameResponse, err error)

// GroupListEdit updates a group values (intensity, color).
GroupListEdit(ctx context.Context, request *GroupListEditRequest) (response *GroupListEditResponse, err error)

// GroupListReorder reorders groups.
GroupListReorder(ctx context.Context, request *GroupListReorderRequest) (response *GroupListReorderResponse, err error)

Expand Down Expand Up @@ -202,9 +206,10 @@ type FlashLightsResponse struct {
}

type Group struct {
GroupNumber uint8
Intensity uint8
Name string
Name string `json:"Name"`
GroupNumber uint8 `json:"Grp"`
Intensity uint8 `json:"Inten"`
Color uint8 `json:"Colr"`
}

type GroupListAddRequest struct {
Expand Down Expand Up @@ -258,6 +263,22 @@ type GroupListRenameResponse struct {
Status int
}

// GroupListEditRequest allows editing/saving of Group number and color assignments
// For updating only the name, use GroupListRename
// For updating all at the same time, call Rename first and (on success),
// use the Name key to then call Edit.
type GroupListEditRequest struct {
Name string
GroupNumber uint8
Color uint8
}

// GroupListEditResponse -- response counterpart
type GroupListEditResponse struct {
// Status will be StatusPreconditionFailed if the name does not exist.
Status int
}

type GroupListReorderRequest struct {
// GroupNumbers should be a new order that includes all existing
// groups exactly once.
Expand Down