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

package com.azure.resourcemanager.eventgrid.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.eventgrid.fluent.VerifiedPartnersClient;
import com.azure.resourcemanager.eventgrid.fluent.models.VerifiedPartnerInner;
import com.azure.resourcemanager.eventgrid.models.VerifiedPartner;
import com.azure.resourcemanager.eventgrid.models.VerifiedPartners;

public final class VerifiedPartnersImpl implements VerifiedPartners {
    private static final ClientLogger LOGGER = new ClientLogger(VerifiedPartnersImpl.class);

    private final VerifiedPartnersClient innerClient;

    private final com.azure.resourcemanager.eventgrid.EventGridManager serviceManager;

    public VerifiedPartnersImpl(
        VerifiedPartnersClient innerClient, com.azure.resourcemanager.eventgrid.EventGridManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<VerifiedPartner> getWithResponse(String verifiedPartnerName, Context context) {
        Response<VerifiedPartnerInner> inner = this.serviceClient().getWithResponse(verifiedPartnerName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new VerifiedPartnerImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public VerifiedPartner get(String verifiedPartnerName) {
        VerifiedPartnerInner inner = this.serviceClient().get(verifiedPartnerName);
        if (inner != null) {
            return new VerifiedPartnerImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

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

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

    private com.azure.resourcemanager.eventgrid.EventGridManager manager() {
        return this.serviceManager;
    }
}
