@@ -50,6 +50,20 @@ rpc CreateTopic(CreateTopicRequest) {
5050}
5151```
5252
53+ The value of the field ` field ` ** must** be one of the following:
54+ 1 . a name of a field in the top-level of the request message
55+ 1 . a dot-separated path of field names leading to a field in a sub-message of
56+ the request message e.g. ` "book.author.name" ` where ` book ` is a message field in
57+ the request message, ` author ` is a message field in the ` book ` message, and
58+ ` name ` is a ` string ` field in the ` author ` message
59+
60+ The _ actual field_ specified in the field ` field ` ** must** have the following
61+ characteristics:
62+ - it is type ` string `
63+ - it either has a path-like value format resembling a resource name or contains
64+ an unstructured value that would be appropriate as an individual path segment
65+ e.g. a ` project_id ` .
66+
5367** Note:** An empty ` google.api.routing ` annotation is acceptable. It means that no
5468routing headers should be generated for the RPC, when they otherwise would be
5569e.g. implicitly from the ` google.api.http ` annotation.
@@ -89,7 +103,9 @@ routing_parameters {
89103 path_template: "{parent=**}"
90104}
91105```
92- NB: an omitted ` path_template ` field does not indicate that key-value pairs with empty values can be sent. It's merely a shorthand.
106+
107+ ** Note:** An omitted ` path_template ` field does not indicate that key-value
108+ pairs with empty values can be sent. It's merely a shorthand.
93109
94110When the user supplies an instance of ` CreateTopicRequest ` to the method, the
95111client library ** must** match all the routing parameters in the order specified
@@ -154,6 +170,54 @@ If none of the routing parameters matched their respective fields, the routing h
154170Much like URL parameters, if there is more than one key-value pair to be sent, the ` & `
155171character is used as the separator.
156172
173+ ### ` path_template ` syntax
174+
175+ As seen in the above examples, the ` path_template ` can use a variety of symbols
176+ that are interpreted by code generators during conversion to regular expressions
177+ or non-regular expression matcher implementations. The ` path_template ` consists
178+ of segments delimited by the segment delimiter. The syntax for ` path_template `
179+ is as follows:
180+
181+ - The only acceptable segment delimiter is ` / ` .
182+ - The last symbol in a ` path_template ` ** may** be a delimiter - it will be
183+ ignored.
184+ - A segment ** must** be of one of the following types:
185+ - ` * ` : A single-segment wildcard. Corresponds to 1 or more non-` / ` symbols.
186+ The regex describing it is ` [^/]+ ` .
187+ - A Single-segment wildcard typically represents a resource ID.
188+ - ` ** ` : A multi-segment wildcard. Corresponds to 0 or more segments.
189+ - A multi-segment wildcard ** must** only appear as the final segment or
190+ make up the entire ` path_template ` .
191+ - In a multi-segment ` path_template ` , a multi-segment wildcard ** must**
192+ appear immediately following a segment delimiter. This delimiter is
193+ consumed while matching so a ` path_template ` like ` foo/** ` matches all of
194+ the following: ` foo ` , ` foo/ ` , ` foo/bar/baz ` .
195+ - In a multi-segment ` path_template ` , when used as the last segment the
196+ regex describing it is ` ([:/].*)? ` .
197+ - When used as the entire ` path_template ` , the regex describing it is ` .* ` .
198+ - Segment delimiters are consumed while matching, including any preceding
199+ delimiter.
200+ - ` LITERAL ` : A literal segment. A literal segment can contain any
201+ alphanumeric symbol.
202+ - A literal segment ** must not** contain a symbol reserved in this syntax.
203+ - Literal segments typically represent a resource collection ID or base
204+ path.
205+ - ` {} ` : A variable segment. This matches part of the path as specified by its
206+ template.
207+ - A variable segment can be either of the following:
208+ - ` {key} ` , where ` key ` is the name to be used in the key-value pair of the
209+ header
210+ - ` {key=template} ` , where the ` template ` is the segment(s) (expressed in
211+ this ` path_template ` syntax) to extract as the value paired with ` key `
212+ - A variable segment of just ` {key} ` defaults to a template of ` * ` which
213+ matches 1 or more non-` / ` symbols.
214+ - While ` {key=*} ` is technicaly valid syntax, the simpler syntax of
215+ ` {key} ` ** should** be used.
216+ - A variable segment ** must not** contain other variable segments. This
217+ syntax is not recursive.
218+ - A segment ** must not** represent a complex resource ID as described in
219+ [ AIP-4231] [ ] . A Generator ** should** emit an error in this case.
220+
157221## Implicit Routing Headers (` google.api.http ` )
158222
159223** Note:** For an RPC annotated with the [ ` google.api.routing ` ] [ routing ] annotation,
@@ -206,8 +270,10 @@ character is used as the separator.
206270[ http ] : https://github.com/googleapis/googleapis/blob/master/google/api/http.proto
207271[ routing ] : https://github.com/googleapis/googleapis/blob/master/google/api/routing.proto
208272[ rfc 6570 §3.2.2 ] : https://tools.ietf.org/html/rfc6570#section-3.2.2
273+ [ AIP-4231 ] : ./4231.md#complex-resource-id-path-segments
209274
210275## Changelog
276+ - ** 2023-07-07** : Include ` path_template ` syntax.
211277- ** 2022-07-13** : Updated to include the new ` google.api.routing ` annotation.
212278- ** 2020-04-21** : Explicitly parse path variables missing a trailing segment.
213279- ** 2019-11-27** : Include ` additional_bindings ` as a request parameter source.
0 commit comments