// 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.SqlPoolRestorePointsClient;
import com.azure.resourcemanager.synapse.fluent.models.RestorePointInner;
import com.azure.resourcemanager.synapse.models.CreateSqlPoolRestorePointDefinition;
import com.azure.resourcemanager.synapse.models.RestorePoint;
import com.azure.resourcemanager.synapse.models.SqlPoolRestorePoints;

public final class SqlPoolRestorePointsImpl implements SqlPoolRestorePoints {
    private static final ClientLogger LOGGER = new ClientLogger(SqlPoolRestorePointsImpl.class);

    private final SqlPoolRestorePointsClient innerClient;

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

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

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

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

    public RestorePoint create(
        String resourceGroupName,
        String workspaceName,
        String sqlPoolName,
        CreateSqlPoolRestorePointDefinition parameters) {
        RestorePointInner inner =
            this.serviceClient().create(resourceGroupName, workspaceName, sqlPoolName, parameters);
        if (inner != null) {
            return new RestorePointImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public RestorePoint create(
        String resourceGroupName,
        String workspaceName,
        String sqlPoolName,
        CreateSqlPoolRestorePointDefinition parameters,
        Context context) {
        RestorePointInner inner =
            this.serviceClient().create(resourceGroupName, workspaceName, sqlPoolName, parameters, context);
        if (inner != null) {
            return new RestorePointImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    public RestorePoint get(
        String resourceGroupName, String workspaceName, String sqlPoolName, String restorePointName) {
        RestorePointInner inner =
            this.serviceClient().get(resourceGroupName, workspaceName, sqlPoolName, restorePointName);
        if (inner != null) {
            return new RestorePointImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<Void> deleteWithResponse(
        String resourceGroupName, String workspaceName, String sqlPoolName, String restorePointName, Context context) {
        return this
            .serviceClient()
            .deleteWithResponse(resourceGroupName, workspaceName, sqlPoolName, restorePointName, context);
    }

    public void delete(String resourceGroupName, String workspaceName, String sqlPoolName, String restorePointName) {
        this.serviceClient().delete(resourceGroupName, workspaceName, sqlPoolName, restorePointName);
    }

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

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