Skip to content

Commit

Permalink
feat(data)!: update Add Event REST endpoint
Browse files Browse the repository at this point in the history
BREAKING CHANGE: POST Event RSET endpoint will become
/event/{serviceName}/{profileName}/{deviceName}/{sourceName}

Signed-off-by: Chris Hung <chris@iotechsys.com>
  • Loading branch information
Chris Hung committed Feb 17, 2023
1 parent 8bb7416 commit c961a5e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 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.15
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.17
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.15 h1:0fPmT+Jm2scrs9iQLX9dNTAaCPXn6fiTCwiYhcTc0fc=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.15/go.mod h1:4lpZUM54ZareGU/yuAJvLEw0BoJ43SvCj1LO+gsKm9c=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.17 h1:29zJpgNGSxEZlGh+1Bgh4if3EU1P0osGnGiRhWYv1SA=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.17/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
17 changes: 9 additions & 8 deletions internal/core/data/controller/http/event_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (C) 2020-2022 IOTech Ltd
// Copyright (C) 2020-2023 IOTech Ltd
//
// SPDX-License-Identifier: Apache-2.0

Expand All @@ -19,11 +19,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/edgexfoundry/edgex-go/internal/core/data/application"
"github.com/edgexfoundry/edgex-go/internal/core/data/config"
"github.com/edgexfoundry/edgex-go/internal/core/data/container"
dbMock "github.com/edgexfoundry/edgex-go/internal/core/data/infrastructure/interfaces/mocks"
"github.com/edgexfoundry/edgex-go/internal/core/data/mocks"
"github.com/edgexfoundry/go-mod-bootstrap/v3/di"
"github.com/edgexfoundry/go-mod-core-contracts/v3/common"
"github.com/edgexfoundry/go-mod-core-contracts/v3/dtos"
Expand All @@ -32,6 +27,12 @@ import (
responseDTO "github.com/edgexfoundry/go-mod-core-contracts/v3/dtos/responses"
"github.com/edgexfoundry/go-mod-core-contracts/v3/errors"
"github.com/edgexfoundry/go-mod-core-contracts/v3/models"

"github.com/edgexfoundry/edgex-go/internal/core/data/application"
"github.com/edgexfoundry/edgex-go/internal/core/data/config"
"github.com/edgexfoundry/edgex-go/internal/core/data/container"
dbMock "github.com/edgexfoundry/edgex-go/internal/core/data/infrastructure/interfaces/mocks"
"github.com/edgexfoundry/edgex-go/internal/core/data/mocks"
)

var expectedEventId = uuid.New().String()
Expand Down Expand Up @@ -243,7 +244,7 @@ func TestAddEvent(t *testing.T) {
require.NoError(t, err)

reader := strings.NewReader(string(byteData))
req, err := http.NewRequest(http.MethodPost, common.ApiEventProfileNameDeviceNameSourceNameRoute, reader)
req, err := http.NewRequest(http.MethodPost, common.ApiEventServiceNameProfileNameDeviceNameSourceNameRoute, reader)
req.Header.Set(common.ContentType, testCase.RequestContentType)
req = mux.SetURLVars(req, map[string]string{common.ServiceName: TestServiceName, common.ProfileName: testCase.ProfileName, common.DeviceName: testCase.DeviceName, common.SourceName: testCase.Request.Event.SourceName})
require.NoError(t, err)
Expand Down Expand Up @@ -330,7 +331,7 @@ func TestAddEventSize(t *testing.T) {
require.NoError(t, err)

reader := strings.NewReader(string(byteData))
req, err := http.NewRequest(http.MethodPost, common.ApiEventProfileNameDeviceNameSourceNameRoute, reader)
req, err := http.NewRequest(http.MethodPost, common.ApiEventServiceNameProfileNameDeviceNameSourceNameRoute, reader)
req.Header.Set(common.ContentType, testCase.RequestContentType)
req = mux.SetURLVars(req, map[string]string{common.ServiceName: TestServiceName, common.ProfileName: validRequest.Event.ProfileName, common.DeviceName: validRequest.Event.DeviceName, common.SourceName: validRequest.Event.SourceName})
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions internal/core/data/router.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 @@ -28,7 +28,7 @@ func LoadRestRoutes(r *mux.Router, dic *di.Container, serviceName string) {

// Events
ec := dataController.NewEventController(dic)
r.HandleFunc(common.ApiEventProfileNameDeviceNameSourceNameRoute, ec.AddEvent).Methods(http.MethodPost)
r.HandleFunc(common.ApiEventServiceNameProfileNameDeviceNameSourceNameRoute, ec.AddEvent).Methods(http.MethodPost)
r.HandleFunc(common.ApiEventIdRoute, ec.EventById).Methods(http.MethodGet)
r.HandleFunc(common.ApiEventIdRoute, ec.DeleteEventById).Methods(http.MethodDelete)
r.HandleFunc(common.ApiEventCountRoute, ec.EventTotalCount).Methods(http.MethodGet)
Expand Down
2 changes: 1 addition & 1 deletion openapi/v3/core-data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ components:
statusCode: 200
count: 3
paths:
/event/{serviceName}{profileName}/{deviceName}/{sourceName}:
/event/{serviceName}/{profileName}/{deviceName}/{sourceName}:
parameters:
- $ref: '#/components/parameters/correlatedRequestHeader'
- name: serviceName
Expand Down

0 comments on commit c961a5e

Please sign in to comment.