Reference documentation and code samples for the Google API Common Protos Client class FieldPolicy.
Google API Policy Annotation
This message defines a simple API policy annotation that can be used to
annotate API request and response message fields with applicable policies.
One field may have multiple applicable policies that must all be satisfied
before a request can be processed. This policy annotation is used to
generate the overall policy that will be used for automatic runtime
policy enforcement and documentation generation.
Generated from protobuf messagegoogle.api.FieldPolicy
Namespace
Google \ Api
Methods
__construct
Constructor.
Parameters
Name
Description
data
array
Optional. Data for populating the Message object.
↳ selector
string
Selects one or more request or response message fields to apply thisFieldPolicy. When aFieldPolicyis used in proto annotation, the selector must be left as empty. The service config generator will automatically fill the correct value. When aFieldPolicyis used in service config, the selector must be a comma-separated string with valid request or response field paths, such as "foo.bar" or "foo.bar,foo.baz".
↳ resource_permission
string
Specifies the required permission(s) for the resource referred to by the field. It requires the field contains a valid resource reference, and the request must pass the permission checks to proceed. For example, "resourcemanager.projects.get".
↳ resource_type
string
Specifies the resource type for the resource referred to by the field.
getSelector
Selects one or more request or response message fields to apply thisFieldPolicy.
When aFieldPolicyis used in proto annotation, the selector must
be left as empty. The service config generator will automatically fill
the correct value.
When aFieldPolicyis used in service config, the selector must be a
comma-separated string with valid request or response field paths,
such as "foo.bar" or "foo.bar,foo.baz".
Returns
Type
Description
string
setSelector
Selects one or more request or response message fields to apply thisFieldPolicy.
When aFieldPolicyis used in proto annotation, the selector must
be left as empty. The service config generator will automatically fill
the correct value.
When aFieldPolicyis used in service config, the selector must be a
comma-separated string with valid request or response field paths,
such as "foo.bar" or "foo.bar,foo.baz".
Parameter
Name
Description
var
string
Returns
Type
Description
$this
getResourcePermission
Specifies the required permission(s) for the resource referred to by the
field. It requires the field contains a valid resource reference, and
the request must pass the permission checks to proceed. For example,
"resourcemanager.projects.get".
Returns
Type
Description
string
setResourcePermission
Specifies the required permission(s) for the resource referred to by the
field. It requires the field contains a valid resource reference, and
the request must pass the permission checks to proceed. For example,
"resourcemanager.projects.get".
Parameter
Name
Description
var
string
Returns
Type
Description
$this
getResourceType
Specifies the resource type for the resource referred to by the field.
Returns
Type
Description
string
setResourceType
Specifies the resource type for the resource referred to by the field.
[[["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 API Common Protos Client - Class FieldPolicy (4.12.3)\n\nVersion latestkeyboard_arrow_down\n\n- [4.12.3 (latest)](/php/docs/reference/common-protos/latest/Api.FieldPolicy)\n- [4.12.2](/php/docs/reference/common-protos/4.12.2/Api.FieldPolicy)\n- [4.11.0](/php/docs/reference/common-protos/4.11.0/Api.FieldPolicy)\n- [4.10.0](/php/docs/reference/common-protos/4.10.0/Api.FieldPolicy)\n- [4.9.0](/php/docs/reference/common-protos/4.9.0/Api.FieldPolicy)\n- [4.8.3](/php/docs/reference/common-protos/4.8.3/Api.FieldPolicy) \nReference documentation and code samples for the Google API Common Protos Client class FieldPolicy.\n\nGoogle API Policy Annotation\nThis message defines a simple API policy annotation that can be used to\nannotate API request and response message fields with applicable policies.\n\nOne field may have multiple applicable policies that must all be satisfied\nbefore a request can be processed. This policy annotation is used to\ngenerate the overall policy that will be used for automatic runtime\npolicy enforcement and documentation generation.\n\nGenerated from protobuf message `google.api.FieldPolicy`\n\nNamespace\n---------\n\nGoogle \\\\ Api\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getSelector\n\nSelects one or more request or response message fields to apply this\n`FieldPolicy`.\n\nWhen a `FieldPolicy` is used in proto annotation, the selector must\nbe left as empty. The service config generator will automatically fill\nthe correct value.\nWhen a `FieldPolicy` is used in service config, the selector must be a\ncomma-separated string with valid request or response field paths,\nsuch as \"foo.bar\" or \"foo.bar,foo.baz\".\n\n### setSelector\n\nSelects one or more request or response message fields to apply this\n`FieldPolicy`.\n\nWhen a `FieldPolicy` is used in proto annotation, the selector must\nbe left as empty. The service config generator will automatically fill\nthe correct value.\nWhen a `FieldPolicy` is used in service config, the selector must be a\ncomma-separated string with valid request or response field paths,\nsuch as \"foo.bar\" or \"foo.bar,foo.baz\".\n\n### getResourcePermission\n\nSpecifies the required permission(s) for the resource referred to by the\nfield. It requires the field contains a valid resource reference, and\nthe request must pass the permission checks to proceed. For example,\n\"resourcemanager.projects.get\".\n\n### setResourcePermission\n\nSpecifies the required permission(s) for the resource referred to by the\nfield. It requires the field contains a valid resource reference, and\nthe request must pass the permission checks to proceed. For example,\n\"resourcemanager.projects.get\".\n\n### getResourceType\n\nSpecifies the resource type for the resource referred to by the field.\n\n### setResourceType\n\nSpecifies the resource type for the resource referred to by the field."]]