A condition which determines whether this rule is used in the evaluation of the policy. When set, theexpressionfield in the `Expr' must include from 1 to 10 subexpressions, joined by the "||" or "&&" operators. Each subexpression must be of the form "resource.matchTag('<ORG_ID>/tag_key_short_name, 'tag_value_short_name')". or "resource.matchTagId('tagKeys/key_id', 'tagValues/value_id')". where key_name and value_name are the resource names for Label Keys and Values. These names are available from the Tag Manager Service. An example expression is: "resource.matchTag('123456789/environment, 'prod')". or "resource.matchTagId('tagKeys/123', 'tagValues/456')".
Optional. Required for managed constraints if parameters are defined. Passes parameter values when policy enforcement is enabled. Ensure that parameter value types match those defined in the constraint definition. For example: { "allowedLocations" : ["us-east1", "us-west1"], "allowAll" : true }
getValues
List of values to be used for this policy rule. This field can be set
only in policies for list constraints.
Setting this to true means that all values are allowed. This field can
be set only in policies for list constraints.
Returns
Type
Description
bool
hasAllowAll
setAllowAll
Setting this to true means that all values are allowed. This field can
be set only in policies for list constraints.
Parameter
Name
Description
var
bool
Returns
Type
Description
$this
getDenyAll
Setting this to true means that all values are denied. This field can
be set only in policies for list constraints.
Returns
Type
Description
bool
hasDenyAll
setDenyAll
Setting this to true means that all values are denied. This field can
be set only in policies for list constraints.
Parameter
Name
Description
var
bool
Returns
Type
Description
$this
getEnforce
Iftrue, then the policy is enforced. Iffalse, then any
configuration is acceptable.
This field can be set only in policies for boolean constraints.
Returns
Type
Description
bool
hasEnforce
setEnforce
Iftrue, then the policy is enforced. Iffalse, then any
configuration is acceptable.
This field can be set only in policies for boolean constraints.
Parameter
Name
Description
var
bool
Returns
Type
Description
$this
getCondition
A condition which determines whether this rule is used
in the evaluation of the policy. When set, theexpressionfield in
the `Expr' must include from 1 to 10 subexpressions, joined by the "||"
or "&&" operators. Each subexpression must be of the form
"resource.matchTag('<ORG_ID>/tag_key_short_name,
'tag_value_short_name')". or "resource.matchTagId('tagKeys/key_id',
'tagValues/value_id')". where key_name and value_name are the resource
names for Label Keys and Values. These names are available from the Tag
Manager Service. An example expression is:
"resource.matchTag('123456789/environment,
'prod')". or "resource.matchTagId('tagKeys/123',
'tagValues/456')".
A condition which determines whether this rule is used
in the evaluation of the policy. When set, theexpressionfield in
the `Expr' must include from 1 to 10 subexpressions, joined by the "||"
or "&&" operators. Each subexpression must be of the form
"resource.matchTag('<ORG_ID>/tag_key_short_name,
'tag_value_short_name')". or "resource.matchTagId('tagKeys/key_id',
'tagValues/value_id')". where key_name and value_name are the resource
names for Label Keys and Values. These names are available from the Tag
Manager Service. An example expression is:
"resource.matchTag('123456789/environment,
'prod')". or "resource.matchTagId('tagKeys/123',
'tagValues/456')".
Optional. Required for managed constraints if parameters are defined.
Passes parameter values when policy enforcement is enabled. Ensure that
parameter value types match those defined in the constraint definition.
For example:
{
"allowedLocations" : ["us-east1", "us-west1"],
"allowAll" : true
}
Optional. Required for managed constraints if parameters are defined.
Passes parameter values when policy enforcement is enabled. Ensure that
parameter value types match those defined in the constraint definition.
For example:
{
"allowedLocations" : ["us-east1", "us-west1"],
"allowAll" : true
}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Google Cloud Org Policy V2 Client - Class PolicyRule (1.2.2)\n\nVersion latestkeyboard_arrow_down\n\n- [1.2.2 (latest)](/php/docs/reference/cloud-org-policy/latest/V2.PolicySpec.PolicyRule)\n- [1.2.1](/php/docs/reference/cloud-org-policy/1.2.1/V2.PolicySpec.PolicyRule)\n- [1.1.3](/php/docs/reference/cloud-org-policy/1.1.3/V2.PolicySpec.PolicyRule)\n- [1.0.0](/php/docs/reference/cloud-org-policy/1.0.0/V2.PolicySpec.PolicyRule)\n- [0.7.0](/php/docs/reference/cloud-org-policy/0.7.0/V2.PolicySpec.PolicyRule)\n- [0.6.5](/php/docs/reference/cloud-org-policy/0.6.5/V2.PolicySpec.PolicyRule)\n- [0.5.3](/php/docs/reference/cloud-org-policy/0.5.3/V2.PolicySpec.PolicyRule)\n- [0.4.2](/php/docs/reference/cloud-org-policy/0.4.2/V2.PolicySpec.PolicyRule)\n- [0.3.7](/php/docs/reference/cloud-org-policy/0.3.7/V2.PolicySpec.PolicyRule) \nReference documentation and code samples for the Google Cloud Org Policy V2 Client class PolicyRule.\n\nA rule used to express this policy.\n\nGenerated from protobuf message `google.cloud.orgpolicy.v2.PolicySpec.PolicyRule`\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ OrgPolicy \\\\ V2 \\\\ PolicySpec\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getValues\n\nList of values to be used for this policy rule. This field can be set\nonly in policies for list constraints.\n\n### hasValues\n\n### setValues\n\nList of values to be used for this policy rule. This field can be set\nonly in policies for list constraints.\n\n### getAllowAll\n\nSetting this to true means that all values are allowed. This field can\nbe set only in policies for list constraints.\n\n### hasAllowAll\n\n### setAllowAll\n\nSetting this to true means that all values are allowed. This field can\nbe set only in policies for list constraints.\n\n### getDenyAll\n\nSetting this to true means that all values are denied. This field can\nbe set only in policies for list constraints.\n\n### hasDenyAll\n\n### setDenyAll\n\nSetting this to true means that all values are denied. This field can\nbe set only in policies for list constraints.\n\n### getEnforce\n\nIf `true`, then the policy is enforced. If `false`, then any\nconfiguration is acceptable.\n\nThis field can be set only in policies for boolean constraints.\n\n### hasEnforce\n\n### setEnforce\n\nIf `true`, then the policy is enforced. If `false`, then any\nconfiguration is acceptable.\n\nThis field can be set only in policies for boolean constraints.\n\n### getCondition\n\nA condition which determines whether this rule is used\nin the evaluation of the policy. When set, the `expression` field in\nthe \\`Expr' must include from 1 to 10 subexpressions, joined by the \"\\|\\|\"\nor \"\\&\\&\" operators. Each subexpression must be of the form\n\"resource.matchTag('\\\u003cORG_ID\\\u003e/tag_key_short_name,\n'tag_value_short_name')\". or \"resource.matchTagId('tagKeys/key_id',\n'tagValues/value_id')\". where key_name and value_name are the resource\nnames for Label Keys and Values. These names are available from the Tag\nManager Service. An example expression is:\n\"resource.matchTag('123456789/environment,\n'prod')\". or \"resource.matchTagId('tagKeys/123',\n'tagValues/456')\".\n\n### hasCondition\n\n### clearCondition\n\n### setCondition\n\nA condition which determines whether this rule is used\nin the evaluation of the policy. When set, the `expression` field in\nthe \\`Expr' must include from 1 to 10 subexpressions, joined by the \"\\|\\|\"\nor \"\\&\\&\" operators. Each subexpression must be of the form\n\"resource.matchTag('\\\u003cORG_ID\\\u003e/tag_key_short_name,\n'tag_value_short_name')\". or \"resource.matchTagId('tagKeys/key_id',\n'tagValues/value_id')\". where key_name and value_name are the resource\nnames for Label Keys and Values. These names are available from the Tag\nManager Service. An example expression is:\n\"resource.matchTag('123456789/environment,\n'prod')\". or \"resource.matchTagId('tagKeys/123',\n'tagValues/456')\".\n\n### getParameters\n\nOptional. Required for managed constraints if parameters are defined.\n\nPasses parameter values when policy enforcement is enabled. Ensure that\nparameter value types match those defined in the constraint definition.\nFor example:\n{\n\"allowedLocations\" : \\[\"us-east1\", \"us-west1\"\\],\n\"allowAll\" : true\n}\n\n### hasParameters\n\n### clearParameters\n\n### setParameters\n\nOptional. Required for managed constraints if parameters are defined.\n\nPasses parameter values when policy enforcement is enabled. Ensure that\nparameter value types match those defined in the constraint definition.\nFor example:\n{\n\"allowedLocations\" : \\[\"us-east1\", \"us-west1\"\\],\n\"allowAll\" : true\n}\n\n### getKind"]]