Skip to content

Commit 02219d0

Browse files
committed
Rename v1 APIs in prep for introducing v2 (CLIP)
1 parent aeb0475 commit 02219d0

File tree

106 files changed

+599
-518
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+599
-518
lines changed

TODO.md

Lines changed: 1 addition & 1 deletion

cmd/api.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
package cmd
22

33
func init() {
4-
_, err := parser.AddCommand("api", "Interact directly with the Hue Bridge JSON API", "", &apiCmd{})
4+
_, err := parser.AddCommand("api", "Interact with Hue Bridge APIs", "", &apiCmd{})
55
if err != nil {
66
panic(err)
77
}
88
}
99

1010
type apiCmd struct {
11-
APICapabilities *apiCapabilitiesCmd `command:"capabilities" description:"Show capabilities and resource usage"`
12-
APIConfig *apiConfigCmd `command:"config" description:"Manage config"`
13-
APIGroups *apiGroupsCmd `command:"groups" description:"Manage groups"`
14-
APILights *apiLightsCmd `command:"lights" description:"Manage lights"`
15-
APIResourceLinks *apiResourceLinksCmd `command:"resourcelinks" description:"Manage resource links"`
16-
APIRules *apiRulesCmd `command:"rules" description:"Manage rules"`
17-
APIScenes *apiScenesCmd `command:"scenes" description:"Manage scenes"`
18-
APISchedules *apiSchedulesCmd `command:"schedules" description:"Manage schedules"`
19-
APISensors *apiSensorsCmd `command:"sensors" description:"Manage sensors"`
11+
V1 *apiV1Cmd `command:"v1" description:"Interact with v1 of the Hue Bridge API"`
2012
}

cmd/api_capabilities.go

Lines changed: 0 additions & 5 deletions
This file was deleted.

cmd/api_v1.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package cmd
2+
3+
type apiV1Cmd struct {
4+
APICapabilities *apiV1CapabilitiesCmd `command:"capabilities" description:"Show capabilities and resource usage"`
5+
APIConfig *apiV1ConfigCmd `command:"config" description:"Manage config"`
6+
APIGroups *apiV1GroupsCmd `command:"groups" description:"Manage groups"`
7+
APILights *apiV1LightsCmd `command:"lights" description:"Manage lights"`
8+
APIResourceLinks *apiV1ResourceLinksCmd `command:"resourcelinks" description:"Manage resource links"`
9+
APIRules *apiV1RulesCmd `command:"rules" description:"Manage rules"`
10+
APIScenes *apiV1ScenesCmd `command:"scenes" description:"Manage scenes"`
11+
APISchedules *apiV1SchedulesCmd `command:"schedules" description:"Manage schedules"`
12+
APISensors *apiV1SensorsCmd `command:"sensors" description:"Manage sensors"`
13+
}

cmd/api_v1_capabilities.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package cmd
2+
3+
//go:generate ./gen_api_read.sh ID=capabilities_get TYPE=apiV1CapabilitiesCmd FUNC_CALL=bridge.GetCapabilities()
4+
type apiV1CapabilitiesCmd struct{}

cmd/api_capabilities_get_gen.go renamed to cmd/api_v1_capabilities_get_gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/api_config.go renamed to cmd/api_v1_config.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ import (
77
"github.com/dansimau/huecfg/pkg/jsonutil"
88
)
99

10-
// huecfg api config ...
11-
type apiConfigCmd struct {
10+
type apiV1ConfigCmd struct {
1211
CreateUser *apiConfigCreateUserCmd `command:"create-user" description:"Create user to interact with Hue Bridge"`
1312
Dump *apiConfigDumpCmd `command:"dump" description:"Fetch the full state of the device in a single JSON document"`
1413
Get *apiConfigGetCmd `command:"get" description:"Show Hue Bridge configuration"`
1514
}
1615

17-
// huecfg api config create-user
1816
type apiConfigCreateUserCmd struct {
1917
DeviceType string `long:"device-type" description:"A string in the format '<application_name>#<devicename>'" default:"huecfg#cli"`
2018
GenerateClientKey bool `long:"generate-client-key" description:"Generate a random username"`
@@ -39,10 +37,8 @@ func (c *apiConfigCreateUserCmd) Execute(args []string) error {
3937
return nil
4038
}
4139

42-
// huecfg api config dump
43-
//go:generate ./gen_api_read.sh ID=config_dump TYPE=apiConfigDumpCmd FUNC_CALL=bridge.GetFullState()
40+
//go:generate ./gen_api_read.sh ID=config_dump TYPE=apiV1ConfigDumpCmd FUNC_CALL=bridge.GetFullState()
4441
type apiConfigDumpCmd struct{}
4542

46-
// huecfg api config get
47-
//go:generate ./gen_api_read.sh ID=config_get TYPE=apiConfigGetCmd FUNC_CALL=bridge.GetConfig()
43+
//go:generate ./gen_api_read.sh ID=config_get TYPE=apiV1ConfigGetCmd FUNC_CALL=bridge.GetConfig()
4844
type apiConfigGetCmd struct{}
File renamed without changes.
File renamed without changes.

cmd/api_groups.go renamed to cmd/api_v1_groups.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package cmd
22

3-
// huecfg api groups ...
4-
type apiGroupsCmd struct {
3+
type apiV1GroupsCmd struct {
54
Create *apiGroupsCreateCmd `command:"create" description:"Create a new group"`
65
Delete *apiGroupsDeleteCmd `command:"delete" description:"Delete a device from the bridge"`
76
Get *apiGroupsGetCmd `command:"get" description:"Fetch the specified group by ID"`
@@ -10,43 +9,37 @@ type apiGroupsCmd struct {
109
SetState *apiGroupsSetStateCmd `command:"set-state" description:"Set the state of all lights in a group"`
1110
}
1211

13-
// huecfg api groups create
14-
//go:generate ./gen_api_write.sh ID=groups_create TYPE=apiGroupsCreateCmd DATA=c.Data FUNC_CALL=bridge.CreateGroup(data)
12+
//go:generate ./gen_api_write.sh ID=groups_create TYPE=apiV1GroupsCreateCmd DATA=c.Data FUNC_CALL=bridge.CreateGroup(data)
1513
type apiGroupsCreateCmd struct {
1614
Data string `long:"data" description:"JSON data to send" default:"-"`
1715
}
1816

19-
// huecfg api groups delete ...
20-
//go:generate ./gen_api_read.sh ID=groups_delete TYPE=apiGroupsDeleteCmd FUNC_CALL=bridge.DeleteGroup(c.Arguments.ID)
17+
//go:generate ./gen_api_read.sh ID=groups_delete TYPE=apiV1GroupsDeleteCmd FUNC_CALL=bridge.DeleteGroup(c.Arguments.ID)
2118
type apiGroupsDeleteCmd struct {
2219
Arguments struct {
2320
ID string `description:"ID of the group to delete."`
2421
} `positional-args:"true" required:"true" positional-arg-name:"group-ID"`
2522
}
2623

27-
// huecfg api groups get-all
28-
//go:generate ./gen_api_read.sh ID=groups_get_all TYPE=apiGroupsGetAllCmd FUNC_CALL=bridge.GetGroups()
24+
//go:generate ./gen_api_read.sh ID=groups_get_all TYPE=apiV1GroupsGetAllCmd FUNC_CALL=bridge.GetGroups()
2925
type apiGroupsGetAllCmd struct{}
3026

31-
// huecfg api groups get
32-
//go:generate ./gen_api_read.sh ID=groups_get TYPE=apiGroupsGetCmd FUNC_CALL=bridge.GetGroup(c.Arguments.ID)
27+
//go:generate ./gen_api_read.sh ID=groups_get TYPE=apiV1GroupsGetCmd FUNC_CALL=bridge.GetGroup(c.Arguments.ID)
3328
type apiGroupsGetCmd struct {
3429
Arguments struct {
3530
ID string
3631
} `positional-args:"true" required:"true" positional-arg-name:"group-ID"`
3732
}
3833

39-
// huecfg api groups set
40-
//go:generate ./gen_api_write.sh ID=groups_set TYPE=apiGroupsSetCmd "FUNC_CALL=bridge.SetGroupAttributes(c.Arguments.ID, data)" DATA=c.Data
34+
//go:generate ./gen_api_write.sh ID=groups_set TYPE=apiV1GroupsSetCmd "FUNC_CALL=bridge.SetGroupAttributes(c.Arguments.ID, data)" DATA=c.Data
4135
type apiGroupsSetCmd struct {
4236
Data string `long:"data" description:"JSON data to send"`
4337
Arguments struct {
4438
ID string `description:"ID of the group to set attributes for."`
4539
} `positional-args:"true" required:"true" positional-arg-name:"light-ID"`
4640
}
4741

48-
// huecfg api groups set-state ...
49-
//go:generate ./gen_api_write.sh ID=groups_set_state TYPE=apiGroupsSetStateCmd "FUNC_CALL=bridge.SetGroupState(c.Arguments.ID, data)" DATA=c.Data
42+
//go:generate ./gen_api_write.sh ID=groups_set_state TYPE=apiV1GroupsSetStateCmd "FUNC_CALL=bridge.SetGroupState(c.Arguments.ID, data)" DATA=c.Data
5043
type apiGroupsSetStateCmd struct {
5144
Data string `long:"data" description:"JSON data to send" default:"-"`
5245
Arguments struct {

0 commit comments

Comments
 (0)