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