xref: /aosp_15_r20/external/googleapis/google/rpc/code.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1*d5c09012SAndroid Build Coastguard Worker// Copyright 2022 Google LLC
2*d5c09012SAndroid Build Coastguard Worker//
3*d5c09012SAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License");
4*d5c09012SAndroid Build Coastguard Worker// you may not use this file except in compliance with the License.
5*d5c09012SAndroid Build Coastguard Worker// You may obtain a copy of the License at
6*d5c09012SAndroid Build Coastguard Worker//
7*d5c09012SAndroid Build Coastguard Worker//     http://www.apache.org/licenses/LICENSE-2.0
8*d5c09012SAndroid Build Coastguard Worker//
9*d5c09012SAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software
10*d5c09012SAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS,
11*d5c09012SAndroid Build Coastguard Worker// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*d5c09012SAndroid Build Coastguard Worker// See the License for the specific language governing permissions and
13*d5c09012SAndroid Build Coastguard Worker// limitations under the License.
14*d5c09012SAndroid Build Coastguard Worker
15*d5c09012SAndroid Build Coastguard Workersyntax = "proto3";
16*d5c09012SAndroid Build Coastguard Worker
17*d5c09012SAndroid Build Coastguard Workerpackage google.rpc;
18*d5c09012SAndroid Build Coastguard Worker
19*d5c09012SAndroid Build Coastguard Workeroption go_package = "google.golang.org/genproto/googleapis/rpc/code;code";
20*d5c09012SAndroid Build Coastguard Workeroption java_multiple_files = true;
21*d5c09012SAndroid Build Coastguard Workeroption java_outer_classname = "CodeProto";
22*d5c09012SAndroid Build Coastguard Workeroption java_package = "com.google.rpc";
23*d5c09012SAndroid Build Coastguard Workeroption objc_class_prefix = "RPC";
24*d5c09012SAndroid Build Coastguard Worker
25*d5c09012SAndroid Build Coastguard Worker// The canonical error codes for gRPC APIs.
26*d5c09012SAndroid Build Coastguard Worker//
27*d5c09012SAndroid Build Coastguard Worker//
28*d5c09012SAndroid Build Coastguard Worker// Sometimes multiple error codes may apply.  Services should return
29*d5c09012SAndroid Build Coastguard Worker// the most specific error code that applies.  For example, prefer
30*d5c09012SAndroid Build Coastguard Worker// `OUT_OF_RANGE` over `FAILED_PRECONDITION` if both codes apply.
31*d5c09012SAndroid Build Coastguard Worker// Similarly prefer `NOT_FOUND` or `ALREADY_EXISTS` over `FAILED_PRECONDITION`.
32*d5c09012SAndroid Build Coastguard Workerenum Code {
33*d5c09012SAndroid Build Coastguard Worker  // Not an error; returned on success.
34*d5c09012SAndroid Build Coastguard Worker  //
35*d5c09012SAndroid Build Coastguard Worker  // HTTP Mapping: 200 OK
36*d5c09012SAndroid Build Coastguard Worker  OK = 0;
37*d5c09012SAndroid Build Coastguard Worker
38*d5c09012SAndroid Build Coastguard Worker  // The operation was cancelled, typically by the caller.
39*d5c09012SAndroid Build Coastguard Worker  //
40*d5c09012SAndroid Build Coastguard Worker  // HTTP Mapping: 499 Client Closed Request
41*d5c09012SAndroid Build Coastguard Worker  CANCELLED = 1;
42*d5c09012SAndroid Build Coastguard Worker
43*d5c09012SAndroid Build Coastguard Worker  // Unknown error.  For example, this error may be returned when
44*d5c09012SAndroid Build Coastguard Worker  // a `Status` value received from another address space belongs to
45*d5c09012SAndroid Build Coastguard Worker  // an error space that is not known in this address space.  Also
46*d5c09012SAndroid Build Coastguard Worker  // errors raised by APIs that do not return enough error information
47*d5c09012SAndroid Build Coastguard Worker  // may be converted to this error.
48*d5c09012SAndroid Build Coastguard Worker  //
49*d5c09012SAndroid Build Coastguard Worker  // HTTP Mapping: 500 Internal Server Error
50*d5c09012SAndroid Build Coastguard Worker  UNKNOWN = 2;
51*d5c09012SAndroid Build Coastguard Worker
52*d5c09012SAndroid Build Coastguard Worker  // The client specified an invalid argument.  Note that this differs
53*d5c09012SAndroid Build Coastguard Worker  // from `FAILED_PRECONDITION`.  `INVALID_ARGUMENT` indicates arguments
54*d5c09012SAndroid Build Coastguard Worker  // that are problematic regardless of the state of the system
55*d5c09012SAndroid Build Coastguard Worker  // (e.g., a malformed file name).
56*d5c09012SAndroid Build Coastguard Worker  //
57*d5c09012SAndroid Build Coastguard Worker  // HTTP Mapping: 400 Bad Request
58*d5c09012SAndroid Build Coastguard Worker  INVALID_ARGUMENT = 3;
59*d5c09012SAndroid Build Coastguard Worker
60*d5c09012SAndroid Build Coastguard Worker  // The deadline expired before the operation could complete. For operations
61*d5c09012SAndroid Build Coastguard Worker  // that change the state of the system, this error may be returned
62*d5c09012SAndroid Build Coastguard Worker  // even if the operation has completed successfully.  For example, a
63*d5c09012SAndroid Build Coastguard Worker  // successful response from a server could have been delayed long
64*d5c09012SAndroid Build Coastguard Worker  // enough for the deadline to expire.
65*d5c09012SAndroid Build Coastguard Worker  //
66*d5c09012SAndroid Build Coastguard Worker  // HTTP Mapping: 504 Gateway Timeout
67*d5c09012SAndroid Build Coastguard Worker  DEADLINE_EXCEEDED = 4;
68*d5c09012SAndroid Build Coastguard Worker
69*d5c09012SAndroid Build Coastguard Worker  // Some requested entity (e.g., file or directory) was not found.
70*d5c09012SAndroid Build Coastguard Worker  //
71*d5c09012SAndroid Build Coastguard Worker  // Note to server developers: if a request is denied for an entire class
72*d5c09012SAndroid Build Coastguard Worker  // of users, such as gradual feature rollout or undocumented allowlist,
73*d5c09012SAndroid Build Coastguard Worker  // `NOT_FOUND` may be used. If a request is denied for some users within
74*d5c09012SAndroid Build Coastguard Worker  // a class of users, such as user-based access control, `PERMISSION_DENIED`
75*d5c09012SAndroid Build Coastguard Worker  // must be used.
76*d5c09012SAndroid Build Coastguard Worker  //
77*d5c09012SAndroid Build Coastguard Worker  // HTTP Mapping: 404 Not Found
78*d5c09012SAndroid Build Coastguard Worker  NOT_FOUND = 5;
79*d5c09012SAndroid Build Coastguard Worker
80*d5c09012SAndroid Build Coastguard Worker  // The entity that a client attempted to create (e.g., file or directory)
81*d5c09012SAndroid Build Coastguard Worker  // already exists.
82*d5c09012SAndroid Build Coastguard Worker  //
83*d5c09012SAndroid Build Coastguard Worker  // HTTP Mapping: 409 Conflict
84*d5c09012SAndroid Build Coastguard Worker  ALREADY_EXISTS = 6;
85*d5c09012SAndroid Build Coastguard Worker
86*d5c09012SAndroid Build Coastguard Worker  // The caller does not have permission to execute the specified
87*d5c09012SAndroid Build Coastguard Worker  // operation. `PERMISSION_DENIED` must not be used for rejections
88*d5c09012SAndroid Build Coastguard Worker  // caused by exhausting some resource (use `RESOURCE_EXHAUSTED`
89*d5c09012SAndroid Build Coastguard Worker  // instead for those errors). `PERMISSION_DENIED` must not be
90*d5c09012SAndroid Build Coastguard Worker  // used if the caller can not be identified (use `UNAUTHENTICATED`
91*d5c09012SAndroid Build Coastguard Worker  // instead for those errors). This error code does not imply the
92*d5c09012SAndroid Build Coastguard Worker  // request is valid or the requested entity exists or satisfies
93*d5c09012SAndroid Build Coastguard Worker  // other pre-conditions.
94*d5c09012SAndroid Build Coastguard Worker  //
95*d5c09012SAndroid Build Coastguard Worker  // HTTP Mapping: 403 Forbidden
96*d5c09012SAndroid Build Coastguard Worker  PERMISSION_DENIED = 7;
97*d5c09012SAndroid Build Coastguard Worker
98*d5c09012SAndroid Build Coastguard Worker  // The request does not have valid authentication credentials for the
99*d5c09012SAndroid Build Coastguard Worker  // operation.
100*d5c09012SAndroid Build Coastguard Worker  //
101*d5c09012SAndroid Build Coastguard Worker  // HTTP Mapping: 401 Unauthorized
102*d5c09012SAndroid Build Coastguard Worker  UNAUTHENTICATED = 16;
103*d5c09012SAndroid Build Coastguard Worker
104*d5c09012SAndroid Build Coastguard Worker  // Some resource has been exhausted, perhaps a per-user quota, or
105*d5c09012SAndroid Build Coastguard Worker  // perhaps the entire file system is out of space.
106*d5c09012SAndroid Build Coastguard Worker  //
107*d5c09012SAndroid Build Coastguard Worker  // HTTP Mapping: 429 Too Many Requests
108*d5c09012SAndroid Build Coastguard Worker  RESOURCE_EXHAUSTED = 8;
109*d5c09012SAndroid Build Coastguard Worker
110*d5c09012SAndroid Build Coastguard Worker  // The operation was rejected because the system is not in a state
111*d5c09012SAndroid Build Coastguard Worker  // required for the operation's execution.  For example, the directory
112*d5c09012SAndroid Build Coastguard Worker  // to be deleted is non-empty, an rmdir operation is applied to
113*d5c09012SAndroid Build Coastguard Worker  // a non-directory, etc.
114*d5c09012SAndroid Build Coastguard Worker  //
115*d5c09012SAndroid Build Coastguard Worker  // Service implementors can use the following guidelines to decide
116*d5c09012SAndroid Build Coastguard Worker  // between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`:
117*d5c09012SAndroid Build Coastguard Worker  //  (a) Use `UNAVAILABLE` if the client can retry just the failing call.
118*d5c09012SAndroid Build Coastguard Worker  //  (b) Use `ABORTED` if the client should retry at a higher level. For
119*d5c09012SAndroid Build Coastguard Worker  //      example, when a client-specified test-and-set fails, indicating the
120*d5c09012SAndroid Build Coastguard Worker  //      client should restart a read-modify-write sequence.
121*d5c09012SAndroid Build Coastguard Worker  //  (c) Use `FAILED_PRECONDITION` if the client should not retry until
122*d5c09012SAndroid Build Coastguard Worker  //      the system state has been explicitly fixed. For example, if an "rmdir"
123*d5c09012SAndroid Build Coastguard Worker  //      fails because the directory is non-empty, `FAILED_PRECONDITION`
124*d5c09012SAndroid Build Coastguard Worker  //      should be returned since the client should not retry unless
125*d5c09012SAndroid Build Coastguard Worker  //      the files are deleted from the directory.
126*d5c09012SAndroid Build Coastguard Worker  //
127*d5c09012SAndroid Build Coastguard Worker  // HTTP Mapping: 400 Bad Request
128*d5c09012SAndroid Build Coastguard Worker  FAILED_PRECONDITION = 9;
129*d5c09012SAndroid Build Coastguard Worker
130*d5c09012SAndroid Build Coastguard Worker  // The operation was aborted, typically due to a concurrency issue such as
131*d5c09012SAndroid Build Coastguard Worker  // a sequencer check failure or transaction abort.
132*d5c09012SAndroid Build Coastguard Worker  //
133*d5c09012SAndroid Build Coastguard Worker  // See the guidelines above for deciding between `FAILED_PRECONDITION`,
134*d5c09012SAndroid Build Coastguard Worker  // `ABORTED`, and `UNAVAILABLE`.
135*d5c09012SAndroid Build Coastguard Worker  //
136*d5c09012SAndroid Build Coastguard Worker  // HTTP Mapping: 409 Conflict
137*d5c09012SAndroid Build Coastguard Worker  ABORTED = 10;
138*d5c09012SAndroid Build Coastguard Worker
139*d5c09012SAndroid Build Coastguard Worker  // The operation was attempted past the valid range.  E.g., seeking or
140*d5c09012SAndroid Build Coastguard Worker  // reading past end-of-file.
141*d5c09012SAndroid Build Coastguard Worker  //
142*d5c09012SAndroid Build Coastguard Worker  // Unlike `INVALID_ARGUMENT`, this error indicates a problem that may
143*d5c09012SAndroid Build Coastguard Worker  // be fixed if the system state changes. For example, a 32-bit file
144*d5c09012SAndroid Build Coastguard Worker  // system will generate `INVALID_ARGUMENT` if asked to read at an
145*d5c09012SAndroid Build Coastguard Worker  // offset that is not in the range [0,2^32-1], but it will generate
146*d5c09012SAndroid Build Coastguard Worker  // `OUT_OF_RANGE` if asked to read from an offset past the current
147*d5c09012SAndroid Build Coastguard Worker  // file size.
148*d5c09012SAndroid Build Coastguard Worker  //
149*d5c09012SAndroid Build Coastguard Worker  // There is a fair bit of overlap between `FAILED_PRECONDITION` and
150*d5c09012SAndroid Build Coastguard Worker  // `OUT_OF_RANGE`.  We recommend using `OUT_OF_RANGE` (the more specific
151*d5c09012SAndroid Build Coastguard Worker  // error) when it applies so that callers who are iterating through
152*d5c09012SAndroid Build Coastguard Worker  // a space can easily look for an `OUT_OF_RANGE` error to detect when
153*d5c09012SAndroid Build Coastguard Worker  // they are done.
154*d5c09012SAndroid Build Coastguard Worker  //
155*d5c09012SAndroid Build Coastguard Worker  // HTTP Mapping: 400 Bad Request
156*d5c09012SAndroid Build Coastguard Worker  OUT_OF_RANGE = 11;
157*d5c09012SAndroid Build Coastguard Worker
158*d5c09012SAndroid Build Coastguard Worker  // The operation is not implemented or is not supported/enabled in this
159*d5c09012SAndroid Build Coastguard Worker  // service.
160*d5c09012SAndroid Build Coastguard Worker  //
161*d5c09012SAndroid Build Coastguard Worker  // HTTP Mapping: 501 Not Implemented
162*d5c09012SAndroid Build Coastguard Worker  UNIMPLEMENTED = 12;
163*d5c09012SAndroid Build Coastguard Worker
164*d5c09012SAndroid Build Coastguard Worker  // Internal errors.  This means that some invariants expected by the
165*d5c09012SAndroid Build Coastguard Worker  // underlying system have been broken.  This error code is reserved
166*d5c09012SAndroid Build Coastguard Worker  // for serious errors.
167*d5c09012SAndroid Build Coastguard Worker  //
168*d5c09012SAndroid Build Coastguard Worker  // HTTP Mapping: 500 Internal Server Error
169*d5c09012SAndroid Build Coastguard Worker  INTERNAL = 13;
170*d5c09012SAndroid Build Coastguard Worker
171*d5c09012SAndroid Build Coastguard Worker  // The service is currently unavailable.  This is most likely a
172*d5c09012SAndroid Build Coastguard Worker  // transient condition, which can be corrected by retrying with
173*d5c09012SAndroid Build Coastguard Worker  // a backoff. Note that it is not always safe to retry
174*d5c09012SAndroid Build Coastguard Worker  // non-idempotent operations.
175*d5c09012SAndroid Build Coastguard Worker  //
176*d5c09012SAndroid Build Coastguard Worker  // See the guidelines above for deciding between `FAILED_PRECONDITION`,
177*d5c09012SAndroid Build Coastguard Worker  // `ABORTED`, and `UNAVAILABLE`.
178*d5c09012SAndroid Build Coastguard Worker  //
179*d5c09012SAndroid Build Coastguard Worker  // HTTP Mapping: 503 Service Unavailable
180*d5c09012SAndroid Build Coastguard Worker  UNAVAILABLE = 14;
181*d5c09012SAndroid Build Coastguard Worker
182*d5c09012SAndroid Build Coastguard Worker  // Unrecoverable data loss or corruption.
183*d5c09012SAndroid Build Coastguard Worker  //
184*d5c09012SAndroid Build Coastguard Worker  // HTTP Mapping: 500 Internal Server Error
185*d5c09012SAndroid Build Coastguard Worker  DATA_LOSS = 15;
186*d5c09012SAndroid Build Coastguard Worker}
187