<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/cloud/dataproc/v1beta2/autoscaling_policies.proto

namespace Google\Cloud\Dataproc\V1beta2;

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

/**
 * Describes an autoscaling policy for Dataproc cluster autoscaler.
 *
 * Generated from protobuf message <code>google.cloud.dataproc.v1beta2.AutoscalingPolicy</code>
 */
class AutoscalingPolicy extends \Google\Protobuf\Internal\Message
{
    /**
     * Required. The policy id.
     * The id must contain only letters (a-z, A-Z), numbers (0-9),
     * underscores (_), and hyphens (-). Cannot begin or end with underscore
     * or hyphen. Must consist of between 3 and 50 characters.
     *
     * Generated from protobuf field <code>string id = 1;</code>
     */
    private $id = '';
    /**
     * Output only. The "resource name" of the policy, as described
     * in https://cloud.google.com/apis/design/resource_names of the form
     * `projects/{project_id}/regions/{region}/autoscalingPolicies/{policy_id}`.
     *
     * Generated from protobuf field <code>string name = 2;</code>
     */
    private $name = '';
    /**
     * Required. Describes how the autoscaler will operate for primary workers.
     *
     * Generated from protobuf field <code>.google.cloud.dataproc.v1beta2.InstanceGroupAutoscalingPolicyConfig worker_config = 4;</code>
     */
    private $worker_config = null;
    /**
     * Optional. Describes how the autoscaler will operate for secondary workers.
     *
     * Generated from protobuf field <code>.google.cloud.dataproc.v1beta2.InstanceGroupAutoscalingPolicyConfig secondary_worker_config = 5;</code>
     */
    private $secondary_worker_config = null;
    protected $algorithm;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type string $id
     *           Required. The policy id.
     *           The id must contain only letters (a-z, A-Z), numbers (0-9),
     *           underscores (_), and hyphens (-). Cannot begin or end with underscore
     *           or hyphen. Must consist of between 3 and 50 characters.
     *     @type string $name
     *           Output only. The "resource name" of the policy, as described
     *           in https://cloud.google.com/apis/design/resource_names of the form
     *           `projects/{project_id}/regions/{region}/autoscalingPolicies/{policy_id}`.
     *     @type \Google\Cloud\Dataproc\V1beta2\BasicAutoscalingAlgorithm $basic_algorithm
     *     @type \Google\Cloud\Dataproc\V1beta2\InstanceGroupAutoscalingPolicyConfig $worker_config
     *           Required. Describes how the autoscaler will operate for primary workers.
     *     @type \Google\Cloud\Dataproc\V1beta2\InstanceGroupAutoscalingPolicyConfig $secondary_worker_config
     *           Optional. Describes how the autoscaler will operate for secondary workers.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Cloud\Dataproc\V1Beta2\AutoscalingPolicies::initOnce();
        parent::__construct($data);
    }

    /**
     * Required. The policy id.
     * The id must contain only letters (a-z, A-Z), numbers (0-9),
     * underscores (_), and hyphens (-). Cannot begin or end with underscore
     * or hyphen. Must consist of between 3 and 50 characters.
     *
     * Generated from protobuf field <code>string id = 1;</code>
     * @return string
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Required. The policy id.
     * The id must contain only letters (a-z, A-Z), numbers (0-9),
     * underscores (_), and hyphens (-). Cannot begin or end with underscore
     * or hyphen. Must consist of between 3 and 50 characters.
     *
     * Generated from protobuf field <code>string id = 1;</code>
     * @param string $var
     * @return $this
     */
    public function setId($var)
    {
        GPBUtil::checkString($var, True);
        $this->id = $var;

        return $this;
    }

    /**
     * Output only. The "resource name" of the policy, as described
     * in https://cloud.google.com/apis/design/resource_names of the form
     * `projects/{project_id}/regions/{region}/autoscalingPolicies/{policy_id}`.
     *
     * Generated from protobuf field <code>string name = 2;</code>
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Output only. The "resource name" of the policy, as described
     * in https://cloud.google.com/apis/design/resource_names of the form
     * `projects/{project_id}/regions/{region}/autoscalingPolicies/{policy_id}`.
     *
     * Generated from protobuf field <code>string name = 2;</code>
     * @param string $var
     * @return $this
     */
    public function setName($var)
    {
        GPBUtil::checkString($var, True);
        $this->name = $var;

        return $this;
    }

    /**
     * Generated from protobuf field <code>.google.cloud.dataproc.v1beta2.BasicAutoscalingAlgorithm basic_algorithm = 3;</code>
     * @return \Google\Cloud\Dataproc\V1beta2\BasicAutoscalingAlgorithm
     */
    public function getBasicAlgorithm()
    {
        return $this->readOneof(3);
    }

    /**
     * Generated from protobuf field <code>.google.cloud.dataproc.v1beta2.BasicAutoscalingAlgorithm basic_algorithm = 3;</code>
     * @param \Google\Cloud\Dataproc\V1beta2\BasicAutoscalingAlgorithm $var
     * @return $this
     */
    public function setBasicAlgorithm($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1beta2\BasicAutoscalingAlgorithm::class);
        $this->writeOneof(3, $var);

        return $this;
    }

    /**
     * Required. Describes how the autoscaler will operate for primary workers.
     *
     * Generated from protobuf field <code>.google.cloud.dataproc.v1beta2.InstanceGroupAutoscalingPolicyConfig worker_config = 4;</code>
     * @return \Google\Cloud\Dataproc\V1beta2\InstanceGroupAutoscalingPolicyConfig
     */
    public function getWorkerConfig()
    {
        return $this->worker_config;
    }

    /**
     * Required. Describes how the autoscaler will operate for primary workers.
     *
     * Generated from protobuf field <code>.google.cloud.dataproc.v1beta2.InstanceGroupAutoscalingPolicyConfig worker_config = 4;</code>
     * @param \Google\Cloud\Dataproc\V1beta2\InstanceGroupAutoscalingPolicyConfig $var
     * @return $this
     */
    public function setWorkerConfig($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1beta2\InstanceGroupAutoscalingPolicyConfig::class);
        $this->worker_config = $var;

        return $this;
    }

    /**
     * Optional. Describes how the autoscaler will operate for secondary workers.
     *
     * Generated from protobuf field <code>.google.cloud.dataproc.v1beta2.InstanceGroupAutoscalingPolicyConfig secondary_worker_config = 5;</code>
     * @return \Google\Cloud\Dataproc\V1beta2\InstanceGroupAutoscalingPolicyConfig
     */
    public function getSecondaryWorkerConfig()
    {
        return $this->secondary_worker_config;
    }

    /**
     * Optional. Describes how the autoscaler will operate for secondary workers.
     *
     * Generated from protobuf field <code>.google.cloud.dataproc.v1beta2.InstanceGroupAutoscalingPolicyConfig secondary_worker_config = 5;</code>
     * @param \Google\Cloud\Dataproc\V1beta2\InstanceGroupAutoscalingPolicyConfig $var
     * @return $this
     */
    public function setSecondaryWorkerConfig($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1beta2\InstanceGroupAutoscalingPolicyConfig::class);
        $this->secondary_worker_config = $var;

        return $this;
    }

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

}

