cx_api/generated/google.rpc.rs
1// This file is @generated by prost-build.
2/// The canonical error codes for gRPC APIs.
3///
4///
5/// Sometimes multiple error codes may apply. Services should return
6/// the most specific error code that applies. For example, prefer
7/// `OUT_OF_RANGE` over `FAILED_PRECONDITION` if both codes apply.
8/// Similarly prefer `NOT_FOUND` or `ALREADY_EXISTS` over `FAILED_PRECONDITION`.
9#[derive(serde::Serialize, serde::Deserialize)]
10#[serde(rename_all = "snake_case")]
11#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
12#[repr(i32)]
13pub enum Code {
14 /// Not an error; returned on success.
15 ///
16 /// HTTP Mapping: 200 OK
17 Ok = 0,
18 /// The operation was cancelled, typically by the caller.
19 ///
20 /// HTTP Mapping: 499 Client Closed Request
21 Cancelled = 1,
22 /// Unknown error. For example, this error may be returned when
23 /// a `Status` value received from another address space belongs to
24 /// an error space that is not known in this address space. Also
25 /// errors raised by APIs that do not return enough error information
26 /// may be converted to this error.
27 ///
28 /// HTTP Mapping: 500 Internal Server Error
29 Unknown = 2,
30 /// The client specified an invalid argument. Note that this differs
31 /// from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments
32 /// that are problematic regardless of the state of the system
33 /// (e.g., a malformed file name).
34 ///
35 /// HTTP Mapping: 400 Bad Request
36 InvalidArgument = 3,
37 /// The deadline expired before the operation could complete. For operations
38 /// that change the state of the system, this error may be returned
39 /// even if the operation has completed successfully. For example, a
40 /// successful response from a server could have been delayed long
41 /// enough for the deadline to expire.
42 ///
43 /// HTTP Mapping: 504 Gateway Timeout
44 DeadlineExceeded = 4,
45 /// Some requested entity (e.g., file or directory) was not found.
46 ///
47 /// Note to server developers: if a request is denied for an entire class
48 /// of users, such as gradual feature rollout or undocumented allowlist,
49 /// `NOT_FOUND` may be used. If a request is denied for some users within
50 /// a class of users, such as user-based access control, `PERMISSION_DENIED`
51 /// must be used.
52 ///
53 /// HTTP Mapping: 404 Not Found
54 NotFound = 5,
55 /// The entity that a client attempted to create (e.g., file or directory)
56 /// already exists.
57 ///
58 /// HTTP Mapping: 409 Conflict
59 AlreadyExists = 6,
60 /// The caller does not have permission to execute the specified
61 /// operation. `PERMISSION_DENIED` must not be used for rejections
62 /// caused by exhausting some resource (use `RESOURCE_EXHAUSTED`
63 /// instead for those errors). `PERMISSION_DENIED` must not be
64 /// used if the caller can not be identified (use `UNAUTHENTICATED`
65 /// instead for those errors). This error code does not imply the
66 /// request is valid or the requested entity exists or satisfies
67 /// other pre-conditions.
68 ///
69 /// HTTP Mapping: 403 Forbidden
70 PermissionDenied = 7,
71 /// The request does not have valid authentication credentials for the
72 /// operation.
73 ///
74 /// HTTP Mapping: 401 Unauthorized
75 Unauthenticated = 16,
76 /// Some resource has been exhausted, perhaps a per-user quota, or
77 /// perhaps the entire file system is out of space.
78 ///
79 /// HTTP Mapping: 429 Too Many Requests
80 ResourceExhausted = 8,
81 /// The operation was rejected because the system is not in a state
82 /// required for the operation's execution. For example, the directory
83 /// to be deleted is non-empty, an rmdir operation is applied to
84 /// a non-directory, etc.
85 ///
86 /// Service implementors can use the following guidelines to decide
87 /// between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`:
88 /// (a) Use `UNAVAILABLE` if the client can retry just the failing call.
89 /// (b) Use `ABORTED` if the client should retry at a higher level. For
90 /// example, when a client-specified test-and-set fails, indicating the
91 /// client should restart a read-modify-write sequence.
92 /// (c) Use `FAILED_PRECONDITION` if the client should not retry until
93 /// the system state has been explicitly fixed. For example, if an "rmdir"
94 /// fails because the directory is non-empty, `FAILED_PRECONDITION`
95 /// should be returned since the client should not retry unless
96 /// the files are deleted from the directory.
97 ///
98 /// HTTP Mapping: 400 Bad Request
99 FailedPrecondition = 9,
100 /// The operation was aborted, typically due to a concurrency issue such as
101 /// a sequencer check failure or transaction abort.
102 ///
103 /// See the guidelines above for deciding between `FAILED_PRECONDITION`,
104 /// `ABORTED`, and `UNAVAILABLE`.
105 ///
106 /// HTTP Mapping: 409 Conflict
107 Aborted = 10,
108 /// The operation was attempted past the valid range. E.g., seeking or
109 /// reading past end-of-file.
110 ///
111 /// Unlike `INVALID_ARGUMENT`, this error indicates a problem that may
112 /// be fixed if the system state changes. For example, a 32-bit file
113 /// system will generate `INVALID_ARGUMENT` if asked to read at an
114 /// offset that is not in the range \[0,2^32-1\], but it will generate
115 /// `OUT_OF_RANGE` if asked to read from an offset past the current
116 /// file size.
117 ///
118 /// There is a fair bit of overlap between `FAILED_PRECONDITION` and
119 /// `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific
120 /// error) when it applies so that callers who are iterating through
121 /// a space can easily look for an `OUT_OF_RANGE` error to detect when
122 /// they are done.
123 ///
124 /// HTTP Mapping: 400 Bad Request
125 OutOfRange = 11,
126 /// The operation is not implemented or is not supported/enabled in this
127 /// service.
128 ///
129 /// HTTP Mapping: 501 Not Implemented
130 Unimplemented = 12,
131 /// Internal errors. This means that some invariants expected by the
132 /// underlying system have been broken. This error code is reserved
133 /// for serious errors.
134 ///
135 /// HTTP Mapping: 500 Internal Server Error
136 Internal = 13,
137 /// The service is currently unavailable. This is most likely a
138 /// transient condition, which can be corrected by retrying with
139 /// a backoff. Note that it is not always safe to retry
140 /// non-idempotent operations.
141 ///
142 /// See the guidelines above for deciding between `FAILED_PRECONDITION`,
143 /// `ABORTED`, and `UNAVAILABLE`.
144 ///
145 /// HTTP Mapping: 503 Service Unavailable
146 Unavailable = 14,
147 /// Unrecoverable data loss or corruption.
148 ///
149 /// HTTP Mapping: 500 Internal Server Error
150 DataLoss = 15,
151}
152impl Code {
153 /// String value of the enum field names used in the ProtoBuf definition.
154 ///
155 /// The values are not transformed in any way and thus are considered stable
156 /// (if the ProtoBuf definition does not change) and safe for programmatic use.
157 pub fn as_str_name(&self) -> &'static str {
158 match self {
159 Self::Ok => "OK",
160 Self::Cancelled => "CANCELLED",
161 Self::Unknown => "UNKNOWN",
162 Self::InvalidArgument => "INVALID_ARGUMENT",
163 Self::DeadlineExceeded => "DEADLINE_EXCEEDED",
164 Self::NotFound => "NOT_FOUND",
165 Self::AlreadyExists => "ALREADY_EXISTS",
166 Self::PermissionDenied => "PERMISSION_DENIED",
167 Self::Unauthenticated => "UNAUTHENTICATED",
168 Self::ResourceExhausted => "RESOURCE_EXHAUSTED",
169 Self::FailedPrecondition => "FAILED_PRECONDITION",
170 Self::Aborted => "ABORTED",
171 Self::OutOfRange => "OUT_OF_RANGE",
172 Self::Unimplemented => "UNIMPLEMENTED",
173 Self::Internal => "INTERNAL",
174 Self::Unavailable => "UNAVAILABLE",
175 Self::DataLoss => "DATA_LOSS",
176 }
177 }
178 /// Creates an enum from field names used in the ProtoBuf definition.
179 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
180 match value {
181 "OK" => Some(Self::Ok),
182 "CANCELLED" => Some(Self::Cancelled),
183 "UNKNOWN" => Some(Self::Unknown),
184 "INVALID_ARGUMENT" => Some(Self::InvalidArgument),
185 "DEADLINE_EXCEEDED" => Some(Self::DeadlineExceeded),
186 "NOT_FOUND" => Some(Self::NotFound),
187 "ALREADY_EXISTS" => Some(Self::AlreadyExists),
188 "PERMISSION_DENIED" => Some(Self::PermissionDenied),
189 "UNAUTHENTICATED" => Some(Self::Unauthenticated),
190 "RESOURCE_EXHAUSTED" => Some(Self::ResourceExhausted),
191 "FAILED_PRECONDITION" => Some(Self::FailedPrecondition),
192 "ABORTED" => Some(Self::Aborted),
193 "OUT_OF_RANGE" => Some(Self::OutOfRange),
194 "UNIMPLEMENTED" => Some(Self::Unimplemented),
195 "INTERNAL" => Some(Self::Internal),
196 "UNAVAILABLE" => Some(Self::Unavailable),
197 "DATA_LOSS" => Some(Self::DataLoss),
198 _ => None,
199 }
200 }
201}