// 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.SqlVulnerabilityAssessmentBaselineRulesClient;
import com.azure.resourcemanager.security.fluent.models.RuleResultsInner;
import com.azure.resourcemanager.security.fluent.models.RulesResultsInner;
import com.azure.resourcemanager.security.models.RuleResults;
import com.azure.resourcemanager.security.models.RulesResults;
import com.azure.resourcemanager.security.models.RulesResultsInput;
import com.azure.resourcemanager.security.models.SqlVulnerabilityAssessmentBaselineRules;

public final class SqlVulnerabilityAssessmentBaselineRulesImpl implements SqlVulnerabilityAssessmentBaselineRules {
    private static final ClientLogger LOGGER = new ClientLogger(SqlVulnerabilityAssessmentBaselineRulesImpl.class);

    private final SqlVulnerabilityAssessmentBaselineRulesClient innerClient;

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

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

    public Response<RuleResults> getWithResponse(
        String ruleId, String workspaceId, String resourceId, Context context) {
        Response<RuleResultsInner> inner =
            this.serviceClient().getWithResponse(ruleId, workspaceId, resourceId, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new RuleResultsImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public RuleResults get(String ruleId, String workspaceId, String resourceId) {
        RuleResultsInner inner = this.serviceClient().get(ruleId, workspaceId, resourceId);
        if (inner != null) {
            return new RuleResultsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<Void> deleteWithResponse(String ruleId, String workspaceId, String resourceId, Context context) {
        return this.serviceClient().deleteWithResponse(ruleId, workspaceId, resourceId, context);
    }

    public void delete(String ruleId, String workspaceId, String resourceId) {
        this.serviceClient().delete(ruleId, workspaceId, resourceId);
    }

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

    public RulesResults list(String workspaceId, String resourceId) {
        RulesResultsInner inner = this.serviceClient().list(workspaceId, resourceId);
        if (inner != null) {
            return new RulesResultsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<RulesResults> addWithResponse(
        String workspaceId, String resourceId, RulesResultsInput body, Context context) {
        Response<RulesResultsInner> inner =
            this.serviceClient().addWithResponse(workspaceId, resourceId, body, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new RulesResultsImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public RulesResults add(String workspaceId, String resourceId) {
        RulesResultsInner inner = this.serviceClient().add(workspaceId, resourceId);
        if (inner != null) {
            return new RulesResultsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

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

    public RuleResultsImpl define(String name) {
        return new RuleResultsImpl(name, this.manager());
    }
}
