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

namespace Google\Cloud\Memorystore\V1\CrossInstanceReplicationConfig;

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

/**
 * An output only view of all the member instances participating in the cross
 * instance replication.
 *
 * Generated from protobuf message <code>google.cloud.memorystore.v1.CrossInstanceReplicationConfig.Membership</code>
 */
class Membership extends \Google\Protobuf\Internal\Message
{
    /**
     * Output only. The primary instance that acts as the source of replication
     * for the secondary instances.
     *
     * Generated from protobuf field <code>.google.cloud.memorystore.v1.CrossInstanceReplicationConfig.RemoteInstance primary_instance = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];</code>
     */
    protected $primary_instance = null;
    /**
     * Output only. The list of secondary instances replicating from the primary
     * instance.
     *
     * Generated from protobuf field <code>repeated .google.cloud.memorystore.v1.CrossInstanceReplicationConfig.RemoteInstance secondary_instances = 2 [(.google.api.field_behavior) = OUTPUT_ONLY];</code>
     */
    private $secondary_instances;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type \Google\Cloud\Memorystore\V1\CrossInstanceReplicationConfig\RemoteInstance $primary_instance
     *           Output only. The primary instance that acts as the source of replication
     *           for the secondary instances.
     *     @type array<\Google\Cloud\Memorystore\V1\CrossInstanceReplicationConfig\RemoteInstance>|\Google\Protobuf\Internal\RepeatedField $secondary_instances
     *           Output only. The list of secondary instances replicating from the primary
     *           instance.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Cloud\Memorystore\V1\Memorystore::initOnce();
        parent::__construct($data);
    }

    /**
     * Output only. The primary instance that acts as the source of replication
     * for the secondary instances.
     *
     * Generated from protobuf field <code>.google.cloud.memorystore.v1.CrossInstanceReplicationConfig.RemoteInstance primary_instance = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];</code>
     * @return \Google\Cloud\Memorystore\V1\CrossInstanceReplicationConfig\RemoteInstance|null
     */
    public function getPrimaryInstance()
    {
        return $this->primary_instance;
    }

    public function hasPrimaryInstance()
    {
        return isset($this->primary_instance);
    }

    public function clearPrimaryInstance()
    {
        unset($this->primary_instance);
    }

    /**
     * Output only. The primary instance that acts as the source of replication
     * for the secondary instances.
     *
     * Generated from protobuf field <code>.google.cloud.memorystore.v1.CrossInstanceReplicationConfig.RemoteInstance primary_instance = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];</code>
     * @param \Google\Cloud\Memorystore\V1\CrossInstanceReplicationConfig\RemoteInstance $var
     * @return $this
     */
    public function setPrimaryInstance($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Memorystore\V1\CrossInstanceReplicationConfig\RemoteInstance::class);
        $this->primary_instance = $var;

        return $this;
    }

    /**
     * Output only. The list of secondary instances replicating from the primary
     * instance.
     *
     * Generated from protobuf field <code>repeated .google.cloud.memorystore.v1.CrossInstanceReplicationConfig.RemoteInstance secondary_instances = 2 [(.google.api.field_behavior) = OUTPUT_ONLY];</code>
     * @return \Google\Protobuf\Internal\RepeatedField
     */
    public function getSecondaryInstances()
    {
        return $this->secondary_instances;
    }

    /**
     * Output only. The list of secondary instances replicating from the primary
     * instance.
     *
     * Generated from protobuf field <code>repeated .google.cloud.memorystore.v1.CrossInstanceReplicationConfig.RemoteInstance secondary_instances = 2 [(.google.api.field_behavior) = OUTPUT_ONLY];</code>
     * @param array<\Google\Cloud\Memorystore\V1\CrossInstanceReplicationConfig\RemoteInstance>|\Google\Protobuf\Internal\RepeatedField $var
     * @return $this
     */
    public function setSecondaryInstances($var)
    {
        $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Memorystore\V1\CrossInstanceReplicationConfig\RemoteInstance::class);
        $this->secondary_instances = $arr;

        return $this;
    }

}


