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

package com.azure.resourcemanager.automation.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.automation.fluent.SoftwareUpdateConfigurationRunsClient;
import com.azure.resourcemanager.automation.fluent.models.SoftwareUpdateConfigurationRunInner;
import com.azure.resourcemanager.automation.fluent.models.SoftwareUpdateConfigurationRunListResultInner;
import com.azure.resourcemanager.automation.models.SoftwareUpdateConfigurationRun;
import com.azure.resourcemanager.automation.models.SoftwareUpdateConfigurationRunListResult;
import com.azure.resourcemanager.automation.models.SoftwareUpdateConfigurationRuns;
import java.util.UUID;

public final class SoftwareUpdateConfigurationRunsImpl implements SoftwareUpdateConfigurationRuns {
    private static final ClientLogger LOGGER = new ClientLogger(SoftwareUpdateConfigurationRunsImpl.class);

    private final SoftwareUpdateConfigurationRunsClient innerClient;

    private final com.azure.resourcemanager.automation.AutomationManager serviceManager;

    public SoftwareUpdateConfigurationRunsImpl(
        SoftwareUpdateConfigurationRunsClient innerClient,
        com.azure.resourcemanager.automation.AutomationManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public SoftwareUpdateConfigurationRun getById(
        String resourceGroupName, String automationAccountName, UUID softwareUpdateConfigurationRunId) {
        SoftwareUpdateConfigurationRunInner inner =
            this.serviceClient().getById(resourceGroupName, automationAccountName, softwareUpdateConfigurationRunId);
        if (inner != null) {
            return new SoftwareUpdateConfigurationRunImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<SoftwareUpdateConfigurationRun> getByIdWithResponse(
        String resourceGroupName,
        String automationAccountName,
        UUID softwareUpdateConfigurationRunId,
        String clientRequestId,
        Context context) {
        Response<SoftwareUpdateConfigurationRunInner> inner =
            this
                .serviceClient()
                .getByIdWithResponse(
                    resourceGroupName,
                    automationAccountName,
                    softwareUpdateConfigurationRunId,
                    clientRequestId,
                    context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new SoftwareUpdateConfigurationRunImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public SoftwareUpdateConfigurationRunListResult list(String resourceGroupName, String automationAccountName) {
        SoftwareUpdateConfigurationRunListResultInner inner =
            this.serviceClient().list(resourceGroupName, automationAccountName);
        if (inner != null) {
            return new SoftwareUpdateConfigurationRunListResultImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<SoftwareUpdateConfigurationRunListResult> listWithResponse(
        String resourceGroupName,
        String automationAccountName,
        String clientRequestId,
        String filter,
        String skip,
        String top,
        Context context) {
        Response<SoftwareUpdateConfigurationRunListResultInner> inner =
            this
                .serviceClient()
                .listWithResponse(
                    resourceGroupName, automationAccountName, clientRequestId, filter, skip, top, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new SoftwareUpdateConfigurationRunListResultImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.automation.AutomationManager manager() {
        return this.serviceManager;
    }
}
