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

package com.azure.resourcemanager.automanage.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.automanage.fluent.ConfigurationProfileHciAssignmentsClient;
import com.azure.resourcemanager.automanage.fluent.models.ConfigurationProfileAssignmentInner;
import com.azure.resourcemanager.automanage.models.ConfigurationProfileAssignment;
import com.azure.resourcemanager.automanage.models.ConfigurationProfileHciAssignments;

public final class ConfigurationProfileHciAssignmentsImpl implements ConfigurationProfileHciAssignments {
    private static final ClientLogger LOGGER = new ClientLogger(ConfigurationProfileHciAssignmentsImpl.class);

    private final ConfigurationProfileHciAssignmentsClient innerClient;

    private final com.azure.resourcemanager.automanage.AutomanageManager serviceManager;

    public ConfigurationProfileHciAssignmentsImpl(
        ConfigurationProfileHciAssignmentsClient innerClient,
        com.azure.resourcemanager.automanage.AutomanageManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public ConfigurationProfileAssignment createOrUpdate(
        String resourceGroupName,
        String clusterName,
        String configurationProfileAssignmentName,
        ConfigurationProfileAssignmentInner parameters) {
        ConfigurationProfileAssignmentInner inner =
            this
                .serviceClient()
                .createOrUpdate(resourceGroupName, clusterName, configurationProfileAssignmentName, parameters);
        if (inner != null) {
            return new ConfigurationProfileAssignmentImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<ConfigurationProfileAssignment> createOrUpdateWithResponse(
        String resourceGroupName,
        String clusterName,
        String configurationProfileAssignmentName,
        ConfigurationProfileAssignmentInner parameters,
        Context context) {
        Response<ConfigurationProfileAssignmentInner> inner =
            this
                .serviceClient()
                .createOrUpdateWithResponse(
                    resourceGroupName, clusterName, configurationProfileAssignmentName, parameters, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new ConfigurationProfileAssignmentImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public ConfigurationProfileAssignment get(
        String resourceGroupName, String clusterName, String configurationProfileAssignmentName) {
        ConfigurationProfileAssignmentInner inner =
            this.serviceClient().get(resourceGroupName, clusterName, configurationProfileAssignmentName);
        if (inner != null) {
            return new ConfigurationProfileAssignmentImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<ConfigurationProfileAssignment> getWithResponse(
        String resourceGroupName, String clusterName, String configurationProfileAssignmentName, Context context) {
        Response<ConfigurationProfileAssignmentInner> inner =
            this
                .serviceClient()
                .getWithResponse(resourceGroupName, clusterName, configurationProfileAssignmentName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new ConfigurationProfileAssignmentImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public void delete(String resourceGroupName, String clusterName, String configurationProfileAssignmentName) {
        this.serviceClient().delete(resourceGroupName, clusterName, configurationProfileAssignmentName);
    }

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

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

    private com.azure.resourcemanager.automanage.AutomanageManager manager() {
        return this.serviceManager;
    }
}
