All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.resourcemanager.authorization.implementation.ActiveDirectoryGroupsImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure Authorization Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt

There is a newer version: 2.44.0
Show newest version
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.resourcemanager.authorization.implementation;

import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedIterable;
import com.azure.resourcemanager.authorization.AuthorizationManager;
import com.azure.resourcemanager.authorization.fluent.GroupsGroupsClient;
import com.azure.resourcemanager.authorization.fluent.models.MicrosoftGraphGroupInner;
import com.azure.resourcemanager.authorization.models.ActiveDirectoryGroup;
import com.azure.resourcemanager.authorization.models.ActiveDirectoryGroups;
import com.azure.resourcemanager.resources.fluentcore.arm.collection.implementation.CreatableWrappersImpl;
import reactor.core.publisher.Mono;
import com.azure.resourcemanager.resources.fluentcore.utils.PagedConverter;

/** The implementation of Users and its parent interfaces. */
public class ActiveDirectoryGroupsImpl
    extends CreatableWrappersImpl
    implements ActiveDirectoryGroups {
    private final AuthorizationManager manager;

    public ActiveDirectoryGroupsImpl(final AuthorizationManager manager) {
        this.manager = manager;
    }

    @Override
    public PagedIterable list() {
        return new PagedIterable<>(listAsync());
    }

    @Override
    protected ActiveDirectoryGroupImpl wrapModel(MicrosoftGraphGroupInner groupInner) {
        if (groupInner == null) {
            return null;
        }
        return new ActiveDirectoryGroupImpl(groupInner, manager());
    }

    @Override
    public ActiveDirectoryGroupImpl getById(String objectId) {
        return (ActiveDirectoryGroupImpl) getByIdAsync(objectId).block();
    }

    @Override
    public Mono getByIdAsync(String id) {
        return inner().getGroupAsync(id)
            .map(groupInner -> new ActiveDirectoryGroupImpl(groupInner, manager()));
    }

    @Override
    public PagedFlux listAsync() {
        return wrapPageAsync(inner().listGroupAsync());
    }

    @Override
    public Mono getByNameAsync(String name) {
        return listByFilterAsync(String.format("displayName eq '%s'", name))
            .singleOrEmpty();
    }

    @Override
    public ActiveDirectoryGroup getByName(String name) {
        return getByNameAsync(name).block();
    }

    @Override
    public ActiveDirectoryGroupImpl define(String name) {
        return wrapModel(name);
    }

    @Override
    protected ActiveDirectoryGroupImpl wrapModel(String name) {
        return wrapModel(new MicrosoftGraphGroupInner().withDisplayName(name));
    }

    @Override
    public Mono deleteByIdAsync(String id) {
        return inner().deleteGroupAsync(id);
    }

    @Override
    public AuthorizationManager manager() {
        return this.manager;
    }

    public GroupsGroupsClient inner() {
        return manager().serviceClient().getGroupsGroups();
    }

    @Override
    public PagedIterable listByFilter(String filter) {
        return new PagedIterable<>(listByFilterAsync(filter));
    }

    @Override
    public PagedFlux listByFilterAsync(String filter) {
        return PagedConverter.mapPage(inner().listGroupAsync(null, null, null, null, filter, null, null, null, null),
            this::wrapModel);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy