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

com.azure.resourcemanager.managementgroups.implementation.ManagementGroupsImpl Maven / Gradle / Ivy

Go to download

This package contains Microsoft Azure SDK for ManagementGroups Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. The Azure Management Groups API enables consolidation of multiple subscriptions/resources into an organizational hierarchy and centrally manage access control, policies, alerting and reporting for those resources. . Package tag package-2021-04.

There is a newer version: 1.0.0-beta.2
Show newest version
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.managementgroups.implementation;

import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.managementgroups.fluent.ManagementGroupsClient;
import com.azure.resourcemanager.managementgroups.fluent.models.AzureAsyncOperationResultsInner;
import com.azure.resourcemanager.managementgroups.fluent.models.DescendantInfoInner;
import com.azure.resourcemanager.managementgroups.fluent.models.ManagementGroupInfoInner;
import com.azure.resourcemanager.managementgroups.fluent.models.ManagementGroupInner;
import com.azure.resourcemanager.managementgroups.models.AzureAsyncOperationResults;
import com.azure.resourcemanager.managementgroups.models.CreateManagementGroupRequest;
import com.azure.resourcemanager.managementgroups.models.DescendantInfo;
import com.azure.resourcemanager.managementgroups.models.ManagementGroup;
import com.azure.resourcemanager.managementgroups.models.ManagementGroupExpandType;
import com.azure.resourcemanager.managementgroups.models.ManagementGroupInfo;
import com.azure.resourcemanager.managementgroups.models.ManagementGroups;
import com.azure.resourcemanager.managementgroups.models.PatchManagementGroupRequest;

public final class ManagementGroupsImpl implements ManagementGroups {
    private static final ClientLogger LOGGER = new ClientLogger(ManagementGroupsImpl.class);

    private final ManagementGroupsClient innerClient;

    private final com.azure.resourcemanager.managementgroups.ManagementGroupsManager serviceManager;

    public ManagementGroupsImpl(
        ManagementGroupsClient innerClient,
        com.azure.resourcemanager.managementgroups.ManagementGroupsManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public PagedIterable list() {
        PagedIterable inner = this.serviceClient().list();
        return Utils.mapPage(inner, inner1 -> new ManagementGroupInfoImpl(inner1, this.manager()));
    }

    public PagedIterable list(String cacheControl, String skiptoken, Context context) {
        PagedIterable inner = this.serviceClient().list(cacheControl, skiptoken, context);
        return Utils.mapPage(inner, inner1 -> new ManagementGroupInfoImpl(inner1, this.manager()));
    }

    public Response getWithResponse(
        String groupId,
        ManagementGroupExpandType expand,
        Boolean recurse,
        String filter,
        String cacheControl,
        Context context) {
        Response inner =
            this.serviceClient().getWithResponse(groupId, expand, recurse, filter, cacheControl, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new ManagementGroupImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public ManagementGroup get(String groupId) {
        ManagementGroupInner inner = this.serviceClient().get(groupId);
        if (inner != null) {
            return new ManagementGroupImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public ManagementGroup createOrUpdate(String groupId, CreateManagementGroupRequest createManagementGroupRequest) {
        ManagementGroupInner inner = this.serviceClient().createOrUpdate(groupId, createManagementGroupRequest);
        if (inner != null) {
            return new ManagementGroupImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public ManagementGroup createOrUpdate(
        String groupId,
        CreateManagementGroupRequest createManagementGroupRequest,
        String cacheControl,
        Context context) {
        ManagementGroupInner inner =
            this.serviceClient().createOrUpdate(groupId, createManagementGroupRequest, cacheControl, context);
        if (inner != null) {
            return new ManagementGroupImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response updateWithResponse(
        String groupId, PatchManagementGroupRequest patchGroupRequest, String cacheControl, Context context) {
        Response inner =
            this.serviceClient().updateWithResponse(groupId, patchGroupRequest, cacheControl, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new ManagementGroupImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public ManagementGroup update(String groupId, PatchManagementGroupRequest patchGroupRequest) {
        ManagementGroupInner inner = this.serviceClient().update(groupId, patchGroupRequest);
        if (inner != null) {
            return new ManagementGroupImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public AzureAsyncOperationResults deleteByResourceGroup(String groupId) {
        AzureAsyncOperationResultsInner inner = this.serviceClient().delete(groupId);
        if (inner != null) {
            return new AzureAsyncOperationResultsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public AzureAsyncOperationResults delete(String groupId, String cacheControl, Context context) {
        AzureAsyncOperationResultsInner inner = this.serviceClient().delete(groupId, cacheControl, context);
        if (inner != null) {
            return new AzureAsyncOperationResultsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public PagedIterable getDescendants(String groupId) {
        PagedIterable inner = this.serviceClient().getDescendants(groupId);
        return Utils.mapPage(inner, inner1 -> new DescendantInfoImpl(inner1, this.manager()));
    }

    public PagedIterable getDescendants(
        String groupId, String skiptoken, Integer top, Context context) {
        PagedIterable inner =
            this.serviceClient().getDescendants(groupId, skiptoken, top, context);
        return Utils.mapPage(inner, inner1 -> new DescendantInfoImpl(inner1, this.manager()));
    }

    private ManagementGroupsClient serviceClient() {
        return this.innerClient;
    }

    private com.azure.resourcemanager.managementgroups.ManagementGroupsManager manager() {
        return this.serviceManager;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy