<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/cloud/batch/v1/task.proto

namespace Google\Cloud\Batch\V1;

use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;

/**
 * LifecyclePolicy describes how to deal with task failures
 * based on different conditions.
 *
 * Generated from protobuf message <code>google.cloud.batch.v1.LifecyclePolicy</code>
 */
class LifecyclePolicy extends \Google\Protobuf\Internal\Message
{
    /**
     * Action to execute when ActionCondition is true.
     *
     * Generated from protobuf field <code>.google.cloud.batch.v1.LifecyclePolicy.Action action = 1;</code>
     */
    private $action = 0;
    /**
     * Conditions that decide why a task failure is dealt with a specific action.
     *
     * Generated from protobuf field <code>.google.cloud.batch.v1.LifecyclePolicy.ActionCondition action_condition = 2;</code>
     */
    private $action_condition = null;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type int $action
     *           Action to execute when ActionCondition is true.
     *     @type \Google\Cloud\Batch\V1\LifecyclePolicy\ActionCondition $action_condition
     *           Conditions that decide why a task failure is dealt with a specific action.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Cloud\Batch\V1\Task::initOnce();
        parent::__construct($data);
    }

    /**
     * Action to execute when ActionCondition is true.
     *
     * Generated from protobuf field <code>.google.cloud.batch.v1.LifecyclePolicy.Action action = 1;</code>
     * @return int
     */
    public function getAction()
    {
        return $this->action;
    }

    /**
     * Action to execute when ActionCondition is true.
     *
     * Generated from protobuf field <code>.google.cloud.batch.v1.LifecyclePolicy.Action action = 1;</code>
     * @param int $var
     * @return $this
     */
    public function setAction($var)
    {
        GPBUtil::checkEnum($var, \Google\Cloud\Batch\V1\LifecyclePolicy\Action::class);
        $this->action = $var;

        return $this;
    }

    /**
     * Conditions that decide why a task failure is dealt with a specific action.
     *
     * Generated from protobuf field <code>.google.cloud.batch.v1.LifecyclePolicy.ActionCondition action_condition = 2;</code>
     * @return \Google\Cloud\Batch\V1\LifecyclePolicy\ActionCondition|null
     */
    public function getActionCondition()
    {
        return $this->action_condition;
    }

    public function hasActionCondition()
    {
        return isset($this->action_condition);
    }

    public function clearActionCondition()
    {
        unset($this->action_condition);
    }

    /**
     * Conditions that decide why a task failure is dealt with a specific action.
     *
     * Generated from protobuf field <code>.google.cloud.batch.v1.LifecyclePolicy.ActionCondition action_condition = 2;</code>
     * @param \Google\Cloud\Batch\V1\LifecyclePolicy\ActionCondition $var
     * @return $this
     */
    public function setActionCondition($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Batch\V1\LifecyclePolicy\ActionCondition::class);
        $this->action_condition = $var;

        return $this;
    }

}

