// 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.SqlPoolVulnerabilityAssessmentScansClient;
import com.azure.resourcemanager.synapse.fluent.models.SqlPoolVulnerabilityAssessmentScansExportInner;
import com.azure.resourcemanager.synapse.fluent.models.VulnerabilityAssessmentScanRecordInner;
import com.azure.resourcemanager.synapse.models.SqlPoolVulnerabilityAssessmentScans;
import com.azure.resourcemanager.synapse.models.SqlPoolVulnerabilityAssessmentScansExport;
import com.azure.resourcemanager.synapse.models.VulnerabilityAssessmentName;
import com.azure.resourcemanager.synapse.models.VulnerabilityAssessmentScanRecord;

public final class SqlPoolVulnerabilityAssessmentScansImpl implements SqlPoolVulnerabilityAssessmentScans {
    private static final ClientLogger LOGGER = new ClientLogger(SqlPoolVulnerabilityAssessmentScansImpl.class);

    private final SqlPoolVulnerabilityAssessmentScansClient innerClient;

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

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

    public PagedIterable<VulnerabilityAssessmentScanRecord> list(
        String resourceGroupName,
        String workspaceName,
        String sqlPoolName,
        VulnerabilityAssessmentName vulnerabilityAssessmentName) {
        PagedIterable<VulnerabilityAssessmentScanRecordInner> inner =
            this.serviceClient().list(resourceGroupName, workspaceName, sqlPoolName, vulnerabilityAssessmentName);
        return Utils.mapPage(inner, inner1 -> new VulnerabilityAssessmentScanRecordImpl(inner1, this.manager()));
    }

    public PagedIterable<VulnerabilityAssessmentScanRecord> list(
        String resourceGroupName,
        String workspaceName,
        String sqlPoolName,
        VulnerabilityAssessmentName vulnerabilityAssessmentName,
        Context context) {
        PagedIterable<VulnerabilityAssessmentScanRecordInner> inner =
            this
                .serviceClient()
                .list(resourceGroupName, workspaceName, sqlPoolName, vulnerabilityAssessmentName, context);
        return Utils.mapPage(inner, inner1 -> new VulnerabilityAssessmentScanRecordImpl(inner1, this.manager()));
    }

    public void initiateScan(
        String resourceGroupName,
        String workspaceName,
        String sqlPoolName,
        VulnerabilityAssessmentName vulnerabilityAssessmentName,
        String scanId) {
        this
            .serviceClient()
            .initiateScan(resourceGroupName, workspaceName, sqlPoolName, vulnerabilityAssessmentName, scanId);
    }

    public void initiateScan(
        String resourceGroupName,
        String workspaceName,
        String sqlPoolName,
        VulnerabilityAssessmentName vulnerabilityAssessmentName,
        String scanId,
        Context context) {
        this
            .serviceClient()
            .initiateScan(resourceGroupName, workspaceName, sqlPoolName, vulnerabilityAssessmentName, scanId, context);
    }

    public Response<SqlPoolVulnerabilityAssessmentScansExport> exportWithResponse(
        String resourceGroupName,
        String workspaceName,
        String sqlPoolName,
        VulnerabilityAssessmentName vulnerabilityAssessmentName,
        String scanId,
        Context context) {
        Response<SqlPoolVulnerabilityAssessmentScansExportInner> inner =
            this
                .serviceClient()
                .exportWithResponse(
                    resourceGroupName, workspaceName, sqlPoolName, vulnerabilityAssessmentName, scanId, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new SqlPoolVulnerabilityAssessmentScansExportImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public SqlPoolVulnerabilityAssessmentScansExport export(
        String resourceGroupName,
        String workspaceName,
        String sqlPoolName,
        VulnerabilityAssessmentName vulnerabilityAssessmentName,
        String scanId) {
        SqlPoolVulnerabilityAssessmentScansExportInner inner =
            this
                .serviceClient()
                .export(resourceGroupName, workspaceName, sqlPoolName, vulnerabilityAssessmentName, scanId);
        if (inner != null) {
            return new SqlPoolVulnerabilityAssessmentScansExportImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<VulnerabilityAssessmentScanRecord> getWithResponse(
        String resourceGroupName,
        String workspaceName,
        String sqlPoolName,
        VulnerabilityAssessmentName vulnerabilityAssessmentName,
        String scanId,
        Context context) {
        Response<VulnerabilityAssessmentScanRecordInner> inner =
            this
                .serviceClient()
                .getWithResponse(
                    resourceGroupName, workspaceName, sqlPoolName, vulnerabilityAssessmentName, scanId, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new VulnerabilityAssessmentScanRecordImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public VulnerabilityAssessmentScanRecord get(
        String resourceGroupName,
        String workspaceName,
        String sqlPoolName,
        VulnerabilityAssessmentName vulnerabilityAssessmentName,
        String scanId) {
        VulnerabilityAssessmentScanRecordInner inner =
            this
                .serviceClient()
                .get(resourceGroupName, workspaceName, sqlPoolName, vulnerabilityAssessmentName, scanId);
        if (inner != null) {
            return new VulnerabilityAssessmentScanRecordImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

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