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

package com.azure.resourcemanager.security.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.security.fluent.SqlVulnerabilityAssessmentScanResultsClient;
import com.azure.resourcemanager.security.fluent.models.ScanResultInner;
import com.azure.resourcemanager.security.fluent.models.ScanResultsInner;
import com.azure.resourcemanager.security.models.ScanResult;
import com.azure.resourcemanager.security.models.ScanResults;
import com.azure.resourcemanager.security.models.SqlVulnerabilityAssessmentScanResults;

public final class SqlVulnerabilityAssessmentScanResultsImpl implements SqlVulnerabilityAssessmentScanResults {
    private static final ClientLogger LOGGER = new ClientLogger(SqlVulnerabilityAssessmentScanResultsImpl.class);

    private final SqlVulnerabilityAssessmentScanResultsClient innerClient;

    private final com.azure.resourcemanager.security.SecurityManager serviceManager;

    public SqlVulnerabilityAssessmentScanResultsImpl(
        SqlVulnerabilityAssessmentScanResultsClient innerClient,
        com.azure.resourcemanager.security.SecurityManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<ScanResult> getWithResponse(
        String scanId, String scanResultId, String workspaceId, String resourceId, Context context) {
        Response<ScanResultInner> inner =
            this.serviceClient().getWithResponse(scanId, scanResultId, workspaceId, resourceId, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new ScanResultImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public ScanResult get(String scanId, String scanResultId, String workspaceId, String resourceId) {
        ScanResultInner inner = this.serviceClient().get(scanId, scanResultId, workspaceId, resourceId);
        if (inner != null) {
            return new ScanResultImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<ScanResults> listWithResponse(
        String scanId, String workspaceId, String resourceId, Context context) {
        Response<ScanResultsInner> inner =
            this.serviceClient().listWithResponse(scanId, workspaceId, resourceId, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new ScanResultsImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public ScanResults list(String scanId, String workspaceId, String resourceId) {
        ScanResultsInner inner = this.serviceClient().list(scanId, workspaceId, resourceId);
        if (inner != null) {
            return new ScanResultsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.security.SecurityManager manager() {
        return this.serviceManager;
    }
}
