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

package com.azure.resourcemanager.devtestlabs.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.devtestlabs.fluent.PolicySetsClient;
import com.azure.resourcemanager.devtestlabs.fluent.models.EvaluatePoliciesResponseInner;
import com.azure.resourcemanager.devtestlabs.models.EvaluatePoliciesRequest;
import com.azure.resourcemanager.devtestlabs.models.EvaluatePoliciesResponse;
import com.azure.resourcemanager.devtestlabs.models.PolicySets;

public final class PolicySetsImpl implements PolicySets {
    private static final ClientLogger LOGGER = new ClientLogger(PolicySetsImpl.class);

    private final PolicySetsClient innerClient;

    private final com.azure.resourcemanager.devtestlabs.DevTestLabsManager serviceManager;

    public PolicySetsImpl(
        PolicySetsClient innerClient, com.azure.resourcemanager.devtestlabs.DevTestLabsManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<EvaluatePoliciesResponse> evaluatePoliciesWithResponse(
        String resourceGroupName,
        String labName,
        String name,
        EvaluatePoliciesRequest evaluatePoliciesRequest,
        Context context) {
        Response<EvaluatePoliciesResponseInner> inner =
            this
                .serviceClient()
                .evaluatePoliciesWithResponse(resourceGroupName, labName, name, evaluatePoliciesRequest, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new EvaluatePoliciesResponseImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public EvaluatePoliciesResponse evaluatePolicies(
        String resourceGroupName, String labName, String name, EvaluatePoliciesRequest evaluatePoliciesRequest) {
        EvaluatePoliciesResponseInner inner =
            this.serviceClient().evaluatePolicies(resourceGroupName, labName, name, evaluatePoliciesRequest);
        if (inner != null) {
            return new EvaluatePoliciesResponseImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.devtestlabs.DevTestLabsManager manager() {
        return this.serviceManager;
    }
}
