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

package com.azure.resourcemanager.logic.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.logic.fluent.WorkflowVersionTriggersClient;
import com.azure.resourcemanager.logic.fluent.models.WorkflowTriggerCallbackUrlInner;
import com.azure.resourcemanager.logic.models.GetCallbackUrlParameters;
import com.azure.resourcemanager.logic.models.WorkflowTriggerCallbackUrl;
import com.azure.resourcemanager.logic.models.WorkflowVersionTriggers;

public final class WorkflowVersionTriggersImpl implements WorkflowVersionTriggers {
    private static final ClientLogger LOGGER = new ClientLogger(WorkflowVersionTriggersImpl.class);

    private final WorkflowVersionTriggersClient innerClient;

    private final com.azure.resourcemanager.logic.LogicManager serviceManager;

    public WorkflowVersionTriggersImpl(
        WorkflowVersionTriggersClient innerClient, com.azure.resourcemanager.logic.LogicManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<WorkflowTriggerCallbackUrl> listCallbackUrlWithResponse(
        String resourceGroupName,
        String workflowName,
        String versionId,
        String triggerName,
        GetCallbackUrlParameters parameters,
        Context context) {
        Response<WorkflowTriggerCallbackUrlInner> inner =
            this
                .serviceClient()
                .listCallbackUrlWithResponse(
                    resourceGroupName, workflowName, versionId, triggerName, parameters, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new WorkflowTriggerCallbackUrlImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public WorkflowTriggerCallbackUrl listCallbackUrl(
        String resourceGroupName, String workflowName, String versionId, String triggerName) {
        WorkflowTriggerCallbackUrlInner inner =
            this.serviceClient().listCallbackUrl(resourceGroupName, workflowName, versionId, triggerName);
        if (inner != null) {
            return new WorkflowTriggerCallbackUrlImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.logic.LogicManager manager() {
        return this.serviceManager;
    }
}
