@@ -53,20 +53,64 @@ rpc UpdateConfig(UpdateConfigRequest) returns (Config) {
5353 their [ resource name] [ aip-122 ] includes the name of their parent followed by
5454 one static-segment.
5555 - Example: ` users/1234/config `
56- - Singleton resources ** must not** define the [ ` Create ` ] [ aip-133 ] ,
57- [ ` List ` ] [ aip-132 ] , or [ ` Delete ` ] [ aip-135 ] standard methods. The singleton is
58- implicitly created or deleted when its parent is created or deleted.
56+ - Singleton resources are always singular.
57+ - Example: ` users/1234/thing `
58+ - Singleton resources ** may** parent other resources.
59+ - Singleton resources ** must not** define the [ ` Create ` ] [ aip-133 ] or
60+ [ ` Delete ` ] [ aip-135 ] standard methods. The singleton is implicitly created or
61+ deleted when its parent is created or deleted.
5962- Singleton resources ** should** define the [ ` Get ` ] [ aip-131 ] and
6063 [ ` Update ` ] [ aip-134 ] methods, and ** may** define custom methods as
6164 appropriate.
6265 - However, singleton resources ** must not** define the [ ` Update ` ] [ aip-134 ]
6366 method if all fields on the resource are [ output only] [ aip-203 ] .
64- - Singleton resources are always singular.
65- - Example: ` users/1234/thing `
66- - Singleton resources ** may** parent other resources.
67+ - Singleton resources ** may** define the [ ` List ` ] [ aip-132 ] method, but ** must**
68+ implement it according to [ AIP-159] [ aip-159 ] . See the example below.
69+ - The trailing segment in the path pattern that typically represents the
70+ collection ** should** be the ` plural ` form of the Singleton resource e.g.
71+ ` /v1/{parent=users/*}/configs ` .
72+ - If a parent resource ID is provided instead of the hyphen ` - ` as per
73+ AIP-159, then the service ** should** return a collection of one Singleton
74+ resource corresponding to the specified parent resource.
75+
76+ ``` proto
77+ rpc ListConfigs(ListConfigsRequest) returns (ListConfigsResponse) {
78+ option (google.api.http) = {
79+ get: "/v1/{parent=users/*}/configs"
80+ };
81+ }
82+
83+ message ListConfigsRequest {
84+ // To list all configs, use `-` as the user id.
85+ // Formats:
86+ // * `users/-`
87+ // * `users/{user}`
88+ //
89+ // Note: Specifying an actual user id will return a collection of one config.
90+ // Use GetConfig instead.
91+ string parent = 1 [
92+ (google.api.resource_reference).child_type = "api.googleapis.com/Config"];
93+
94+ // other standard pagination fields...
95+ }
96+ ```
97+ ## Rationale
98+
99+ ### Support for Standard List
100+
101+ While Singleton resources are not directly part of a collection themselves, they
102+ can be viewed as part of their parent's collection. The one-to-one relationship
103+ of parent-to-singleton means that for every one parent there is one singleton
104+ instance, naturally enabling some collection-based methods when combined with
105+ the pattern of [ Reading Across Collections] [ aip-159 ] . The Singleton can present
106+ as a collection to the API consumer as it is indirectly one based on its parent.
107+ Furthermore, presenting the Singleton resource as a pseudo-collection in such
108+ methods enables future expansion to a real collection, should a Singleton be
109+ found lacking.
67110
68111## Changelog
69112
113+ - ** 2023-08-10:** Add Standard ` List ` support.
70114- ** 2023-07-26:** Clarified that read-only singletons should not have ` Update ` .
71115- ** 2021-11-02:** Added an example message and state parent eligibility.
72116- ** 2021-01-14:** Changed example from ` settings ` to ` config ` for clarity.
@@ -77,4 +121,5 @@ rpc UpdateConfig(UpdateConfigRequest) returns (Config) {
77121[ aip-133 ] : ./0133.md
78122[ aip-134 ] : ./0134.md
79123[ aip-135 ] : ./0135.md
124+ [ aip-159 ] : ./0159.md
80125[ aip-203 ] : ./0203.md#output-only
0 commit comments