GithubHelp home page GithubHelp logo

Comments (14)

shubhamarora97 avatar shubhamarora97 commented on June 15, 2024 1

Ah I forgot there is another way of doing this (I added support for this a couple of weeks ago for another user):

Try:

CollectionPage<User> page = client.users().memberOf().filter(User.class).get();

I tried this example and it worked for me.
CollectionPage page = client.users().members().filter(User.class).get();

Now, I am able to list sub-groups and users in a group separately.
Thanks a lot for the response and have a good day.

from odata-client.

davidmoten avatar davidmoten commented on June 15, 2024 1

Client side filtering using streams and select to reduce data downloaded:

List<User> users = client //
    .groups() //
    .select("id,groupTypes") //
    .stream() //
    .filter(g -> {
        List<String> types = g.getGroupTypes().toList();
        return types.contains("Unified") || types.isEmpty();
    }) //
    .flatMap(g -> g.getMembers().filter(User.class).stream()) //
    .collect(Collectors.toList());

I know this compiles but I haven't tested it live.

from odata-client.

shubhamarora97 avatar shubhamarora97 commented on June 15, 2024 1

One last thing, we can filter groups with odata-client on the basis of group-type which can be unified or null(i.e- Security and Office 365 group)
In Graph API 1.0 we cannot filter with group-type property.

So groupType is a collection itself in a group so you'd need to look for some contains operator in a filter. If you want all users in groups of a certain group-type or group-types then I doubt you'd be able to do it in one call (OData does not give you full sql-like join control). Just return the appropriate groups then on each group return the users. Are there so many groups returned that you can't filter client side? If you are concerned with bringing back lots of data in these calls then use .select and .metadataNone().

Thanks for the information.

from odata-client.

davidmoten avatar davidmoten commented on June 15, 2024

A bit more googling would have got you there. There is an isOf operator you can use in a filter:

GET https://graph.microsoft.com/beta/directoryObjects/delta?$filter=isOf('Microsoft.Graph.User')+or+isOf('Microsoft.Graph.Group')

From https://docs.microsoft.com/en-us/graph/api/directoryobject-delta?view=graph-rest-beta&tabs=http#request-3

from odata-client.

davidmoten avatar davidmoten commented on June 15, 2024

Ah I forgot there is another way of doing this (I added support for this a couple of weeks ago for another user):

Try:

CollectionPage<User> page = client.users().memberOf().filter(User.class).get();

from odata-client.

shubhamarora97 avatar shubhamarora97 commented on June 15, 2024

A bit more googling would have got you there. There is an isOf operator you can use in a filter:

GET https://graph.microsoft.com/beta/directoryObjects/delta?$filter=isOf('Microsoft.Graph.User')+or+isOf('Microsoft.Graph.Group')

From https://docs.microsoft.com/en-us/graph/api/directoryobject-delta?view=graph-rest-beta&tabs=http#request-3

I was referring to the documentation for Microsoft Graph API 1.0.
I did not want to use the beta version for Microsoft Graph API.

from odata-client.

davidmoten avatar davidmoten commented on June 15, 2024

What version are you using?

When I try client.users() there is no .members() method.

from odata-client.

davidmoten avatar davidmoten commented on June 15, 2024

Ah you mean client.groups().members()?

from odata-client.

shubhamarora97 avatar shubhamarora97 commented on June 15, 2024

Ah you mean client.groups().members()?

Yes.

Ah I forgot there is another way of doing this (I added support for this a couple of weeks ago for another user):
Try:

CollectionPage<User> page = client.users().memberOf().filter(User.class).get();

I tried this example and it worked for me.
CollectionPage page = client.groups().members().filter(User.class).get();

Now, I am able to list sub-groups and users in a group separately.
Thanks a lot for the response and have a good day.

from odata-client.

davidmoten avatar davidmoten commented on June 15, 2024

Ripper, glad you're sorted.

from odata-client.

shubhamarora97 avatar shubhamarora97 commented on June 15, 2024

Ah you mean client.groups().members()?

Yes, groups().members().
It was a typo.

from odata-client.

shubhamarora97 avatar shubhamarora97 commented on June 15, 2024

Ah you mean client.groups().members()?

Yes, groups().members().
It was a typo.

Thanks a lot.

from odata-client.

shubhamarora97 avatar shubhamarora97 commented on June 15, 2024

One last thing, we can filter groups with odata-client on the basis of group-type which can be unified or null(i.e- Security and Office 365 group)
In Graph API 1.0 we cannot filter with group-type property.

from odata-client.

davidmoten avatar davidmoten commented on June 15, 2024

One last thing, we can filter groups with odata-client on the basis of group-type which can be unified or null(i.e- Security and Office 365 group)
In Graph API 1.0 we cannot filter with group-type property.

So groupType is a collection itself in a group so you'd need to look for some contains operator in a filter. If you want all users in groups of a certain group-type or group-types then I doubt you'd be able to do it in one call (OData does not give you full sql-like join control). Just return the appropriate groups then on each group return the users. Are there so many groups returned that you can't filter client side? If you are concerned with bringing back lots of data in these calls then use .select and .metadataNone().

from odata-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.