Skip to content

Commit

Permalink
Merge pull request #4375 from judehung/contract-issue-805-772
Browse files Browse the repository at this point in the history
feat!: Remove Notify field out of Device dto and add Properties field into ProvisionWatcher dto
  • Loading branch information
cloudxxx8 authored Feb 21, 2023
2 parents affa4ba + 879c8ea commit d1220c9
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 17 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require (
github.com/eclipse/paho.mqtt.golang v1.4.2
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.25
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.3
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.18
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.20
github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.9
github.com/edgexfoundry/go-mod-secrets/v3 v3.0.0-dev.7
github.com/fxamacker/cbor/v2 v2.4.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.25 h1:PkmFk6qTwc4WHxAwRBY
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.25/go.mod h1:iv/czxi4ciFWMgrO+3nnanGfkT2X1QW5L3iCb+deewk=
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.3 h1:0Ew4PzLSFJ+sb7AYtvb9m1mRN45Sh0ELU1HdMCel5t8=
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.3/go.mod h1:ESOWI4GokQfQ3Bn2hGsdfOVx5idj7QEdCPT/SAQDd9M=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.18 h1:98BcSFWiuTYSls25hX73l0mDNNgh3Sd7L5mhLj6maG0=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.18/go.mod h1:4lpZUM54ZareGU/yuAJvLEw0BoJ43SvCj1LO+gsKm9c=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.20 h1:U1jnaIMecwReLJMnSibgwhlF8zDuSXbYjUbqjdDL/cE=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.20/go.mod h1:4lpZUM54ZareGU/yuAJvLEw0BoJ43SvCj1LO+gsKm9c=
github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.9 h1:CUUieXQ8roD4M770GXj1he707V3V9Jiygk302+dwvKk=
github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.9/go.mod h1:iKBxmZkc7jdOrT99+IR1nyg7PlRgooAQMhZxDh2mTUQ=
github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.3 h1:QgZF9f70Cwpvkjw3tP1aiVGHc+yNFJNzW6hO8pDs3fg=
Expand Down
12 changes: 9 additions & 3 deletions internal/core/metadata/controller/http/device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ import (

var testDeviceLabels = []string{"MODBUS", "TEMP"}

var testProperties = map[string]any{
"TestProperty1": "property1",
"TestProperty2": true,
"TestProperty3": 123.45,
}

func buildTestDeviceRequest() requests.AddDeviceRequest {
var testAutoEvents = []dtos.AutoEvent{
{SourceName: "TestResource", Interval: "300ms", OnChange: true},
Expand Down Expand Up @@ -59,6 +65,7 @@ func buildTestDeviceRequest() requests.AddDeviceRequest {
Location: "{40lat;45long}",
AutoEvents: testAutoEvents,
Protocols: testProtocols,
Properties: testProperties,
},
}

Expand All @@ -73,7 +80,6 @@ func buildTestUpdateDeviceRequest() requests.UpdateDeviceRequest {
testProfileName := TestDeviceProfileName
testAdminState := models.Unlocked
testOperatingState := models.Up
testNotify := false
var testAutoEvents = []dtos.AutoEvent{
{SourceName: "TestResource", Interval: "300ms", OnChange: true},
}
Expand Down Expand Up @@ -101,7 +107,7 @@ func buildTestUpdateDeviceRequest() requests.UpdateDeviceRequest {
Location: "{40lat;45long}",
AutoEvents: testAutoEvents,
Protocols: testProtocols,
Notify: &testNotify,
Properties: testProperties,
},
}

Expand Down Expand Up @@ -471,7 +477,7 @@ func TestPatchDevice(t *testing.T) {
ProfileName: *testReq.Device.ProfileName,
AutoEvents: dtos.ToAutoEventModels(testReq.Device.AutoEvents),
Protocols: dtos.ToProtocolModels(testReq.Device.Protocols),
Notify: *testReq.Device.Notify,
Properties: testProperties,
}

valid := testReq
Expand Down
2 changes: 2 additions & 0 deletions internal/core/metadata/controller/http/deviceprofile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func buildTestDeviceProfileRequest() requests.DeviceProfileRequest {
ValueType: common.ValueTypeInt16,
ReadWrite: common.ReadWrite_RW,
Units: TestUnits,
Others: testProperties,
},
Tags: testTags,
}, {
Expand All @@ -68,6 +69,7 @@ func buildTestDeviceProfileRequest() requests.DeviceProfileRequest {
ValueType: common.ValueTypeInt16,
ReadWrite: common.ReadWrite_RW,
Units: TestUnits,
Others: testProperties,
},
Tags: testTags,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func buildTestAddProvisionWatcherRequest() requests.AddProvisionWatcherRequest {
ServiceName: TestDeviceServiceName,
AdminState: models.Unlocked,
AutoEvents: testProvisionWatcherAutoEvents,
Properties: testProperties,
},
}
}
Expand All @@ -84,6 +85,7 @@ func buildTestUpdateProvisionWatcherRequest() requests.UpdateProvisionWatcherReq
ProfileName: &testProfileName,
AdminState: &testAdminState,
AutoEvents: testProvisionWatcherAutoEvents,
Properties: testProperties,
},
}

Expand Down Expand Up @@ -670,6 +672,7 @@ func TestProvisionWatcherController_PatchProvisionWatcher(t *testing.T) {
ServiceName: *testReq.ProvisionWatcher.ServiceName,
ProfileName: *testReq.ProvisionWatcher.ProfileName,
AutoEvents: dtos.ToAutoEventModels(testReq.ProvisionWatcher.AutoEvents),
Properties: testProperties,
}

valid := testReq
Expand Down
97 changes: 86 additions & 11 deletions openapi/v3/core-metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,12 @@ components:
description: A map of supported protocols for the given device
additionalProperties:
$ref: '#/components/schemas/ProtocolProperties'
notify:
type: boolean
description: If the 'notify' property is set to true, the device service managing the device will receive a notification
tags:
type: object
description: A map of tags used to tag the given device
properties:
type: object
description: A map of properties required to address the given device
CreateDevice:
type: object
properties:
Expand Down Expand Up @@ -215,9 +218,12 @@ components:
description: A map of supported protocols for the given device
additionalProperties:
$ref: '#/components/schemas/ProtocolProperties'
notify:
type: boolean
description: If the 'notify' property is set to true, the device service managing the device will receive a notification
tags:
type: object
description: A map of tags used to tag the given device
properties:
type: object
description: A map of properties required to address the given device
required:
- name
- adminState
Expand Down Expand Up @@ -268,9 +274,13 @@ components:
description: A map of supported protocols for the given device
additionalProperties:
$ref: '#/components/schemas/ProtocolProperties'
notify:
type: boolean
description: If the 'notify' property is set to true, the device service managing the device will receive a notification
tags:
type: object
description: A map of tags used to tag the given device
properties:
type: object
description: A map of properties required to address the given device

DeviceProfileBasicInfo:
description: "A profile basic information"
type: object
Expand Down Expand Up @@ -628,6 +638,9 @@ components:
description: Autoevents that allow device service to automatically start generating data from new devices
items:
$ref: '#/components/schemas/AutoEvent'
properties:
type: object
description: A map of properties required to address the given provision watcher
CreateProvisionWatcher:
description: "A ProvisionWatcher defines the filtering criteria for device auto discovery."
type: object
Expand Down Expand Up @@ -666,6 +679,9 @@ components:
description: Autoevents that allow device service to automatically start generating data from new devices
items:
$ref: '#/components/schemas/AutoEvent'
properties:
type: object
description: A map of properties required to address the given provision watcher
required:
- name
- identifiers
Expand Down Expand Up @@ -716,6 +732,9 @@ components:
description: Autoevents that allow device service to automatically start generating data from new devices
items:
$ref: '#/components/schemas/AutoEvent'
properties:
type: object
description: A map of properties required to address the given provision watcher
ProvisionWatcherResponse:
allOf:
- $ref: '#/components/schemas/BaseResponse'
Expand Down Expand Up @@ -927,7 +946,7 @@ components:
UpdateDeviceRequest:
allOf:
- $ref: '#/components/schemas/BaseRequest'
description: "A request to update an existing device definition. 'id' and 'deviceName' must be populated in order to identify the device. If the 'notify' property is set to true, the device service managing the device will receive a notification. Any other property that is populated in the request will be updated. Empty/blank properties will not be considered."
description: "A request to update an existing device definition. 'id' and 'deviceName' must be populated in order to identify the device. Any other property that is populated in the request will be updated. Empty/blank properties will not be considered."
type: object
properties:
device:
Expand Down Expand Up @@ -1167,7 +1186,21 @@ components:
Address: "localhost"
Port: "502"
UnitID: "1"
notify: false
tags:
- tag1:
field1: "field1Value"
field2: "field2Value"
- tag2:
field3: "field3Value"
field4: "field4Value"
field5: "field5Value"
properties:
- DeviceInstance:
instanceName: "myInstance"
instanceId: "instance1"
- Firmware:
firmwareId: "firmwareABC"
firmwareVersion: "v1.1.2"
UpdateDeviceRequest:
value:
- apiVersion: v3
Expand Down Expand Up @@ -1268,6 +1301,10 @@ components:
profileName: "device-simple"
serviceName: "device-simple"
adminState: "UNLOCKED"
properties:
- DeviceNameTemplate:
valueReplace: true
template: "device-name-{{Address}}-{{Port}"
GetAllDevicesResponse:
value:
apiVersion: "v3"
Expand Down Expand Up @@ -1295,6 +1332,21 @@ components:
other:
Address: "device-virtual-bool-01"
Port: "300"
tags:
- tag1:
field1: "field1Value"
field2: "field2Value"
- tag2:
field3: "field3Value"
field4: "field4Value"
field5: "field5Value"
properties:
- DeviceInstance:
instanceName: "myInstance"
instanceId: "instance1"
- Firmware:
firmwareId: "firmwareABC"
firmwareVersion: "v1.1.2"
- id: "03bd5ce0-b967-4165-a335-775fea604142"
name: "Random-UnsignedInteger-Device"
description: "Example of Device Virtual"
Expand All @@ -1318,6 +1370,21 @@ components:
other:
Address: "device-virtual-uint-01"
Port: "300"
tags:
- tag1:
field1: "field1Value"
field2: "field2Value"
- tag2:
field3: "field3Value"
field4: "field4Value"
field5: "field5Value"
properties:
- DeviceInstance:
instanceName: "myInstance"
instanceId: "instance2"
- Firmware:
firmwareId: "firmwareXYZ"
firmwareVersion: "v3.1.0"
GetAllDeviceProfilesResponse:
value:
apiVersion: "v3"
Expand Down Expand Up @@ -1397,6 +1464,10 @@ components:
- sourceName: "Bool"
interval: "10s"
onChange: false
properties:
- DeviceNameTemplate:
valueReplace: true
template: "device-name-{{Address}}-{{Port}"
- id: "90c971f0-cb84-4bda-a9f0-d9494196b54d"
name: "simple-watcher"
created: 0
Expand Down Expand Up @@ -3533,6 +3604,10 @@ paths:
- sourceName: "Bool"
interval: "10s"
onChange: false
properties:
- DeviceNameTemplate:
valueReplace: true
template: "device-name-{{Address}}-{{Port}"
'400':
description: "Request is in an invalid state"
headers:
Expand Down

0 comments on commit d1220c9

Please sign in to comment.