-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: add 'discoveredDevice' for discovered device fields
BREAKING CHANGE: add 'discoveredDevice' field which includes serviceName, profileName,adminState,autoEvents and properties for discovered device closes #813 Signed-off-by: Chris Hung <[email protected]>
- Loading branch information
Chris Hung
committed
Mar 21, 2023
1 parent
274c66a
commit f889069
Showing
7 changed files
with
145 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// Copyright (C) 2023 IOTech Ltd | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package dtos | ||
|
||
import "github.com/edgexfoundry/go-mod-core-contracts/v3/models" | ||
|
||
type DiscoveredDevice struct { | ||
ProfileName string `json:"profileName" yaml:"profileName" validate:"required,edgex-dto-none-empty-string,edgex-dto-rfc3986-unreserved-chars"` | ||
ServiceName string `json:"serviceName" yaml:"serviceName" validate:"required,edgex-dto-none-empty-string,edgex-dto-rfc3986-unreserved-chars"` | ||
AdminState string `json:"adminState" yaml:"adminState" validate:"oneof='LOCKED' 'UNLOCKED'"` | ||
AutoEvents []AutoEvent `json:"autoEvents,omitempty" yaml:"autoEvents,omitempty" validate:"dive"` | ||
Properties map[string]any `json:"properties,omitempty" yaml:"properties,omitempty"` | ||
} | ||
|
||
type UpdateDiscoveredDevice struct { | ||
ProfileName *string `json:"profileName" validate:"omitempty,edgex-dto-none-empty-string,edgex-dto-rfc3986-unreserved-chars"` | ||
ServiceName *string `json:"serviceName" validate:"omitempty,edgex-dto-none-empty-string,edgex-dto-rfc3986-unreserved-chars"` | ||
AdminState *string `json:"adminState" validate:"omitempty,oneof='LOCKED' 'UNLOCKED'"` | ||
AutoEvents []AutoEvent `json:"autoEvents" validate:"dive"` | ||
Properties map[string]any `json:"properties"` | ||
} | ||
|
||
func ToDiscoveredDeviceModel(dto DiscoveredDevice) models.DiscoveredDevice { | ||
return models.DiscoveredDevice{ | ||
ProfileName: dto.ProfileName, | ||
ServiceName: dto.ServiceName, | ||
AdminState: models.AdminState(dto.AdminState), | ||
AutoEvents: ToAutoEventModels(dto.AutoEvents), | ||
Properties: dto.Properties, | ||
} | ||
} | ||
|
||
func FromDiscoveredDeviceModelToDTO(d models.DiscoveredDevice) DiscoveredDevice { | ||
return DiscoveredDevice{ | ||
ProfileName: d.ProfileName, | ||
ServiceName: d.ServiceName, | ||
AdminState: string(d.AdminState), | ||
AutoEvents: FromAutoEventModelsToDTOs(d.AutoEvents), | ||
Properties: d.Properties, | ||
} | ||
} | ||
|
||
func FromDiscoveredDeviceModelToUpdateDTO(d models.DiscoveredDevice) UpdateDiscoveredDevice { | ||
adminState := string(d.AdminState) | ||
return UpdateDiscoveredDevice{ | ||
ProfileName: &d.ProfileName, | ||
ServiceName: &d.ServiceName, | ||
AdminState: &adminState, | ||
AutoEvents: FromAutoEventModelsToDTOs(d.AutoEvents), | ||
Properties: d.Properties, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// Copyright (C) 2023 IOTech Ltd | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package models | ||
|
||
type DiscoveredDevice struct { | ||
ProfileName string | ||
ServiceName string | ||
AdminState AdminState | ||
AutoEvents []AutoEvent | ||
Properties map[string]any | ||
} |
Oops, something went wrong.