Skip to content

Commit

Permalink
NOISSUE: Listing of shared things with users & Update SDK (#1923)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
arvindh123 and dborovcanin authored Oct 17, 2023
1 parent b4e7e85 commit cd82cc5
Show file tree
Hide file tree
Showing 44 changed files with 1,046 additions and 2,187 deletions.
54 changes: 0 additions & 54 deletions api/openapi/things.yml
Original file line number Diff line number Diff line change
Expand Up @@ -540,60 +540,6 @@ paths:
"500":
$ref: "#/components/responses/ServiceError"

/channels/{chanID}/assign:
post:
summary: Assigns a member to a channel
description: |
Assigns a specific member to a channel that is identifier by the channel ID.
tags:
- Channels
parameters:
- $ref: "#/components/parameters/chanID"
requestBody:
$ref: "#/components/requestBodies/AssignReq"
security:
- bearerAuth: []
responses:
"200":
description: Thing shared.
"400":
description: Failed due to malformed thing's ID.
"401":
description: Missing or invalid access token provided.
"404":
description: A non-existent entity request.
"422":
description: Database can't process request.
"500":
$ref: "#/components/responses/ServiceError"

/channels/{chanID}/unassign:
post:
summary: Unassigns a member from a channel
description: |
Unassigns a specific member from a channel that is identifier by the channel ID.
tags:
- Channels
parameters:
- $ref: "#/components/parameters/chanID"
requestBody:
$ref: "#/components/requestBodies/AssignReq"
security:
- bearerAuth: []
responses:
"200":
description: Thing unshared.
"400":
description: Failed due to malformed thing's ID.
"401":
description: Missing or invalid access token provided.
"404":
description: A non-existent entity request.
"422":
description: Database can't process request.
"500":
$ref: "#/components/responses/ServiceError"

/channels/{chanID}/users/assign:
post:
summary: Assigns a member to a channel
Expand Down
54 changes: 0 additions & 54 deletions api/openapi/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -690,60 +690,6 @@ paths:
"500":
$ref: "#/components/responses/ServiceError"

/groups/{groupID}/members/assign:
post:
summary: Assigns a member to a group
description: |
Assigns a specific member to a group that is identifier by the group ID.
tags:
- Groups
parameters:
- $ref: "#/components/parameters/GroupID"
requestBody:
$ref: "#/components/requestBodies/AssignReq"
security:
- bearerAuth: []
responses:
"200":
description: Member assigned.
"400":
description: Failed due to malformed group's ID.
"401":
description: Missing or invalid access token provided.
"404":
description: A non-existent entity request.
"422":
description: Database can't process request.
"500":
$ref: "#/components/responses/ServiceError"

/groups/{groupID}/members/unassign:
post:
summary: Unassigns a member to a group
description: |
Unassigns a specific member to a group that is identifier by the group ID.
tags:
- Groups
parameters:
- $ref: "#/components/parameters/GroupID"
requestBody:
$ref: "#/components/requestBodies/AssignReq"
security:
- bearerAuth: []
responses:
"200":
description: Member assigned.
"400":
description: Failed due to malformed group's ID.
"401":
description: Missing or invalid access token provided.
"404":
description: A non-existent entity request.
"422":
description: Database can't process request.
"500":
$ref: "#/components/responses/ServiceError"

/groups/{groupID}/users/assign:
post:
summary: Assigns a user to a group
Expand Down
142 changes: 141 additions & 1 deletion cli/channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,152 @@ var cmdChannels = []cobra.Command{
logJSON(channel)
},
},
{
Use: "assign user <relation> <user_ids> <channel_id> <user_auth_token>",
Short: "Assign user",
Long: "Assign user to a channel\n" +
"Usage:\n" +
"\tmainflux-cli channels assign user <relation> '[\"<user_id_1>\", \"<user_id_2>\"]' <channel_id> $USERTOKEN\n",
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 5 {
logUsage(cmd.Use)
return
}
var userIDs []string
if err := json.Unmarshal([]byte(args[1]), &userIDs); err != nil {
logError(err)
return
}
if err := sdk.AddUserToChannel(args[2], mfxsdk.UsersRelationRequest{Relation: args[0], UserIDs: userIDs}, args[3]); err != nil {
logError(err)
return
}
logOK()
},
},
{
Use: "unassign user <relation> <user_ids> <channel_id> <user_auth_token>",
Short: "Unassign user",
Long: "Unassign user from a channel\n" +
"Usage:\n" +
"\tmainflux-cli channels unassign user <relation> '[\"<user_id_1>\", \"<user_id_2>\"]' <channel_id> $USERTOKEN\n",
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 5 {
logUsage(cmd.Use)
return
}
var userIDs []string
if err := json.Unmarshal([]byte(args[1]), &userIDs); err != nil {
logError(err)
return
}
if err := sdk.RemoveUserFromChannel(args[2], mfxsdk.UsersRelationRequest{Relation: args[0], UserIDs: userIDs}, args[3]); err != nil {
logError(err)
return
}
logOK()
},
},
{
Use: "assign group <group_ids> <channel_id> <user_auth_token>",
Short: "Assign group",
Long: "Assign group to a channel\n" +
"Usage:\n" +
"\tmainflux-cli channels assign group '[\"<group_id_1>\", \"<group_id_2>\"]' <channel_id> $USERTOKEN\n",
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 5 {
logUsage(cmd.Use)
return
}
var groupIDs []string
if err := json.Unmarshal([]byte(args[0]), &groupIDs); err != nil {
logError(err)
return
}
if err := sdk.AddUserGroupToChannel(args[1], mfxsdk.UserGroupsRequest{UserGroupIDs: groupIDs}, args[2]); err != nil {
logError(err)
return
}
logOK()
},
},
{
Use: "unassign group <group_ids> <channel_id> <user_auth_token>",
Short: "Unassign group",
Long: "Unassign group from a channel\n" +
"Usage:\n" +
"\tmainflux-cli channels unassign group '[\"<group_id_1>\", \"<group_id_2>\"]' <channel_id> $USERTOKEN\n",
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 5 {
logUsage(cmd.Use)
return
}
var groupIDs []string
if err := json.Unmarshal([]byte(args[0]), &groupIDs); err != nil {
logError(err)
return
}
if err := sdk.RemoveUserGroupFromChannel(args[1], mfxsdk.UserGroupsRequest{UserGroupIDs: groupIDs}, args[2]); err != nil {
logError(err)
return
}
logOK()
},
},
{
Use: "users <channel_id> <user_auth_token>",
Short: "List users",
Long: "List users of a channel\n" +
"Usage:\n" +
"\tmainflux-cli channels users <channel_id> $USERTOKEN\n",
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 2 {
logUsage(cmd.Use)
return
}
pm := mfxsdk.PageMetadata{
Offset: Offset,
Limit: Limit,
}
ul, err := sdk.ListChannelUsers(args[0], pm, args[1])
if err != nil {
logError(err)
return
}

logJSON(ul)
},
},
{
Use: "groups <channel_id> <user_auth_token>",
Short: "List groups",
Long: "List groups of a channel\n" +
"Usage:\n" +
"\tmainflux-cli channels groups <channel_id> $USERTOKEN\n",
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 2 {
logUsage(cmd.Use)
return
}
pm := mfxsdk.PageMetadata{
Offset: Offset,
Limit: Limit,
}
ul, err := sdk.ListChannelUserGroups(args[0], pm, args[1])
if err != nil {
logError(err)
return
}

logJSON(ul)
},
},
}

// NewChannelsCmd returns channels command.
func NewChannelsCmd() *cobra.Command {
cmd := cobra.Command{
Use: "channels [create | get | update | delete | connections | not-connected]",
Use: "channels [create | get | update | delete | connections | not-connected | assign | unassign | users | groups]",
Short: "Channels management",
Long: `Channels management: create, get, update or delete Channel and get list of Things connected or not connected to a Channel`,
}
Expand Down
Loading

0 comments on commit cd82cc5

Please sign in to comment.