// 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.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.SqlPoolConnectionPoliciesClient;
import com.azure.resourcemanager.synapse.fluent.models.SqlPoolConnectionPolicyInner;
import com.azure.resourcemanager.synapse.models.ConnectionPolicyName;
import com.azure.resourcemanager.synapse.models.SqlPoolConnectionPolicies;
import com.azure.resourcemanager.synapse.models.SqlPoolConnectionPolicy;

public final class SqlPoolConnectionPoliciesImpl implements SqlPoolConnectionPolicies {
    private static final ClientLogger LOGGER = new ClientLogger(SqlPoolConnectionPoliciesImpl.class);

    private final SqlPoolConnectionPoliciesClient innerClient;

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

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

    public Response<SqlPoolConnectionPolicy> getWithResponse(
        String resourceGroupName,
        String workspaceName,
        String sqlPoolName,
        ConnectionPolicyName connectionPolicyName,
        Context context) {
        Response<SqlPoolConnectionPolicyInner> inner =
            this
                .serviceClient()
                .getWithResponse(resourceGroupName, workspaceName, sqlPoolName, connectionPolicyName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new SqlPoolConnectionPolicyImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public SqlPoolConnectionPolicy get(
        String resourceGroupName, String workspaceName, String sqlPoolName, ConnectionPolicyName connectionPolicyName) {
        SqlPoolConnectionPolicyInner inner =
            this.serviceClient().get(resourceGroupName, workspaceName, sqlPoolName, connectionPolicyName);
        if (inner != null) {
            return new SqlPoolConnectionPolicyImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

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