// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.policyinsights.implementation;

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.policyinsights.fluent.PolicyRestrictionsClient;
import com.azure.resourcemanager.policyinsights.fluent.models.CheckRestrictionsResultInner;
import com.azure.resourcemanager.policyinsights.models.CheckManagementGroupRestrictionsRequest;
import com.azure.resourcemanager.policyinsights.models.CheckRestrictionsRequest;
import com.azure.resourcemanager.policyinsights.models.CheckRestrictionsResult;
import com.azure.resourcemanager.policyinsights.models.PolicyRestrictions;

public final class PolicyRestrictionsImpl implements PolicyRestrictions {
    private static final ClientLogger LOGGER = new ClientLogger(PolicyRestrictionsImpl.class);

    private final PolicyRestrictionsClient innerClient;

    private final com.azure.resourcemanager.policyinsights.PolicyInsightsManager serviceManager;

    public PolicyRestrictionsImpl(
        PolicyRestrictionsClient innerClient,
        com.azure.resourcemanager.policyinsights.PolicyInsightsManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<CheckRestrictionsResult> checkAtSubscriptionScopeWithResponse(
        CheckRestrictionsRequest parameters, Context context) {
        Response<CheckRestrictionsResultInner> inner =
            this.serviceClient().checkAtSubscriptionScopeWithResponse(parameters, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new CheckRestrictionsResultImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public CheckRestrictionsResult checkAtSubscriptionScope(CheckRestrictionsRequest parameters) {
        CheckRestrictionsResultInner inner = this.serviceClient().checkAtSubscriptionScope(parameters);
        if (inner != null) {
            return new CheckRestrictionsResultImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<CheckRestrictionsResult> checkAtResourceGroupScopeWithResponse(
        String resourceGroupName, CheckRestrictionsRequest parameters, Context context) {
        Response<CheckRestrictionsResultInner> inner =
            this.serviceClient().checkAtResourceGroupScopeWithResponse(resourceGroupName, parameters, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new CheckRestrictionsResultImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public CheckRestrictionsResult checkAtResourceGroupScope(
        String resourceGroupName, CheckRestrictionsRequest parameters) {
        CheckRestrictionsResultInner inner =
            this.serviceClient().checkAtResourceGroupScope(resourceGroupName, parameters);
        if (inner != null) {
            return new CheckRestrictionsResultImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<CheckRestrictionsResult> checkAtManagementGroupScopeWithResponse(
        String managementGroupId, CheckManagementGroupRestrictionsRequest parameters, Context context) {
        Response<CheckRestrictionsResultInner> inner =
            this.serviceClient().checkAtManagementGroupScopeWithResponse(managementGroupId, parameters, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new CheckRestrictionsResultImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public CheckRestrictionsResult checkAtManagementGroupScope(
        String managementGroupId, CheckManagementGroupRestrictionsRequest parameters) {
        CheckRestrictionsResultInner inner =
            this.serviceClient().checkAtManagementGroupScope(managementGroupId, parameters);
        if (inner != null) {
            return new CheckRestrictionsResultImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.policyinsights.PolicyInsightsManager manager() {
        return this.serviceManager;
    }
}
