1
0
mirror of https://github.com/mainflux/mainflux.git synced 2025-04-24 13:48:49 +08:00
Arvindh cd82cc5a43
NOISSUE: Listing of shared things with users & Update SDK (#1923)
* NOISSUE - Fix Bugs (#20)

* fix bugs

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix bugs

Signed-off-by: Arvindh <arvindh91@gmail.com>

---------

Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>

* Add Connect Disconnect endpoints (#23)

* fix bugs

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix bugs

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix list of things in a channel and Add connect disconnect endpoint

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix list of things in a channel and Add connect disconnect endpoint

Signed-off-by: Arvindh <arvindh91@gmail.com>

---------

Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>

* Add: Things share with users (#25)

* fix list of things in a channel and Add connect disconnect endpoint

Signed-off-by: Arvindh <arvindh91@gmail.com>

* add: things share with other users

Signed-off-by: Arvindh <arvindh91@gmail.com>

---------

Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>

* Add: Listing of things, channels, groups, users  (#26)

* add: listing of channels, users, groups, things

Signed-off-by: Arvindh <arvindh91@gmail.com>

* add: listing of channels, users, groups, things

Signed-off-by: Arvindh <arvindh91@gmail.com>

* add: listing of channels, users, groups, things

Signed-off-by: Arvindh <arvindh91@gmail.com>

* add: listing of channels, users, groups, things

Signed-off-by: Arvindh <arvindh91@gmail.com>

---------

Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>

* Add: List of user groups & removed repeating code in groups (#29)

* removed repeating code in list groups

Signed-off-by: Arvindh <arvindh91@gmail.com>

* add: list of user group

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix: otel handler operator name for endpoints

Signed-off-by: Arvindh <arvindh91@gmail.com>

---------

Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>

* add: listing of shared things and users

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix: listing of shared things and users

Signed-off-by: Arvindh <arvindh91@gmail.com>

* add: new SDK

Signed-off-by: Arvindh <arvindh91@gmail.com>

* add: new SDK

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix: comment

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix: sdk function names

Signed-off-by: Arvindh <arvindh91@gmail.com>

* update: api spec

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix: channels connect request

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix: listing of clients and groups

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix: CLI

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix: array len comparision

Signed-off-by: Arvindh <arvindh91@gmail.com>

* fix: nginx

Signed-off-by: Arvindh <arvindh91@gmail.com>

---------

Signed-off-by: Arvindh <arvindh91@gmail.com>
Signed-off-by: dusanb94 <dusan.borovcanin@mainflux.com>
Co-authored-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
2023-10-17 15:38:06 +02:00

325 lines
5.6 KiB
Go

// Copyright (c) Mainflux
// SPDX-License-Identifier: Apache-2.0
package api
import (
"github.com/mainflux/mainflux/internal/api"
"github.com/mainflux/mainflux/internal/apiutil"
mfclients "github.com/mainflux/mainflux/pkg/clients"
)
const maxLimitSize = 100
type createClientReq struct {
client mfclients.Client
token string
}
func (req createClientReq) validate() error {
if len(req.client.Name) > api.MaxNameSize {
return apiutil.ErrNameSize
}
return req.client.Validate()
}
type viewClientReq struct {
token string
id string
}
func (req viewClientReq) validate() error {
if req.token == "" {
return apiutil.ErrBearerToken
}
if req.id == "" {
return apiutil.ErrMissingID
}
return nil
}
type viewProfileReq struct {
token string
}
func (req viewProfileReq) validate() error {
if req.token == "" {
return apiutil.ErrBearerToken
}
return nil
}
type listClientsReq struct {
token string
status mfclients.Status
offset uint64
limit uint64
name string
tag string
identity string
visibility string
owner string
sharedBy string
metadata mfclients.Metadata
}
func (req listClientsReq) validate() error {
if req.token == "" {
return apiutil.ErrBearerToken
}
if req.limit > maxLimitSize || req.limit < 1 {
return apiutil.ErrLimitSize
}
if req.visibility != "" &&
req.visibility != api.AllVisibility &&
req.visibility != api.MyVisibility &&
req.visibility != api.SharedVisibility {
return apiutil.ErrInvalidVisibilityType
}
return nil
}
type listMembersByObjectReq struct {
mfclients.Page
token string
objectKind string
objectID string
}
func (req listMembersByObjectReq) validate() error {
if req.token == "" {
return apiutil.ErrBearerToken
}
if req.objectID == "" {
return apiutil.ErrMissingID
}
if req.objectKind == "" {
return apiutil.ErrMissingMemberKind
}
return nil
}
type updateClientReq struct {
token string
id string
Name string `json:"name,omitempty"`
Metadata mfclients.Metadata `json:"metadata,omitempty"`
}
func (req updateClientReq) validate() error {
if req.token == "" {
return apiutil.ErrBearerToken
}
if req.id == "" {
return apiutil.ErrMissingID
}
return nil
}
type updateClientTagsReq struct {
id string
token string
Tags []string `json:"tags,omitempty"`
}
func (req updateClientTagsReq) validate() error {
if req.token == "" {
return apiutil.ErrBearerToken
}
if req.id == "" {
return apiutil.ErrMissingID
}
return nil
}
type updateClientOwnerReq struct {
id string
token string
Owner string `json:"owner,omitempty"`
}
func (req updateClientOwnerReq) validate() error {
if req.token == "" {
return apiutil.ErrBearerToken
}
if req.id == "" {
return apiutil.ErrMissingID
}
return nil
}
type updateClientIdentityReq struct {
token string
id string
Identity string `json:"identity,omitempty"`
}
func (req updateClientIdentityReq) validate() error {
if req.token == "" {
return apiutil.ErrBearerToken
}
if req.id == "" {
return apiutil.ErrMissingID
}
return nil
}
type updateClientSecretReq struct {
token string
OldSecret string `json:"old_secret,omitempty"`
NewSecret string `json:"new_secret,omitempty"`
}
func (req updateClientSecretReq) validate() error {
if req.token == "" {
return apiutil.ErrBearerToken
}
return nil
}
type changeClientStatusReq struct {
token string
id string
}
func (req changeClientStatusReq) validate() error {
if req.token == "" {
return apiutil.ErrBearerToken
}
if req.id == "" {
return apiutil.ErrMissingID
}
return nil
}
type loginClientReq struct {
Identity string `json:"identity,omitempty"`
Secret string `json:"secret,omitempty"`
}
func (req loginClientReq) validate() error {
if req.Identity == "" {
return apiutil.ErrMissingIdentity
}
if req.Secret == "" {
return apiutil.ErrMissingSecret
}
return nil
}
type tokenReq struct {
RefreshToken string `json:"refresh_token,omitempty"`
}
func (req tokenReq) validate() error {
if req.RefreshToken == "" {
return apiutil.ErrBearerToken
}
return nil
}
type passwResetReq struct {
Email string `json:"email"`
Host string `json:"host"`
}
func (req passwResetReq) validate() error {
if req.Email == "" {
return apiutil.ErrMissingEmail
}
if req.Host == "" {
return apiutil.ErrMissingHost
}
return nil
}
type resetTokenReq struct {
Token string `json:"token"`
Password string `json:"password"`
ConfPass string `json:"confirm_password"`
}
func (req resetTokenReq) validate() error {
if req.Password == "" {
return apiutil.ErrMissingPass
}
if req.ConfPass == "" {
return apiutil.ErrMissingConfPass
}
if req.Token == "" {
return apiutil.ErrBearerToken
}
if req.Password != req.ConfPass {
return apiutil.ErrInvalidResetPass
}
return nil
}
type assignUsersReq struct {
token string
groupID string
Relation string `json:"relation"`
UserIDs []string `json:"user_ids"`
}
func (req assignUsersReq) validate() error {
if req.token == "" {
return apiutil.ErrBearerToken
}
if req.Relation == "" {
return apiutil.ErrMissingRelation
}
if req.groupID == "" {
return apiutil.ErrMissingID
}
if len(req.UserIDs) == 0 {
return apiutil.ErrEmptyList
}
return nil
}
type unassignUsersReq struct {
token string
groupID string
Relation string `json:"relation"`
UserIDs []string `json:"user_ids"`
}
func (req unassignUsersReq) validate() error {
if req.token == "" {
return apiutil.ErrBearerToken
}
if req.groupID == "" {
return apiutil.ErrMissingID
}
if req.Relation == "" {
return apiutil.ErrMissingRelation
}
if len(req.UserIDs) == 0 {
return apiutil.ErrEmptyList
}
return nil
}