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

package com.azure.resourcemanager.advisor.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.advisor.fluent.RecommendationsClient;
import com.azure.resourcemanager.advisor.fluent.models.ResourceRecommendationBaseInner;
import com.azure.resourcemanager.advisor.models.Recommendations;
import com.azure.resourcemanager.advisor.models.RecommendationsGenerateResponse;
import com.azure.resourcemanager.advisor.models.ResourceRecommendationBase;
import java.util.UUID;

public final class RecommendationsImpl implements Recommendations {
    private static final ClientLogger LOGGER = new ClientLogger(RecommendationsImpl.class);

    private final RecommendationsClient innerClient;

    private final com.azure.resourcemanager.advisor.AdvisorManager serviceManager;

    public RecommendationsImpl(
        RecommendationsClient innerClient, com.azure.resourcemanager.advisor.AdvisorManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public RecommendationsGenerateResponse generateWithResponse(Context context) {
        return this.serviceClient().generateWithResponse(context);
    }

    public void generate() {
        this.serviceClient().generate();
    }

    public Response<Void> getGenerateStatusWithResponse(UUID operationId, Context context) {
        return this.serviceClient().getGenerateStatusWithResponse(operationId, context);
    }

    public void getGenerateStatus(UUID operationId) {
        this.serviceClient().getGenerateStatus(operationId);
    }

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

    public PagedIterable<ResourceRecommendationBase> list(
        String filter, Integer top, String skipToken, Context context) {
        PagedIterable<ResourceRecommendationBaseInner> inner =
            this.serviceClient().list(filter, top, skipToken, context);
        return Utils.mapPage(inner, inner1 -> new ResourceRecommendationBaseImpl(inner1, this.manager()));
    }

    public Response<ResourceRecommendationBase> getWithResponse(
        String resourceUri, String recommendationId, Context context) {
        Response<ResourceRecommendationBaseInner> inner =
            this.serviceClient().getWithResponse(resourceUri, recommendationId, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new ResourceRecommendationBaseImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public ResourceRecommendationBase get(String resourceUri, String recommendationId) {
        ResourceRecommendationBaseInner inner = this.serviceClient().get(resourceUri, recommendationId);
        if (inner != null) {
            return new ResourceRecommendationBaseImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.advisor.AdvisorManager manager() {
        return this.serviceManager;
    }
}
