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

namespace Google\Cloud\Batch\V1\AllocationPolicy;

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

/**
 * Either an InstancePolicy or an instance template.
 *
 * Generated from protobuf message <code>google.cloud.batch.v1.AllocationPolicy.InstancePolicyOrTemplate</code>
 */
class InstancePolicyOrTemplate extends \Google\Protobuf\Internal\Message
{
    protected $policy_template;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type \Google\Cloud\Batch\V1\AllocationPolicy\InstancePolicy $policy
     *           InstancePolicy.
     *     @type string $instance_template
     *           Name of an instance template used to create VMs.
     *           Named the field as 'instance_template' instead of 'template' to avoid
     *           c++ keyword conflict.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Cloud\Batch\V1\Job::initOnce();
        parent::__construct($data);
    }

    /**
     * InstancePolicy.
     *
     * Generated from protobuf field <code>.google.cloud.batch.v1.AllocationPolicy.InstancePolicy policy = 1;</code>
     * @return \Google\Cloud\Batch\V1\AllocationPolicy\InstancePolicy|null
     */
    public function getPolicy()
    {
        return $this->readOneof(1);
    }

    public function hasPolicy()
    {
        return $this->hasOneof(1);
    }

    /**
     * InstancePolicy.
     *
     * Generated from protobuf field <code>.google.cloud.batch.v1.AllocationPolicy.InstancePolicy policy = 1;</code>
     * @param \Google\Cloud\Batch\V1\AllocationPolicy\InstancePolicy $var
     * @return $this
     */
    public function setPolicy($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Batch\V1\AllocationPolicy\InstancePolicy::class);
        $this->writeOneof(1, $var);

        return $this;
    }

    /**
     * Name of an instance template used to create VMs.
     * Named the field as 'instance_template' instead of 'template' to avoid
     * c++ keyword conflict.
     *
     * Generated from protobuf field <code>string instance_template = 2;</code>
     * @return string
     */
    public function getInstanceTemplate()
    {
        return $this->readOneof(2);
    }

    public function hasInstanceTemplate()
    {
        return $this->hasOneof(2);
    }

    /**
     * Name of an instance template used to create VMs.
     * Named the field as 'instance_template' instead of 'template' to avoid
     * c++ keyword conflict.
     *
     * Generated from protobuf field <code>string instance_template = 2;</code>
     * @param string $var
     * @return $this
     */
    public function setInstanceTemplate($var)
    {
        GPBUtil::checkString($var, True);
        $this->writeOneof(2, $var);

        return $this;
    }

    /**
     * @return string
     */
    public function getPolicyTemplate()
    {
        return $this->whichOneof("policy_template");
    }

}


