Reference documentation and code samples for the Google API Common Protos Client class Context.
Contextdefines which contexts an API requests.
Example:
context:
rules:
selector: "*"
requested:
google.rpc.context.ProjectContext
google.rpc.context.OriginContext
The above specifies that all methods in the API requestgoogle.rpc.context.ProjectContextandgoogle.rpc.context.OriginContext.
Available context types are defined in packagegoogle.rpc.context.
This also provides mechanism to allowlist any protobuf message extension that
can be sent in grpc metadata using “x-goog-ext-<extension_id>-bin” and
“x-goog-ext-<extension_id>-jspb” format. For example, list any service
specific protobuf types that can appear in grpc metadata as follows in your
yaml file:
Example:
context:
rules:
[[["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 Context (4.12.3)\n\nVersion latestkeyboard_arrow_down\n\n- [4.12.3 (latest)](/php/docs/reference/common-protos/latest/Api.Context)\n- [4.12.2](/php/docs/reference/common-protos/4.12.2/Api.Context)\n- [4.11.0](/php/docs/reference/common-protos/4.11.0/Api.Context)\n- [4.10.0](/php/docs/reference/common-protos/4.10.0/Api.Context)\n- [4.9.0](/php/docs/reference/common-protos/4.9.0/Api.Context)\n- [4.8.3](/php/docs/reference/common-protos/4.8.3/Api.Context) \nReference documentation and code samples for the Google API Common Protos Client class Context.\n\n`Context` defines which contexts an API requests.\n\nExample:\ncontext:\nrules:\n\n- selector: \"\\*\" requested:\n - google.rpc.context.ProjectContext\n - google.rpc.context.OriginContext The above specifies that all methods in the API request `google.rpc.context.ProjectContext` and `google.rpc.context.OriginContext`. Available context types are defined in package `google.rpc.context`. This also provides mechanism to allowlist any protobuf message extension that can be sent in grpc metadata using \"x-goog-ext-\\\u003cextension_id\\\u003e-bin\" and \"x-goog-ext-\\\u003cextension_id\\\u003e-jspb\" format. For example, list any service specific protobuf types that can appear in grpc metadata as follows in your yaml file: Example: context: rules:\n - selector: \"google.example.library.v1.LibraryService.CreateBook\" allowed_request_extensions:\n - google.foo.v1.NewExtension allowed_response_extensions:\n - google.foo.v1.NewExtension You can also specify extension ID instead of fully qualified extension name here.\n\nGenerated from protobuf message `google.api.Context`\n\nNamespace\n---------\n\nGoogle \\\\ Api\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getRules\n\nA list of RPC context rules that apply to individual API methods.\n\n**NOTE:** All service configuration rules follow \"last one wins\" order.\n\n### setRules\n\nA list of RPC context rules that apply to individual API methods.\n\n**NOTE:** All service configuration rules follow \"last one wins\" order."]]