Skip to content

Commit

Permalink
feat!: update API version to v3
Browse files Browse the repository at this point in the history
BREAKING CHNAGE: all EdgeX base API version is changed to v3

closes #774

Signed-off-by: Chris Hung <[email protected]>
  • Loading branch information
Chris Hung committed Apr 19, 2023
1 parent dacf12b commit 4f0fddb
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 32 deletions.
10 changes: 5 additions & 5 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

package common

// Constants related to defined routes in the v2 service APIs
// Constants related to defined routes in the v3 service APIs
const (
ApiVersion = "v2"
ApiBase = "/api/v2"
ApiVersion = "v3"
ApiBase = "/api/v3"

ApiEventRoute = ApiBase + "/event"
ApiEventServiceNameProfileNameDeviceNameSourceNameRoute = ApiEventRoute + "/{" + ServiceName + "}" + "/{" + ProfileName + "}" + "/{" + DeviceName + "}" + "/{" + SourceName + "}"
Expand Down Expand Up @@ -131,7 +131,7 @@ const (
ApiMultiConfigRoute = ApiSystemRoute + "/config"
)

// Constants related to defined url path names and parameters in the v2 service APIs
// Constants related to defined url path names and parameters in the v3 service APIs
const (
All = "all"
Id = "id"
Expand Down Expand Up @@ -185,7 +185,7 @@ const (
RegexCommand = "ds-regexcmd" //query string to specify if the command name is in regular expression format
)

// Constants related to the default value of query strings in the v2 service APIs
// Constants related to the default value of query strings in the v3 service APIs
const (
DefaultOffset = 0
DefaultLimit = 20
Expand Down
2 changes: 1 addition & 1 deletion dtos/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestEvent_ToXML(t *testing.T) {
}
// Since the order in map is random we have to verify the individual items exists without depending on order
contains := []string{
"<Event><ApiVersion>v2</ApiVersion><Id>7a1707f0-166f-4c4b-bc9d-1d54c74e0137</Id><DeviceName>TestDevice</DeviceName><ProfileName>TestDeviceProfileName</ProfileName><SourceName>TestSourceName</SourceName><Origin>1594963842</Origin><Tags>",
"<Event><ApiVersion>v3</ApiVersion><Id>7a1707f0-166f-4c4b-bc9d-1d54c74e0137</Id><DeviceName>TestDevice</DeviceName><ProfileName>TestDeviceProfileName</ProfileName><SourceName>TestSourceName</SourceName><Origin>1594963842</Origin><Tags>",
"<GatewayID>Houston-0001</GatewayID>",
"<Latitude>29.630771</Latitude>",
"<Longitude>-95.377603</Longitude>",
Expand Down
4 changes: 3 additions & 1 deletion dtos/metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/edgexfoundry/go-mod-core-contracts/v3/common"
)

func TestNewMetric(t *testing.T) {
expectedTimestamp := time.Now().UnixNano()
expectedApiVersion := "v2"
expectedApiVersion := common.ApiVersion
expectedName := "my-metric"

validFields := []MetricField{
Expand Down
11 changes: 6 additions & 5 deletions dtos/requests/device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ package requests
import (
"encoding/json"
"fmt"
"testing"

"github.com/edgexfoundry/go-mod-core-contracts/v3/common"
"github.com/edgexfoundry/go-mod-core-contracts/v3/dtos"
dtoCommon "github.com/edgexfoundry/go-mod-core-contracts/v3/dtos/common"
"github.com/edgexfoundry/go-mod-core-contracts/v3/models"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -360,9 +361,9 @@ func TestUpdateDeviceRequest_Validate(t *testing.T) {

func TestUpdateDeviceRequest_UnmarshalJSON_NilField(t *testing.T) {
reqJson := `{
"apiVersion" : "v2",
"apiVersion" : "v3",
"requestId":"7a1707f0-166f-4c4b-bc9d-1d54c74e0137",
"device":{"apiVersion":"v2", "name":"TestDevice"}
"device":{"apiVersion":"v3", "name":"TestDevice"}
}`
var req UpdateDeviceRequest

Expand All @@ -385,10 +386,10 @@ func TestUpdateDeviceRequest_UnmarshalJSON_NilField(t *testing.T) {

func TestUpdateDeviceRequest_UnmarshalJSON_EmptySlice(t *testing.T) {
reqJson := `{
"apiVersion" : "v2",
"apiVersion" : "v3",
"requestId":"7a1707f0-166f-4c4b-bc9d-1d54c74e0137",
"device":{
"apiVersion":"v2",
"apiVersion":"v3",
"name":"TestDevice",
"labels":[],
"autoEvents":[]
Expand Down
2 changes: 1 addition & 1 deletion dtos/requests/devicecommand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func TestUpdateDeviceCommandRequest_Validate(t *testing.T) {

func TestUpdateDeviceCommandRequest_UnmarshalJSON_NilField(t *testing.T) {
reqJson := `{
"apiVersion" : "v2",
"apiVersion" : "v3",
"requestId":"7a1707f0-166f-4c4b-bc9d-1d54c74e0137",
"profileName": "TestProfile",
"deviceCommand":{"name":"TestCommand"}
Expand Down
11 changes: 6 additions & 5 deletions dtos/requests/deviceprofilebasicinfo_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (C) 2022 IOTech Ltd
// Copyright (C) 2022-2023 IOTech Ltd
//
// SPDX-License-Identifier: Apache-2.0

Expand All @@ -8,12 +8,13 @@ package requests
import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/edgexfoundry/go-mod-core-contracts/v3/common"
"github.com/edgexfoundry/go-mod-core-contracts/v3/dtos"
dtoCommon "github.com/edgexfoundry/go-mod-core-contracts/v3/dtos/common"
"github.com/edgexfoundry/go-mod-core-contracts/v3/models"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

var testBasicInfoRequest = DeviceProfileBasicInfoRequest{
Expand Down Expand Up @@ -114,7 +115,7 @@ func TestDeviceProfileBasicInfoRequest_Validate(t *testing.T) {

func TestDeviceProfileBasicInfoRequest_UnmarshalJSON_NilField(t *testing.T) {
reqJson := `{
"apiVersion" : "v2",
"apiVersion" : "v3",
"requestId":"7a1707f0-166f-4c4b-bc9d-1d54c74e0137",
"basicinfo": {
"name": "TestProfile"
Expand All @@ -134,7 +135,7 @@ func TestDeviceProfileBasicInfoRequest_UnmarshalJSON_NilField(t *testing.T) {

func TestDeviceProfileBasicInfoRequest_UnmarshalJSON_EmptySlice(t *testing.T) {
reqJson := `{
"apiVersion" : "v2",
"apiVersion" : "v3",
"requestId":"7a1707f0-166f-4c4b-bc9d-1d54c74e0137",
"basicinfo": {
"name": "TestProfile",
Expand Down
2 changes: 1 addition & 1 deletion dtos/requests/deviceresource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func TestUpdateDeviceResourceRequest_Validate(t *testing.T) {

func TestUpdateDeviceResourceRequest_UnmarshalJSON_NilField(t *testing.T) {
reqJson := `{
"apiVersion" : "v2",
"apiVersion" : "v3",
"requestId":"7a1707f0-166f-4c4b-bc9d-1d54c74e0137",
"profileName": "TestProfile",
"resource":{"name":"TestResource"}
Expand Down
6 changes: 3 additions & 3 deletions dtos/requests/deviceservice_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (C) 2020-2021 IOTech Ltd
// Copyright (C) 2020-2023 IOTech Ltd
//
// SPDX-License-Identifier: Apache-2.0

Expand Down Expand Up @@ -283,10 +283,10 @@ func TestUpdateDeviceServiceRequest_UnmarshalJSON_NilField(t *testing.T) {

func TestUpdateDeviceServiceRequest_UnmarshalJSON_EmptySlice(t *testing.T) {
reqJson := `{
"apiVersion" : "v2",
"apiVersion" : "v3",
"requestId":"7a1707f0-166f-4c4b-bc9d-1d54c74e0137",
"service":{
"apiVersion":"v2",
"apiVersion":"v3",
"name":"TestDevice",
"labels":[]
}
Expand Down
6 changes: 3 additions & 3 deletions dtos/requests/interval_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (C) 2021 IOTech Ltd
// Copyright (C) 2021-2023 IOTech Ltd
//
// SPDX-License-Identifier: Apache-2.0

Expand Down Expand Up @@ -230,9 +230,9 @@ func TestUpdateIntervalRequest_Validate(t *testing.T) {

func TestUpdateIntervalRequest_UnmarshalJSON_NilField(t *testing.T) {
reqJson := `{
"apiVersion" : "v2",
"apiVersion" : "v3",
"requestId":"7a1707f0-166f-4c4b-bc9d-1d54c74e0137",
"interval":{"apiVersion":"v2", "name":"TestInterval"}
"interval":{"apiVersion":"v3", "name":"TestInterval"}
}`
var req UpdateIntervalRequest

Expand Down
6 changes: 3 additions & 3 deletions dtos/requests/intervalaction_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (C) 2021 IOTech Ltd
// Copyright (C) 2021-2023 IOTech Ltd
//
// SPDX-License-Identifier: Apache-2.0

Expand Down Expand Up @@ -245,9 +245,9 @@ func TestUpdateIntervalActionRequest_Validate(t *testing.T) {

func TestUpdateIntervalActionRequest_UnmarshalJSON_NilField(t *testing.T) {
reqJson := `{
"apiVersion" : "v2",
"apiVersion" : "v3",
"requestId":"7a1707f0-166f-4c4b-bc9d-1d54c74e0137",
"action":{"apiVersion":"v2", "name":"TestIntervalAction", "intervalName": "afternoon"}
"action":{"apiVersion":"v3", "name":"TestIntervalAction", "intervalName": "afternoon"}
}`
var req UpdateIntervalActionRequest

Expand Down
8 changes: 4 additions & 4 deletions dtos/requests/provisionwatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ func TestUpdateProvisionWatcherRequest_Validate(t *testing.T) {

func TestUpdateProvisionWatcherRequest_UnmarshalJSON_NilField(t *testing.T) {
reqJson := `{
"apiVersion" : "v2",
"apiVersion" : "v3",
"requestId":"7a1707f0-166f-4c4b-bc9d-1d54c74e0137",
"provisionWatcher":{"apiVersion" : "v2","name":"test-watcher"}
"provisionWatcher":{"apiVersion" : "v3","name":"test-watcher"}
}`
var req UpdateProvisionWatcherRequest

Expand All @@ -313,10 +313,10 @@ func TestUpdateProvisionWatcherRequest_UnmarshalJSON_NilField(t *testing.T) {

func TestUpdateProvisionWatcherRequest_UnmarshalJSON_EmptySlice(t *testing.T) {
reqJson := `{
"apiVersion" : "v2",
"apiVersion" : "v3",
"requestId":"7a1707f0-166f-4c4b-bc9d-1d54c74e0137",
"provisionWatcher":{
"apiVersion" : "v2",
"apiVersion" : "v3",
"name":"test-watcher",
"labels":[],
"discoveredDevice":{
Expand Down

0 comments on commit 4f0fddb

Please sign in to comment.