// 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 com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;
import java.util.Map;

/** The OnlineDeploymentProperties model. */
@JsonTypeInfo(
    use = JsonTypeInfo.Id.NAME,
    include = JsonTypeInfo.As.PROPERTY,
    property = "endpointComputeType",
    defaultImpl = OnlineDeploymentProperties.class)
@JsonTypeName("OnlineDeploymentProperties")
@JsonSubTypes({
    @JsonSubTypes.Type(name = "Kubernetes", value = KubernetesOnlineDeployment.class),
    @JsonSubTypes.Type(name = "Managed", value = ManagedOnlineDeployment.class)
})
@Fluent
public class OnlineDeploymentProperties extends EndpointDeploymentPropertiesBase {
    /*
     * If true, enables Application Insights logging.
     */
    @JsonProperty(value = "appInsightsEnabled")
    private Boolean appInsightsEnabled;

    /*
     * If Enabled, allow egress public network access. If Disabled, this will create secure egress. Default: Enabled.
     */
    @JsonProperty(value = "egressPublicNetworkAccess")
    private EgressPublicNetworkAccessType egressPublicNetworkAccess;

    /*
     * Compute instance type.
     */
    @JsonProperty(value = "instanceType")
    private String instanceType;

    /*
     * Liveness probe monitors the health of the container regularly.
     */
    @JsonProperty(value = "livenessProbe")
    private ProbeSettings livenessProbe;

    /*
     * The URI path to the model.
     */
    @JsonProperty(value = "model")
    private String model;

    /*
     * The path to mount the model in custom container.
     */
    @JsonProperty(value = "modelMountPath")
    private String modelMountPath;

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

    /*
     * Readiness probe validates if the container is ready to serve traffic. The properties and defaults are the same
     * as liveness probe.
     */
    @JsonProperty(value = "readinessProbe")
    private ProbeSettings readinessProbe;

    /*
     * Request settings for the deployment.
     */
    @JsonProperty(value = "requestSettings")
    private OnlineRequestSettings requestSettings;

    /*
     * Scale settings for the deployment.
     * If it is null or not provided,
     * it defaults to TargetUtilizationScaleSettings for KubernetesOnlineDeployment
     * and to DefaultScaleSettings for ManagedOnlineDeployment.
     */
    @JsonProperty(value = "scaleSettings")
    private OnlineScaleSettings scaleSettings;

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

    /**
     * Get the appInsightsEnabled property: If true, enables Application Insights logging.
     *
     * @return the appInsightsEnabled value.
     */
    public Boolean appInsightsEnabled() {
        return this.appInsightsEnabled;
    }

    /**
     * Set the appInsightsEnabled property: If true, enables Application Insights logging.
     *
     * @param appInsightsEnabled the appInsightsEnabled value to set.
     * @return the OnlineDeploymentProperties object itself.
     */
    public OnlineDeploymentProperties withAppInsightsEnabled(Boolean appInsightsEnabled) {
        this.appInsightsEnabled = appInsightsEnabled;
        return this;
    }

    /**
     * Get the egressPublicNetworkAccess property: If Enabled, allow egress public network access. If Disabled, this
     * will create secure egress. Default: Enabled.
     *
     * @return the egressPublicNetworkAccess value.
     */
    public EgressPublicNetworkAccessType egressPublicNetworkAccess() {
        return this.egressPublicNetworkAccess;
    }

    /**
     * Set the egressPublicNetworkAccess property: If Enabled, allow egress public network access. If Disabled, this
     * will create secure egress. Default: Enabled.
     *
     * @param egressPublicNetworkAccess the egressPublicNetworkAccess value to set.
     * @return the OnlineDeploymentProperties object itself.
     */
    public OnlineDeploymentProperties withEgressPublicNetworkAccess(
        EgressPublicNetworkAccessType egressPublicNetworkAccess) {
        this.egressPublicNetworkAccess = egressPublicNetworkAccess;
        return this;
    }

    /**
     * Get the instanceType property: Compute instance type.
     *
     * @return the instanceType value.
     */
    public String instanceType() {
        return this.instanceType;
    }

    /**
     * Set the instanceType property: Compute instance type.
     *
     * @param instanceType the instanceType value to set.
     * @return the OnlineDeploymentProperties object itself.
     */
    public OnlineDeploymentProperties withInstanceType(String instanceType) {
        this.instanceType = instanceType;
        return this;
    }

    /**
     * Get the livenessProbe property: Liveness probe monitors the health of the container regularly.
     *
     * @return the livenessProbe value.
     */
    public ProbeSettings livenessProbe() {
        return this.livenessProbe;
    }

    /**
     * Set the livenessProbe property: Liveness probe monitors the health of the container regularly.
     *
     * @param livenessProbe the livenessProbe value to set.
     * @return the OnlineDeploymentProperties object itself.
     */
    public OnlineDeploymentProperties withLivenessProbe(ProbeSettings livenessProbe) {
        this.livenessProbe = livenessProbe;
        return this;
    }

    /**
     * Get the model property: The URI path to the model.
     *
     * @return the model value.
     */
    public String model() {
        return this.model;
    }

    /**
     * Set the model property: The URI path to the model.
     *
     * @param model the model value to set.
     * @return the OnlineDeploymentProperties object itself.
     */
    public OnlineDeploymentProperties withModel(String model) {
        this.model = model;
        return this;
    }

    /**
     * Get the modelMountPath property: The path to mount the model in custom container.
     *
     * @return the modelMountPath value.
     */
    public String modelMountPath() {
        return this.modelMountPath;
    }

    /**
     * Set the modelMountPath property: The path to mount the model in custom container.
     *
     * @param modelMountPath the modelMountPath value to set.
     * @return the OnlineDeploymentProperties object itself.
     */
    public OnlineDeploymentProperties withModelMountPath(String modelMountPath) {
        this.modelMountPath = modelMountPath;
        return this;
    }

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

    /**
     * Get the readinessProbe property: Readiness probe validates if the container is ready to serve traffic. The
     * properties and defaults are the same as liveness probe.
     *
     * @return the readinessProbe value.
     */
    public ProbeSettings readinessProbe() {
        return this.readinessProbe;
    }

    /**
     * Set the readinessProbe property: Readiness probe validates if the container is ready to serve traffic. The
     * properties and defaults are the same as liveness probe.
     *
     * @param readinessProbe the readinessProbe value to set.
     * @return the OnlineDeploymentProperties object itself.
     */
    public OnlineDeploymentProperties withReadinessProbe(ProbeSettings readinessProbe) {
        this.readinessProbe = readinessProbe;
        return this;
    }

    /**
     * Get the requestSettings property: Request settings for the deployment.
     *
     * @return the requestSettings value.
     */
    public OnlineRequestSettings requestSettings() {
        return this.requestSettings;
    }

    /**
     * Set the requestSettings property: Request settings for the deployment.
     *
     * @param requestSettings the requestSettings value to set.
     * @return the OnlineDeploymentProperties object itself.
     */
    public OnlineDeploymentProperties withRequestSettings(OnlineRequestSettings requestSettings) {
        this.requestSettings = requestSettings;
        return this;
    }

    /**
     * Get the scaleSettings property: Scale settings for the deployment. If it is null or not provided, it defaults to
     * TargetUtilizationScaleSettings for KubernetesOnlineDeployment and to DefaultScaleSettings for
     * ManagedOnlineDeployment.
     *
     * @return the scaleSettings value.
     */
    public OnlineScaleSettings scaleSettings() {
        return this.scaleSettings;
    }

    /**
     * Set the scaleSettings property: Scale settings for the deployment. If it is null or not provided, it defaults to
     * TargetUtilizationScaleSettings for KubernetesOnlineDeployment and to DefaultScaleSettings for
     * ManagedOnlineDeployment.
     *
     * @param scaleSettings the scaleSettings value to set.
     * @return the OnlineDeploymentProperties object itself.
     */
    public OnlineDeploymentProperties withScaleSettings(OnlineScaleSettings scaleSettings) {
        this.scaleSettings = scaleSettings;
        return this;
    }

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

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

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

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

    /** {@inheritDoc} */
    @Override
    public OnlineDeploymentProperties 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 (livenessProbe() != null) {
            livenessProbe().validate();
        }
        if (readinessProbe() != null) {
            readinessProbe().validate();
        }
        if (requestSettings() != null) {
            requestSettings().validate();
        }
        if (scaleSettings() != null) {
            scaleSettings().validate();
        }
    }
}
