func (s *accountServiceServer) ListGroups(ctx context.Context, req *v1.ListGroupsRequest) (*v1.ListGroupsResponse, error) {
	claims, ok := grpc_middleware.RetrieveClaims(ctx)
	if !ok {
		return nil, status.Error(codes.Internal, "cannot find claims in context")
	}
	userID := claims.UserID  
	totalGrps, groups, err := s.accountRepo.UserOwnedGroups(ctx, userID, nil)
	if err != nil {
		logger.Log.Error("service/v1 - ListGroups - ", zap.String("reason", err.Error()), zap.String("UserID", userID))
		return nil, status.Error(codes.Unknown, "service/v1 - ListGroups - failed to get Groups")
	}
	userGroups := &v1.ListGroupsResponse{
		NumOfRecords: int32(totalGrps),
		Groups:       make([]*v1.Group, totalGrps),
	}
	for i := range groups {
		userGroups.Groups[i] = convertRepoGroupToSrvGroup(groups[i])
	}
	return userGroups, nil
}
ListGroups list all the groups owned by admin user.
package v1
import (
	"context"
	v1 "optisam-backend/account-service/pkg/api/v1"
	repo "optisam-backend/account-service/pkg/repository/v1"
	"optisam-backend/common/optisam/logger"
	grpc_middleware "optisam-backend/common/optisam/middleware/grpc"
	"optisam-backend/common/optisam/strcomp"
	"optisam-backend/common/optisam/token/claims"
	"strings"
	"go.uber.org/zap"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
)