diff --git a/v2/dtos/autoevent.go b/v2/dtos/autoevent.go index 3306553d..16022836 100644 --- a/v2/dtos/autoevent.go +++ b/v2/dtos/autoevent.go @@ -1,5 +1,5 @@ // -// Copyright (C) 2020 IOTech Ltd +// Copyright (C) 2020-2021 IOTech Ltd // // SPDX-License-Identifier: Apache-2.0 @@ -12,17 +12,17 @@ import ( // AutoEvent and its properties are defined in the APIv2 specification: // https://app.swaggerhub.com/apis-docs/EdgeXFoundry1/core-metadata/2.x#/AutoEvent type AutoEvent struct { - Frequency string `json:"frequency" validate:"required,edgex-dto-frequency"` - OnChange bool `json:"onChange,omitempty"` - Resource string `json:"resource" validate:"required"` + Frequency string `json:"frequency" validate:"required,edgex-dto-frequency"` + OnChange bool `json:"onChange,omitempty"` + SourceName string `json:"sourceName" validate:"required"` } // ToAutoEventModel transforms the AutoEvent DTO to the AutoEvent model func ToAutoEventModel(a AutoEvent) models.AutoEvent { return models.AutoEvent{ - Frequency: a.Frequency, - OnChange: a.OnChange, - Resource: a.Resource, + Frequency: a.Frequency, + OnChange: a.OnChange, + SourceName: a.SourceName, } } @@ -38,9 +38,9 @@ func ToAutoEventModels(autoEventDTOs []AutoEvent) []models.AutoEvent { // FromAutoEventModelToDTO transforms the AutoEvent model to the AutoEvent DTO func FromAutoEventModelToDTO(a models.AutoEvent) AutoEvent { return AutoEvent{ - Frequency: a.Frequency, - OnChange: a.OnChange, - Resource: a.Resource, + Frequency: a.Frequency, + OnChange: a.OnChange, + SourceName: a.SourceName, } } diff --git a/v2/dtos/requests/device_test.go b/v2/dtos/requests/device_test.go index 6ea0c47d..d1c49b5a 100644 --- a/v2/dtos/requests/device_test.go +++ b/v2/dtos/requests/device_test.go @@ -23,10 +23,10 @@ import ( var testDeviceLabels = []string{"MODBUS", "TEMP"} var testDeviceLocation = "{40lat;45long}" var testAutoEvents = []dtos.AutoEvent{ - {Resource: "TestDevice", Frequency: "300ms", OnChange: true}, + {SourceName: "TestDevice", Frequency: "300ms", OnChange: true}, } var testAutoEventsWithInvalidFrequency = []dtos.AutoEvent{ - {Resource: "TestDevice", Frequency: "300", OnChange: true}, + {SourceName: "TestDevice", Frequency: "300", OnChange: true}, } var testProtocols = map[string]dtos.ProtocolProperties{ "modbus-ip": { @@ -108,7 +108,7 @@ func TestAddDeviceRequest_Validate(t *testing.T) { noProtocols.Device.Protocols = map[string]dtos.ProtocolProperties{} noAutoEventFrequency := testAddDevice noAutoEventFrequency.Device.AutoEvents = []dtos.AutoEvent{ - {Resource: "TestDevice", OnChange: true}, + {SourceName: "TestDevice", OnChange: true}, } noAutoEventResource := testAddDevice noAutoEventResource.Device.AutoEvents = []dtos.AutoEvent{ @@ -228,7 +228,7 @@ func Test_AddDeviceReqToDeviceModels(t *testing.T) { Labels: testDeviceLabels, Location: testDeviceLocation, AutoEvents: []models.AutoEvent{ - {Resource: "TestDevice", Frequency: "300ms", OnChange: true}, + {SourceName: "TestDevice", Frequency: "300ms", OnChange: true}, }, Protocols: map[string]models.ProtocolProperties{ "modbus-ip": { diff --git a/v2/dtos/requests/provisionwatcher_test.go b/v2/dtos/requests/provisionwatcher_test.go index ce2bf5be..4b7d6211 100644 --- a/v2/dtos/requests/provisionwatcher_test.go +++ b/v2/dtos/requests/provisionwatcher_test.go @@ -100,11 +100,11 @@ func TestAddProvisionWatcherRequest_Validate(t *testing.T) { noProfileName.ProvisionWatcher.ProfileName = emptyString invalidFrequency := testAddProvisionWatcher invalidFrequency.ProvisionWatcher.AutoEvents = []dtos.AutoEvent{ - {Resource: "TestDevice", Frequency: "-1", OnChange: true}, + {SourceName: "TestDevice", Frequency: "-1", OnChange: true}, } noAutoEventFrequency := testAddProvisionWatcher noAutoEventFrequency.ProvisionWatcher.AutoEvents = []dtos.AutoEvent{ - {Resource: "TestDevice", OnChange: true}, + {SourceName: "TestDevice", OnChange: true}, } noAutoEventResource := testAddProvisionWatcher noAutoEventResource.ProvisionWatcher.AutoEvents = []dtos.AutoEvent{ @@ -186,7 +186,7 @@ func TestAddProvisionWatcherReqToProvisionWatcherModels(t *testing.T) { ProfileName: TestDeviceProfileName, AdminState: models.Locked, AutoEvents: []models.AutoEvent{ - {Resource: "TestDevice", Frequency: "300ms", OnChange: true}, + {SourceName: "TestDevice", Frequency: "300ms", OnChange: true}, }, }, } diff --git a/v2/models/autoevent.go b/v2/models/autoevent.go index e3c60270..94e757c1 100644 --- a/v2/models/autoevent.go +++ b/v2/models/autoevent.go @@ -1,5 +1,5 @@ // -// Copyright (C) 2020 IOTech Ltd +// Copyright (C) 2020-2021 IOTech Ltd // // SPDX-License-Identifier: Apache-2.0 @@ -9,7 +9,7 @@ package models // https://app.swaggerhub.com/apis-docs/EdgeXFoundry1/core-metadata/2.x#/AutoEvent // Model fields are same as the DTOs documented by this swagger. Exceptions, if any, are noted below. type AutoEvent struct { - Frequency string - OnChange bool - Resource string + Frequency string + OnChange bool + SourceName string }