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

namespace Google\Cloud\PolicySimulator\V1;

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

/**
 * Details about how a binding in a policy affects a principal's ability to use
 * a permission.
 *
 * Generated from protobuf message <code>google.cloud.policysimulator.v1.BindingExplanation</code>
 */
class BindingExplanation extends \Google\Protobuf\Internal\Message
{
    /**
     * Required. Indicates whether _this binding_ provides the specified
     * permission to the specified principal for the specified resource.
     * This field does _not_ indicate whether the principal actually has the
     * permission for the resource. There might be another binding that overrides
     * this binding. To determine whether the principal actually has the
     * permission, use the `access` field in the
     * [TroubleshootIamPolicyResponse][IamChecker.TroubleshootIamPolicyResponse].
     *
     * Generated from protobuf field <code>.google.cloud.policysimulator.v1.AccessState access = 1 [(.google.api.field_behavior) = REQUIRED];</code>
     */
    protected $access = 0;
    /**
     * The role that this binding grants. For example,
     * `roles/compute.serviceAgent`.
     * For a complete list of predefined IAM roles, as well as the permissions in
     * each role, see https://cloud.google.com/iam/help/roles/reference.
     *
     * Generated from protobuf field <code>string role = 2;</code>
     */
    protected $role = '';
    /**
     * Indicates whether the role granted by this binding contains the specified
     * permission.
     *
     * Generated from protobuf field <code>.google.cloud.policysimulator.v1.BindingExplanation.RolePermission role_permission = 3;</code>
     */
    protected $role_permission = 0;
    /**
     * The relevance of the permission's existence, or nonexistence, in the role
     * to the overall determination for the entire policy.
     *
     * Generated from protobuf field <code>.google.cloud.policysimulator.v1.HeuristicRelevance role_permission_relevance = 4;</code>
     */
    protected $role_permission_relevance = 0;
    /**
     * Indicates whether each principal in the binding includes the principal
     * specified in the request, either directly or indirectly. Each key
     * identifies a principal in the binding, and each value indicates whether the
     * principal in the binding includes the principal in the request.
     * For example, suppose that a binding includes the following principals:
     * * `user:alice&#64;example.com`
     * * `group:product-eng&#64;example.com`
     * The principal in the replayed access tuple is `user:bob&#64;example.com`. This
     * user is a principal of the group `group:product-eng&#64;example.com`.
     * For the first principal in the binding, the key is
     * `user:alice&#64;example.com`, and the `membership` field in the value is set to
     * `MEMBERSHIP_NOT_INCLUDED`.
     * For the second principal in the binding, the key is
     * `group:product-eng&#64;example.com`, and the `membership` field in the value is
     * set to `MEMBERSHIP_INCLUDED`.
     *
     * Generated from protobuf field <code>map<string, .google.cloud.policysimulator.v1.BindingExplanation.AnnotatedMembership> memberships = 5;</code>
     */
    private $memberships;
    /**
     * The relevance of this binding to the overall determination for the entire
     * policy.
     *
     * Generated from protobuf field <code>.google.cloud.policysimulator.v1.HeuristicRelevance relevance = 6;</code>
     */
    protected $relevance = 0;
    /**
     * A condition expression that prevents this binding from granting access
     * unless the expression evaluates to `true`.
     * To learn about IAM Conditions, see
     * https://cloud.google.com/iam/docs/conditions-overview.
     *
     * Generated from protobuf field <code>.google.type.Expr condition = 7;</code>
     */
    protected $condition = null;

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type int $access
     *           Required. Indicates whether _this binding_ provides the specified
     *           permission to the specified principal for the specified resource.
     *           This field does _not_ indicate whether the principal actually has the
     *           permission for the resource. There might be another binding that overrides
     *           this binding. To determine whether the principal actually has the
     *           permission, use the `access` field in the
     *           [TroubleshootIamPolicyResponse][IamChecker.TroubleshootIamPolicyResponse].
     *     @type string $role
     *           The role that this binding grants. For example,
     *           `roles/compute.serviceAgent`.
     *           For a complete list of predefined IAM roles, as well as the permissions in
     *           each role, see https://cloud.google.com/iam/help/roles/reference.
     *     @type int $role_permission
     *           Indicates whether the role granted by this binding contains the specified
     *           permission.
     *     @type int $role_permission_relevance
     *           The relevance of the permission's existence, or nonexistence, in the role
     *           to the overall determination for the entire policy.
     *     @type array|\Google\Protobuf\Internal\MapField $memberships
     *           Indicates whether each principal in the binding includes the principal
     *           specified in the request, either directly or indirectly. Each key
     *           identifies a principal in the binding, and each value indicates whether the
     *           principal in the binding includes the principal in the request.
     *           For example, suppose that a binding includes the following principals:
     *           * `user:alice&#64;example.com`
     *           * `group:product-eng&#64;example.com`
     *           The principal in the replayed access tuple is `user:bob&#64;example.com`. This
     *           user is a principal of the group `group:product-eng&#64;example.com`.
     *           For the first principal in the binding, the key is
     *           `user:alice&#64;example.com`, and the `membership` field in the value is set to
     *           `MEMBERSHIP_NOT_INCLUDED`.
     *           For the second principal in the binding, the key is
     *           `group:product-eng&#64;example.com`, and the `membership` field in the value is
     *           set to `MEMBERSHIP_INCLUDED`.
     *     @type int $relevance
     *           The relevance of this binding to the overall determination for the entire
     *           policy.
     *     @type \Google\Type\Expr $condition
     *           A condition expression that prevents this binding from granting access
     *           unless the expression evaluates to `true`.
     *           To learn about IAM Conditions, see
     *           https://cloud.google.com/iam/docs/conditions-overview.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Cloud\Policysimulator\V1\Explanations::initOnce();
        parent::__construct($data);
    }

    /**
     * Required. Indicates whether _this binding_ provides the specified
     * permission to the specified principal for the specified resource.
     * This field does _not_ indicate whether the principal actually has the
     * permission for the resource. There might be another binding that overrides
     * this binding. To determine whether the principal actually has the
     * permission, use the `access` field in the
     * [TroubleshootIamPolicyResponse][IamChecker.TroubleshootIamPolicyResponse].
     *
     * Generated from protobuf field <code>.google.cloud.policysimulator.v1.AccessState access = 1 [(.google.api.field_behavior) = REQUIRED];</code>
     * @return int
     */
    public function getAccess()
    {
        return $this->access;
    }

    /**
     * Required. Indicates whether _this binding_ provides the specified
     * permission to the specified principal for the specified resource.
     * This field does _not_ indicate whether the principal actually has the
     * permission for the resource. There might be another binding that overrides
     * this binding. To determine whether the principal actually has the
     * permission, use the `access` field in the
     * [TroubleshootIamPolicyResponse][IamChecker.TroubleshootIamPolicyResponse].
     *
     * Generated from protobuf field <code>.google.cloud.policysimulator.v1.AccessState access = 1 [(.google.api.field_behavior) = REQUIRED];</code>
     * @param int $var
     * @return $this
     */
    public function setAccess($var)
    {
        GPBUtil::checkEnum($var, \Google\Cloud\PolicySimulator\V1\AccessState::class);
        $this->access = $var;

        return $this;
    }

    /**
     * The role that this binding grants. For example,
     * `roles/compute.serviceAgent`.
     * For a complete list of predefined IAM roles, as well as the permissions in
     * each role, see https://cloud.google.com/iam/help/roles/reference.
     *
     * Generated from protobuf field <code>string role = 2;</code>
     * @return string
     */
    public function getRole()
    {
        return $this->role;
    }

    /**
     * The role that this binding grants. For example,
     * `roles/compute.serviceAgent`.
     * For a complete list of predefined IAM roles, as well as the permissions in
     * each role, see https://cloud.google.com/iam/help/roles/reference.
     *
     * Generated from protobuf field <code>string role = 2;</code>
     * @param string $var
     * @return $this
     */
    public function setRole($var)
    {
        GPBUtil::checkString($var, True);
        $this->role = $var;

        return $this;
    }

    /**
     * Indicates whether the role granted by this binding contains the specified
     * permission.
     *
     * Generated from protobuf field <code>.google.cloud.policysimulator.v1.BindingExplanation.RolePermission role_permission = 3;</code>
     * @return int
     */
    public function getRolePermission()
    {
        return $this->role_permission;
    }

    /**
     * Indicates whether the role granted by this binding contains the specified
     * permission.
     *
     * Generated from protobuf field <code>.google.cloud.policysimulator.v1.BindingExplanation.RolePermission role_permission = 3;</code>
     * @param int $var
     * @return $this
     */
    public function setRolePermission($var)
    {
        GPBUtil::checkEnum($var, \Google\Cloud\PolicySimulator\V1\BindingExplanation\RolePermission::class);
        $this->role_permission = $var;

        return $this;
    }

    /**
     * The relevance of the permission's existence, or nonexistence, in the role
     * to the overall determination for the entire policy.
     *
     * Generated from protobuf field <code>.google.cloud.policysimulator.v1.HeuristicRelevance role_permission_relevance = 4;</code>
     * @return int
     */
    public function getRolePermissionRelevance()
    {
        return $this->role_permission_relevance;
    }

    /**
     * The relevance of the permission's existence, or nonexistence, in the role
     * to the overall determination for the entire policy.
     *
     * Generated from protobuf field <code>.google.cloud.policysimulator.v1.HeuristicRelevance role_permission_relevance = 4;</code>
     * @param int $var
     * @return $this
     */
    public function setRolePermissionRelevance($var)
    {
        GPBUtil::checkEnum($var, \Google\Cloud\PolicySimulator\V1\HeuristicRelevance::class);
        $this->role_permission_relevance = $var;

        return $this;
    }

    /**
     * Indicates whether each principal in the binding includes the principal
     * specified in the request, either directly or indirectly. Each key
     * identifies a principal in the binding, and each value indicates whether the
     * principal in the binding includes the principal in the request.
     * For example, suppose that a binding includes the following principals:
     * * `user:alice&#64;example.com`
     * * `group:product-eng&#64;example.com`
     * The principal in the replayed access tuple is `user:bob&#64;example.com`. This
     * user is a principal of the group `group:product-eng&#64;example.com`.
     * For the first principal in the binding, the key is
     * `user:alice&#64;example.com`, and the `membership` field in the value is set to
     * `MEMBERSHIP_NOT_INCLUDED`.
     * For the second principal in the binding, the key is
     * `group:product-eng&#64;example.com`, and the `membership` field in the value is
     * set to `MEMBERSHIP_INCLUDED`.
     *
     * Generated from protobuf field <code>map<string, .google.cloud.policysimulator.v1.BindingExplanation.AnnotatedMembership> memberships = 5;</code>
     * @return \Google\Protobuf\Internal\MapField
     */
    public function getMemberships()
    {
        return $this->memberships;
    }

    /**
     * Indicates whether each principal in the binding includes the principal
     * specified in the request, either directly or indirectly. Each key
     * identifies a principal in the binding, and each value indicates whether the
     * principal in the binding includes the principal in the request.
     * For example, suppose that a binding includes the following principals:
     * * `user:alice&#64;example.com`
     * * `group:product-eng&#64;example.com`
     * The principal in the replayed access tuple is `user:bob&#64;example.com`. This
     * user is a principal of the group `group:product-eng&#64;example.com`.
     * For the first principal in the binding, the key is
     * `user:alice&#64;example.com`, and the `membership` field in the value is set to
     * `MEMBERSHIP_NOT_INCLUDED`.
     * For the second principal in the binding, the key is
     * `group:product-eng&#64;example.com`, and the `membership` field in the value is
     * set to `MEMBERSHIP_INCLUDED`.
     *
     * Generated from protobuf field <code>map<string, .google.cloud.policysimulator.v1.BindingExplanation.AnnotatedMembership> memberships = 5;</code>
     * @param array|\Google\Protobuf\Internal\MapField $var
     * @return $this
     */
    public function setMemberships($var)
    {
        $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\PolicySimulator\V1\BindingExplanation\AnnotatedMembership::class);
        $this->memberships = $arr;

        return $this;
    }

    /**
     * The relevance of this binding to the overall determination for the entire
     * policy.
     *
     * Generated from protobuf field <code>.google.cloud.policysimulator.v1.HeuristicRelevance relevance = 6;</code>
     * @return int
     */
    public function getRelevance()
    {
        return $this->relevance;
    }

    /**
     * The relevance of this binding to the overall determination for the entire
     * policy.
     *
     * Generated from protobuf field <code>.google.cloud.policysimulator.v1.HeuristicRelevance relevance = 6;</code>
     * @param int $var
     * @return $this
     */
    public function setRelevance($var)
    {
        GPBUtil::checkEnum($var, \Google\Cloud\PolicySimulator\V1\HeuristicRelevance::class);
        $this->relevance = $var;

        return $this;
    }

    /**
     * A condition expression that prevents this binding from granting access
     * unless the expression evaluates to `true`.
     * To learn about IAM Conditions, see
     * https://cloud.google.com/iam/docs/conditions-overview.
     *
     * Generated from protobuf field <code>.google.type.Expr condition = 7;</code>
     * @return \Google\Type\Expr|null
     */
    public function getCondition()
    {
        return $this->condition;
    }

    public function hasCondition()
    {
        return isset($this->condition);
    }

    public function clearCondition()
    {
        unset($this->condition);
    }

    /**
     * A condition expression that prevents this binding from granting access
     * unless the expression evaluates to `true`.
     * To learn about IAM Conditions, see
     * https://cloud.google.com/iam/docs/conditions-overview.
     *
     * Generated from protobuf field <code>.google.type.Expr condition = 7;</code>
     * @param \Google\Type\Expr $var
     * @return $this
     */
    public function setCondition($var)
    {
        GPBUtil::checkMessage($var, \Google\Type\Expr::class);
        $this->condition = $var;

        return $this;
    }

}

