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

package com.azure.resourcemanager.support.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.support.fluent.ProblemClassificationsClient;
import com.azure.resourcemanager.support.fluent.models.ProblemClassificationInner;
import com.azure.resourcemanager.support.models.ProblemClassification;
import com.azure.resourcemanager.support.models.ProblemClassifications;

public final class ProblemClassificationsImpl implements ProblemClassifications {
    private static final ClientLogger LOGGER = new ClientLogger(ProblemClassificationsImpl.class);

    private final ProblemClassificationsClient innerClient;

    private final com.azure.resourcemanager.support.SupportManager serviceManager;

    public ProblemClassificationsImpl(
        ProblemClassificationsClient innerClient, com.azure.resourcemanager.support.SupportManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public PagedIterable<ProblemClassification> list(String serviceName) {
        PagedIterable<ProblemClassificationInner> inner = this.serviceClient().list(serviceName);
        return Utils.mapPage(inner, inner1 -> new ProblemClassificationImpl(inner1, this.manager()));
    }

    public PagedIterable<ProblemClassification> list(String serviceName, Context context) {
        PagedIterable<ProblemClassificationInner> inner = this.serviceClient().list(serviceName, context);
        return Utils.mapPage(inner, inner1 -> new ProblemClassificationImpl(inner1, this.manager()));
    }

    public Response<ProblemClassification> getWithResponse(
        String serviceName, String problemClassificationName, Context context) {
        Response<ProblemClassificationInner> inner =
            this.serviceClient().getWithResponse(serviceName, problemClassificationName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new ProblemClassificationImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public ProblemClassification get(String serviceName, String problemClassificationName) {
        ProblemClassificationInner inner = this.serviceClient().get(serviceName, problemClassificationName);
        if (inner != null) {
            return new ProblemClassificationImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.support.SupportManager manager() {
        return this.serviceManager;
    }
}
