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

package com.azure.resourcemanager.machinelearning.models;

import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import java.util.Map;

/** Pipeline Job definition: defines generic to MFE attributes. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "jobType")
@JsonTypeName("Pipeline")
@Fluent
public final class PipelineJob extends JobBaseProperties {
    /*
     * Inputs for the pipeline job.
     */
    @JsonProperty(value = "inputs")
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, JobInput> inputs;

    /*
     * Jobs construct the Pipeline Job.
     */
    @JsonProperty(value = "jobs")
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, Object> jobs;

    /*
     * Outputs for the pipeline job
     */
    @JsonProperty(value = "outputs")
    @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS)
    private Map<String, JobOutput> outputs;

    /*
     * Pipeline settings, for things like ContinueRunOnStepFailure etc.
     */
    @JsonProperty(value = "settings")
    private Object settings;

    /*
     * ARM resource ID of source job.
     */
    @JsonProperty(value = "sourceJobId")
    private String sourceJobId;

    /** Creates an instance of PipelineJob class. */
    public PipelineJob() {
    }

    /**
     * Get the inputs property: Inputs for the pipeline job.
     *
     * @return the inputs value.
     */
    public Map<String, JobInput> inputs() {
        return this.inputs;
    }

    /**
     * Set the inputs property: Inputs for the pipeline job.
     *
     * @param inputs the inputs value to set.
     * @return the PipelineJob object itself.
     */
    public PipelineJob withInputs(Map<String, JobInput> inputs) {
        this.inputs = inputs;
        return this;
    }

    /**
     * Get the jobs property: Jobs construct the Pipeline Job.
     *
     * @return the jobs value.
     */
    public Map<String, Object> jobs() {
        return this.jobs;
    }

    /**
     * Set the jobs property: Jobs construct the Pipeline Job.
     *
     * @param jobs the jobs value to set.
     * @return the PipelineJob object itself.
     */
    public PipelineJob withJobs(Map<String, Object> jobs) {
        this.jobs = jobs;
        return this;
    }

    /**
     * Get the outputs property: Outputs for the pipeline job.
     *
     * @return the outputs value.
     */
    public Map<String, JobOutput> outputs() {
        return this.outputs;
    }

    /**
     * Set the outputs property: Outputs for the pipeline job.
     *
     * @param outputs the outputs value to set.
     * @return the PipelineJob object itself.
     */
    public PipelineJob withOutputs(Map<String, JobOutput> outputs) {
        this.outputs = outputs;
        return this;
    }

    /**
     * Get the settings property: Pipeline settings, for things like ContinueRunOnStepFailure etc.
     *
     * @return the settings value.
     */
    public Object settings() {
        return this.settings;
    }

    /**
     * Set the settings property: Pipeline settings, for things like ContinueRunOnStepFailure etc.
     *
     * @param settings the settings value to set.
     * @return the PipelineJob object itself.
     */
    public PipelineJob withSettings(Object settings) {
        this.settings = settings;
        return this;
    }

    /**
     * Get the sourceJobId property: ARM resource ID of source job.
     *
     * @return the sourceJobId value.
     */
    public String sourceJobId() {
        return this.sourceJobId;
    }

    /**
     * Set the sourceJobId property: ARM resource ID of source job.
     *
     * @param sourceJobId the sourceJobId value to set.
     * @return the PipelineJob object itself.
     */
    public PipelineJob withSourceJobId(String sourceJobId) {
        this.sourceJobId = sourceJobId;
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public PipelineJob withComponentId(String componentId) {
        super.withComponentId(componentId);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public PipelineJob withComputeId(String computeId) {
        super.withComputeId(computeId);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public PipelineJob withDisplayName(String displayName) {
        super.withDisplayName(displayName);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public PipelineJob withExperimentName(String experimentName) {
        super.withExperimentName(experimentName);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public PipelineJob withIdentity(IdentityConfiguration identity) {
        super.withIdentity(identity);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public PipelineJob withIsArchived(Boolean isArchived) {
        super.withIsArchived(isArchived);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public PipelineJob withServices(Map<String, JobService> services) {
        super.withServices(services);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public PipelineJob withDescription(String description) {
        super.withDescription(description);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public PipelineJob withProperties(Map<String, String> properties) {
        super.withProperties(properties);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public PipelineJob withTags(Map<String, String> tags) {
        super.withTags(tags);
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        super.validate();
        if (inputs() != null) {
            inputs()
                .values()
                .forEach(
                    e -> {
                        if (e != null) {
                            e.validate();
                        }
                    });
        }
        if (outputs() != null) {
            outputs()
                .values()
                .forEach(
                    e -> {
                        if (e != null) {
                            e.validate();
                        }
                    });
        }
    }
}
