// 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.TestJobsClient;
import com.azure.resourcemanager.automation.fluent.models.TestJobInner;
import com.azure.resourcemanager.automation.models.TestJob;
import com.azure.resourcemanager.automation.models.TestJobCreateParameters;
import com.azure.resourcemanager.automation.models.TestJobs;

public final class TestJobsImpl implements TestJobs {
    private static final ClientLogger LOGGER = new ClientLogger(TestJobsImpl.class);

    private final TestJobsClient innerClient;

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

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

    public TestJob create(
        String resourceGroupName,
        String automationAccountName,
        String runbookName,
        TestJobCreateParameters parameters) {
        TestJobInner inner =
            this.serviceClient().create(resourceGroupName, automationAccountName, runbookName, parameters);
        if (inner != null) {
            return new TestJobImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<TestJob> createWithResponse(
        String resourceGroupName,
        String automationAccountName,
        String runbookName,
        TestJobCreateParameters parameters,
        Context context) {
        Response<TestJobInner> inner =
            this
                .serviceClient()
                .createWithResponse(resourceGroupName, automationAccountName, runbookName, parameters, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new TestJobImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public TestJob get(String resourceGroupName, String automationAccountName, String runbookName) {
        TestJobInner inner = this.serviceClient().get(resourceGroupName, automationAccountName, runbookName);
        if (inner != null) {
            return new TestJobImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<TestJob> getWithResponse(
        String resourceGroupName, String automationAccountName, String runbookName, Context context) {
        Response<TestJobInner> inner =
            this.serviceClient().getWithResponse(resourceGroupName, automationAccountName, runbookName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new TestJobImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public void resume(String resourceGroupName, String automationAccountName, String runbookName) {
        this.serviceClient().resume(resourceGroupName, automationAccountName, runbookName);
    }

    public Response<Void> resumeWithResponse(
        String resourceGroupName, String automationAccountName, String runbookName, Context context) {
        return this.serviceClient().resumeWithResponse(resourceGroupName, automationAccountName, runbookName, context);
    }

    public void stop(String resourceGroupName, String automationAccountName, String runbookName) {
        this.serviceClient().stop(resourceGroupName, automationAccountName, runbookName);
    }

    public Response<Void> stopWithResponse(
        String resourceGroupName, String automationAccountName, String runbookName, Context context) {
        return this.serviceClient().stopWithResponse(resourceGroupName, automationAccountName, runbookName, context);
    }

    public void suspend(String resourceGroupName, String automationAccountName, String runbookName) {
        this.serviceClient().suspend(resourceGroupName, automationAccountName, runbookName);
    }

    public Response<Void> suspendWithResponse(
        String resourceGroupName, String automationAccountName, String runbookName, Context context) {
        return this.serviceClient().suspendWithResponse(resourceGroupName, automationAccountName, runbookName, context);
    }

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

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