// 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.WorkspaceManagedSqlServerDedicatedSqlMinimalTlsSettingsClient;
import com.azure.resourcemanager.synapse.fluent.models.DedicatedSQLminimalTlsSettingsInner;
import com.azure.resourcemanager.synapse.models.DedicatedSQLminimalTlsSettings;
import com.azure.resourcemanager.synapse.models.DedicatedSqlMinimalTlsSettingsName;
import com.azure.resourcemanager.synapse.models.WorkspaceManagedSqlServerDedicatedSqlMinimalTlsSettings;

public final class WorkspaceManagedSqlServerDedicatedSqlMinimalTlsSettingsImpl
    implements WorkspaceManagedSqlServerDedicatedSqlMinimalTlsSettings {
    private static final ClientLogger LOGGER =
        new ClientLogger(WorkspaceManagedSqlServerDedicatedSqlMinimalTlsSettingsImpl.class);

    private final WorkspaceManagedSqlServerDedicatedSqlMinimalTlsSettingsClient innerClient;

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

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

    public DedicatedSQLminimalTlsSettings update(
        String resourceGroupName,
        String workspaceName,
        DedicatedSqlMinimalTlsSettingsName dedicatedSQLminimalTlsSettingsName,
        DedicatedSQLminimalTlsSettingsInner parameters) {
        DedicatedSQLminimalTlsSettingsInner inner =
            this
                .serviceClient()
                .update(resourceGroupName, workspaceName, dedicatedSQLminimalTlsSettingsName, parameters);
        if (inner != null) {
            return new DedicatedSQLminimalTlsSettingsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public DedicatedSQLminimalTlsSettings update(
        String resourceGroupName,
        String workspaceName,
        DedicatedSqlMinimalTlsSettingsName dedicatedSQLminimalTlsSettingsName,
        DedicatedSQLminimalTlsSettingsInner parameters,
        Context context) {
        DedicatedSQLminimalTlsSettingsInner inner =
            this
                .serviceClient()
                .update(resourceGroupName, workspaceName, dedicatedSQLminimalTlsSettingsName, parameters, context);
        if (inner != null) {
            return new DedicatedSQLminimalTlsSettingsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<DedicatedSQLminimalTlsSettings> getWithResponse(
        String resourceGroupName, String workspaceName, String dedicatedSQLminimalTlsSettingsName, Context context) {
        Response<DedicatedSQLminimalTlsSettingsInner> inner =
            this
                .serviceClient()
                .getWithResponse(resourceGroupName, workspaceName, dedicatedSQLminimalTlsSettingsName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new DedicatedSQLminimalTlsSettingsImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public DedicatedSQLminimalTlsSettings get(
        String resourceGroupName, String workspaceName, String dedicatedSQLminimalTlsSettingsName) {
        DedicatedSQLminimalTlsSettingsInner inner =
            this.serviceClient().get(resourceGroupName, workspaceName, dedicatedSQLminimalTlsSettingsName);
        if (inner != null) {
            return new DedicatedSQLminimalTlsSettingsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public PagedIterable<DedicatedSQLminimalTlsSettings> list(String resourceGroupName, String workspaceName) {
        PagedIterable<DedicatedSQLminimalTlsSettingsInner> inner =
            this.serviceClient().list(resourceGroupName, workspaceName);
        return Utils.mapPage(inner, inner1 -> new DedicatedSQLminimalTlsSettingsImpl(inner1, this.manager()));
    }

    public PagedIterable<DedicatedSQLminimalTlsSettings> list(
        String resourceGroupName, String workspaceName, Context context) {
        PagedIterable<DedicatedSQLminimalTlsSettingsInner> inner =
            this.serviceClient().list(resourceGroupName, workspaceName, context);
        return Utils.mapPage(inner, inner1 -> new DedicatedSQLminimalTlsSettingsImpl(inner1, this.manager()));
    }

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

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