From 19f0437f577fa24ae0fe280fda3a0cf0a6a1c674 Mon Sep 17 00:00:00 2001 From: Burak Sekili Date: Tue, 13 Jul 2021 14:31:20 +0300 Subject: [PATCH] NOISSUE - Update the /disconnect endpoint HTTP method as PUT (#1438) * NOISSUE - Update the /disconnect endpoint HTTP method as POST Signed-off-by: Burak Sekili * Update disconnection request name in spec Signed-off-by: Burak Sekili Update description Signed-off-by: Burak Sekili * Replaced POST with PUT Signed-off-by: Burak Sekili --- api/things.yml | 34 +++++++++++++++++++++++++ things/api/things/http/endpoint_test.go | 2 +- things/api/things/http/transport.go | 2 +- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/api/things.yml b/api/things.yml index 41296c0d..a9f07ecd 100644 --- a/api/things.yml +++ b/api/things.yml @@ -375,6 +375,31 @@ paths: description: Missing or invalid content type. '500': $ref: "#/components/responses/ServiceError" + /disconnect: + put: + summary: Disconnect things and channels using lists of IDs. + description: | + Disconnect things from channels specified by lists of IDs. + Channels and things are owned by user identified using the provided access token. + tags: + - things + parameters: + - $ref: "#/components/parameters/Authorization" + requestBody: + $ref: "#/components/requestBodies/DisconnReq" + responses: + '200': + $ref: "#/components/responses/DisconnRes" + '400': + description: Failed due to malformed JSON. + '401': + description: Missing or invalid access token provided. + '404': + description: A non-existent entity request. + '415': + description: Missing or invalid content type. + '500': + $ref: "#/components/responses/ServiceError" /things/{thingId}/channels: get: summary: List of channels connected to specified thing @@ -912,6 +937,13 @@ components: application/json: schema: $ref: "#/components/schemas/ConnectionReqSchema" + DisconnReq: + description: JSON-formatted document describing the entities for disconnection. + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/ConnectionReqSchema" IdentityReq: description: JSON-formatted document that contains thing key. required: true @@ -993,6 +1025,8 @@ components: type: string description: Created thing's relative URL. example: /things/{thingId} + DisconnRes: + description: Things disconnected. AccessGrantedRes: description: | Thing has access to the specified channel and the thing ID is returned. diff --git a/things/api/things/http/endpoint_test.go b/things/api/things/http/endpoint_test.go index 2f9bf3e1..5e9ab719 100644 --- a/things/api/things/http/endpoint_test.go +++ b/things/api/things/http/endpoint_test.go @@ -2587,7 +2587,7 @@ func TestDisconnectList(t *testing.T) { req := testRequest{ client: ts.Client(), - method: http.MethodDelete, + method: http.MethodPut, url: fmt.Sprintf("%s/disconnect", ts.URL), contentType: tc.contentType, token: tc.auth, diff --git a/things/api/things/http/transport.go b/things/api/things/http/transport.go index e3211ee8..7a82ae66 100644 --- a/things/api/things/http/transport.go +++ b/things/api/things/http/transport.go @@ -162,7 +162,7 @@ func MakeHandler(tracer opentracing.Tracer, svc things.Service) http.Handler { opts..., )) - r.Delete("/disconnect", kithttp.NewServer( + r.Put("/disconnect", kithttp.NewServer( kitot.TraceServer(tracer, "disconnect")(disconnectEndpoint(svc)), decodeConnectList, encodeResponse,