Skip to content

Commit

Permalink
refactor(meta): V2 Device OperatingState value change
Browse files Browse the repository at this point in the history
Discussed in the Device WG meeting on 5th-Oct-2020, we would like to change the enumeration value of OperatingState from Enabled/Disabled to Up/Down/Unknown.

Fix #318

Signed-off-by: weichou <weichou1229@gmail.com>
  • Loading branch information
weichou1229 committed Dec 8, 2020
1 parent 617ea87 commit 15a3b03
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions v2/dtos/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Device struct {
Name string `json:"name" validate:"required,edgex-dto-none-empty-string"`
Description string `json:"description,omitempty"`
AdminState string `json:"adminState" validate:"oneof='LOCKED' 'UNLOCKED'"`
OperatingState string `json:"operatingState" validate:"oneof='ENABLED' 'DISABLED'"`
OperatingState string `json:"operatingState" validate:"oneof='UP' 'DOWN' 'UNKNOWN'"`
LastConnected int64 `json:"lastConnected,omitempty"`
LastReported int64 `json:"lastReported,omitempty"`
Labels []string `json:"labels,omitempty"`
Expand All @@ -38,7 +38,7 @@ type UpdateDevice struct {
Name *string `json:"name" validate:"required_without=Id,edgex-dto-none-empty-string"`
Description *string `json:"description" validate:"omitempty,edgex-dto-none-empty-string"`
AdminState *string `json:"adminState" validate:"omitempty,oneof='LOCKED' 'UNLOCKED'"`
OperatingState *string `json:"operatingState" validate:"omitempty,oneof='ENABLED' 'DISABLED'"`
OperatingState *string `json:"operatingState" validate:"omitempty,oneof='UP' 'DOWN' 'UNKNOWN'"`
LastConnected *int64 `json:"lastConnected"`
LastReported *int64 `json:"lastReported"`
ServiceName *string `json:"serviceName" validate:"omitempty,edgex-dto-none-empty-string"`
Expand Down
8 changes: 4 additions & 4 deletions v2/dtos/requests/device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var testAddDevice = AddDeviceRequest{
ServiceName: TestDeviceServiceName,
ProfileName: TestDeviceProfileName,
AdminState: models.Locked,
OperatingState: models.Enabled,
OperatingState: models.Up,
Labels: testDeviceLabels,
Location: testDeviceLocation,
AutoEvents: testAutoEvents,
Expand All @@ -64,7 +64,7 @@ func mockUpdateDevice() dtos.UpdateDevice {
testName := TestDeviceName
testDescription := TestDescription
testAdminState := models.Locked
testOperatingState := models.Enabled
testOperatingState := models.Up
testDeviceServiceName := TestDeviceServiceName
testProfileName := TestDeviceProfileName
d := dtos.UpdateDevice{}
Expand Down Expand Up @@ -172,7 +172,7 @@ func Test_AddDeviceReqToDeviceModels(t *testing.T) {
ServiceName: TestDeviceServiceName,
ProfileName: TestDeviceProfileName,
AdminState: models.Locked,
OperatingState: models.Enabled,
OperatingState: models.Up,
Labels: testDeviceLabels,
Location: testDeviceLocation,
AutoEvents: []models.AutoEvent{
Expand Down Expand Up @@ -366,7 +366,7 @@ func TestReplaceDeviceModelFieldsWithDTO(t *testing.T) {

assert.Equal(t, TestDescription, device.Description)
assert.Equal(t, models.AdminState(models.Locked), device.AdminState)
assert.Equal(t, models.OperatingState(models.Enabled), device.OperatingState)
assert.Equal(t, models.OperatingState(models.Up), device.OperatingState)
assert.Equal(t, testNowTime, device.LastConnected)
assert.Equal(t, testNowTime, device.LastReported)
assert.Equal(t, TestDeviceServiceName, device.ServiceName)
Expand Down
10 changes: 6 additions & 4 deletions v2/models/operatingstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ package models
type OperatingState string

/*
Enabled : ENABLED
Disabled : DISABLED
Up : UP
Down : DOWN
Unknown : UNKNOWN
*/
const (
Enabled = "ENABLED"
Disabled = "DISABLED"
Up = "UP"
Down = "DOWN"
Unknown = "UNKNOWN"
)

0 comments on commit 15a3b03

Please sign in to comment.