// 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.ServerVulnerabilityAssessmentsClient;
import com.azure.resourcemanager.security.fluent.models.ServerVulnerabilityAssessmentInner;
import com.azure.resourcemanager.security.fluent.models.ServerVulnerabilityAssessmentsListInner;
import com.azure.resourcemanager.security.models.ServerVulnerabilityAssessment;
import com.azure.resourcemanager.security.models.ServerVulnerabilityAssessments;
import com.azure.resourcemanager.security.models.ServerVulnerabilityAssessmentsList;

public final class ServerVulnerabilityAssessmentsImpl implements ServerVulnerabilityAssessments {
    private static final ClientLogger LOGGER = new ClientLogger(ServerVulnerabilityAssessmentsImpl.class);

    private final ServerVulnerabilityAssessmentsClient innerClient;

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

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

    public Response<ServerVulnerabilityAssessmentsList> listByExtendedResourceWithResponse(
        String resourceGroupName, String resourceNamespace, String resourceType, String resourceName, Context context) {
        Response<ServerVulnerabilityAssessmentsListInner> inner =
            this
                .serviceClient()
                .listByExtendedResourceWithResponse(
                    resourceGroupName, resourceNamespace, resourceType, resourceName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new ServerVulnerabilityAssessmentsListImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public ServerVulnerabilityAssessmentsList listByExtendedResource(
        String resourceGroupName, String resourceNamespace, String resourceType, String resourceName) {
        ServerVulnerabilityAssessmentsListInner inner =
            this
                .serviceClient()
                .listByExtendedResource(resourceGroupName, resourceNamespace, resourceType, resourceName);
        if (inner != null) {
            return new ServerVulnerabilityAssessmentsListImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<ServerVulnerabilityAssessment> getWithResponse(
        String resourceGroupName, String resourceNamespace, String resourceType, String resourceName, Context context) {
        Response<ServerVulnerabilityAssessmentInner> inner =
            this
                .serviceClient()
                .getWithResponse(resourceGroupName, resourceNamespace, resourceType, resourceName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new ServerVulnerabilityAssessmentImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public ServerVulnerabilityAssessment get(
        String resourceGroupName, String resourceNamespace, String resourceType, String resourceName) {
        ServerVulnerabilityAssessmentInner inner =
            this.serviceClient().get(resourceGroupName, resourceNamespace, resourceType, resourceName);
        if (inner != null) {
            return new ServerVulnerabilityAssessmentImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<ServerVulnerabilityAssessment> createOrUpdateWithResponse(
        String resourceGroupName, String resourceNamespace, String resourceType, String resourceName, Context context) {
        Response<ServerVulnerabilityAssessmentInner> inner =
            this
                .serviceClient()
                .createOrUpdateWithResponse(resourceGroupName, resourceNamespace, resourceType, resourceName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new ServerVulnerabilityAssessmentImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public ServerVulnerabilityAssessment createOrUpdate(
        String resourceGroupName, String resourceNamespace, String resourceType, String resourceName) {
        ServerVulnerabilityAssessmentInner inner =
            this.serviceClient().createOrUpdate(resourceGroupName, resourceNamespace, resourceType, resourceName);
        if (inner != null) {
            return new ServerVulnerabilityAssessmentImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public void delete(String resourceGroupName, String resourceNamespace, String resourceType, String resourceName) {
        this.serviceClient().delete(resourceGroupName, resourceNamespace, resourceType, resourceName);
    }

    public void delete(
        String resourceGroupName, String resourceNamespace, String resourceType, String resourceName, Context context) {
        this.serviceClient().delete(resourceGroupName, resourceNamespace, resourceType, resourceName, context);
    }

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

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