@@ -44,42 +44,41 @@ document this behavior for clients.
4444
4545## Vocabulary
4646
47- ### Required
47+ ### Immutable
4848
49- The use of ` REQUIRED ` indicates that the field ** must** be present (and set to
50- a non-empty value) on the request or resource.
49+ The use of ` IMMUTABLE ` indicates that a field on a resource cannot be changed
50+ after it's creation. This can apply to either fields that are input or outputs,
51+ required or optional.
5152
52- A field ** should** only be described as required if _ either_ :
53+ When a service receives an immutable field in an update request (or similar),
54+ even if included in the update mask, the service ** should** ignore the field if
55+ the value matches, but ** should** error with ` INVALID_ARGUMENT ` if a change is
56+ requested.
5357
54- - It is a field on a resource that a user provides somewhere as input. In this
55- case, the resource is only valid if a "truthy" value is _ stored_ .
56- - When [ creating] [ aip-133 ] the resource, a value ** must** be provided for the
57- field on the create request.
58- - When [ updating] [ aip-134 ] the resource, the user ** may** omit the field
59- provided that the field is also absent from the field mask, indicating no
60- change to the field (otherwise it ** must** be provided).
61- - It is a field on a request message (a message that is an argument to an RPC,
62- with a name usually ending in ` Request ` ). In this case, a value ** must** be
63- provided as part of the request, and failure to do so ** must** cause an error
64- (usually ` INVALID_ARGUMENT ` ).
58+ Potential use cases for immutable fields (this is not an exhaustive list) are:
6559
66- We define the term "truthy" above as follows:
60+ - Names or IDs which are set on creation and then used as a primary key.
6761
68- - For primitives, values other than ` 0 ` , ` 0.0 ` , empty string/bytes, and ` false `
69- - For repeated fields maps, values with at least one entry
70- - For messages, any message with at least one "truthy" field.
62+ ** Note:** Fields which are "conditionally immutable" ** must not** be given the
63+ immutable annotation.
7164
72- Fields ** should not ** be described as required in order to signify:
65+ ### Input only
7366
74- - A field which will always be present in a response.
75- - A field which is conditionally required in some situations.
76- - A field on any message (including messages that are resources) which is never
77- used as user input.
67+ The use of ` INPUT_ONLY ` indicates that the field is provided in requests and
68+ that the corresponding field will not be included in output.
7869
79- ** Note:** In most cases, empty values (such as ` false ` for booleans, ` 0 ` for
80- integers, or the unspecified value for enums) are indistinguishable from unset
81- values, and therefore setting a required field to a falsy value yields an
82- error. A corollary to this is that a required boolean must be set to ` true ` .
70+ Additionally, a field ** should** only be described as input only if it is a
71+ field in a resource message or a field of a message included within a resource
72+ message. Notably, fields in request messages (a message which only ever acts as
73+ an argument to an RPC, with a name usually ending in ` Request ` ) ** should not**
74+ be described as input only because this is already implied.
75+
76+ Potential use cases for input only fields (this is not an exhaustive list) are:
77+
78+ - The ` ttl ` field as described in AIP-214.
79+
80+ ** Warning:** Input only fields are rare and should be considered carefully
81+ before use.
8382
8483### Optional
8584
@@ -112,41 +111,42 @@ are:
112111- Derived or structured information based on original user input.
113112- Properties of a resource assigned by the service which can not be altered.
114113
115- ### Input only
116-
117- The use of ` INPUT_ONLY ` indicates that the field is provided in requests and
118- that the corresponding field will not be included in output.
119-
120- Additionally, a field ** should** only be described as input only if it is a
121- field in a resource message or a field of a message included within a resource
122- message. Notably, fields in request messages (a message which only ever acts as
123- an argument to an RPC, with a name usually ending in ` Request ` ) ** should not**
124- be described as input only because this is already implied.
125-
126- Potential use cases for input only fields (this is not an exhaustive list) are:
114+ ### Required
127115
128- - The ` ttl ` field as described in AIP-214.
116+ The use of ` REQUIRED ` indicates that the field ** must** be present (and set to
117+ a non-empty value) on the request or resource.
129118
130- ** Warning:** Input only fields are rare and should be considered carefully
131- before use.
119+ A field ** should** only be described as required if _ either_ :
132120
133- ### Immutable
121+ - It is a field on a resource that a user provides somewhere as input. In this
122+ case, the resource is only valid if a "truthy" value is _ stored_ .
123+ - When [ creating] [ aip-133 ] the resource, a value ** must** be provided for the
124+ field on the create request.
125+ - When [ updating] [ aip-134 ] the resource, the user ** may** omit the field
126+ provided that the field is also absent from the field mask, indicating no
127+ change to the field (otherwise it ** must** be provided).
128+ - It is a field on a request message (a message that is an argument to an RPC,
129+ with a name usually ending in ` Request ` ). In this case, a value ** must** be
130+ provided as part of the request, and failure to do so ** must** cause an error
131+ (usually ` INVALID_ARGUMENT ` ).
134132
135- The use of ` IMMUTABLE ` indicates that a field on a resource cannot be changed
136- after it's creation. This can apply to either fields that are input or outputs,
137- required or optional.
133+ We define the term "truthy" above as follows:
138134
139- When a service receives an immutable field in an update request (or similar),
140- even if included in the update mask, the service ** should** ignore the field if
141- the value matches, but ** should** error with ` INVALID_ARGUMENT ` if a change is
142- requested.
135+ - For primitives, values other than ` 0 ` , ` 0.0 ` , empty string/bytes, and ` false `
136+ - For repeated fields maps, values with at least one entry
137+ - For messages, any message with at least one "truthy" field.
143138
144- Potential use cases for immutable fields (this is not an exhaustive list) are :
139+ Fields ** should not ** be described as required in order to signify :
145140
146- - Names or IDs which are set on creation and then used as a primary key.
141+ - A field which will always be present in a response.
142+ - A field which is conditionally required in some situations.
143+ - A field on any message (including messages that are resources) which is never
144+ used as user input.
147145
148- ** Note:** Fields which are "conditionally immutable" ** must not** be given the
149- immutable annotation.
146+ ** Note:** In most cases, empty values (such as ` false ` for booleans, ` 0 ` for
147+ integers, or the unspecified value for enums) are indistinguishable from unset
148+ values, and therefore setting a required field to a falsy value yields an
149+ error. A corollary to this is that a required boolean must be set to ` true ` .
150150
151151### Unordered List
152152
0 commit comments