// 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.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;

/** AutoML vertical class. Base class for AutoML verticals - TableVertical/ImageVertical/NLPVertical. */
@JsonTypeInfo(
    use = JsonTypeInfo.Id.NAME,
    include = JsonTypeInfo.As.PROPERTY,
    property = "taskType",
    defaultImpl = AutoMLVertical.class)
@JsonTypeName("AutoMLVertical")
@JsonSubTypes({
    @JsonSubTypes.Type(name = "Classification", value = Classification.class),
    @JsonSubTypes.Type(name = "Forecasting", value = Forecasting.class),
    @JsonSubTypes.Type(name = "ImageClassification", value = ImageClassification.class),
    @JsonSubTypes.Type(name = "ImageClassificationMultilabel", value = ImageClassificationMultilabel.class),
    @JsonSubTypes.Type(name = "ImageInstanceSegmentation", value = ImageInstanceSegmentation.class),
    @JsonSubTypes.Type(name = "ImageObjectDetection", value = ImageObjectDetection.class),
    @JsonSubTypes.Type(name = "Regression", value = Regression.class),
    @JsonSubTypes.Type(name = "TextClassification", value = TextClassification.class),
    @JsonSubTypes.Type(name = "TextClassificationMultilabel", value = TextClassificationMultilabel.class),
    @JsonSubTypes.Type(name = "TextNER", value = TextNer.class)
})
@Fluent
public class AutoMLVertical {
    /*
     * Log verbosity for the job.
     */
    @JsonProperty(value = "logVerbosity")
    private LogVerbosity logVerbosity;

    /*
     * Target column name: This is prediction values column.
     * Also known as label column name in context of classification tasks.
     */
    @JsonProperty(value = "targetColumnName")
    private String targetColumnName;

    /*
     * [Required] Training data input.
     */
    @JsonProperty(value = "trainingData", required = true)
    private MLTableJobInput trainingData;

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

    /**
     * Get the logVerbosity property: Log verbosity for the job.
     *
     * @return the logVerbosity value.
     */
    public LogVerbosity logVerbosity() {
        return this.logVerbosity;
    }

    /**
     * Set the logVerbosity property: Log verbosity for the job.
     *
     * @param logVerbosity the logVerbosity value to set.
     * @return the AutoMLVertical object itself.
     */
    public AutoMLVertical withLogVerbosity(LogVerbosity logVerbosity) {
        this.logVerbosity = logVerbosity;
        return this;
    }

    /**
     * Get the targetColumnName property: Target column name: This is prediction values column. Also known as label
     * column name in context of classification tasks.
     *
     * @return the targetColumnName value.
     */
    public String targetColumnName() {
        return this.targetColumnName;
    }

    /**
     * Set the targetColumnName property: Target column name: This is prediction values column. Also known as label
     * column name in context of classification tasks.
     *
     * @param targetColumnName the targetColumnName value to set.
     * @return the AutoMLVertical object itself.
     */
    public AutoMLVertical withTargetColumnName(String targetColumnName) {
        this.targetColumnName = targetColumnName;
        return this;
    }

    /**
     * Get the trainingData property: [Required] Training data input.
     *
     * @return the trainingData value.
     */
    public MLTableJobInput trainingData() {
        return this.trainingData;
    }

    /**
     * Set the trainingData property: [Required] Training data input.
     *
     * @param trainingData the trainingData value to set.
     * @return the AutoMLVertical object itself.
     */
    public AutoMLVertical withTrainingData(MLTableJobInput trainingData) {
        this.trainingData = trainingData;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (trainingData() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property trainingData in model AutoMLVertical"));
        } else {
            trainingData().validate();
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(AutoMLVertical.class);
}
