Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: New gRPC function to list mutiple users permissions at single request #2291

Open
arvindh123 opened this issue Jun 16, 2024 · 0 comments

Comments

@arvindh123
Copy link
Contributor

Is your feature request related to a problem? Please describe.

No

Describe the feature you are requesting, as well as the possible use case(s) for it.

ListPermissionsReq gRPC can list permission for single subject.

This is used to retrieve the users permission in list endpoint.
Because ListPermissionsReq gRPC can list permission only for single subject, we iterate the for users list, this leads to mutiple network calls. Instead if create new gRPC function which can list permissions for mutiple subject, the network call can be reduced.
And the code will be like

	if pm.ListPerms && len(usersPage.Clients) > 0 && pm.EntityType != "" && pm.EntityID != "" {
-		g, gctx := errgroup.WithContext(ctx)
-		for i := range usersPage.Clients {
-			// Copying loop variable "i" to avoid "loop variable captured by func literal"
-			iter := i
-			g.Go(func() error {
-				return svc.retrieveObjectUsersPermissions(gctx, res.GetDomainId(), pm.EntityType, pm.EntityID, &usersPage.Clients[iter])
-			})
-		}

-		if err := g.Wait(); err != nil {
-			gctx.Done()
-			return mgclients.ClientsPage{}, err
-		}
+             usersIDs := []string{}
+		for _, client := range usersPage.Clients {
+			userIDs = append(userIDs, client.ID)
+		}
+             
+             svc.agent.ListPermissionsOfMutipleSubjects(ctx,  &magistrala.ListPermissionsOfMutipleSubjects{
+		    SubjectType: auth.UserType,
+		    Subjects:     userIDs,
+		    Object:      objectID,
+                  ObjectType:  objectType,
+	       }
	}

Indicate the importance of this feature to you.

Must-have

Anything else?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant