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

package com.azure.resourcemanager.appcontainers.models;

import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Probe describes a health check to be performed against a container to determine whether it is alive or ready to
 * receive traffic.
 */
@Fluent
public final class ContainerAppProbe {
    /*
     * Minimum consecutive failures for the probe to be considered failed after having succeeded. Defaults to 3.
     * Minimum value is 1. Maximum value is 10.
     */
    @JsonProperty(value = "failureThreshold")
    private Integer failureThreshold;

    /*
     * HTTPGet specifies the http request to perform.
     */
    @JsonProperty(value = "httpGet")
    private ContainerAppProbeHttpGet httpGet;

    /*
     * Number of seconds after the container has started before liveness probes are initiated. Minimum value is 1.
     * Maximum value is 60.
     */
    @JsonProperty(value = "initialDelaySeconds")
    private Integer initialDelaySeconds;

    /*
     * How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value is 1. Maximum value is 240.
     */
    @JsonProperty(value = "periodSeconds")
    private Integer periodSeconds;

    /*
     * Minimum consecutive successes for the probe to be considered successful after having failed. Defaults to 1. Must
     * be 1 for liveness and startup. Minimum value is 1. Maximum value is 10.
     */
    @JsonProperty(value = "successThreshold")
    private Integer successThreshold;

    /*
     * TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported.
     */
    @JsonProperty(value = "tcpSocket")
    private ContainerAppProbeTcpSocket tcpSocket;

    /*
     * Optional duration in seconds the pod needs to terminate gracefully upon probe failure. The grace period is the
     * duration in seconds after the processes running in the pod are sent a termination signal and the time when the
     * processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your
     * process. If this value is nil, the pod's terminationGracePeriodSeconds will be used. Otherwise, this value
     * overrides the value provided by the pod spec. Value must be non-negative integer. The value zero indicates stop
     * immediately via the kill signal (no opportunity to shut down). This is an alpha field and requires enabling
     * ProbeTerminationGracePeriod feature gate. Maximum value is 3600 seconds (1 hour)
     */
    @JsonProperty(value = "terminationGracePeriodSeconds")
    private Long terminationGracePeriodSeconds;

    /*
     * Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. Maximum value is
     * 240.
     */
    @JsonProperty(value = "timeoutSeconds")
    private Integer timeoutSeconds;

    /*
     * The type of probe.
     */
    @JsonProperty(value = "type")
    private Type type;

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

    /**
     * Get the failureThreshold property: Minimum consecutive failures for the probe to be considered failed after
     * having succeeded. Defaults to 3. Minimum value is 1. Maximum value is 10.
     *
     * @return the failureThreshold value.
     */
    public Integer failureThreshold() {
        return this.failureThreshold;
    }

    /**
     * Set the failureThreshold property: Minimum consecutive failures for the probe to be considered failed after
     * having succeeded. Defaults to 3. Minimum value is 1. Maximum value is 10.
     *
     * @param failureThreshold the failureThreshold value to set.
     * @return the ContainerAppProbe object itself.
     */
    public ContainerAppProbe withFailureThreshold(Integer failureThreshold) {
        this.failureThreshold = failureThreshold;
        return this;
    }

    /**
     * Get the httpGet property: HTTPGet specifies the http request to perform.
     *
     * @return the httpGet value.
     */
    public ContainerAppProbeHttpGet httpGet() {
        return this.httpGet;
    }

    /**
     * Set the httpGet property: HTTPGet specifies the http request to perform.
     *
     * @param httpGet the httpGet value to set.
     * @return the ContainerAppProbe object itself.
     */
    public ContainerAppProbe withHttpGet(ContainerAppProbeHttpGet httpGet) {
        this.httpGet = httpGet;
        return this;
    }

    /**
     * Get the initialDelaySeconds property: Number of seconds after the container has started before liveness probes
     * are initiated. Minimum value is 1. Maximum value is 60.
     *
     * @return the initialDelaySeconds value.
     */
    public Integer initialDelaySeconds() {
        return this.initialDelaySeconds;
    }

    /**
     * Set the initialDelaySeconds property: Number of seconds after the container has started before liveness probes
     * are initiated. Minimum value is 1. Maximum value is 60.
     *
     * @param initialDelaySeconds the initialDelaySeconds value to set.
     * @return the ContainerAppProbe object itself.
     */
    public ContainerAppProbe withInitialDelaySeconds(Integer initialDelaySeconds) {
        this.initialDelaySeconds = initialDelaySeconds;
        return this;
    }

    /**
     * Get the periodSeconds property: How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value
     * is 1. Maximum value is 240.
     *
     * @return the periodSeconds value.
     */
    public Integer periodSeconds() {
        return this.periodSeconds;
    }

    /**
     * Set the periodSeconds property: How often (in seconds) to perform the probe. Default to 10 seconds. Minimum value
     * is 1. Maximum value is 240.
     *
     * @param periodSeconds the periodSeconds value to set.
     * @return the ContainerAppProbe object itself.
     */
    public ContainerAppProbe withPeriodSeconds(Integer periodSeconds) {
        this.periodSeconds = periodSeconds;
        return this;
    }

    /**
     * Get the successThreshold property: Minimum consecutive successes for the probe to be considered successful after
     * having failed. Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. Maximum value is 10.
     *
     * @return the successThreshold value.
     */
    public Integer successThreshold() {
        return this.successThreshold;
    }

    /**
     * Set the successThreshold property: Minimum consecutive successes for the probe to be considered successful after
     * having failed. Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. Maximum value is 10.
     *
     * @param successThreshold the successThreshold value to set.
     * @return the ContainerAppProbe object itself.
     */
    public ContainerAppProbe withSuccessThreshold(Integer successThreshold) {
        this.successThreshold = successThreshold;
        return this;
    }

    /**
     * Get the tcpSocket property: TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported.
     *
     * @return the tcpSocket value.
     */
    public ContainerAppProbeTcpSocket tcpSocket() {
        return this.tcpSocket;
    }

    /**
     * Set the tcpSocket property: TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported.
     *
     * @param tcpSocket the tcpSocket value to set.
     * @return the ContainerAppProbe object itself.
     */
    public ContainerAppProbe withTcpSocket(ContainerAppProbeTcpSocket tcpSocket) {
        this.tcpSocket = tcpSocket;
        return this;
    }

    /**
     * Get the terminationGracePeriodSeconds property: Optional duration in seconds the pod needs to terminate
     * gracefully upon probe failure. The grace period is the duration in seconds after the processes running in the pod
     * are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this
     * value longer than the expected cleanup time for your process. If this value is nil, the pod's
     * terminationGracePeriodSeconds will be used. Otherwise, this value overrides the value provided by the pod spec.
     * Value must be non-negative integer. The value zero indicates stop immediately via the kill signal (no opportunity
     * to shut down). This is an alpha field and requires enabling ProbeTerminationGracePeriod feature gate. Maximum
     * value is 3600 seconds (1 hour).
     *
     * @return the terminationGracePeriodSeconds value.
     */
    public Long terminationGracePeriodSeconds() {
        return this.terminationGracePeriodSeconds;
    }

    /**
     * Set the terminationGracePeriodSeconds property: Optional duration in seconds the pod needs to terminate
     * gracefully upon probe failure. The grace period is the duration in seconds after the processes running in the pod
     * are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this
     * value longer than the expected cleanup time for your process. If this value is nil, the pod's
     * terminationGracePeriodSeconds will be used. Otherwise, this value overrides the value provided by the pod spec.
     * Value must be non-negative integer. The value zero indicates stop immediately via the kill signal (no opportunity
     * to shut down). This is an alpha field and requires enabling ProbeTerminationGracePeriod feature gate. Maximum
     * value is 3600 seconds (1 hour).
     *
     * @param terminationGracePeriodSeconds the terminationGracePeriodSeconds value to set.
     * @return the ContainerAppProbe object itself.
     */
    public ContainerAppProbe withTerminationGracePeriodSeconds(Long terminationGracePeriodSeconds) {
        this.terminationGracePeriodSeconds = terminationGracePeriodSeconds;
        return this;
    }

    /**
     * Get the timeoutSeconds property: Number of seconds after which the probe times out. Defaults to 1 second. Minimum
     * value is 1. Maximum value is 240.
     *
     * @return the timeoutSeconds value.
     */
    public Integer timeoutSeconds() {
        return this.timeoutSeconds;
    }

    /**
     * Set the timeoutSeconds property: Number of seconds after which the probe times out. Defaults to 1 second. Minimum
     * value is 1. Maximum value is 240.
     *
     * @param timeoutSeconds the timeoutSeconds value to set.
     * @return the ContainerAppProbe object itself.
     */
    public ContainerAppProbe withTimeoutSeconds(Integer timeoutSeconds) {
        this.timeoutSeconds = timeoutSeconds;
        return this;
    }

    /**
     * Get the type property: The type of probe.
     *
     * @return the type value.
     */
    public Type type() {
        return this.type;
    }

    /**
     * Set the type property: The type of probe.
     *
     * @param type the type value to set.
     * @return the ContainerAppProbe object itself.
     */
    public ContainerAppProbe withType(Type type) {
        this.type = type;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (httpGet() != null) {
            httpGet().validate();
        }
        if (tcpSocket() != null) {
            tcpSocket().validate();
        }
    }
}
