mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-26 13:48:53 +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:
|
info:
|
||||||
title: MQTT Adapter
|
title: Mainflux MQTT Adapter
|
||||||
license:
|
|
||||||
name: Apache 2.0
|
|
||||||
url: https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
version: '1.0.0'
|
version: '1.0.0'
|
||||||
|
contact:
|
||||||
|
name: Mainflux Team
|
||||||
|
url: 'https://github.com/mainflux/mainflux'
|
||||||
|
email: info@mainflux.com
|
||||||
description: |
|
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.
|
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.
|
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
|
defaultContentType: application/json
|
||||||
|
|
||||||
servers:
|
servers:
|
||||||
@ -23,18 +30,21 @@ servers:
|
|||||||
enum:
|
enum:
|
||||||
- '1883'
|
- '1883'
|
||||||
- '8883'
|
- '8883'
|
||||||
username:
|
security:
|
||||||
description: Thing ID connected to the channel defined in the MQTT topic.
|
- user-password: []
|
||||||
password:
|
|
||||||
description: Thing Key corresponding to the Thing ID.
|
|
||||||
|
|
||||||
channels:
|
channels:
|
||||||
channels/{channelId}/messages/{subtopic}:
|
channels/{channelID}/messages/{subtopic}:
|
||||||
parameters:
|
parameters:
|
||||||
channelId:
|
channelID:
|
||||||
$ref: '#/components/parameters/channelId'
|
$ref: '#/components/parameters/channelID'
|
||||||
|
in: path
|
||||||
|
required: true
|
||||||
subtopic:
|
subtopic:
|
||||||
$ref: '#/components/parameters/subtopic'
|
$ref: '#/components/parameters/subtopic'
|
||||||
|
in: path
|
||||||
|
required: false
|
||||||
|
|
||||||
publish:
|
publish:
|
||||||
traits:
|
traits:
|
||||||
- $ref: '#/components/operationTraits/mqtt'
|
- $ref: '#/components/operationTraits/mqtt'
|
||||||
@ -74,7 +84,7 @@ components:
|
|||||||
```
|
```
|
||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
channelId:
|
channelID:
|
||||||
description: Channel ID connected to the Thing ID defined in the username.
|
description: Channel ID connected to the Thing ID defined in the username.
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
@ -85,6 +95,13 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
default: ''
|
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:
|
operationTraits:
|
||||||
mqtt:
|
mqtt:
|
||||||
bindings:
|
bindings:
|
||||||
|
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.
|
description: Missing or invalid content type.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/keys/{id}:
|
/keys/{keyID}:
|
||||||
get:
|
get:
|
||||||
summary: Gets API key details.
|
summary: Gets API key details.
|
||||||
description: |
|
description: |
|
||||||
@ -65,8 +65,8 @@ paths:
|
|||||||
Creates new group that can be used for grouping entities - things, users.
|
Creates new group that can be used for grouping entities - things, users.
|
||||||
tags:
|
tags:
|
||||||
- auth
|
- auth
|
||||||
parameters:
|
requestBody:
|
||||||
- $ref: "#/components/requestBodies/GroupCreateReq"
|
$ref: "#/components/requestBodies/GroupCreateReq"
|
||||||
responses:
|
responses:
|
||||||
'201':
|
'201':
|
||||||
$ref: "#/components/responses/GroupCreateRes"
|
$ref: "#/components/responses/GroupCreateRes"
|
||||||
@ -101,7 +101,7 @@ paths:
|
|||||||
description: Group does not exist.
|
description: Group does not exist.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/groups/{groupId}:
|
/groups/{groupID}:
|
||||||
get:
|
get:
|
||||||
summary: Gets group info.
|
summary: Gets group info.
|
||||||
description: |
|
description: |
|
||||||
@ -166,7 +166,7 @@ paths:
|
|||||||
description: Group does not exist.
|
description: Group does not exist.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/groups/{groupId}/children:
|
/groups/{groupID}/children:
|
||||||
get:
|
get:
|
||||||
summary: Gets group children.
|
summary: Gets group children.
|
||||||
description: |
|
description: |
|
||||||
@ -191,7 +191,7 @@ paths:
|
|||||||
description: Group does not exist.
|
description: Group does not exist.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/groups/{groupId}/parents:
|
/groups/{groupID}/parents:
|
||||||
get:
|
get:
|
||||||
summary: Gets group info.
|
summary: Gets group info.
|
||||||
description: |
|
description: |
|
||||||
@ -216,7 +216,7 @@ paths:
|
|||||||
description: Group does not exist.
|
description: Group does not exist.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/groups/{groupId}/members:
|
/groups/{groupID}/members:
|
||||||
post:
|
post:
|
||||||
summary: Assigns members to a group.
|
summary: Assigns members to a group.
|
||||||
description: |
|
description: |
|
||||||
@ -277,7 +277,7 @@ paths:
|
|||||||
description: Missing or invalid content type.
|
description: Missing or invalid content type.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/members/{memberId}/groups:
|
/members/{memberID}/groups:
|
||||||
get:
|
get:
|
||||||
summary: Gets memberships for a member with member id.
|
summary: Gets memberships for a member with member id.
|
||||||
description: |
|
description: |
|
||||||
@ -541,7 +541,7 @@ components:
|
|||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
ApiKeyId:
|
ApiKeyId:
|
||||||
name: id
|
name: keyID
|
||||||
description: API Key ID.
|
description: API Key ID.
|
||||||
in: path
|
in: path
|
||||||
schema:
|
schema:
|
||||||
@ -557,7 +557,7 @@ components:
|
|||||||
format: uuid
|
format: uuid
|
||||||
required: true
|
required: true
|
||||||
GroupId:
|
GroupId:
|
||||||
name: groupId
|
name: groupID
|
||||||
description: Group ID.
|
description: Group ID.
|
||||||
in: path
|
in: path
|
||||||
schema:
|
schema:
|
||||||
@ -565,7 +565,7 @@ components:
|
|||||||
format: uuid
|
format: uuid
|
||||||
required: true
|
required: true
|
||||||
MemberId:
|
MemberId:
|
||||||
name: memberId
|
name: memberID
|
||||||
description: Member id.
|
description: Member id.
|
||||||
in: path
|
in: path
|
||||||
schema:
|
schema:
|
||||||
|
@ -49,7 +49,7 @@ paths:
|
|||||||
description: Missing or invalid access token provided.
|
description: Missing or invalid access token provided.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/things/configs/{configId}:
|
/things/configs/{configID}:
|
||||||
get:
|
get:
|
||||||
summary: Retrieves config info (with channels).
|
summary: Retrieves config info (with channels).
|
||||||
tags:
|
tags:
|
||||||
@ -108,7 +108,7 @@ paths:
|
|||||||
description: Missing or invalid access token provided.
|
description: Missing or invalid access token provided.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/things/configs/certs/{configId}:
|
/things/configs/certs/{configID}:
|
||||||
patch:
|
patch:
|
||||||
summary: Updates certs
|
summary: Updates certs
|
||||||
description: |
|
description: |
|
||||||
@ -133,7 +133,7 @@ paths:
|
|||||||
description: Missing or invalid content type.
|
description: Missing or invalid content type.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/things/configs/connections/{configId}:
|
/things/configs/connections/{configID}:
|
||||||
put:
|
put:
|
||||||
summary: Updates channels the thing is connected to
|
summary: Updates channels the thing is connected to
|
||||||
description: |
|
description: |
|
||||||
@ -158,7 +158,7 @@ paths:
|
|||||||
description: Missing or invalid content type.
|
description: Missing or invalid content type.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/things/bootstrap/{externalId}:
|
/things/bootstrap/{externalID}:
|
||||||
get:
|
get:
|
||||||
summary: Retrieves configuration.
|
summary: Retrieves configuration.
|
||||||
description: |
|
description: |
|
||||||
@ -180,7 +180,7 @@ paths:
|
|||||||
description: Failed to retrieve corresponding config.
|
description: Failed to retrieve corresponding config.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/things/bootstrap/secure/{externalId}:
|
/things/bootstrap/secure/{externalID}:
|
||||||
get:
|
get:
|
||||||
summary: Retrieves configuration.
|
summary: Retrieves configuration.
|
||||||
description: |
|
description: |
|
||||||
@ -199,7 +199,7 @@ paths:
|
|||||||
Failed to retrieve corresponding config.
|
Failed to retrieve corresponding config.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/things/state/{configId}:
|
/things/state/{configID}:
|
||||||
put:
|
put:
|
||||||
summary: Updates Config state.
|
summary: Updates Config state.
|
||||||
description: |
|
description: |
|
||||||
@ -338,7 +338,7 @@ components:
|
|||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
ConfigId:
|
ConfigId:
|
||||||
name: configId
|
name: configID
|
||||||
description: Unique Config identifier. It's the ID of the corresponding Thing.
|
description: Unique Config identifier. It's the ID of the corresponding Thing.
|
||||||
in: path
|
in: path
|
||||||
schema:
|
schema:
|
||||||
@ -346,7 +346,7 @@ components:
|
|||||||
format: uuid
|
format: uuid
|
||||||
required: true
|
required: true
|
||||||
ExternalId:
|
ExternalId:
|
||||||
name: externalId
|
name: externalID
|
||||||
description: Unique Config identifier provided by external entity.
|
description: Unique Config identifier provided by external entity.
|
||||||
in: path
|
in: path
|
||||||
schema:
|
schema:
|
||||||
|
@ -135,12 +135,6 @@ components:
|
|||||||
expire:
|
expire:
|
||||||
type: string
|
type: string
|
||||||
description: Certificate expiry date
|
description: Certificate expiry date
|
||||||
Serial:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
serial:
|
|
||||||
type: string
|
|
||||||
description: Certificate serial
|
|
||||||
CertsPage:
|
CertsPage:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
@ -42,7 +42,7 @@ paths:
|
|||||||
description: Missing or invalid access token provided.
|
description: Missing or invalid access token provided.
|
||||||
"500":
|
"500":
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/subscriptions/{id}:
|
/subscriptions/{subID}:
|
||||||
get:
|
get:
|
||||||
summary: Get subscription with the provided id
|
summary: Get subscription with the provided id
|
||||||
description: Retrieves a subscription with the provided id.
|
description: Retrieves a subscription with the provided id.
|
||||||
@ -126,7 +126,7 @@ components:
|
|||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
Id:
|
Id:
|
||||||
name: id
|
name: subID
|
||||||
description: Unique identifier.
|
description: Unique identifier.
|
||||||
in: path
|
in: path
|
||||||
schema:
|
schema:
|
||||||
@ -186,7 +186,7 @@ components:
|
|||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
description: Created subscription relative URL
|
description: Created subscription relative URL
|
||||||
example: /subscriptions/{id}
|
example: /subscriptions/{subId}
|
||||||
View:
|
View:
|
||||||
description: View subscription.
|
description: View subscription.
|
||||||
content:
|
content:
|
||||||
|
@ -4,7 +4,7 @@ info:
|
|||||||
description: HTTP API for sending messages through communication channels.
|
description: HTTP API for sending messages through communication channels.
|
||||||
version: "1.0.0"
|
version: "1.0.0"
|
||||||
paths:
|
paths:
|
||||||
/channels/{id}/messages:
|
/channels/{chanID}/messages:
|
||||||
post:
|
post:
|
||||||
summary: Sends message to the communication channel
|
summary: Sends message to the communication channel
|
||||||
description: |
|
description: |
|
||||||
@ -106,7 +106,7 @@ components:
|
|||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
ID:
|
ID:
|
||||||
name: id
|
name: chanID
|
||||||
description: Unique channel identifier.
|
description: Unique channel identifier.
|
||||||
in: path
|
in: path
|
||||||
schema:
|
schema:
|
||||||
|
@ -5,7 +5,7 @@ info:
|
|||||||
version: "1.0.0"
|
version: "1.0.0"
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/channels/{chanId}/messages:
|
/channels/{chanID}/messages:
|
||||||
get:
|
get:
|
||||||
summary: Retrieves messages sent to single channel
|
summary: Retrieves messages sent to single channel
|
||||||
description: |
|
description: |
|
||||||
@ -107,7 +107,7 @@ components:
|
|||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
ChanId:
|
ChanId:
|
||||||
name: chanId
|
name: chanID
|
||||||
description: Unique channel identifier.
|
description: Unique channel identifier.
|
||||||
in: path
|
in: path
|
||||||
schema:
|
schema:
|
||||||
|
@ -106,7 +106,7 @@ paths:
|
|||||||
description: Missing or invalid content type.
|
description: Missing or invalid content type.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/things/{thingId}:
|
/things/{thingID}:
|
||||||
get:
|
get:
|
||||||
summary: Retrieves thing info
|
summary: Retrieves thing info
|
||||||
tags:
|
tags:
|
||||||
@ -167,7 +167,7 @@ paths:
|
|||||||
description: Missing or invalid access token provided.
|
description: Missing or invalid access token provided.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/things/{thingId}/share:
|
/things/{thingID}/share:
|
||||||
post:
|
post:
|
||||||
summary: Shares a thing with user identified by request body.
|
summary: Shares a thing with user identified by request body.
|
||||||
description: |
|
description: |
|
||||||
@ -192,7 +192,7 @@ paths:
|
|||||||
description: Missing or invalid content type.
|
description: Missing or invalid content type.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/things/{thingId}/key:
|
/things/{thingID}/key:
|
||||||
patch:
|
patch:
|
||||||
summary: Updates thing key
|
summary: Updates thing key
|
||||||
description: |
|
description: |
|
||||||
@ -291,7 +291,7 @@ paths:
|
|||||||
description: Missing or invalid content type.
|
description: Missing or invalid content type.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/channels/{chanId}:
|
/channels/{chanID}:
|
||||||
get:
|
get:
|
||||||
summary: Retrieves channel info
|
summary: Retrieves channel info
|
||||||
tags:
|
tags:
|
||||||
@ -402,7 +402,7 @@ paths:
|
|||||||
description: Missing or invalid content type.
|
description: Missing or invalid content type.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/things/{thingId}/channels:
|
/things/{thingID}/channels:
|
||||||
get:
|
get:
|
||||||
summary: List of channels connected to specified thing
|
summary: List of channels connected to specified thing
|
||||||
description: |
|
description: |
|
||||||
@ -428,7 +428,7 @@ paths:
|
|||||||
description: Database can't process request.
|
description: Database can't process request.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/channels/{chanId}/things:
|
/channels/{chanID}/things:
|
||||||
get:
|
get:
|
||||||
summary: List of things connected to specified channel
|
summary: List of things connected to specified channel
|
||||||
description: |
|
description: |
|
||||||
@ -454,7 +454,7 @@ paths:
|
|||||||
description: Database can't process request.
|
description: Database can't process request.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/channels/{chanId}/things/{thingId}:
|
/channels/{chanID}/things/{thingID}:
|
||||||
put:
|
put:
|
||||||
summary: Connects the thing to the channel
|
summary: Connects the thing to the channel
|
||||||
description: |
|
description: |
|
||||||
@ -497,7 +497,7 @@ paths:
|
|||||||
description: Channel or thing does not exist.
|
description: Channel or thing does not exist.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/identify/channels/{chanId}/access-by-key:
|
/identify/channels/{chanID}/access-by-key:
|
||||||
post:
|
post:
|
||||||
summary: Checks if thing has access to a channel.
|
summary: Checks if thing has access to a channel.
|
||||||
description: |
|
description: |
|
||||||
@ -520,7 +520,7 @@ paths:
|
|||||||
description: Missing or invalid content type.
|
description: Missing or invalid content type.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/identify/channels/{chanId}/access-by-id:
|
/identify/channels/{chanID}/access-by-id:
|
||||||
post:
|
post:
|
||||||
summary: Checks if thing has access to a channel.
|
summary: Checks if thing has access to a channel.
|
||||||
description: |
|
description: |
|
||||||
@ -562,7 +562,7 @@ paths:
|
|||||||
description: Missing or invalid content type.
|
description: Missing or invalid content type.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/groups/{groupId}:
|
/groups/{groupID}:
|
||||||
get:
|
get:
|
||||||
summary: Retrieves things
|
summary: Retrieves things
|
||||||
description: |
|
description: |
|
||||||
@ -783,7 +783,7 @@ components:
|
|||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
ChanId:
|
ChanId:
|
||||||
name: chanId
|
name: chanID
|
||||||
description: Unique channel identifier.
|
description: Unique channel identifier.
|
||||||
in: path
|
in: path
|
||||||
schema:
|
schema:
|
||||||
@ -791,7 +791,7 @@ components:
|
|||||||
format: uuid
|
format: uuid
|
||||||
required: true
|
required: true
|
||||||
ThingId:
|
ThingId:
|
||||||
name: thingId
|
name: thingID
|
||||||
description: Unique thing identifier.
|
description: Unique thing identifier.
|
||||||
in: path
|
in: path
|
||||||
schema:
|
schema:
|
||||||
@ -799,7 +799,7 @@ components:
|
|||||||
format: uuid
|
format: uuid
|
||||||
required: true
|
required: true
|
||||||
GroupId:
|
GroupId:
|
||||||
name: groupId
|
name: groupID
|
||||||
description: Unique group identifier.
|
description: Unique group identifier.
|
||||||
in: path
|
in: path
|
||||||
schema:
|
schema:
|
||||||
|
@ -94,7 +94,7 @@ paths:
|
|||||||
description: Missing or invalid access token provided.
|
description: Missing or invalid access token provided.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/groups/{groupId}:
|
/groups/{groupID}:
|
||||||
get:
|
get:
|
||||||
summary: Retrieves users
|
summary: Retrieves users
|
||||||
description: |
|
description: |
|
||||||
@ -216,7 +216,7 @@ paths:
|
|||||||
description: Missing or invalid content type.
|
description: Missing or invalid content type.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/users/{userId}/enable:
|
/users/{userID}/enable:
|
||||||
post:
|
post:
|
||||||
summary: Enables a user account
|
summary: Enables a user account
|
||||||
description: |
|
description: |
|
||||||
@ -236,7 +236,7 @@ paths:
|
|||||||
description: Missing or invalid access token provided.
|
description: Missing or invalid access token provided.
|
||||||
'500':
|
'500':
|
||||||
$ref: "#/components/responses/ServiceError"
|
$ref: "#/components/responses/ServiceError"
|
||||||
/users/{userId}/disable:
|
/users/{userID}/disable:
|
||||||
post:
|
post:
|
||||||
summary: Disables a user account
|
summary: Disables a user account
|
||||||
description: |
|
description: |
|
||||||
@ -360,7 +360,7 @@ components:
|
|||||||
minimum: 0
|
minimum: 0
|
||||||
required: false
|
required: false
|
||||||
UserId:
|
UserId:
|
||||||
name: userId
|
name: userID
|
||||||
description: Unique user identifier.
|
description: Unique user identifier.
|
||||||
in: path
|
in: path
|
||||||
schema:
|
schema:
|
||||||
@ -368,7 +368,7 @@ components:
|
|||||||
format: uuid
|
format: uuid
|
||||||
required: true
|
required: true
|
||||||
GroupId:
|
GroupId:
|
||||||
name: groupId
|
name: groupID
|
||||||
description: Unique group identifier.
|
description: Unique group identifier.
|
||||||
in: path
|
in: path
|
||||||
schema:
|
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...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
mux.Post("/groups/:subjectGroupID/share", kithttp.NewServer(
|
mux.Post("/groups/:groupID/share", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "share_group_access")(shareGroupAccessEndpoint(svc)),
|
kitot.TraceServer(tracer, "share_group_access")(shareGroupAccessEndpoint(svc)),
|
||||||
decodeShareGroupRequest,
|
decodeShareGroupRequest,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
@ -130,7 +130,7 @@ func decodeShareGroupRequest(ctx context.Context, r *http.Request) (interface{},
|
|||||||
|
|
||||||
req := shareGroupAccessReq{
|
req := shareGroupAccessReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
userGroupID: bone.GetValue(r, "subjectGroupID"),
|
userGroupID: bone.GetValue(r, "groupID"),
|
||||||
}
|
}
|
||||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
||||||
|
@ -34,14 +34,14 @@ func MakeHandler(svc auth.Service, mux *bone.Mux, tracer opentracing.Tracer, log
|
|||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
mux.Get("/keys/:id", kithttp.NewServer(
|
mux.Get("/keys/:keyID", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "retrieve")(retrieveEndpoint(svc)),
|
kitot.TraceServer(tracer, "retrieve")(retrieveEndpoint(svc)),
|
||||||
decodeKeyReq,
|
decodeKeyReq,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
mux.Delete("/keys/:id", kithttp.NewServer(
|
mux.Delete("/keys/:keyID", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "revoke")(revokeEndpoint(svc)),
|
kitot.TraceServer(tracer, "revoke")(revokeEndpoint(svc)),
|
||||||
decodeKeyReq,
|
decodeKeyReq,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
@ -67,7 +67,7 @@ func decodeIssue(_ context.Context, r *http.Request) (interface{}, error) {
|
|||||||
func decodeKeyReq(_ context.Context, r *http.Request) (interface{}, error) {
|
func decodeKeyReq(_ context.Context, r *http.Request) (interface{}, error) {
|
||||||
req := keyReq{
|
req := keyReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
id: bone.GetValue(r, "id"),
|
id: bone.GetValue(r, "keyID"),
|
||||||
}
|
}
|
||||||
return req, nil
|
return req, nil
|
||||||
}
|
}
|
||||||
|
@ -46,25 +46,25 @@ func MakeHandler(svc bootstrap.Service, reader bootstrap.ConfigReader, logger lo
|
|||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...))
|
opts...))
|
||||||
|
|
||||||
r.Get("/things/configs/:id", kithttp.NewServer(
|
r.Get("/things/configs/:configID", kithttp.NewServer(
|
||||||
viewEndpoint(svc),
|
viewEndpoint(svc),
|
||||||
decodeEntityRequest,
|
decodeEntityRequest,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...))
|
opts...))
|
||||||
|
|
||||||
r.Put("/things/configs/:id", kithttp.NewServer(
|
r.Put("/things/configs/:configID", kithttp.NewServer(
|
||||||
updateEndpoint(svc),
|
updateEndpoint(svc),
|
||||||
decodeUpdateRequest,
|
decodeUpdateRequest,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...))
|
opts...))
|
||||||
|
|
||||||
r.Patch("/things/configs/certs/:id", kithttp.NewServer(
|
r.Patch("/things/configs/certs/:certID", kithttp.NewServer(
|
||||||
updateCertEndpoint(svc),
|
updateCertEndpoint(svc),
|
||||||
decodeUpdateCertRequest,
|
decodeUpdateCertRequest,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...))
|
opts...))
|
||||||
|
|
||||||
r.Put("/things/configs/connections/:id", kithttp.NewServer(
|
r.Put("/things/configs/connections/:connID", kithttp.NewServer(
|
||||||
updateConnEndpoint(svc),
|
updateConnEndpoint(svc),
|
||||||
decodeUpdateConnRequest,
|
decodeUpdateConnRequest,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
@ -76,25 +76,25 @@ func MakeHandler(svc bootstrap.Service, reader bootstrap.ConfigReader, logger lo
|
|||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...))
|
opts...))
|
||||||
|
|
||||||
r.Get("/things/bootstrap/:external_id", kithttp.NewServer(
|
r.Get("/things/bootstrap/:externalID", kithttp.NewServer(
|
||||||
bootstrapEndpoint(svc, reader, false),
|
bootstrapEndpoint(svc, reader, false),
|
||||||
decodeBootstrapRequest,
|
decodeBootstrapRequest,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...))
|
opts...))
|
||||||
|
|
||||||
r.Get("/things/bootstrap/secure/:external_id", kithttp.NewServer(
|
r.Get("/things/bootstrap/secure/:externalID", kithttp.NewServer(
|
||||||
bootstrapEndpoint(svc, reader, true),
|
bootstrapEndpoint(svc, reader, true),
|
||||||
decodeBootstrapRequest,
|
decodeBootstrapRequest,
|
||||||
encodeSecureRes,
|
encodeSecureRes,
|
||||||
opts...))
|
opts...))
|
||||||
|
|
||||||
r.Put("/things/state/:id", kithttp.NewServer(
|
r.Put("/things/state/:thingID", kithttp.NewServer(
|
||||||
stateEndpoint(svc),
|
stateEndpoint(svc),
|
||||||
decodeStateRequest,
|
decodeStateRequest,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...))
|
opts...))
|
||||||
|
|
||||||
r.Delete("/things/configs/:id", kithttp.NewServer(
|
r.Delete("/things/configs/:configID", kithttp.NewServer(
|
||||||
removeEndpoint(svc),
|
removeEndpoint(svc),
|
||||||
decodeEntityRequest,
|
decodeEntityRequest,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
@ -126,7 +126,7 @@ func decodeUpdateRequest(_ context.Context, r *http.Request) (interface{}, error
|
|||||||
|
|
||||||
req := updateReq{
|
req := updateReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
id: bone.GetValue(r, "id"),
|
id: bone.GetValue(r, "configID"),
|
||||||
}
|
}
|
||||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
||||||
@ -142,7 +142,7 @@ func decodeUpdateCertRequest(_ context.Context, r *http.Request) (interface{}, e
|
|||||||
|
|
||||||
req := updateCertReq{
|
req := updateCertReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
thingID: bone.GetValue(r, "id"),
|
thingID: bone.GetValue(r, "certID"),
|
||||||
}
|
}
|
||||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
||||||
@ -158,7 +158,7 @@ func decodeUpdateConnRequest(_ context.Context, r *http.Request) (interface{}, e
|
|||||||
|
|
||||||
req := updateConnReq{
|
req := updateConnReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
id: bone.GetValue(r, "id"),
|
id: bone.GetValue(r, "connID"),
|
||||||
}
|
}
|
||||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
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) {
|
func decodeBootstrapRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||||
req := bootstrapReq{
|
req := bootstrapReq{
|
||||||
id: bone.GetValue(r, "external_id"),
|
id: bone.GetValue(r, "externalID"),
|
||||||
key: apiutil.ExtractThingKey(r),
|
key: apiutil.ExtractThingKey(r),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ func decodeStateRequest(_ context.Context, r *http.Request) (interface{}, error)
|
|||||||
|
|
||||||
req := changeStateReq{
|
req := changeStateReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
id: bone.GetValue(r, "id"),
|
id: bone.GetValue(r, "thingID"),
|
||||||
}
|
}
|
||||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
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) {
|
func decodeEntityRequest(_ context.Context, r *http.Request) (interface{}, error) {
|
||||||
req := entityReq{
|
req := entityReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
id: bone.GetValue(r, "id"),
|
id: bone.GetValue(r, "configID"),
|
||||||
}
|
}
|
||||||
|
|
||||||
return req, nil
|
return req, nil
|
||||||
|
@ -41,21 +41,21 @@ func MakeHandler(svc certs.Service, logger logger.Logger) http.Handler {
|
|||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
r.Get("/certs/:certId", kithttp.NewServer(
|
r.Get("/certs/:certID", kithttp.NewServer(
|
||||||
viewCert(svc),
|
viewCert(svc),
|
||||||
decodeViewCert,
|
decodeViewCert,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
r.Delete("/certs/:certId", kithttp.NewServer(
|
r.Delete("/certs/:certID", kithttp.NewServer(
|
||||||
revokeCert(svc),
|
revokeCert(svc),
|
||||||
decodeRevokeCerts,
|
decodeRevokeCerts,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
r.Get("/serials/:thingId", kithttp.NewServer(
|
r.Get("/serials/:thingID", kithttp.NewServer(
|
||||||
listSerials(svc),
|
listSerials(svc),
|
||||||
decodeListCerts,
|
decodeListCerts,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
@ -98,7 +98,7 @@ func decodeListCerts(_ context.Context, r *http.Request) (interface{}, error) {
|
|||||||
|
|
||||||
req := listReq{
|
req := listReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
thingID: bone.GetValue(r, "thingId"),
|
thingID: bone.GetValue(r, "thingID"),
|
||||||
limit: l,
|
limit: l,
|
||||||
offset: o,
|
offset: o,
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ func decodeListCerts(_ context.Context, r *http.Request) (interface{}, error) {
|
|||||||
func decodeViewCert(_ context.Context, r *http.Request) (interface{}, error) {
|
func decodeViewCert(_ context.Context, r *http.Request) (interface{}, error) {
|
||||||
req := viewReq{
|
req := viewReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
serialID: bone.GetValue(r, "certId"),
|
serialID: bone.GetValue(r, "certID"),
|
||||||
}
|
}
|
||||||
|
|
||||||
return req, nil
|
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) {
|
func decodeRevokeCerts(_ context.Context, r *http.Request) (interface{}, error) {
|
||||||
req := revokeReq{
|
req := revokeReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
certID: bone.GetValue(r, "certId"),
|
certID: bone.GetValue(r, "certID"),
|
||||||
}
|
}
|
||||||
|
|
||||||
return req, nil
|
return req, nil
|
||||||
|
@ -46,7 +46,7 @@ func MakeHandler(svc notifiers.Service, tracer opentracing.Tracer, logger logger
|
|||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
mux.Get("/subscriptions/:id", kithttp.NewServer(
|
mux.Get("/subscriptions/:subID", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "view_subscription")(viewSubscriptionEndpint(svc)),
|
kitot.TraceServer(tracer, "view_subscription")(viewSubscriptionEndpint(svc)),
|
||||||
decodeSubscription,
|
decodeSubscription,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
@ -60,7 +60,7 @@ func MakeHandler(svc notifiers.Service, tracer opentracing.Tracer, logger logger
|
|||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
mux.Delete("/subscriptions/:id", kithttp.NewServer(
|
mux.Delete("/subscriptions/:subID", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "delete_subscription")(deleteSubscriptionEndpint(svc)),
|
kitot.TraceServer(tracer, "delete_subscription")(deleteSubscriptionEndpint(svc)),
|
||||||
decodeSubscription,
|
decodeSubscription,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
@ -88,7 +88,7 @@ func decodeCreate(_ context.Context, r *http.Request) (interface{}, error) {
|
|||||||
|
|
||||||
func decodeSubscription(_ context.Context, r *http.Request) (interface{}, error) {
|
func decodeSubscription(_ context.Context, r *http.Request) (interface{}, error) {
|
||||||
req := subReq{
|
req := subReq{
|
||||||
id: bone.GetValue(r, "id"),
|
id: bone.GetValue(r, "subID"),
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,14 +48,14 @@ func MakeHandler(svc adapter.Service, tracer opentracing.Tracer, logger logger.L
|
|||||||
}
|
}
|
||||||
|
|
||||||
r := bone.New()
|
r := bone.New()
|
||||||
r.Post("/channels/:id/messages", kithttp.NewServer(
|
r.Post("/channels/:chanID/messages", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "publish")(sendMessageEndpoint(svc)),
|
kitot.TraceServer(tracer, "publish")(sendMessageEndpoint(svc)),
|
||||||
decodeRequest,
|
decodeRequest,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
r.Post("/channels/:id/messages/*", kithttp.NewServer(
|
r.Post("/channels/:chanID/messages/*", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "publish")(sendMessageEndpoint(svc)),
|
kitot.TraceServer(tracer, "publish")(sendMessageEndpoint(svc)),
|
||||||
decodeRequest,
|
decodeRequest,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
@ -131,7 +131,7 @@ func decodeRequest(ctx context.Context, r *http.Request) (interface{}, error) {
|
|||||||
req := publishReq{
|
req := publishReq{
|
||||||
msg: &messaging.Message{
|
msg: &messaging.Message{
|
||||||
Protocol: protocol,
|
Protocol: protocol,
|
||||||
Channel: bone.GetValue(r, "id"),
|
Channel: bone.GetValue(r, "chanID"),
|
||||||
Subtopic: subtopic,
|
Subtopic: subtopic,
|
||||||
Payload: payload,
|
Payload: payload,
|
||||||
Created: time.Now().UnixNano(),
|
Created: time.Now().UnixNano(),
|
||||||
|
@ -37,14 +37,14 @@ func MakeHandler(tracer opentracing.Tracer, svc things.Service, logger logger.Lo
|
|||||||
opts...,
|
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)),
|
kitot.TraceServer(tracer, "can_access_by_key")(canAccessByKeyEndpoint(svc)),
|
||||||
decodeCanAccessByKey,
|
decodeCanAccessByKey,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...,
|
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)),
|
kitot.TraceServer(tracer, "can_access_by_id")(canAccessByIDEndpoint(svc)),
|
||||||
decodeCanAccessByID,
|
decodeCanAccessByID,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
@ -73,7 +73,7 @@ func decodeCanAccessByKey(_ context.Context, r *http.Request) (interface{}, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
req := canAccessByKeyReq{
|
req := canAccessByKeyReq{
|
||||||
chanID: bone.GetValue(r, "chanId"),
|
chanID: bone.GetValue(r, "chanID"),
|
||||||
}
|
}
|
||||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
||||||
@ -88,7 +88,7 @@ func decodeCanAccessByID(_ context.Context, r *http.Request) (interface{}, error
|
|||||||
}
|
}
|
||||||
|
|
||||||
req := canAccessByIDReq{
|
req := canAccessByIDReq{
|
||||||
chanID: bone.GetValue(r, "chanId"),
|
chanID: bone.GetValue(r, "chanID"),
|
||||||
}
|
}
|
||||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
||||||
|
@ -58,44 +58,44 @@ func MakeHandler(tracer opentracing.Tracer, svc things.Service, logger log.Logge
|
|||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
r.Post("/things/:id/share", kithttp.NewServer(
|
r.Post("/things/:thingID/share", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "share_thing")(shareThingEndpoint(svc)),
|
kitot.TraceServer(tracer, "share_thing")(shareThingEndpoint(svc)),
|
||||||
decodeShareThing,
|
decodeShareThing,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
r.Patch("/things/:id/key", kithttp.NewServer(
|
r.Patch("/things/:thingID/key", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "update_key")(updateKeyEndpoint(svc)),
|
kitot.TraceServer(tracer, "update_key")(updateKeyEndpoint(svc)),
|
||||||
decodeKeyUpdate,
|
decodeKeyUpdate,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
r.Put("/things/:id", kithttp.NewServer(
|
r.Put("/things/:thingID", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "update_thing")(updateThingEndpoint(svc)),
|
kitot.TraceServer(tracer, "update_thing")(updateThingEndpoint(svc)),
|
||||||
decodeThingUpdate,
|
decodeThingUpdate,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
r.Delete("/things/:id", kithttp.NewServer(
|
r.Delete("/things/:thingID", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "remove_thing")(removeThingEndpoint(svc)),
|
kitot.TraceServer(tracer, "remove_thing")(removeThingEndpoint(svc)),
|
||||||
decodeView,
|
decodeThingView,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
r.Get("/things/:id", kithttp.NewServer(
|
r.Get("/things/:thingID", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "view_thing")(viewThingEndpoint(svc)),
|
kitot.TraceServer(tracer, "view_thing")(viewThingEndpoint(svc)),
|
||||||
decodeView,
|
decodeThingView,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
r.Get("/things/:id/channels", kithttp.NewServer(
|
r.Get("/things/:thingID/channels", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "list_channels_by_thing")(listChannelsByThingEndpoint(svc)),
|
kitot.TraceServer(tracer, "list_channels_by_thing")(listChannelsByThingEndpoint(svc)),
|
||||||
decodeListByConnection,
|
decodeThingListByConnection,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
@ -128,30 +128,30 @@ func MakeHandler(tracer opentracing.Tracer, svc things.Service, logger log.Logge
|
|||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
r.Put("/channels/:id", kithttp.NewServer(
|
r.Put("/channels/:chanID", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "update_channel")(updateChannelEndpoint(svc)),
|
kitot.TraceServer(tracer, "update_channel")(updateChannelEndpoint(svc)),
|
||||||
decodeChannelUpdate,
|
decodeChannelUpdate,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
r.Delete("/channels/:id", kithttp.NewServer(
|
r.Delete("/channels/:chanID", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "remove_channel")(removeChannelEndpoint(svc)),
|
kitot.TraceServer(tracer, "remove_channel")(removeChannelEndpoint(svc)),
|
||||||
decodeView,
|
decodeChannelView,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
r.Get("/channels/:id", kithttp.NewServer(
|
r.Get("/channels/:chanID", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "view_channel")(viewChannelEndpoint(svc)),
|
kitot.TraceServer(tracer, "view_channel")(viewChannelEndpoint(svc)),
|
||||||
decodeView,
|
decodeChannelView,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
r.Get("/channels/:id/things", kithttp.NewServer(
|
r.Get("/channels/:chanID/things", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "list_things_by_channel")(listThingsByChannelEndpoint(svc)),
|
kitot.TraceServer(tracer, "list_things_by_channel")(listThingsByChannelEndpoint(svc)),
|
||||||
decodeListByConnection,
|
decodeChannelListByConnection,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
@ -177,21 +177,21 @@ func MakeHandler(tracer opentracing.Tracer, svc things.Service, logger log.Logge
|
|||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
r.Put("/channels/:chanId/things/:thingId", kithttp.NewServer(
|
r.Put("/channels/:chanID/things/:thingID", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "connect_thing")(connectThingEndpoint(svc)),
|
kitot.TraceServer(tracer, "connect_thing")(connectThingEndpoint(svc)),
|
||||||
decodeConnectThing,
|
decodeConnectThing,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
r.Delete("/channels/:chanId/things/:thingId", kithttp.NewServer(
|
r.Delete("/channels/:chanID/things/:thingID", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "disconnect_thing")(disconnectThingEndpoint(svc)),
|
kitot.TraceServer(tracer, "disconnect_thing")(disconnectThingEndpoint(svc)),
|
||||||
decodeConnectThing,
|
decodeConnectThing,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
r.Get("/groups/:groupId", kithttp.NewServer(
|
r.Get("/groups/:groupID", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "list_members")(listMembersEndpoint(svc)),
|
kitot.TraceServer(tracer, "list_members")(listMembersEndpoint(svc)),
|
||||||
decodeListMembersRequest,
|
decodeListMembersRequest,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
@ -237,7 +237,7 @@ func decodeShareThing(ctx context.Context, r *http.Request) (interface{}, error)
|
|||||||
|
|
||||||
req := shareThingReq{
|
req := shareThingReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
thingID: bone.GetValue(r, "id"),
|
thingID: bone.GetValue(r, "thingID"),
|
||||||
}
|
}
|
||||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
||||||
@ -253,7 +253,7 @@ func decodeThingUpdate(_ context.Context, r *http.Request) (interface{}, error)
|
|||||||
|
|
||||||
req := updateThingReq{
|
req := updateThingReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
id: bone.GetValue(r, "id"),
|
id: bone.GetValue(r, "thingID"),
|
||||||
}
|
}
|
||||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
||||||
@ -269,7 +269,7 @@ func decodeKeyUpdate(_ context.Context, r *http.Request) (interface{}, error) {
|
|||||||
|
|
||||||
req := updateKeyReq{
|
req := updateKeyReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
id: bone.GetValue(r, "id"),
|
id: bone.GetValue(r, "thingID"),
|
||||||
}
|
}
|
||||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
||||||
@ -311,7 +311,7 @@ func decodeChannelUpdate(_ context.Context, r *http.Request) (interface{}, error
|
|||||||
|
|
||||||
req := updateChannelReq{
|
req := updateChannelReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
id: bone.GetValue(r, "id"),
|
id: bone.GetValue(r, "chanID"),
|
||||||
}
|
}
|
||||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
||||||
@ -320,10 +320,18 @@ func decodeChannelUpdate(_ context.Context, r *http.Request) (interface{}, error
|
|||||||
return req, nil
|
return req, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeView(_ context.Context, r *http.Request) (interface{}, error) {
|
func decodeChannelView(_ context.Context, r *http.Request) (interface{}, error) {
|
||||||
req := viewResourceReq{
|
req := viewResourceReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
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
|
return req, nil
|
||||||
@ -389,7 +397,7 @@ func decodeListByMetadata(_ context.Context, r *http.Request) (interface{}, erro
|
|||||||
return req, nil
|
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)
|
o, err := apiutil.ReadUintQuery(r, offsetKey, defOffset)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -417,7 +425,48 @@ func decodeListByConnection(_ context.Context, r *http.Request) (interface{}, er
|
|||||||
|
|
||||||
req := listByConnectionReq{
|
req := listByConnectionReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
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{
|
pageMetadata: things.PageMetadata{
|
||||||
Offset: o,
|
Offset: o,
|
||||||
Limit: l,
|
Limit: l,
|
||||||
@ -433,8 +482,8 @@ func decodeListByConnection(_ context.Context, r *http.Request) (interface{}, er
|
|||||||
func decodeConnectThing(_ context.Context, r *http.Request) (interface{}, error) {
|
func decodeConnectThing(_ context.Context, r *http.Request) (interface{}, error) {
|
||||||
req := connectThingReq{
|
req := connectThingReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
chanID: bone.GetValue(r, "chanId"),
|
chanID: bone.GetValue(r, "chanID"),
|
||||||
thingID: bone.GetValue(r, "thingId"),
|
thingID: bone.GetValue(r, "thingID"),
|
||||||
}
|
}
|
||||||
|
|
||||||
return req, nil
|
return req, nil
|
||||||
@ -471,7 +520,7 @@ func decodeListMembersRequest(_ context.Context, r *http.Request) (interface{},
|
|||||||
|
|
||||||
req := listThingsGroupReq{
|
req := listThingsGroupReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
groupID: bone.GetValue(r, "groupId"),
|
groupID: bone.GetValue(r, "groupID"),
|
||||||
pageMetadata: things.PageMetadata{
|
pageMetadata: things.PageMetadata{
|
||||||
Offset: o,
|
Offset: o,
|
||||||
Limit: l,
|
Limit: l,
|
||||||
|
@ -46,21 +46,21 @@ func MakeHandler(tracer opentracing.Tracer, svc twins.Service, logger logger.Log
|
|||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
r.Put("/twins/:id", kithttp.NewServer(
|
r.Put("/twins/:twinID", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "update_twin")(updateTwinEndpoint(svc)),
|
kitot.TraceServer(tracer, "update_twin")(updateTwinEndpoint(svc)),
|
||||||
decodeTwinUpdate,
|
decodeTwinUpdate,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
r.Get("/twins/:id", kithttp.NewServer(
|
r.Get("/twins/:twinID", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "view_twin")(viewTwinEndpoint(svc)),
|
kitot.TraceServer(tracer, "view_twin")(viewTwinEndpoint(svc)),
|
||||||
decodeView,
|
decodeView,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
r.Delete("/twins/:id", kithttp.NewServer(
|
r.Delete("/twins/:twinID", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "remove_twin")(removeTwinEndpoint(svc)),
|
kitot.TraceServer(tracer, "remove_twin")(removeTwinEndpoint(svc)),
|
||||||
decodeView,
|
decodeView,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
@ -74,7 +74,7 @@ func MakeHandler(tracer opentracing.Tracer, svc twins.Service, logger logger.Log
|
|||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
r.Get("/states/:id", kithttp.NewServer(
|
r.Get("/states/:twinID", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "list_states")(listStatesEndpoint(svc)),
|
kitot.TraceServer(tracer, "list_states")(listStatesEndpoint(svc)),
|
||||||
decodeListStates,
|
decodeListStates,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
@ -107,7 +107,7 @@ func decodeTwinUpdate(_ context.Context, r *http.Request) (interface{}, error) {
|
|||||||
|
|
||||||
req := updateTwinReq{
|
req := updateTwinReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
id: bone.GetValue(r, "id"),
|
id: bone.GetValue(r, "twinID"),
|
||||||
}
|
}
|
||||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||||
return nil, errors.Wrap(errors.ErrMalformedEntity, err)
|
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) {
|
func decodeView(_ context.Context, r *http.Request) (interface{}, error) {
|
||||||
req := viewTwinReq{
|
req := viewTwinReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
id: bone.GetValue(r, "id"),
|
id: bone.GetValue(r, "twinID"),
|
||||||
}
|
}
|
||||||
|
|
||||||
return req, nil
|
return req, nil
|
||||||
@ -172,7 +172,7 @@ func decodeListStates(_ context.Context, r *http.Request) (interface{}, error) {
|
|||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
limit: l,
|
limit: l,
|
||||||
offset: o,
|
offset: o,
|
||||||
id: bone.GetValue(r, "id"),
|
id: bone.GetValue(r, "twinID"),
|
||||||
}
|
}
|
||||||
|
|
||||||
return req, nil
|
return req, nil
|
||||||
|
@ -55,7 +55,7 @@ func MakeHandler(svc users.Service, tracer opentracing.Tracer, logger logger.Log
|
|||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
mux.Get("/users/:id", kithttp.NewServer(
|
mux.Get("/users/:userID", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "view_user")(viewUserEndpoint(svc)),
|
kitot.TraceServer(tracer, "view_user")(viewUserEndpoint(svc)),
|
||||||
decodeViewUser,
|
decodeViewUser,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
@ -97,7 +97,7 @@ func MakeHandler(svc users.Service, tracer opentracing.Tracer, logger logger.Log
|
|||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
mux.Get("/groups/:id", kithttp.NewServer(
|
mux.Get("/groups/:groupID", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "list_members")(listMembersEndpoint(svc)),
|
kitot.TraceServer(tracer, "list_members")(listMembersEndpoint(svc)),
|
||||||
decodeListMembersRequest,
|
decodeListMembersRequest,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
@ -111,14 +111,14 @@ func MakeHandler(svc users.Service, tracer opentracing.Tracer, logger logger.Log
|
|||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
mux.Post("/users/:id/enable", kithttp.NewServer(
|
mux.Post("/users/:userID/enable", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "enable_user")(enableUserEndpoint(svc)),
|
kitot.TraceServer(tracer, "enable_user")(enableUserEndpoint(svc)),
|
||||||
decodeChangeUserStatus,
|
decodeChangeUserStatus,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
opts...,
|
opts...,
|
||||||
))
|
))
|
||||||
|
|
||||||
mux.Post("/users/:id/disable", kithttp.NewServer(
|
mux.Post("/users/:userID/disable", kithttp.NewServer(
|
||||||
kitot.TraceServer(tracer, "disable_user")(disableUserEndpoint(svc)),
|
kitot.TraceServer(tracer, "disable_user")(disableUserEndpoint(svc)),
|
||||||
decodeChangeUserStatus,
|
decodeChangeUserStatus,
|
||||||
encodeResponse,
|
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) {
|
func decodeViewUser(_ context.Context, r *http.Request) (interface{}, error) {
|
||||||
req := viewUserReq{
|
req := viewUserReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
id: bone.GetValue(r, "id"),
|
id: bone.GetValue(r, "userID"),
|
||||||
}
|
}
|
||||||
|
|
||||||
return req, nil
|
return req, nil
|
||||||
@ -287,7 +287,7 @@ func decodeListMembersRequest(_ context.Context, r *http.Request) (interface{},
|
|||||||
req := listMemberGroupReq{
|
req := listMemberGroupReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
status: s,
|
status: s,
|
||||||
id: bone.GetValue(r, "id"),
|
id: bone.GetValue(r, "groupID"),
|
||||||
offset: o,
|
offset: o,
|
||||||
limit: l,
|
limit: l,
|
||||||
metadata: m,
|
metadata: m,
|
||||||
@ -298,7 +298,7 @@ func decodeListMembersRequest(_ context.Context, r *http.Request) (interface{},
|
|||||||
func decodeChangeUserStatus(_ context.Context, r *http.Request) (interface{}, error) {
|
func decodeChangeUserStatus(_ context.Context, r *http.Request) (interface{}, error) {
|
||||||
req := changeUserStatusReq{
|
req := changeUserStatusReq{
|
||||||
token: apiutil.ExtractBearerToken(r),
|
token: apiutil.ExtractBearerToken(r),
|
||||||
id: bone.GetValue(r, "id"),
|
id: bone.GetValue(r, "userID"),
|
||||||
}
|
}
|
||||||
|
|
||||||
return req, nil
|
return req, nil
|
||||||
|
@ -61,7 +61,7 @@ func decodeRequest(r *http.Request) (connReq, error) {
|
|||||||
authKey = authKeys[0]
|
authKey = authKeys[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
chanID := bone.GetValue(r, "id")
|
chanID := bone.GetValue(r, "chanID")
|
||||||
|
|
||||||
req := connReq{
|
req := connReq{
|
||||||
thingKey: authKey,
|
thingKey: authKey,
|
||||||
|
@ -39,8 +39,8 @@ func MakeHandler(svc ws.Service, l log.Logger) http.Handler {
|
|||||||
logger = l
|
logger = l
|
||||||
|
|
||||||
mux := bone.New()
|
mux := bone.New()
|
||||||
mux.GetFunc("/channels/:id/messages", handshake(svc))
|
mux.GetFunc("/channels/:chanID/messages", handshake(svc))
|
||||||
mux.GetFunc("/channels/:id/messages/*", handshake(svc))
|
mux.GetFunc("/channels/:chanID/messages/*", handshake(svc))
|
||||||
mux.GetFunc("/version", mainflux.Health(protocol))
|
mux.GetFunc("/version", mainflux.Health(protocol))
|
||||||
mux.Handle("/metrics", promhttp.Handler())
|
mux.Handle("/metrics", promhttp.Handler())
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user