mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-24 13:48:49 +08:00
MF-1761 - Improve path parameters naming (#1762)
* Improve path parameters naming Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * Improve path parameter naming improve path parameter naming for: bootstrap/api/transport.go twins/api/http/transport.go Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * Change functions to suit updated path params Duplicated the functions decodeView and decodeListByConnection to form new functions decodeThingView, decodeChannelView, decodeThingListByConnection and decodeChannelListByConnection. This was as a result of the two functions being used for both view thing and view channel services Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * Improve path parameter naming Improve path parameter naming for: auth/api/http/groups/transport.go bootstrap/api/transport.go twins/api/http/transport.go ws/api/endpoints.go Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * fix swagger files Updated the following swagger files api/openapi/auth.yml api/openapi/cert.yml api/openapi/websocket.yml Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * Move websocket.yml from openapi to asyncapi deleted websocket.yml file in openapi and created websocket.yml file in asyncapi Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * Update websocket.yml file Update the websocket.yml file to make subtopic optional and added security (bearerAuth) Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * Format new line correctly format newline for api/asyncapi/websocket.yml Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * update websocket.yml file update the websocket.yml file based on the requested review changes The document is now valid Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * Update path parameter naming make changes to path parameter naming in: api/openapi/consumers-notifiers.yml Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * update path parameters naming Update path parameters naming to be consistent with Go Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * update the mqtt.yml file update the mqtt.yml file to the latest AsyncAPI version and make changes on the security of the server Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * Add contact information Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * Update api/asyncapi/mqtt.yml Co-authored-by: b1ackd0t <blackd0t@protonmail.com> Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * Add an empty line between functions Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> --------- Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> Co-authored-by: b1ackd0t <blackd0t@protonmail.com> Co-authored-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
This commit is contained in:
parent
1a77d384bb
commit
7948aa72e8
@ -1,14 +1,21 @@
|
||||
asyncapi: '2.2.0'
|
||||
asyncapi: '2.6.0'
|
||||
id: 'https://github.com/mainflux/mainflux/blob/master/api/asyncapi/mqtt.yml'
|
||||
info:
|
||||
title: MQTT Adapter
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: https://www.apache.org/licenses/LICENSE-2.0
|
||||
title: Mainflux MQTT Adapter
|
||||
version: '1.0.0'
|
||||
contact:
|
||||
name: Mainflux Team
|
||||
url: 'https://github.com/mainflux/mainflux'
|
||||
email: info@mainflux.com
|
||||
description: |
|
||||
MQTT adapter provides an MQTT API for sending messages through the platform. MQTT adapter uses [mProxy](https://github.com/mainflux/mproxy) for proxying traffic between client and MQTT broker.
|
||||
Additionally, the MQTT adapter and the message broker are replicating the traffic between brokers.
|
||||
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: 'https://github.com/mainflux/mainflux/blob/master/LICENSE'
|
||||
|
||||
|
||||
defaultContentType: application/json
|
||||
|
||||
servers:
|
||||
@ -23,18 +30,21 @@ servers:
|
||||
enum:
|
||||
- '1883'
|
||||
- '8883'
|
||||
username:
|
||||
description: Thing ID connected to the channel defined in the MQTT topic.
|
||||
password:
|
||||
description: Thing Key corresponding to the Thing ID.
|
||||
security:
|
||||
- user-password: []
|
||||
|
||||
channels:
|
||||
channels/{channelId}/messages/{subtopic}:
|
||||
channels/{channelID}/messages/{subtopic}:
|
||||
parameters:
|
||||
channelId:
|
||||
$ref: '#/components/parameters/channelId'
|
||||
channelID:
|
||||
$ref: '#/components/parameters/channelID'
|
||||
in: path
|
||||
required: true
|
||||
subtopic:
|
||||
$ref: '#/components/parameters/subtopic'
|
||||
in: path
|
||||
required: false
|
||||
|
||||
publish:
|
||||
traits:
|
||||
- $ref: '#/components/operationTraits/mqtt'
|
||||
@ -74,7 +84,7 @@ components:
|
||||
```
|
||||
|
||||
parameters:
|
||||
channelId:
|
||||
channelID:
|
||||
description: Channel ID connected to the Thing ID defined in the username.
|
||||
schema:
|
||||
type: string
|
||||
@ -84,6 +94,13 @@ components:
|
||||
schema:
|
||||
type: string
|
||||
default: ''
|
||||
|
||||
securitySchemes:
|
||||
user-password:
|
||||
type: userPassword
|
||||
description: |
|
||||
username is thing ID connected to the channel defined in the mqtt topic and
|
||||
password is thing key corresponding to the thing ID
|
||||
|
||||
operationTraits:
|
||||
mqtt:
|
||||
|
141
api/asyncapi/websocket.yml
Normal file
141
api/asyncapi/websocket.yml
Normal file
@ -0,0 +1,141 @@
|
||||
asyncapi: 2.6.0
|
||||
id: 'https://github.com/mainflux/mainflux/blob/master/api/asyncapi/websocket.yml'
|
||||
info:
|
||||
title: Mainflux WebSocket adapter
|
||||
description: WebSocket API for sending messages through communication channels
|
||||
version: '1.0.0'
|
||||
contact:
|
||||
name: Mainflux Team
|
||||
url: 'https://github.com/mainflux/mainflux'
|
||||
email: info@mainflux.com
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: 'https://github.com/mainflux/mainflux/blob/master/LICENSE'
|
||||
tags:
|
||||
- name: WebSocket
|
||||
defaultContentType: application/json
|
||||
|
||||
servers:
|
||||
dev:
|
||||
url: 'ws://{host}:{port}'
|
||||
protocol: ws
|
||||
description: Default WebSocket Adapter URL
|
||||
variables:
|
||||
host:
|
||||
description: Hostname of the WebSocket adapter
|
||||
default: localhost
|
||||
port:
|
||||
description: Mainflux WebSocket Adapter port
|
||||
default: '8186'
|
||||
|
||||
channels:
|
||||
'channels/{channelID}/messages/{subtopic}':
|
||||
parameters:
|
||||
channelID:
|
||||
$ref: '#/components/parameters/channelID'
|
||||
in: path
|
||||
required: true
|
||||
subtopic:
|
||||
$ref: '#/components/parameters/subtopic'
|
||||
in: path
|
||||
required: false
|
||||
publish:
|
||||
summary: Publish messages to a channel
|
||||
operationId: publishToChannel
|
||||
message:
|
||||
$ref: '#/components/messages/jsonMsg'
|
||||
messageId: publishMessage
|
||||
bindings:
|
||||
ws:
|
||||
method: POST
|
||||
query:
|
||||
subtopic: '{$request.query.subtopic}'
|
||||
security:
|
||||
- bearerAuth: []
|
||||
subscribe:
|
||||
summary: Subscribe to receive messages from a channel
|
||||
operationId: subscribeToChannel
|
||||
message:
|
||||
$ref: '#/components/messages/jsonMsg'
|
||||
messageId: subscribeMessage
|
||||
bindings:
|
||||
ws:
|
||||
method: GET
|
||||
query:
|
||||
subtopic: '{$request.query.subtopic}'
|
||||
security:
|
||||
- bearerAuth: []
|
||||
/version:
|
||||
subscribe:
|
||||
summary: Get the version of the Mainflux adapter
|
||||
operationId: getVersion
|
||||
bindings:
|
||||
http:
|
||||
method: GET
|
||||
metrics:
|
||||
description: Endpoint for getting service metrics.
|
||||
subscribe:
|
||||
operationId: metrics
|
||||
summary: Service metrics
|
||||
bindings:
|
||||
http:
|
||||
type: request
|
||||
method: GET
|
||||
|
||||
components:
|
||||
messages:
|
||||
jsonMsg:
|
||||
title: JSON Message
|
||||
summary: Arbitrary JSON array or object.
|
||||
contentType: application/json
|
||||
payload:
|
||||
$ref: '#/components/schemas/jsonMsg'
|
||||
schemas:
|
||||
jsonMsg:
|
||||
type: object
|
||||
description: Arbitrary JSON object or array. SenML format is recommended.
|
||||
example: >
|
||||
### SenML
|
||||
|
||||
```json
|
||||
|
||||
[{"bn":"some-base-name:","bt":1641646520, "bu":"A","bver":5,
|
||||
"n":"voltage","u":"V","v":120.1}, {"n":"current","t":-5,"v":1.2},
|
||||
{"n":"current","t":-4,"v":1.3}]
|
||||
|
||||
```
|
||||
|
||||
### JSON
|
||||
|
||||
```json
|
||||
|
||||
{"field_1":"val_1", "t": 1641646525}
|
||||
|
||||
```
|
||||
|
||||
### JSON Array
|
||||
|
||||
```json
|
||||
|
||||
[{"field_1":"val_1", "t": 1641646520},{"field_2":"val_2", "t":
|
||||
1641646522}]
|
||||
|
||||
```
|
||||
parameters:
|
||||
channelID:
|
||||
description: Channel ID connected to the Thing ID defined in the username.
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
subtopic:
|
||||
description: Arbitrary message subtopic.
|
||||
schema:
|
||||
type: string
|
||||
default: ''
|
||||
securitySchemes:
|
||||
bearerAuth:
|
||||
type: http
|
||||
scheme: bearer
|
||||
bearerFormat: uuid
|
||||
description: |
|
||||
* Thing access: "Authorization: Thing <thing_key>"
|
@ -25,7 +25,7 @@ paths:
|
||||
description: Missing or invalid content type.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/keys/{id}:
|
||||
/keys/{keyID}:
|
||||
get:
|
||||
summary: Gets API key details.
|
||||
description: |
|
||||
@ -65,8 +65,8 @@ paths:
|
||||
Creates new group that can be used for grouping entities - things, users.
|
||||
tags:
|
||||
- auth
|
||||
parameters:
|
||||
- $ref: "#/components/requestBodies/GroupCreateReq"
|
||||
requestBody:
|
||||
$ref: "#/components/requestBodies/GroupCreateReq"
|
||||
responses:
|
||||
'201':
|
||||
$ref: "#/components/responses/GroupCreateRes"
|
||||
@ -101,7 +101,7 @@ paths:
|
||||
description: Group does not exist.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/groups/{groupId}:
|
||||
/groups/{groupID}:
|
||||
get:
|
||||
summary: Gets group info.
|
||||
description: |
|
||||
@ -166,7 +166,7 @@ paths:
|
||||
description: Group does not exist.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/groups/{groupId}/children:
|
||||
/groups/{groupID}/children:
|
||||
get:
|
||||
summary: Gets group children.
|
||||
description: |
|
||||
@ -191,7 +191,7 @@ paths:
|
||||
description: Group does not exist.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/groups/{groupId}/parents:
|
||||
/groups/{groupID}/parents:
|
||||
get:
|
||||
summary: Gets group info.
|
||||
description: |
|
||||
@ -216,7 +216,7 @@ paths:
|
||||
description: Group does not exist.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/groups/{groupId}/members:
|
||||
/groups/{groupID}/members:
|
||||
post:
|
||||
summary: Assigns members to a group.
|
||||
description: |
|
||||
@ -277,7 +277,7 @@ paths:
|
||||
description: Missing or invalid content type.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/members/{memberId}/groups:
|
||||
/members/{memberID}/groups:
|
||||
get:
|
||||
summary: Gets memberships for a member with member id.
|
||||
description: |
|
||||
@ -541,7 +541,7 @@ components:
|
||||
|
||||
parameters:
|
||||
ApiKeyId:
|
||||
name: id
|
||||
name: keyID
|
||||
description: API Key ID.
|
||||
in: path
|
||||
schema:
|
||||
@ -557,7 +557,7 @@ components:
|
||||
format: uuid
|
||||
required: true
|
||||
GroupId:
|
||||
name: groupId
|
||||
name: groupID
|
||||
description: Group ID.
|
||||
in: path
|
||||
schema:
|
||||
@ -565,7 +565,7 @@ components:
|
||||
format: uuid
|
||||
required: true
|
||||
MemberId:
|
||||
name: memberId
|
||||
name: memberID
|
||||
description: Member id.
|
||||
in: path
|
||||
schema:
|
||||
|
@ -49,7 +49,7 @@ paths:
|
||||
description: Missing or invalid access token provided.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/things/configs/{configId}:
|
||||
/things/configs/{configID}:
|
||||
get:
|
||||
summary: Retrieves config info (with channels).
|
||||
tags:
|
||||
@ -108,7 +108,7 @@ paths:
|
||||
description: Missing or invalid access token provided.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/things/configs/certs/{configId}:
|
||||
/things/configs/certs/{configID}:
|
||||
patch:
|
||||
summary: Updates certs
|
||||
description: |
|
||||
@ -133,7 +133,7 @@ paths:
|
||||
description: Missing or invalid content type.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/things/configs/connections/{configId}:
|
||||
/things/configs/connections/{configID}:
|
||||
put:
|
||||
summary: Updates channels the thing is connected to
|
||||
description: |
|
||||
@ -158,7 +158,7 @@ paths:
|
||||
description: Missing or invalid content type.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/things/bootstrap/{externalId}:
|
||||
/things/bootstrap/{externalID}:
|
||||
get:
|
||||
summary: Retrieves configuration.
|
||||
description: |
|
||||
@ -180,7 +180,7 @@ paths:
|
||||
description: Failed to retrieve corresponding config.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/things/bootstrap/secure/{externalId}:
|
||||
/things/bootstrap/secure/{externalID}:
|
||||
get:
|
||||
summary: Retrieves configuration.
|
||||
description: |
|
||||
@ -199,7 +199,7 @@ paths:
|
||||
Failed to retrieve corresponding config.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/things/state/{configId}:
|
||||
/things/state/{configID}:
|
||||
put:
|
||||
summary: Updates Config state.
|
||||
description: |
|
||||
@ -338,7 +338,7 @@ components:
|
||||
|
||||
parameters:
|
||||
ConfigId:
|
||||
name: configId
|
||||
name: configID
|
||||
description: Unique Config identifier. It's the ID of the corresponding Thing.
|
||||
in: path
|
||||
schema:
|
||||
@ -346,7 +346,7 @@ components:
|
||||
format: uuid
|
||||
required: true
|
||||
ExternalId:
|
||||
name: externalId
|
||||
name: externalID
|
||||
description: Unique Config identifier provided by external entity.
|
||||
in: path
|
||||
schema:
|
||||
|
@ -135,12 +135,6 @@ components:
|
||||
expire:
|
||||
type: string
|
||||
description: Certificate expiry date
|
||||
Serial:
|
||||
type: object
|
||||
properties:
|
||||
serial:
|
||||
type: string
|
||||
description: Certificate serial
|
||||
CertsPage:
|
||||
type: object
|
||||
properties:
|
||||
|
@ -42,7 +42,7 @@ paths:
|
||||
description: Missing or invalid access token provided.
|
||||
"500":
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/subscriptions/{id}:
|
||||
/subscriptions/{subID}:
|
||||
get:
|
||||
summary: Get subscription with the provided id
|
||||
description: Retrieves a subscription with the provided id.
|
||||
@ -126,7 +126,7 @@ components:
|
||||
|
||||
parameters:
|
||||
Id:
|
||||
name: id
|
||||
name: subID
|
||||
description: Unique identifier.
|
||||
in: path
|
||||
schema:
|
||||
@ -186,7 +186,7 @@ components:
|
||||
schema:
|
||||
type: string
|
||||
description: Created subscription relative URL
|
||||
example: /subscriptions/{id}
|
||||
example: /subscriptions/{subId}
|
||||
View:
|
||||
description: View subscription.
|
||||
content:
|
||||
|
@ -4,7 +4,7 @@ info:
|
||||
description: HTTP API for sending messages through communication channels.
|
||||
version: "1.0.0"
|
||||
paths:
|
||||
/channels/{id}/messages:
|
||||
/channels/{chanID}/messages:
|
||||
post:
|
||||
summary: Sends message to the communication channel
|
||||
description: |
|
||||
@ -106,7 +106,7 @@ components:
|
||||
|
||||
parameters:
|
||||
ID:
|
||||
name: id
|
||||
name: chanID
|
||||
description: Unique channel identifier.
|
||||
in: path
|
||||
schema:
|
||||
|
@ -5,7 +5,7 @@ info:
|
||||
version: "1.0.0"
|
||||
|
||||
paths:
|
||||
/channels/{chanId}/messages:
|
||||
/channels/{chanID}/messages:
|
||||
get:
|
||||
summary: Retrieves messages sent to single channel
|
||||
description: |
|
||||
@ -107,7 +107,7 @@ components:
|
||||
|
||||
parameters:
|
||||
ChanId:
|
||||
name: chanId
|
||||
name: chanID
|
||||
description: Unique channel identifier.
|
||||
in: path
|
||||
schema:
|
||||
|
@ -106,7 +106,7 @@ paths:
|
||||
description: Missing or invalid content type.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/things/{thingId}:
|
||||
/things/{thingID}:
|
||||
get:
|
||||
summary: Retrieves thing info
|
||||
tags:
|
||||
@ -167,7 +167,7 @@ paths:
|
||||
description: Missing or invalid access token provided.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/things/{thingId}/share:
|
||||
/things/{thingID}/share:
|
||||
post:
|
||||
summary: Shares a thing with user identified by request body.
|
||||
description: |
|
||||
@ -192,7 +192,7 @@ paths:
|
||||
description: Missing or invalid content type.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/things/{thingId}/key:
|
||||
/things/{thingID}/key:
|
||||
patch:
|
||||
summary: Updates thing key
|
||||
description: |
|
||||
@ -291,7 +291,7 @@ paths:
|
||||
description: Missing or invalid content type.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/channels/{chanId}:
|
||||
/channels/{chanID}:
|
||||
get:
|
||||
summary: Retrieves channel info
|
||||
tags:
|
||||
@ -402,7 +402,7 @@ paths:
|
||||
description: Missing or invalid content type.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/things/{thingId}/channels:
|
||||
/things/{thingID}/channels:
|
||||
get:
|
||||
summary: List of channels connected to specified thing
|
||||
description: |
|
||||
@ -428,7 +428,7 @@ paths:
|
||||
description: Database can't process request.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/channels/{chanId}/things:
|
||||
/channels/{chanID}/things:
|
||||
get:
|
||||
summary: List of things connected to specified channel
|
||||
description: |
|
||||
@ -454,7 +454,7 @@ paths:
|
||||
description: Database can't process request.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/channels/{chanId}/things/{thingId}:
|
||||
/channels/{chanID}/things/{thingID}:
|
||||
put:
|
||||
summary: Connects the thing to the channel
|
||||
description: |
|
||||
@ -497,7 +497,7 @@ paths:
|
||||
description: Channel or thing does not exist.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/identify/channels/{chanId}/access-by-key:
|
||||
/identify/channels/{chanID}/access-by-key:
|
||||
post:
|
||||
summary: Checks if thing has access to a channel.
|
||||
description: |
|
||||
@ -520,7 +520,7 @@ paths:
|
||||
description: Missing or invalid content type.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/identify/channels/{chanId}/access-by-id:
|
||||
/identify/channels/{chanID}/access-by-id:
|
||||
post:
|
||||
summary: Checks if thing has access to a channel.
|
||||
description: |
|
||||
@ -562,7 +562,7 @@ paths:
|
||||
description: Missing or invalid content type.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/groups/{groupId}:
|
||||
/groups/{groupID}:
|
||||
get:
|
||||
summary: Retrieves things
|
||||
description: |
|
||||
@ -783,7 +783,7 @@ components:
|
||||
|
||||
parameters:
|
||||
ChanId:
|
||||
name: chanId
|
||||
name: chanID
|
||||
description: Unique channel identifier.
|
||||
in: path
|
||||
schema:
|
||||
@ -791,7 +791,7 @@ components:
|
||||
format: uuid
|
||||
required: true
|
||||
ThingId:
|
||||
name: thingId
|
||||
name: thingID
|
||||
description: Unique thing identifier.
|
||||
in: path
|
||||
schema:
|
||||
@ -799,7 +799,7 @@ components:
|
||||
format: uuid
|
||||
required: true
|
||||
GroupId:
|
||||
name: groupId
|
||||
name: groupID
|
||||
description: Unique group identifier.
|
||||
in: path
|
||||
schema:
|
||||
|
@ -94,7 +94,7 @@ paths:
|
||||
description: Missing or invalid access token provided.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/groups/{groupId}:
|
||||
/groups/{groupID}:
|
||||
get:
|
||||
summary: Retrieves users
|
||||
description: |
|
||||
@ -216,7 +216,7 @@ paths:
|
||||
description: Missing or invalid content type.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/users/{userId}/enable:
|
||||
/users/{userID}/enable:
|
||||
post:
|
||||
summary: Enables a user account
|
||||
description: |
|
||||
@ -236,7 +236,7 @@ paths:
|
||||
description: Missing or invalid access token provided.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/users/{userId}/disable:
|
||||
/users/{userID}/disable:
|
||||
post:
|
||||
summary: Disables a user account
|
||||
description: |
|
||||
@ -360,7 +360,7 @@ components:
|
||||
minimum: 0
|
||||
required: false
|
||||
UserId:
|
||||
name: userId
|
||||
name: userID
|
||||
description: Unique user identifier.
|
||||
in: path
|
||||
schema:
|
||||
@ -368,7 +368,7 @@ components:
|
||||
format: uuid
|
||||
required: true
|
||||
GroupId:
|
||||
name: groupId
|
||||
name: groupID
|
||||
description: Unique group identifier.
|
||||
in: path
|
||||
schema:
|
||||
|
@ -1,41 +0,0 @@
|
||||
openapi: 3.0.1
|
||||
info:
|
||||
title: Mainflux ws adapter
|
||||
description: WebSocket API for sending messages through communication channels.
|
||||
version: "1.0.0"
|
||||
paths:
|
||||
/channels/{id}/messages:
|
||||
post:
|
||||
summary: Sends message to the communication channel
|
||||
description: |
|
||||
Sends message to the communication channel. Messages can be sent as
|
||||
JSON formatted SenML or as blob.
|
||||
tags:
|
||||
- messages
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/ID"
|
||||
requestBody:
|
||||
$ref: "#/components/requestBodies/MessageReq"
|
||||
responses:
|
||||
"202":
|
||||
description: Message is accepted for processing.
|
||||
"400":
|
||||
description: Message discarded due to its malformed content.
|
||||
"401":
|
||||
description: Missing or invalid access token provided.
|
||||
"404":
|
||||
description: Message discarded due to invalid channel id.
|
||||
"415":
|
||||
description: Message discarded due to invalid or missing content type.
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
||||
/health:
|
||||
get:
|
||||
summary: Retrieves service health check info.
|
||||
tags:
|
||||
- health
|
||||
responses:
|
||||
'200':
|
||||
$ref: "#/components/responses/HealthRes"
|
||||
'500':
|
||||
$ref: "#/components/responses/ServiceError"
|
@ -64,7 +64,7 @@ func MakeHandler(svc auth.Service, mux *bone.Mux, tracer opentracing.Tracer, log
|
||||
opts...,
|
||||
))
|
||||
|
||||
mux.Post("/groups/:subjectGroupID/share", kithttp.NewServer(
|
||||
mux.Post("/groups/:groupID/share", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "share_group_access")(shareGroupAccessEndpoint(svc)),
|
||||
decodeShareGroupRequest,
|
||||
encodeResponse,
|
||||
@ -130,7 +130,7 @@ func decodeShareGroupRequest(ctx context.Context, r *http.Request) (interface{},
|
||||
|
||||
req := shareGroupAccessReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
userGroupID: bone.GetValue(r, "subjectGroupID"),
|
||||
userGroupID: bone.GetValue(r, "groupID"),
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
||||
|
@ -34,14 +34,14 @@ func MakeHandler(svc auth.Service, mux *bone.Mux, tracer opentracing.Tracer, log
|
||||
opts...,
|
||||
))
|
||||
|
||||
mux.Get("/keys/:id", kithttp.NewServer(
|
||||
mux.Get("/keys/:keyID", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "retrieve")(retrieveEndpoint(svc)),
|
||||
decodeKeyReq,
|
||||
encodeResponse,
|
||||
opts...,
|
||||
))
|
||||
|
||||
mux.Delete("/keys/:id", kithttp.NewServer(
|
||||
mux.Delete("/keys/:keyID", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "revoke")(revokeEndpoint(svc)),
|
||||
decodeKeyReq,
|
||||
encodeResponse,
|
||||
@ -67,7 +67,7 @@ func decodeIssue(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeKeyReq(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
req := keyReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
id: bone.GetValue(r, "id"),
|
||||
id: bone.GetValue(r, "keyID"),
|
||||
}
|
||||
return req, nil
|
||||
}
|
||||
|
@ -46,25 +46,25 @@ func MakeHandler(svc bootstrap.Service, reader bootstrap.ConfigReader, logger lo
|
||||
encodeResponse,
|
||||
opts...))
|
||||
|
||||
r.Get("/things/configs/:id", kithttp.NewServer(
|
||||
r.Get("/things/configs/:configID", kithttp.NewServer(
|
||||
viewEndpoint(svc),
|
||||
decodeEntityRequest,
|
||||
encodeResponse,
|
||||
opts...))
|
||||
|
||||
r.Put("/things/configs/:id", kithttp.NewServer(
|
||||
r.Put("/things/configs/:configID", kithttp.NewServer(
|
||||
updateEndpoint(svc),
|
||||
decodeUpdateRequest,
|
||||
encodeResponse,
|
||||
opts...))
|
||||
|
||||
r.Patch("/things/configs/certs/:id", kithttp.NewServer(
|
||||
r.Patch("/things/configs/certs/:certID", kithttp.NewServer(
|
||||
updateCertEndpoint(svc),
|
||||
decodeUpdateCertRequest,
|
||||
encodeResponse,
|
||||
opts...))
|
||||
|
||||
r.Put("/things/configs/connections/:id", kithttp.NewServer(
|
||||
r.Put("/things/configs/connections/:connID", kithttp.NewServer(
|
||||
updateConnEndpoint(svc),
|
||||
decodeUpdateConnRequest,
|
||||
encodeResponse,
|
||||
@ -76,25 +76,25 @@ func MakeHandler(svc bootstrap.Service, reader bootstrap.ConfigReader, logger lo
|
||||
encodeResponse,
|
||||
opts...))
|
||||
|
||||
r.Get("/things/bootstrap/:external_id", kithttp.NewServer(
|
||||
r.Get("/things/bootstrap/:externalID", kithttp.NewServer(
|
||||
bootstrapEndpoint(svc, reader, false),
|
||||
decodeBootstrapRequest,
|
||||
encodeResponse,
|
||||
opts...))
|
||||
|
||||
r.Get("/things/bootstrap/secure/:external_id", kithttp.NewServer(
|
||||
r.Get("/things/bootstrap/secure/:externalID", kithttp.NewServer(
|
||||
bootstrapEndpoint(svc, reader, true),
|
||||
decodeBootstrapRequest,
|
||||
encodeSecureRes,
|
||||
opts...))
|
||||
|
||||
r.Put("/things/state/:id", kithttp.NewServer(
|
||||
r.Put("/things/state/:thingID", kithttp.NewServer(
|
||||
stateEndpoint(svc),
|
||||
decodeStateRequest,
|
||||
encodeResponse,
|
||||
opts...))
|
||||
|
||||
r.Delete("/things/configs/:id", kithttp.NewServer(
|
||||
r.Delete("/things/configs/:configID", kithttp.NewServer(
|
||||
removeEndpoint(svc),
|
||||
decodeEntityRequest,
|
||||
encodeResponse,
|
||||
@ -126,7 +126,7 @@ func decodeUpdateRequest(_ context.Context, r *http.Request) (interface{}, error
|
||||
|
||||
req := updateReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
id: bone.GetValue(r, "id"),
|
||||
id: bone.GetValue(r, "configID"),
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
||||
@ -142,7 +142,7 @@ func decodeUpdateCertRequest(_ context.Context, r *http.Request) (interface{}, e
|
||||
|
||||
req := updateCertReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
thingID: bone.GetValue(r, "id"),
|
||||
thingID: bone.GetValue(r, "certID"),
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
||||
@ -158,7 +158,7 @@ func decodeUpdateConnRequest(_ context.Context, r *http.Request) (interface{}, e
|
||||
|
||||
req := updateConnReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
id: bone.GetValue(r, "id"),
|
||||
id: bone.GetValue(r, "connID"),
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
||||
@ -195,7 +195,7 @@ func decodeListRequest(_ context.Context, r *http.Request) (interface{}, error)
|
||||
|
||||
func decodeBootstrapRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
req := bootstrapReq{
|
||||
id: bone.GetValue(r, "external_id"),
|
||||
id: bone.GetValue(r, "externalID"),
|
||||
key: apiutil.ExtractThingKey(r),
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ func decodeStateRequest(_ context.Context, r *http.Request) (interface{}, error)
|
||||
|
||||
req := changeStateReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
id: bone.GetValue(r, "id"),
|
||||
id: bone.GetValue(r, "thingID"),
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
||||
@ -221,7 +221,7 @@ func decodeStateRequest(_ context.Context, r *http.Request) (interface{}, error)
|
||||
func decodeEntityRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
req := entityReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
id: bone.GetValue(r, "id"),
|
||||
id: bone.GetValue(r, "configID"),
|
||||
}
|
||||
|
||||
return req, nil
|
||||
|
@ -41,21 +41,21 @@ func MakeHandler(svc certs.Service, logger logger.Logger) http.Handler {
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Get("/certs/:certId", kithttp.NewServer(
|
||||
r.Get("/certs/:certID", kithttp.NewServer(
|
||||
viewCert(svc),
|
||||
decodeViewCert,
|
||||
encodeResponse,
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Delete("/certs/:certId", kithttp.NewServer(
|
||||
r.Delete("/certs/:certID", kithttp.NewServer(
|
||||
revokeCert(svc),
|
||||
decodeRevokeCerts,
|
||||
encodeResponse,
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Get("/serials/:thingId", kithttp.NewServer(
|
||||
r.Get("/serials/:thingID", kithttp.NewServer(
|
||||
listSerials(svc),
|
||||
decodeListCerts,
|
||||
encodeResponse,
|
||||
@ -98,7 +98,7 @@ func decodeListCerts(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
|
||||
req := listReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
thingID: bone.GetValue(r, "thingId"),
|
||||
thingID: bone.GetValue(r, "thingID"),
|
||||
limit: l,
|
||||
offset: o,
|
||||
}
|
||||
@ -108,7 +108,7 @@ func decodeListCerts(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeViewCert(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
req := viewReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
serialID: bone.GetValue(r, "certId"),
|
||||
serialID: bone.GetValue(r, "certID"),
|
||||
}
|
||||
|
||||
return req, nil
|
||||
@ -130,7 +130,7 @@ func decodeCerts(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeRevokeCerts(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
req := revokeReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
certID: bone.GetValue(r, "certId"),
|
||||
certID: bone.GetValue(r, "certID"),
|
||||
}
|
||||
|
||||
return req, nil
|
||||
|
@ -46,7 +46,7 @@ func MakeHandler(svc notifiers.Service, tracer opentracing.Tracer, logger logger
|
||||
opts...,
|
||||
))
|
||||
|
||||
mux.Get("/subscriptions/:id", kithttp.NewServer(
|
||||
mux.Get("/subscriptions/:subID", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "view_subscription")(viewSubscriptionEndpint(svc)),
|
||||
decodeSubscription,
|
||||
encodeResponse,
|
||||
@ -60,7 +60,7 @@ func MakeHandler(svc notifiers.Service, tracer opentracing.Tracer, logger logger
|
||||
opts...,
|
||||
))
|
||||
|
||||
mux.Delete("/subscriptions/:id", kithttp.NewServer(
|
||||
mux.Delete("/subscriptions/:subID", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "delete_subscription")(deleteSubscriptionEndpint(svc)),
|
||||
decodeSubscription,
|
||||
encodeResponse,
|
||||
@ -88,7 +88,7 @@ func decodeCreate(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
|
||||
func decodeSubscription(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
req := subReq{
|
||||
id: bone.GetValue(r, "id"),
|
||||
id: bone.GetValue(r, "subID"),
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
}
|
||||
|
||||
|
@ -48,14 +48,14 @@ func MakeHandler(svc adapter.Service, tracer opentracing.Tracer, logger logger.L
|
||||
}
|
||||
|
||||
r := bone.New()
|
||||
r.Post("/channels/:id/messages", kithttp.NewServer(
|
||||
r.Post("/channels/:chanID/messages", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "publish")(sendMessageEndpoint(svc)),
|
||||
decodeRequest,
|
||||
encodeResponse,
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Post("/channels/:id/messages/*", kithttp.NewServer(
|
||||
r.Post("/channels/:chanID/messages/*", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "publish")(sendMessageEndpoint(svc)),
|
||||
decodeRequest,
|
||||
encodeResponse,
|
||||
@ -131,7 +131,7 @@ func decodeRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
||||
req := publishReq{
|
||||
msg: &messaging.Message{
|
||||
Protocol: protocol,
|
||||
Channel: bone.GetValue(r, "id"),
|
||||
Channel: bone.GetValue(r, "chanID"),
|
||||
Subtopic: subtopic,
|
||||
Payload: payload,
|
||||
Created: time.Now().UnixNano(),
|
||||
|
@ -37,14 +37,14 @@ func MakeHandler(tracer opentracing.Tracer, svc things.Service, logger logger.Lo
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Post("/identify/channels/:chanId/access-by-key", kithttp.NewServer(
|
||||
r.Post("/identify/channels/:chanID/access-by-key", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "can_access_by_key")(canAccessByKeyEndpoint(svc)),
|
||||
decodeCanAccessByKey,
|
||||
encodeResponse,
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Post("/identify/channels/:chanId/access-by-id", kithttp.NewServer(
|
||||
r.Post("/identify/channels/:chanID/access-by-id", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "can_access_by_id")(canAccessByIDEndpoint(svc)),
|
||||
decodeCanAccessByID,
|
||||
encodeResponse,
|
||||
@ -73,7 +73,7 @@ func decodeCanAccessByKey(_ context.Context, r *http.Request) (interface{}, erro
|
||||
}
|
||||
|
||||
req := canAccessByKeyReq{
|
||||
chanID: bone.GetValue(r, "chanId"),
|
||||
chanID: bone.GetValue(r, "chanID"),
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
||||
@ -88,7 +88,7 @@ func decodeCanAccessByID(_ context.Context, r *http.Request) (interface{}, error
|
||||
}
|
||||
|
||||
req := canAccessByIDReq{
|
||||
chanID: bone.GetValue(r, "chanId"),
|
||||
chanID: bone.GetValue(r, "chanID"),
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
||||
|
@ -58,44 +58,44 @@ func MakeHandler(tracer opentracing.Tracer, svc things.Service, logger log.Logge
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Post("/things/:id/share", kithttp.NewServer(
|
||||
r.Post("/things/:thingID/share", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "share_thing")(shareThingEndpoint(svc)),
|
||||
decodeShareThing,
|
||||
encodeResponse,
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Patch("/things/:id/key", kithttp.NewServer(
|
||||
r.Patch("/things/:thingID/key", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "update_key")(updateKeyEndpoint(svc)),
|
||||
decodeKeyUpdate,
|
||||
encodeResponse,
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Put("/things/:id", kithttp.NewServer(
|
||||
r.Put("/things/:thingID", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "update_thing")(updateThingEndpoint(svc)),
|
||||
decodeThingUpdate,
|
||||
encodeResponse,
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Delete("/things/:id", kithttp.NewServer(
|
||||
r.Delete("/things/:thingID", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "remove_thing")(removeThingEndpoint(svc)),
|
||||
decodeView,
|
||||
decodeThingView,
|
||||
encodeResponse,
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Get("/things/:id", kithttp.NewServer(
|
||||
r.Get("/things/:thingID", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "view_thing")(viewThingEndpoint(svc)),
|
||||
decodeView,
|
||||
decodeThingView,
|
||||
encodeResponse,
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Get("/things/:id/channels", kithttp.NewServer(
|
||||
r.Get("/things/:thingID/channels", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "list_channels_by_thing")(listChannelsByThingEndpoint(svc)),
|
||||
decodeListByConnection,
|
||||
decodeThingListByConnection,
|
||||
encodeResponse,
|
||||
opts...,
|
||||
))
|
||||
@ -128,30 +128,30 @@ func MakeHandler(tracer opentracing.Tracer, svc things.Service, logger log.Logge
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Put("/channels/:id", kithttp.NewServer(
|
||||
r.Put("/channels/:chanID", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "update_channel")(updateChannelEndpoint(svc)),
|
||||
decodeChannelUpdate,
|
||||
encodeResponse,
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Delete("/channels/:id", kithttp.NewServer(
|
||||
r.Delete("/channels/:chanID", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "remove_channel")(removeChannelEndpoint(svc)),
|
||||
decodeView,
|
||||
decodeChannelView,
|
||||
encodeResponse,
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Get("/channels/:id", kithttp.NewServer(
|
||||
r.Get("/channels/:chanID", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "view_channel")(viewChannelEndpoint(svc)),
|
||||
decodeView,
|
||||
decodeChannelView,
|
||||
encodeResponse,
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Get("/channels/:id/things", kithttp.NewServer(
|
||||
r.Get("/channels/:chanID/things", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "list_things_by_channel")(listThingsByChannelEndpoint(svc)),
|
||||
decodeListByConnection,
|
||||
decodeChannelListByConnection,
|
||||
encodeResponse,
|
||||
opts...,
|
||||
))
|
||||
@ -177,21 +177,21 @@ func MakeHandler(tracer opentracing.Tracer, svc things.Service, logger log.Logge
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Put("/channels/:chanId/things/:thingId", kithttp.NewServer(
|
||||
r.Put("/channels/:chanID/things/:thingID", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "connect_thing")(connectThingEndpoint(svc)),
|
||||
decodeConnectThing,
|
||||
encodeResponse,
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Delete("/channels/:chanId/things/:thingId", kithttp.NewServer(
|
||||
r.Delete("/channels/:chanID/things/:thingID", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "disconnect_thing")(disconnectThingEndpoint(svc)),
|
||||
decodeConnectThing,
|
||||
encodeResponse,
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Get("/groups/:groupId", kithttp.NewServer(
|
||||
r.Get("/groups/:groupID", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "list_members")(listMembersEndpoint(svc)),
|
||||
decodeListMembersRequest,
|
||||
encodeResponse,
|
||||
@ -237,7 +237,7 @@ func decodeShareThing(ctx context.Context, r *http.Request) (interface{}, error)
|
||||
|
||||
req := shareThingReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
thingID: bone.GetValue(r, "id"),
|
||||
thingID: bone.GetValue(r, "thingID"),
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
||||
@ -253,7 +253,7 @@ func decodeThingUpdate(_ context.Context, r *http.Request) (interface{}, error)
|
||||
|
||||
req := updateThingReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
id: bone.GetValue(r, "id"),
|
||||
id: bone.GetValue(r, "thingID"),
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
||||
@ -269,7 +269,7 @@ func decodeKeyUpdate(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
|
||||
req := updateKeyReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
id: bone.GetValue(r, "id"),
|
||||
id: bone.GetValue(r, "thingID"),
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
||||
@ -311,7 +311,7 @@ func decodeChannelUpdate(_ context.Context, r *http.Request) (interface{}, error
|
||||
|
||||
req := updateChannelReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
id: bone.GetValue(r, "id"),
|
||||
id: bone.GetValue(r, "chanID"),
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
||||
@ -320,10 +320,18 @@ func decodeChannelUpdate(_ context.Context, r *http.Request) (interface{}, error
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeView(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeChannelView(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
req := viewResourceReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
id: bone.GetValue(r, "id"),
|
||||
id: bone.GetValue(r, "chanID"),
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
func decodeThingView(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
req := viewResourceReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
id: bone.GetValue(r, "thingID"),
|
||||
}
|
||||
|
||||
return req, nil
|
||||
@ -389,7 +397,7 @@ func decodeListByMetadata(_ context.Context, r *http.Request) (interface{}, erro
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeListByConnection(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeChannelListByConnection(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
o, err := apiutil.ReadUintQuery(r, offsetKey, defOffset)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -417,7 +425,48 @@ func decodeListByConnection(_ context.Context, r *http.Request) (interface{}, er
|
||||
|
||||
req := listByConnectionReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
id: bone.GetValue(r, "id"),
|
||||
id: bone.GetValue(r, "chanID"),
|
||||
pageMetadata: things.PageMetadata{
|
||||
Offset: o,
|
||||
Limit: l,
|
||||
Disconnected: c,
|
||||
Order: or,
|
||||
Dir: d,
|
||||
},
|
||||
}
|
||||
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func decodeThingListByConnection(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
o, err := apiutil.ReadUintQuery(r, offsetKey, defOffset)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
l, err := apiutil.ReadUintQuery(r, limitKey, defLimit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
c, err := apiutil.ReadBoolQuery(r, disconnKey, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
or, err := apiutil.ReadStringQuery(r, orderKey, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
d, err := apiutil.ReadStringQuery(r, dirKey, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req := listByConnectionReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
id: bone.GetValue(r, "thingID"),
|
||||
pageMetadata: things.PageMetadata{
|
||||
Offset: o,
|
||||
Limit: l,
|
||||
@ -433,8 +482,8 @@ func decodeListByConnection(_ context.Context, r *http.Request) (interface{}, er
|
||||
func decodeConnectThing(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
req := connectThingReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
chanID: bone.GetValue(r, "chanId"),
|
||||
thingID: bone.GetValue(r, "thingId"),
|
||||
chanID: bone.GetValue(r, "chanID"),
|
||||
thingID: bone.GetValue(r, "thingID"),
|
||||
}
|
||||
|
||||
return req, nil
|
||||
@ -471,7 +520,7 @@ func decodeListMembersRequest(_ context.Context, r *http.Request) (interface{},
|
||||
|
||||
req := listThingsGroupReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
groupID: bone.GetValue(r, "groupId"),
|
||||
groupID: bone.GetValue(r, "groupID"),
|
||||
pageMetadata: things.PageMetadata{
|
||||
Offset: o,
|
||||
Limit: l,
|
||||
|
@ -46,21 +46,21 @@ func MakeHandler(tracer opentracing.Tracer, svc twins.Service, logger logger.Log
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Put("/twins/:id", kithttp.NewServer(
|
||||
r.Put("/twins/:twinID", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "update_twin")(updateTwinEndpoint(svc)),
|
||||
decodeTwinUpdate,
|
||||
encodeResponse,
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Get("/twins/:id", kithttp.NewServer(
|
||||
r.Get("/twins/:twinID", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "view_twin")(viewTwinEndpoint(svc)),
|
||||
decodeView,
|
||||
encodeResponse,
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Delete("/twins/:id", kithttp.NewServer(
|
||||
r.Delete("/twins/:twinID", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "remove_twin")(removeTwinEndpoint(svc)),
|
||||
decodeView,
|
||||
encodeResponse,
|
||||
@ -74,7 +74,7 @@ func MakeHandler(tracer opentracing.Tracer, svc twins.Service, logger logger.Log
|
||||
opts...,
|
||||
))
|
||||
|
||||
r.Get("/states/:id", kithttp.NewServer(
|
||||
r.Get("/states/:twinID", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "list_states")(listStatesEndpoint(svc)),
|
||||
decodeListStates,
|
||||
encodeResponse,
|
||||
@ -107,7 +107,7 @@ func decodeTwinUpdate(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
|
||||
req := updateTwinReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
id: bone.GetValue(r, "id"),
|
||||
id: bone.GetValue(r, "twinID"),
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
||||
@ -119,7 +119,7 @@ func decodeTwinUpdate(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
func decodeView(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
req := viewTwinReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
id: bone.GetValue(r, "id"),
|
||||
id: bone.GetValue(r, "twinID"),
|
||||
}
|
||||
|
||||
return req, nil
|
||||
@ -172,7 +172,7 @@ func decodeListStates(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
limit: l,
|
||||
offset: o,
|
||||
id: bone.GetValue(r, "id"),
|
||||
id: bone.GetValue(r, "twinID"),
|
||||
}
|
||||
|
||||
return req, nil
|
||||
|
@ -55,7 +55,7 @@ func MakeHandler(svc users.Service, tracer opentracing.Tracer, logger logger.Log
|
||||
opts...,
|
||||
))
|
||||
|
||||
mux.Get("/users/:id", kithttp.NewServer(
|
||||
mux.Get("/users/:userID", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "view_user")(viewUserEndpoint(svc)),
|
||||
decodeViewUser,
|
||||
encodeResponse,
|
||||
@ -97,7 +97,7 @@ func MakeHandler(svc users.Service, tracer opentracing.Tracer, logger logger.Log
|
||||
opts...,
|
||||
))
|
||||
|
||||
mux.Get("/groups/:id", kithttp.NewServer(
|
||||
mux.Get("/groups/:groupID", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "list_members")(listMembersEndpoint(svc)),
|
||||
decodeListMembersRequest,
|
||||
encodeResponse,
|
||||
@ -111,14 +111,14 @@ func MakeHandler(svc users.Service, tracer opentracing.Tracer, logger logger.Log
|
||||
opts...,
|
||||
))
|
||||
|
||||
mux.Post("/users/:id/enable", kithttp.NewServer(
|
||||
mux.Post("/users/:userID/enable", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "enable_user")(enableUserEndpoint(svc)),
|
||||
decodeChangeUserStatus,
|
||||
encodeResponse,
|
||||
opts...,
|
||||
))
|
||||
|
||||
mux.Post("/users/:id/disable", kithttp.NewServer(
|
||||
mux.Post("/users/:userID/disable", kithttp.NewServer(
|
||||
kitot.TraceServer(tracer, "disable_user")(disableUserEndpoint(svc)),
|
||||
decodeChangeUserStatus,
|
||||
encodeResponse,
|
||||
@ -134,7 +134,7 @@ func MakeHandler(svc users.Service, tracer opentracing.Tracer, logger logger.Log
|
||||
func decodeViewUser(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
req := viewUserReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
id: bone.GetValue(r, "id"),
|
||||
id: bone.GetValue(r, "userID"),
|
||||
}
|
||||
|
||||
return req, nil
|
||||
@ -287,7 +287,7 @@ func decodeListMembersRequest(_ context.Context, r *http.Request) (interface{},
|
||||
req := listMemberGroupReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
status: s,
|
||||
id: bone.GetValue(r, "id"),
|
||||
id: bone.GetValue(r, "groupID"),
|
||||
offset: o,
|
||||
limit: l,
|
||||
metadata: m,
|
||||
@ -298,7 +298,7 @@ func decodeListMembersRequest(_ context.Context, r *http.Request) (interface{},
|
||||
func decodeChangeUserStatus(_ context.Context, r *http.Request) (interface{}, error) {
|
||||
req := changeUserStatusReq{
|
||||
token: apiutil.ExtractBearerToken(r),
|
||||
id: bone.GetValue(r, "id"),
|
||||
id: bone.GetValue(r, "userID"),
|
||||
}
|
||||
|
||||
return req, nil
|
||||
|
@ -61,7 +61,7 @@ func decodeRequest(r *http.Request) (connReq, error) {
|
||||
authKey = authKeys[0]
|
||||
}
|
||||
|
||||
chanID := bone.GetValue(r, "id")
|
||||
chanID := bone.GetValue(r, "chanID")
|
||||
|
||||
req := connReq{
|
||||
thingKey: authKey,
|
||||
|
@ -39,8 +39,8 @@ func MakeHandler(svc ws.Service, l log.Logger) http.Handler {
|
||||
logger = l
|
||||
|
||||
mux := bone.New()
|
||||
mux.GetFunc("/channels/:id/messages", handshake(svc))
|
||||
mux.GetFunc("/channels/:id/messages/*", handshake(svc))
|
||||
mux.GetFunc("/channels/:chanID/messages", handshake(svc))
|
||||
mux.GetFunc("/channels/:chanID/messages/*", handshake(svc))
|
||||
mux.GetFunc("/version", mainflux.Health(protocol))
|
||||
mux.Handle("/metrics", promhttp.Handler())
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user