xref: /aosp_15_r20/external/protobuf/src/google/protobuf/api.proto (revision 1b3f573f81763fcece89efc2b6a5209149e44ab8)
1*1b3f573fSAndroid Build Coastguard Worker// Protocol Buffers - Google's data interchange format
2*1b3f573fSAndroid Build Coastguard Worker// Copyright 2008 Google Inc.  All rights reserved.
3*1b3f573fSAndroid Build Coastguard Worker// https://developers.google.com/protocol-buffers/
4*1b3f573fSAndroid Build Coastguard Worker//
5*1b3f573fSAndroid Build Coastguard Worker// Redistribution and use in source and binary forms, with or without
6*1b3f573fSAndroid Build Coastguard Worker// modification, are permitted provided that the following conditions are
7*1b3f573fSAndroid Build Coastguard Worker// met:
8*1b3f573fSAndroid Build Coastguard Worker//
9*1b3f573fSAndroid Build Coastguard Worker//     * Redistributions of source code must retain the above copyright
10*1b3f573fSAndroid Build Coastguard Worker// notice, this list of conditions and the following disclaimer.
11*1b3f573fSAndroid Build Coastguard Worker//     * Redistributions in binary form must reproduce the above
12*1b3f573fSAndroid Build Coastguard Worker// copyright notice, this list of conditions and the following disclaimer
13*1b3f573fSAndroid Build Coastguard Worker// in the documentation and/or other materials provided with the
14*1b3f573fSAndroid Build Coastguard Worker// distribution.
15*1b3f573fSAndroid Build Coastguard Worker//     * Neither the name of Google Inc. nor the names of its
16*1b3f573fSAndroid Build Coastguard Worker// contributors may be used to endorse or promote products derived from
17*1b3f573fSAndroid Build Coastguard Worker// this software without specific prior written permission.
18*1b3f573fSAndroid Build Coastguard Worker//
19*1b3f573fSAndroid Build Coastguard Worker// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20*1b3f573fSAndroid Build Coastguard Worker// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21*1b3f573fSAndroid Build Coastguard Worker// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22*1b3f573fSAndroid Build Coastguard Worker// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23*1b3f573fSAndroid Build Coastguard Worker// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24*1b3f573fSAndroid Build Coastguard Worker// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25*1b3f573fSAndroid Build Coastguard Worker// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26*1b3f573fSAndroid Build Coastguard Worker// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27*1b3f573fSAndroid Build Coastguard Worker// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28*1b3f573fSAndroid Build Coastguard Worker// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29*1b3f573fSAndroid Build Coastguard Worker// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30*1b3f573fSAndroid Build Coastguard Worker
31*1b3f573fSAndroid Build Coastguard Workersyntax = "proto3";
32*1b3f573fSAndroid Build Coastguard Worker
33*1b3f573fSAndroid Build Coastguard Workerpackage google.protobuf;
34*1b3f573fSAndroid Build Coastguard Worker
35*1b3f573fSAndroid Build Coastguard Workerimport "google/protobuf/source_context.proto";
36*1b3f573fSAndroid Build Coastguard Workerimport "google/protobuf/type.proto";
37*1b3f573fSAndroid Build Coastguard Worker
38*1b3f573fSAndroid Build Coastguard Workeroption csharp_namespace = "Google.Protobuf.WellKnownTypes";
39*1b3f573fSAndroid Build Coastguard Workeroption java_package = "com.google.protobuf";
40*1b3f573fSAndroid Build Coastguard Workeroption java_outer_classname = "ApiProto";
41*1b3f573fSAndroid Build Coastguard Workeroption java_multiple_files = true;
42*1b3f573fSAndroid Build Coastguard Workeroption objc_class_prefix = "GPB";
43*1b3f573fSAndroid Build Coastguard Workeroption go_package = "google.golang.org/protobuf/types/known/apipb";
44*1b3f573fSAndroid Build Coastguard Worker
45*1b3f573fSAndroid Build Coastguard Worker// Api is a light-weight descriptor for an API Interface.
46*1b3f573fSAndroid Build Coastguard Worker//
47*1b3f573fSAndroid Build Coastguard Worker// Interfaces are also described as "protocol buffer services" in some contexts,
48*1b3f573fSAndroid Build Coastguard Worker// such as by the "service" keyword in a .proto file, but they are different
49*1b3f573fSAndroid Build Coastguard Worker// from API Services, which represent a concrete implementation of an interface
50*1b3f573fSAndroid Build Coastguard Worker// as opposed to simply a description of methods and bindings. They are also
51*1b3f573fSAndroid Build Coastguard Worker// sometimes simply referred to as "APIs" in other contexts, such as the name of
52*1b3f573fSAndroid Build Coastguard Worker// this message itself. See https://cloud.google.com/apis/design/glossary for
53*1b3f573fSAndroid Build Coastguard Worker// detailed terminology.
54*1b3f573fSAndroid Build Coastguard Workermessage Api {
55*1b3f573fSAndroid Build Coastguard Worker  // The fully qualified name of this interface, including package name
56*1b3f573fSAndroid Build Coastguard Worker  // followed by the interface's simple name.
57*1b3f573fSAndroid Build Coastguard Worker  string name = 1;
58*1b3f573fSAndroid Build Coastguard Worker
59*1b3f573fSAndroid Build Coastguard Worker  // The methods of this interface, in unspecified order.
60*1b3f573fSAndroid Build Coastguard Worker  repeated Method methods = 2;
61*1b3f573fSAndroid Build Coastguard Worker
62*1b3f573fSAndroid Build Coastguard Worker  // Any metadata attached to the interface.
63*1b3f573fSAndroid Build Coastguard Worker  repeated Option options = 3;
64*1b3f573fSAndroid Build Coastguard Worker
65*1b3f573fSAndroid Build Coastguard Worker  // A version string for this interface. If specified, must have the form
66*1b3f573fSAndroid Build Coastguard Worker  // `major-version.minor-version`, as in `1.10`. If the minor version is
67*1b3f573fSAndroid Build Coastguard Worker  // omitted, it defaults to zero. If the entire version field is empty, the
68*1b3f573fSAndroid Build Coastguard Worker  // major version is derived from the package name, as outlined below. If the
69*1b3f573fSAndroid Build Coastguard Worker  // field is not empty, the version in the package name will be verified to be
70*1b3f573fSAndroid Build Coastguard Worker  // consistent with what is provided here.
71*1b3f573fSAndroid Build Coastguard Worker  //
72*1b3f573fSAndroid Build Coastguard Worker  // The versioning schema uses [semantic
73*1b3f573fSAndroid Build Coastguard Worker  // versioning](http://semver.org) where the major version number
74*1b3f573fSAndroid Build Coastguard Worker  // indicates a breaking change and the minor version an additive,
75*1b3f573fSAndroid Build Coastguard Worker  // non-breaking change. Both version numbers are signals to users
76*1b3f573fSAndroid Build Coastguard Worker  // what to expect from different versions, and should be carefully
77*1b3f573fSAndroid Build Coastguard Worker  // chosen based on the product plan.
78*1b3f573fSAndroid Build Coastguard Worker  //
79*1b3f573fSAndroid Build Coastguard Worker  // The major version is also reflected in the package name of the
80*1b3f573fSAndroid Build Coastguard Worker  // interface, which must end in `v<major-version>`, as in
81*1b3f573fSAndroid Build Coastguard Worker  // `google.feature.v1`. For major versions 0 and 1, the suffix can
82*1b3f573fSAndroid Build Coastguard Worker  // be omitted. Zero major versions must only be used for
83*1b3f573fSAndroid Build Coastguard Worker  // experimental, non-GA interfaces.
84*1b3f573fSAndroid Build Coastguard Worker  //
85*1b3f573fSAndroid Build Coastguard Worker  //
86*1b3f573fSAndroid Build Coastguard Worker  string version = 4;
87*1b3f573fSAndroid Build Coastguard Worker
88*1b3f573fSAndroid Build Coastguard Worker  // Source context for the protocol buffer service represented by this
89*1b3f573fSAndroid Build Coastguard Worker  // message.
90*1b3f573fSAndroid Build Coastguard Worker  SourceContext source_context = 5;
91*1b3f573fSAndroid Build Coastguard Worker
92*1b3f573fSAndroid Build Coastguard Worker  // Included interfaces. See [Mixin][].
93*1b3f573fSAndroid Build Coastguard Worker  repeated Mixin mixins = 6;
94*1b3f573fSAndroid Build Coastguard Worker
95*1b3f573fSAndroid Build Coastguard Worker  // The source syntax of the service.
96*1b3f573fSAndroid Build Coastguard Worker  Syntax syntax = 7;
97*1b3f573fSAndroid Build Coastguard Worker}
98*1b3f573fSAndroid Build Coastguard Worker
99*1b3f573fSAndroid Build Coastguard Worker// Method represents a method of an API interface.
100*1b3f573fSAndroid Build Coastguard Workermessage Method {
101*1b3f573fSAndroid Build Coastguard Worker  // The simple name of this method.
102*1b3f573fSAndroid Build Coastguard Worker  string name = 1;
103*1b3f573fSAndroid Build Coastguard Worker
104*1b3f573fSAndroid Build Coastguard Worker  // A URL of the input message type.
105*1b3f573fSAndroid Build Coastguard Worker  string request_type_url = 2;
106*1b3f573fSAndroid Build Coastguard Worker
107*1b3f573fSAndroid Build Coastguard Worker  // If true, the request is streamed.
108*1b3f573fSAndroid Build Coastguard Worker  bool request_streaming = 3;
109*1b3f573fSAndroid Build Coastguard Worker
110*1b3f573fSAndroid Build Coastguard Worker  // The URL of the output message type.
111*1b3f573fSAndroid Build Coastguard Worker  string response_type_url = 4;
112*1b3f573fSAndroid Build Coastguard Worker
113*1b3f573fSAndroid Build Coastguard Worker  // If true, the response is streamed.
114*1b3f573fSAndroid Build Coastguard Worker  bool response_streaming = 5;
115*1b3f573fSAndroid Build Coastguard Worker
116*1b3f573fSAndroid Build Coastguard Worker  // Any metadata attached to the method.
117*1b3f573fSAndroid Build Coastguard Worker  repeated Option options = 6;
118*1b3f573fSAndroid Build Coastguard Worker
119*1b3f573fSAndroid Build Coastguard Worker  // The source syntax of this method.
120*1b3f573fSAndroid Build Coastguard Worker  Syntax syntax = 7;
121*1b3f573fSAndroid Build Coastguard Worker}
122*1b3f573fSAndroid Build Coastguard Worker
123*1b3f573fSAndroid Build Coastguard Worker// Declares an API Interface to be included in this interface. The including
124*1b3f573fSAndroid Build Coastguard Worker// interface must redeclare all the methods from the included interface, but
125*1b3f573fSAndroid Build Coastguard Worker// documentation and options are inherited as follows:
126*1b3f573fSAndroid Build Coastguard Worker//
127*1b3f573fSAndroid Build Coastguard Worker// - If after comment and whitespace stripping, the documentation
128*1b3f573fSAndroid Build Coastguard Worker//   string of the redeclared method is empty, it will be inherited
129*1b3f573fSAndroid Build Coastguard Worker//   from the original method.
130*1b3f573fSAndroid Build Coastguard Worker//
131*1b3f573fSAndroid Build Coastguard Worker// - Each annotation belonging to the service config (http,
132*1b3f573fSAndroid Build Coastguard Worker//   visibility) which is not set in the redeclared method will be
133*1b3f573fSAndroid Build Coastguard Worker//   inherited.
134*1b3f573fSAndroid Build Coastguard Worker//
135*1b3f573fSAndroid Build Coastguard Worker// - If an http annotation is inherited, the path pattern will be
136*1b3f573fSAndroid Build Coastguard Worker//   modified as follows. Any version prefix will be replaced by the
137*1b3f573fSAndroid Build Coastguard Worker//   version of the including interface plus the [root][] path if
138*1b3f573fSAndroid Build Coastguard Worker//   specified.
139*1b3f573fSAndroid Build Coastguard Worker//
140*1b3f573fSAndroid Build Coastguard Worker// Example of a simple mixin:
141*1b3f573fSAndroid Build Coastguard Worker//
142*1b3f573fSAndroid Build Coastguard Worker//     package google.acl.v1;
143*1b3f573fSAndroid Build Coastguard Worker//     service AccessControl {
144*1b3f573fSAndroid Build Coastguard Worker//       // Get the underlying ACL object.
145*1b3f573fSAndroid Build Coastguard Worker//       rpc GetAcl(GetAclRequest) returns (Acl) {
146*1b3f573fSAndroid Build Coastguard Worker//         option (google.api.http).get = "/v1/{resource=**}:getAcl";
147*1b3f573fSAndroid Build Coastguard Worker//       }
148*1b3f573fSAndroid Build Coastguard Worker//     }
149*1b3f573fSAndroid Build Coastguard Worker//
150*1b3f573fSAndroid Build Coastguard Worker//     package google.storage.v2;
151*1b3f573fSAndroid Build Coastguard Worker//     service Storage {
152*1b3f573fSAndroid Build Coastguard Worker//       rpc GetAcl(GetAclRequest) returns (Acl);
153*1b3f573fSAndroid Build Coastguard Worker//
154*1b3f573fSAndroid Build Coastguard Worker//       // Get a data record.
155*1b3f573fSAndroid Build Coastguard Worker//       rpc GetData(GetDataRequest) returns (Data) {
156*1b3f573fSAndroid Build Coastguard Worker//         option (google.api.http).get = "/v2/{resource=**}";
157*1b3f573fSAndroid Build Coastguard Worker//       }
158*1b3f573fSAndroid Build Coastguard Worker//     }
159*1b3f573fSAndroid Build Coastguard Worker//
160*1b3f573fSAndroid Build Coastguard Worker// Example of a mixin configuration:
161*1b3f573fSAndroid Build Coastguard Worker//
162*1b3f573fSAndroid Build Coastguard Worker//     apis:
163*1b3f573fSAndroid Build Coastguard Worker//     - name: google.storage.v2.Storage
164*1b3f573fSAndroid Build Coastguard Worker//       mixins:
165*1b3f573fSAndroid Build Coastguard Worker//       - name: google.acl.v1.AccessControl
166*1b3f573fSAndroid Build Coastguard Worker//
167*1b3f573fSAndroid Build Coastguard Worker// The mixin construct implies that all methods in `AccessControl` are
168*1b3f573fSAndroid Build Coastguard Worker// also declared with same name and request/response types in
169*1b3f573fSAndroid Build Coastguard Worker// `Storage`. A documentation generator or annotation processor will
170*1b3f573fSAndroid Build Coastguard Worker// see the effective `Storage.GetAcl` method after inheriting
171*1b3f573fSAndroid Build Coastguard Worker// documentation and annotations as follows:
172*1b3f573fSAndroid Build Coastguard Worker//
173*1b3f573fSAndroid Build Coastguard Worker//     service Storage {
174*1b3f573fSAndroid Build Coastguard Worker//       // Get the underlying ACL object.
175*1b3f573fSAndroid Build Coastguard Worker//       rpc GetAcl(GetAclRequest) returns (Acl) {
176*1b3f573fSAndroid Build Coastguard Worker//         option (google.api.http).get = "/v2/{resource=**}:getAcl";
177*1b3f573fSAndroid Build Coastguard Worker//       }
178*1b3f573fSAndroid Build Coastguard Worker//       ...
179*1b3f573fSAndroid Build Coastguard Worker//     }
180*1b3f573fSAndroid Build Coastguard Worker//
181*1b3f573fSAndroid Build Coastguard Worker// Note how the version in the path pattern changed from `v1` to `v2`.
182*1b3f573fSAndroid Build Coastguard Worker//
183*1b3f573fSAndroid Build Coastguard Worker// If the `root` field in the mixin is specified, it should be a
184*1b3f573fSAndroid Build Coastguard Worker// relative path under which inherited HTTP paths are placed. Example:
185*1b3f573fSAndroid Build Coastguard Worker//
186*1b3f573fSAndroid Build Coastguard Worker//     apis:
187*1b3f573fSAndroid Build Coastguard Worker//     - name: google.storage.v2.Storage
188*1b3f573fSAndroid Build Coastguard Worker//       mixins:
189*1b3f573fSAndroid Build Coastguard Worker//       - name: google.acl.v1.AccessControl
190*1b3f573fSAndroid Build Coastguard Worker//         root: acls
191*1b3f573fSAndroid Build Coastguard Worker//
192*1b3f573fSAndroid Build Coastguard Worker// This implies the following inherited HTTP annotation:
193*1b3f573fSAndroid Build Coastguard Worker//
194*1b3f573fSAndroid Build Coastguard Worker//     service Storage {
195*1b3f573fSAndroid Build Coastguard Worker//       // Get the underlying ACL object.
196*1b3f573fSAndroid Build Coastguard Worker//       rpc GetAcl(GetAclRequest) returns (Acl) {
197*1b3f573fSAndroid Build Coastguard Worker//         option (google.api.http).get = "/v2/acls/{resource=**}:getAcl";
198*1b3f573fSAndroid Build Coastguard Worker//       }
199*1b3f573fSAndroid Build Coastguard Worker//       ...
200*1b3f573fSAndroid Build Coastguard Worker//     }
201*1b3f573fSAndroid Build Coastguard Workermessage Mixin {
202*1b3f573fSAndroid Build Coastguard Worker  // The fully qualified name of the interface which is included.
203*1b3f573fSAndroid Build Coastguard Worker  string name = 1;
204*1b3f573fSAndroid Build Coastguard Worker
205*1b3f573fSAndroid Build Coastguard Worker  // If non-empty specifies a path under which inherited HTTP paths
206*1b3f573fSAndroid Build Coastguard Worker  // are rooted.
207*1b3f573fSAndroid Build Coastguard Worker  string root = 2;
208*1b3f573fSAndroid Build Coastguard Worker}
209