-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathaip.md.j2
More file actions
44 lines (33 loc) · 1.52 KB
/
aip.md.j2
File metadata and controls
44 lines (33 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Singleton resources
APIs sometimes need to represent a resource where exactly one instance of the
resource always exists within any given parent. A common use case for this is
for a configuration object, with distinct permissions from the parent resource.
## Guidance
An API **may** define _singleton resources_. A singleton resource **must**
always exist by virtue of the existence of its parent, with one and exactly one
per parent.
```http
GET /v1/publishers/{publisher}/config HTTP/2
Host: library.googleapis.com
Accept: application/json
```
- Singleton resources **must not** have a user-provided or system-generated ID;
their canonical URI includes the name of their parent followed by one
static-segment.
- Example: `publishers/lacroix/config`
- Singleton resources **should** define a `GET` operation, which **must**
correspond to `GET` for individual resources (AIP-131), and **not** `GET` for
collections (AIP-132).
- Singleton resources **should** define a `PATCH` operation, which **must**
correspond to a standard update (AIP-134).
- Singleton resources **must not** define operations to create (AIP-133) or
delete (AIP-135) the resource.
- The service **should** reply with an HTTP 405 (Method Not Allowed) error if
the user sends a `POST` or `DELETE` request.
- Singleton resources **may** define custom methods as appropriate.
## Interface Definitions
{% tab proto %}
{% sample 'singleton.proto', 'rpc GetConfig', 'rpc UpdateConfig' %}
{% tab oas %}
{% sample 'singleton.oas.yaml', 'paths' %}
{% endtabs %}