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

package com.azure.resourcemanager.agrifood.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.agrifood.fluent.FarmBeatsExtensionsClient;
import com.azure.resourcemanager.agrifood.fluent.models.FarmBeatsExtensionInner;
import com.azure.resourcemanager.agrifood.models.FarmBeatsExtension;
import com.azure.resourcemanager.agrifood.models.FarmBeatsExtensions;
import java.util.List;

public final class FarmBeatsExtensionsImpl implements FarmBeatsExtensions {
    private static final ClientLogger LOGGER = new ClientLogger(FarmBeatsExtensionsImpl.class);

    private final FarmBeatsExtensionsClient innerClient;

    private final com.azure.resourcemanager.agrifood.AgriFoodManager serviceManager;

    public FarmBeatsExtensionsImpl(
        FarmBeatsExtensionsClient innerClient, com.azure.resourcemanager.agrifood.AgriFoodManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

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

    public PagedIterable<FarmBeatsExtension> list(
        List<String> farmBeatsExtensionIds,
        List<String> farmBeatsExtensionNames,
        List<String> extensionCategories,
        List<String> publisherIds,
        Integer maxPageSize,
        Context context) {
        PagedIterable<FarmBeatsExtensionInner> inner =
            this
                .serviceClient()
                .list(
                    farmBeatsExtensionIds,
                    farmBeatsExtensionNames,
                    extensionCategories,
                    publisherIds,
                    maxPageSize,
                    context);
        return Utils.mapPage(inner, inner1 -> new FarmBeatsExtensionImpl(inner1, this.manager()));
    }

    public FarmBeatsExtension get(String farmBeatsExtensionId) {
        FarmBeatsExtensionInner inner = this.serviceClient().get(farmBeatsExtensionId);
        if (inner != null) {
            return new FarmBeatsExtensionImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<FarmBeatsExtension> getWithResponse(String farmBeatsExtensionId, Context context) {
        Response<FarmBeatsExtensionInner> inner = this.serviceClient().getWithResponse(farmBeatsExtensionId, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new FarmBeatsExtensionImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.agrifood.AgriFoodManager manager() {
        return this.serviceManager;
    }
}
