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

package com.azure.resourcemanager.synapse.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.synapse.fluent.SqlPoolSchemasClient;
import com.azure.resourcemanager.synapse.fluent.models.SqlPoolSchemaInner;
import com.azure.resourcemanager.synapse.models.SqlPoolSchema;
import com.azure.resourcemanager.synapse.models.SqlPoolSchemas;

public final class SqlPoolSchemasImpl implements SqlPoolSchemas {
    private static final ClientLogger LOGGER = new ClientLogger(SqlPoolSchemasImpl.class);

    private final SqlPoolSchemasClient innerClient;

    private final com.azure.resourcemanager.synapse.SynapseManager serviceManager;

    public SqlPoolSchemasImpl(
        SqlPoolSchemasClient innerClient, com.azure.resourcemanager.synapse.SynapseManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public PagedIterable<SqlPoolSchema> list(String resourceGroupName, String workspaceName, String sqlPoolName) {
        PagedIterable<SqlPoolSchemaInner> inner =
            this.serviceClient().list(resourceGroupName, workspaceName, sqlPoolName);
        return Utils.mapPage(inner, inner1 -> new SqlPoolSchemaImpl(inner1, this.manager()));
    }

    public PagedIterable<SqlPoolSchema> list(
        String resourceGroupName, String workspaceName, String sqlPoolName, String filter, Context context) {
        PagedIterable<SqlPoolSchemaInner> inner =
            this.serviceClient().list(resourceGroupName, workspaceName, sqlPoolName, filter, context);
        return Utils.mapPage(inner, inner1 -> new SqlPoolSchemaImpl(inner1, this.manager()));
    }

    public Response<SqlPoolSchema> getWithResponse(
        String resourceGroupName, String workspaceName, String sqlPoolName, String schemaName, Context context) {
        Response<SqlPoolSchemaInner> inner =
            this.serviceClient().getWithResponse(resourceGroupName, workspaceName, sqlPoolName, schemaName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new SqlPoolSchemaImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public SqlPoolSchema get(String resourceGroupName, String workspaceName, String sqlPoolName, String schemaName) {
        SqlPoolSchemaInner inner = this.serviceClient().get(resourceGroupName, workspaceName, sqlPoolName, schemaName);
        if (inner != null) {
            return new SqlPoolSchemaImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.synapse.SynapseManager manager() {
        return this.serviceManager;
    }
}
