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

package com.azure.resourcemanager.education.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.education.fluent.LabsClient;
import com.azure.resourcemanager.education.fluent.models.LabDetailsInner;
import com.azure.resourcemanager.education.models.InviteCodeGenerateRequest;
import com.azure.resourcemanager.education.models.LabDetails;
import com.azure.resourcemanager.education.models.Labs;

public final class LabsImpl implements Labs {
    private static final ClientLogger LOGGER = new ClientLogger(LabsImpl.class);

    private final LabsClient innerClient;

    private final com.azure.resourcemanager.education.EducationManager serviceManager;

    public LabsImpl(LabsClient innerClient, com.azure.resourcemanager.education.EducationManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public PagedIterable<LabDetails> listAll(String billingAccountName, String billingProfileName) {
        PagedIterable<LabDetailsInner> inner = this.serviceClient().listAll(billingAccountName, billingProfileName);
        return Utils.mapPage(inner, inner1 -> new LabDetailsImpl(inner1, this.manager()));
    }

    public PagedIterable<LabDetails> listAll(
        String billingAccountName,
        String billingProfileName,
        Boolean includeBudget,
        Boolean includeDeleted,
        Context context) {
        PagedIterable<LabDetailsInner> inner =
            this
                .serviceClient()
                .listAll(billingAccountName, billingProfileName, includeBudget, includeDeleted, context);
        return Utils.mapPage(inner, inner1 -> new LabDetailsImpl(inner1, this.manager()));
    }

    public PagedIterable<LabDetails> list(
        String billingAccountName, String billingProfileName, String invoiceSectionName) {
        PagedIterable<LabDetailsInner> inner =
            this.serviceClient().list(billingAccountName, billingProfileName, invoiceSectionName);
        return Utils.mapPage(inner, inner1 -> new LabDetailsImpl(inner1, this.manager()));
    }

    public PagedIterable<LabDetails> list(
        String billingAccountName,
        String billingProfileName,
        String invoiceSectionName,
        Boolean includeBudget,
        Context context) {
        PagedIterable<LabDetailsInner> inner =
            this
                .serviceClient()
                .list(billingAccountName, billingProfileName, invoiceSectionName, includeBudget, context);
        return Utils.mapPage(inner, inner1 -> new LabDetailsImpl(inner1, this.manager()));
    }

    public Response<LabDetails> getWithResponse(
        String billingAccountName,
        String billingProfileName,
        String invoiceSectionName,
        Boolean includeBudget,
        Context context) {
        Response<LabDetailsInner> inner =
            this
                .serviceClient()
                .getWithResponse(billingAccountName, billingProfileName, invoiceSectionName, includeBudget, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new LabDetailsImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public LabDetails get(String billingAccountName, String billingProfileName, String invoiceSectionName) {
        LabDetailsInner inner = this.serviceClient().get(billingAccountName, billingProfileName, invoiceSectionName);
        if (inner != null) {
            return new LabDetailsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<Void> deleteWithResponse(
        String billingAccountName, String billingProfileName, String invoiceSectionName, Context context) {
        return this
            .serviceClient()
            .deleteWithResponse(billingAccountName, billingProfileName, invoiceSectionName, context);
    }

    public void delete(String billingAccountName, String billingProfileName, String invoiceSectionName) {
        this.serviceClient().delete(billingAccountName, billingProfileName, invoiceSectionName);
    }

    public Response<LabDetails> createOrUpdateWithResponse(
        String billingAccountName,
        String billingProfileName,
        String invoiceSectionName,
        LabDetailsInner parameters,
        Context context) {
        Response<LabDetailsInner> inner =
            this
                .serviceClient()
                .createOrUpdateWithResponse(
                    billingAccountName, billingProfileName, invoiceSectionName, parameters, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new LabDetailsImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public LabDetails createOrUpdate(
        String billingAccountName, String billingProfileName, String invoiceSectionName, LabDetailsInner parameters) {
        LabDetailsInner inner =
            this.serviceClient().createOrUpdate(billingAccountName, billingProfileName, invoiceSectionName, parameters);
        if (inner != null) {
            return new LabDetailsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<LabDetails> generateInviteCodeWithResponse(
        String billingAccountName,
        String billingProfileName,
        String invoiceSectionName,
        InviteCodeGenerateRequest parameters,
        Boolean onlyUpdateStudentCountParameter,
        Context context) {
        Response<LabDetailsInner> inner =
            this
                .serviceClient()
                .generateInviteCodeWithResponse(
                    billingAccountName,
                    billingProfileName,
                    invoiceSectionName,
                    parameters,
                    onlyUpdateStudentCountParameter,
                    context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new LabDetailsImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public LabDetails generateInviteCode(
        String billingAccountName,
        String billingProfileName,
        String invoiceSectionName,
        InviteCodeGenerateRequest parameters) {
        LabDetailsInner inner =
            this
                .serviceClient()
                .generateInviteCode(billingAccountName, billingProfileName, invoiceSectionName, parameters);
        if (inner != null) {
            return new LabDetailsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.education.EducationManager manager() {
        return this.serviceManager;
    }
}
