// 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.JsonProperty;
import java.util.Map;

/** Batch inference settings per deployment. */
@Fluent
public final class BatchDeploymentProperties extends EndpointDeploymentPropertiesBase {
    /*
     * Compute target for batch inference operation.
     */
    @JsonProperty(value = "compute")
    private String compute;

    /*
     * Error threshold, if the error count for the entire input goes above this value,
     * the batch inference will be aborted. Range is [-1, int.MaxValue].
     * For FileDataset, this value is the count of file failures.
     * For TabularDataset, this value is the count of record failures.
     * If set to -1 (the lower bound), all failures during batch inference will be ignored.
     */
    @JsonProperty(value = "errorThreshold")
    private Integer errorThreshold;

    /*
     * Logging level for batch inference operation.
     */
    @JsonProperty(value = "loggingLevel")
    private BatchLoggingLevel loggingLevel;

    /*
     * Indicates maximum number of parallelism per instance.
     */
    @JsonProperty(value = "maxConcurrencyPerInstance")
    private Integer maxConcurrencyPerInstance;

    /*
     * Size of the mini-batch passed to each batch invocation.
     * For FileDataset, this is the number of files per mini-batch.
     * For TabularDataset, this is the size of the records in bytes, per mini-batch.
     */
    @JsonProperty(value = "miniBatchSize")
    private Long miniBatchSize;

    /*
     * Reference to the model asset for the endpoint deployment.
     */
    @JsonProperty(value = "model")
    private AssetReferenceBase model;

    /*
     * Indicates how the output will be organized.
     */
    @JsonProperty(value = "outputAction")
    private BatchOutputAction outputAction;

    /*
     * Customized output file name for append_row output action.
     */
    @JsonProperty(value = "outputFileName")
    private String outputFileName;

    /*
     * Provisioning state for the endpoint deployment.
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private DeploymentProvisioningState provisioningState;

    /*
     * Indicates compute configuration for the job.
     * If not provided, will default to the defaults defined in ResourceConfiguration.
     */
    @JsonProperty(value = "resources")
    private DeploymentResourceConfiguration resources;

    /*
     * Retry Settings for the batch inference operation.
     * If not provided, will default to the defaults defined in BatchRetrySettings.
     */
    @JsonProperty(value = "retrySettings")
    private BatchRetrySettings retrySettings;

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

    /**
     * Get the compute property: Compute target for batch inference operation.
     *
     * @return the compute value.
     */
    public String compute() {
        return this.compute;
    }

    /**
     * Set the compute property: Compute target for batch inference operation.
     *
     * @param compute the compute value to set.
     * @return the BatchDeploymentProperties object itself.
     */
    public BatchDeploymentProperties withCompute(String compute) {
        this.compute = compute;
        return this;
    }

    /**
     * Get the errorThreshold property: Error threshold, if the error count for the entire input goes above this value,
     * the batch inference will be aborted. Range is [-1, int.MaxValue]. For FileDataset, this value is the count of
     * file failures. For TabularDataset, this value is the count of record failures. If set to -1 (the lower bound),
     * all failures during batch inference will be ignored.
     *
     * @return the errorThreshold value.
     */
    public Integer errorThreshold() {
        return this.errorThreshold;
    }

    /**
     * Set the errorThreshold property: Error threshold, if the error count for the entire input goes above this value,
     * the batch inference will be aborted. Range is [-1, int.MaxValue]. For FileDataset, this value is the count of
     * file failures. For TabularDataset, this value is the count of record failures. If set to -1 (the lower bound),
     * all failures during batch inference will be ignored.
     *
     * @param errorThreshold the errorThreshold value to set.
     * @return the BatchDeploymentProperties object itself.
     */
    public BatchDeploymentProperties withErrorThreshold(Integer errorThreshold) {
        this.errorThreshold = errorThreshold;
        return this;
    }

    /**
     * Get the loggingLevel property: Logging level for batch inference operation.
     *
     * @return the loggingLevel value.
     */
    public BatchLoggingLevel loggingLevel() {
        return this.loggingLevel;
    }

    /**
     * Set the loggingLevel property: Logging level for batch inference operation.
     *
     * @param loggingLevel the loggingLevel value to set.
     * @return the BatchDeploymentProperties object itself.
     */
    public BatchDeploymentProperties withLoggingLevel(BatchLoggingLevel loggingLevel) {
        this.loggingLevel = loggingLevel;
        return this;
    }

    /**
     * Get the maxConcurrencyPerInstance property: Indicates maximum number of parallelism per instance.
     *
     * @return the maxConcurrencyPerInstance value.
     */
    public Integer maxConcurrencyPerInstance() {
        return this.maxConcurrencyPerInstance;
    }

    /**
     * Set the maxConcurrencyPerInstance property: Indicates maximum number of parallelism per instance.
     *
     * @param maxConcurrencyPerInstance the maxConcurrencyPerInstance value to set.
     * @return the BatchDeploymentProperties object itself.
     */
    public BatchDeploymentProperties withMaxConcurrencyPerInstance(Integer maxConcurrencyPerInstance) {
        this.maxConcurrencyPerInstance = maxConcurrencyPerInstance;
        return this;
    }

    /**
     * Get the miniBatchSize property: Size of the mini-batch passed to each batch invocation. For FileDataset, this is
     * the number of files per mini-batch. For TabularDataset, this is the size of the records in bytes, per mini-batch.
     *
     * @return the miniBatchSize value.
     */
    public Long miniBatchSize() {
        return this.miniBatchSize;
    }

    /**
     * Set the miniBatchSize property: Size of the mini-batch passed to each batch invocation. For FileDataset, this is
     * the number of files per mini-batch. For TabularDataset, this is the size of the records in bytes, per mini-batch.
     *
     * @param miniBatchSize the miniBatchSize value to set.
     * @return the BatchDeploymentProperties object itself.
     */
    public BatchDeploymentProperties withMiniBatchSize(Long miniBatchSize) {
        this.miniBatchSize = miniBatchSize;
        return this;
    }

    /**
     * Get the model property: Reference to the model asset for the endpoint deployment.
     *
     * @return the model value.
     */
    public AssetReferenceBase model() {
        return this.model;
    }

    /**
     * Set the model property: Reference to the model asset for the endpoint deployment.
     *
     * @param model the model value to set.
     * @return the BatchDeploymentProperties object itself.
     */
    public BatchDeploymentProperties withModel(AssetReferenceBase model) {
        this.model = model;
        return this;
    }

    /**
     * Get the outputAction property: Indicates how the output will be organized.
     *
     * @return the outputAction value.
     */
    public BatchOutputAction outputAction() {
        return this.outputAction;
    }

    /**
     * Set the outputAction property: Indicates how the output will be organized.
     *
     * @param outputAction the outputAction value to set.
     * @return the BatchDeploymentProperties object itself.
     */
    public BatchDeploymentProperties withOutputAction(BatchOutputAction outputAction) {
        this.outputAction = outputAction;
        return this;
    }

    /**
     * Get the outputFileName property: Customized output file name for append_row output action.
     *
     * @return the outputFileName value.
     */
    public String outputFileName() {
        return this.outputFileName;
    }

    /**
     * Set the outputFileName property: Customized output file name for append_row output action.
     *
     * @param outputFileName the outputFileName value to set.
     * @return the BatchDeploymentProperties object itself.
     */
    public BatchDeploymentProperties withOutputFileName(String outputFileName) {
        this.outputFileName = outputFileName;
        return this;
    }

    /**
     * Get the provisioningState property: Provisioning state for the endpoint deployment.
     *
     * @return the provisioningState value.
     */
    public DeploymentProvisioningState provisioningState() {
        return this.provisioningState;
    }

    /**
     * Get the resources property: Indicates compute configuration for the job. If not provided, will default to the
     * defaults defined in ResourceConfiguration.
     *
     * @return the resources value.
     */
    public DeploymentResourceConfiguration resources() {
        return this.resources;
    }

    /**
     * Set the resources property: Indicates compute configuration for the job. If not provided, will default to the
     * defaults defined in ResourceConfiguration.
     *
     * @param resources the resources value to set.
     * @return the BatchDeploymentProperties object itself.
     */
    public BatchDeploymentProperties withResources(DeploymentResourceConfiguration resources) {
        this.resources = resources;
        return this;
    }

    /**
     * Get the retrySettings property: Retry Settings for the batch inference operation. If not provided, will default
     * to the defaults defined in BatchRetrySettings.
     *
     * @return the retrySettings value.
     */
    public BatchRetrySettings retrySettings() {
        return this.retrySettings;
    }

    /**
     * Set the retrySettings property: Retry Settings for the batch inference operation. If not provided, will default
     * to the defaults defined in BatchRetrySettings.
     *
     * @param retrySettings the retrySettings value to set.
     * @return the BatchDeploymentProperties object itself.
     */
    public BatchDeploymentProperties withRetrySettings(BatchRetrySettings retrySettings) {
        this.retrySettings = retrySettings;
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public BatchDeploymentProperties withCodeConfiguration(CodeConfiguration codeConfiguration) {
        super.withCodeConfiguration(codeConfiguration);
        return this;
    }

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

    /** {@inheritDoc} */
    @Override
    public BatchDeploymentProperties withEnvironmentId(String environmentId) {
        super.withEnvironmentId(environmentId);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public BatchDeploymentProperties withEnvironmentVariables(Map<String, String> environmentVariables) {
        super.withEnvironmentVariables(environmentVariables);
        return this;
    }

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

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        super.validate();
        if (model() != null) {
            model().validate();
        }
        if (resources() != null) {
            resources().validate();
        }
        if (retrySettings() != null) {
            retrySettings().validate();
        }
    }
}
