2019-10-07 08:14:47 -06:00
|
|
|
// Copyright (c) Mainflux
|
2018-08-26 13:15:48 +02:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2018-05-15 17:13:09 +02:00
|
|
|
package grpc
|
|
|
|
|
2022-03-03 17:13:46 +01:00
|
|
|
import "github.com/mainflux/mainflux/internal/apiutil"
|
2018-05-15 17:13:09 +02:00
|
|
|
|
2022-03-03 17:13:46 +01:00
|
|
|
type accessByKeyReq struct {
|
2018-05-15 17:13:09 +02:00
|
|
|
thingKey string
|
2018-12-05 13:09:25 +01:00
|
|
|
chanID string
|
2018-05-15 17:13:09 +02:00
|
|
|
}
|
|
|
|
|
2022-03-03 17:13:46 +01:00
|
|
|
func (req accessByKeyReq) validate() error {
|
|
|
|
if req.chanID == "" {
|
|
|
|
return apiutil.ErrMissingID
|
|
|
|
}
|
|
|
|
|
|
|
|
if req.thingKey == "" {
|
|
|
|
return apiutil.ErrBearerKey
|
2018-05-15 17:13:09 +02:00
|
|
|
}
|
2019-07-15 18:28:15 +02:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type accessByIDReq struct {
|
|
|
|
thingID string
|
|
|
|
chanID string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req accessByIDReq) validate() error {
|
|
|
|
if req.thingID == "" || req.chanID == "" {
|
2022-03-03 17:13:46 +01:00
|
|
|
return apiutil.ErrMissingID
|
2019-07-15 18:28:15 +02:00
|
|
|
}
|
|
|
|
|
2018-05-15 17:13:09 +02:00
|
|
|
return nil
|
|
|
|
}
|
2018-05-17 20:17:02 +02:00
|
|
|
|
2021-02-22 19:41:59 +01:00
|
|
|
type channelOwnerReq struct {
|
|
|
|
owner string
|
|
|
|
chanID string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req channelOwnerReq) validate() error {
|
|
|
|
if req.owner == "" || req.chanID == "" {
|
2022-03-03 17:13:46 +01:00
|
|
|
return apiutil.ErrMissingID
|
2021-02-22 19:41:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-05-17 20:17:02 +02:00
|
|
|
type identifyReq struct {
|
|
|
|
key string
|
|
|
|
}
|
2019-07-15 18:28:15 +02:00
|
|
|
|
|
|
|
func (req identifyReq) validate() error {
|
|
|
|
if req.key == "" {
|
2022-03-03 17:13:46 +01:00
|
|
|
return apiutil.ErrBearerKey
|
2019-07-15 18:28:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|