8
8
import httpx
9
9
10
10
from ._utils import is_mapping
11
+ from ._models import construct_type
11
12
12
13
__all__ = [
13
14
"BadRequestError" ,
@@ -136,10 +137,16 @@ def __init__(self, message: str, *, body: object, response: httpx.Response) -> N
136
137
data = cast (Mapping [str , object ], body if is_mapping (body ) else {})
137
138
super ().__init__ (message , response = response , body = body )
138
139
139
- self .status = cast (Any , data .get ("status" ))
140
- self .type = cast (Any , data .get ("type" ))
141
- self .detail = cast (Any , data .get ("detail" ))
142
- self .title = cast (Any , data .get ("title" ))
140
+ self .status = cast (Any , construct_type (type_ = Literal [400 ], value = data .get ("status" )))
141
+ self .type = cast (
142
+ Any ,
143
+ construct_type (
144
+ type_ = Literal ["https://docs.withorb.com/reference/error-responses#400-constraint-violation" ],
145
+ value = data .get ("type" ),
146
+ ),
147
+ )
148
+ self .detail = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("detail" )))
149
+ self .title = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("title" )))
143
150
144
151
145
152
class DuplicateResourceCreation (BadRequestError ):
@@ -155,10 +162,16 @@ def __init__(self, message: str, *, body: object, response: httpx.Response) -> N
155
162
data = cast (Mapping [str , object ], body if is_mapping (body ) else {})
156
163
super ().__init__ (message , response = response , body = body )
157
164
158
- self .status = cast (Any , data .get ("status" ))
159
- self .type = cast (Any , data .get ("type" ))
160
- self .detail = cast (Any , data .get ("detail" ))
161
- self .title = cast (Any , data .get ("title" ))
165
+ self .status = cast (Any , construct_type (type_ = Literal [400 ], value = data .get ("status" )))
166
+ self .type = cast (
167
+ Any ,
168
+ construct_type (
169
+ type_ = Literal ["https://docs.withorb.com/reference/error-responses#400-duplicate-resource-creation" ],
170
+ value = data .get ("type" ),
171
+ ),
172
+ )
173
+ self .detail = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("detail" )))
174
+ self .title = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("title" )))
162
175
163
176
164
177
class FeatureNotAvailable (BadRequestError ):
@@ -174,10 +187,16 @@ def __init__(self, message: str, *, body: object, response: httpx.Response) -> N
174
187
data = cast (Mapping [str , object ], body if is_mapping (body ) else {})
175
188
super ().__init__ (message , response = response , body = body )
176
189
177
- self .status = cast (Any , data .get ("status" ))
178
- self .type = cast (Any , data .get ("type" ))
179
- self .detail = cast (Any , data .get ("detail" ))
180
- self .title = cast (Any , data .get ("title" ))
190
+ self .status = cast (Any , construct_type (type_ = Literal [400 ], value = data .get ("status" )))
191
+ self .type = cast (
192
+ Any ,
193
+ construct_type (
194
+ type_ = Literal ["https://docs.withorb.com/reference/error-responses#404-feature-not-available" ],
195
+ value = data .get ("type" ),
196
+ ),
197
+ )
198
+ self .detail = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("detail" )))
199
+ self .title = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("title" )))
181
200
182
201
183
202
class RequestValidationError (BadRequestError ):
@@ -195,11 +214,17 @@ def __init__(self, message: str, *, body: object, response: httpx.Response) -> N
195
214
data = cast (Mapping [str , object ], body if is_mapping (body ) else {})
196
215
super ().__init__ (message , response = response , body = body )
197
216
198
- self .status = cast (Any , data .get ("status" ))
199
- self .type = cast (Any , data .get ("type" ))
200
- self .validation_errors = cast (Any , data .get ("validation_errors" ))
201
- self .detail = cast (Any , data .get ("detail" ))
202
- self .title = cast (Any , data .get ("title" ))
217
+ self .status = cast (Any , construct_type (type_ = Literal [400 ], value = data .get ("status" )))
218
+ self .type = cast (
219
+ Any ,
220
+ construct_type (
221
+ type_ = Literal ["https://docs.withorb.com/reference/error-responses#400-request-validation-errors" ],
222
+ value = data .get ("type" ),
223
+ ),
224
+ )
225
+ self .validation_errors = cast (Any , construct_type (type_ = List [object ], value = data .get ("validation_errors" )))
226
+ self .detail = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("detail" )))
227
+ self .title = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("title" )))
203
228
204
229
205
230
class OrbAuthenticationError (AuthenticationError ):
@@ -215,10 +240,16 @@ def __init__(self, message: str, *, body: object, response: httpx.Response) -> N
215
240
data = cast (Mapping [str , object ], body if is_mapping (body ) else {})
216
241
super ().__init__ (message , response = response , body = body )
217
242
218
- self .status = cast (Any , data .get ("status" ))
219
- self .type = cast (Any , data .get ("type" ))
220
- self .detail = cast (Any , data .get ("detail" ))
221
- self .title = cast (Any , data .get ("title" ))
243
+ self .status = cast (Any , construct_type (type_ = Literal [401 ], value = data .get ("status" )))
244
+ self .type = cast (
245
+ Any ,
246
+ construct_type (
247
+ type_ = Literal ["https://docs.withorb.com/reference/error-responses#401-authentication-error" ],
248
+ value = data .get ("type" ),
249
+ ),
250
+ )
251
+ self .detail = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("detail" )))
252
+ self .title = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("title" )))
222
253
223
254
224
255
class ResourceNotFound (NotFoundError ):
@@ -234,10 +265,16 @@ def __init__(self, message: str, *, body: object, response: httpx.Response) -> N
234
265
data = cast (Mapping [str , object ], body if is_mapping (body ) else {})
235
266
super ().__init__ (message , response = response , body = body )
236
267
237
- self .status = cast (Any , data .get ("status" ))
238
- self .title = cast (Any , data .get ("title" ))
239
- self .type = cast (Any , data .get ("type" ))
240
- self .detail = cast (Any , data .get ("detail" ))
268
+ self .status = cast (Any , construct_type (type_ = Literal [404 ], value = data .get ("status" )))
269
+ self .title = cast (Any , construct_type (type_ = str , value = data .get ("title" )))
270
+ self .type = cast (
271
+ Any ,
272
+ construct_type (
273
+ type_ = Literal ["https://docs.withorb.com/reference/error-responses#404-resource-not-found" ],
274
+ value = data .get ("type" ),
275
+ ),
276
+ )
277
+ self .detail = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("detail" )))
241
278
242
279
243
280
class URLNotFound (NotFoundError ):
@@ -253,10 +290,16 @@ def __init__(self, message: str, *, body: object, response: httpx.Response) -> N
253
290
data = cast (Mapping [str , object ], body if is_mapping (body ) else {})
254
291
super ().__init__ (message , response = response , body = body )
255
292
256
- self .status = cast (Any , data .get ("status" ))
257
- self .type = cast (Any , data .get ("type" ))
258
- self .detail = cast (Any , data .get ("detail" ))
259
- self .title = cast (Any , data .get ("title" ))
293
+ self .status = cast (Any , construct_type (type_ = Literal [404 ], value = data .get ("status" )))
294
+ self .type = cast (
295
+ Any ,
296
+ construct_type (
297
+ type_ = Literal ["https://docs.withorb.com/reference/error-responses#404-url-not-found" ],
298
+ value = data .get ("type" ),
299
+ ),
300
+ )
301
+ self .detail = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("detail" )))
302
+ self .title = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("title" )))
260
303
261
304
262
305
class ResourceConflict (ConflictError ):
@@ -272,10 +315,16 @@ def __init__(self, message: str, *, body: object, response: httpx.Response) -> N
272
315
data = cast (Mapping [str , object ], body if is_mapping (body ) else {})
273
316
super ().__init__ (message , response = response , body = body )
274
317
275
- self .status = cast (Any , data .get ("status" ))
276
- self .type = cast (Any , data .get ("type" ))
277
- self .detail = cast (Any , data .get ("detail" ))
278
- self .title = cast (Any , data .get ("title" ))
318
+ self .status = cast (Any , construct_type (type_ = Literal [409 ], value = data .get ("status" )))
319
+ self .type = cast (
320
+ Any ,
321
+ construct_type (
322
+ type_ = Literal ["https://docs.withorb.com/reference/error-responses#409-resource-conflict" ],
323
+ value = data .get ("type" ),
324
+ ),
325
+ )
326
+ self .detail = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("detail" )))
327
+ self .title = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("title" )))
279
328
280
329
281
330
class RequestTooLarge (APIStatusError ):
@@ -291,10 +340,16 @@ def __init__(self, message: str, *, body: object, response: httpx.Response) -> N
291
340
data = cast (Mapping [str , object ], body if is_mapping (body ) else {})
292
341
super ().__init__ (message , response = response , body = body )
293
342
294
- self .status = cast (Any , data .get ("status" ))
295
- self .type = cast (Any , data .get ("type" ))
296
- self .detail = cast (Any , data .get ("detail" ))
297
- self .title = cast (Any , data .get ("title" ))
343
+ self .status = cast (Any , construct_type (type_ = Literal [413 ], value = data .get ("status" )))
344
+ self .type = cast (
345
+ Any ,
346
+ construct_type (
347
+ type_ = Literal ["https://docs.withorb.com/reference/error-responses#413-request-too-large" ],
348
+ value = data .get ("type" ),
349
+ ),
350
+ )
351
+ self .detail = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("detail" )))
352
+ self .title = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("title" )))
298
353
299
354
300
355
class ResourceTooLarge (APIStatusError ):
@@ -310,10 +365,16 @@ def __init__(self, message: str, *, body: object, response: httpx.Response) -> N
310
365
data = cast (Mapping [str , object ], body if is_mapping (body ) else {})
311
366
super ().__init__ (message , response = response , body = body )
312
367
313
- self .status = cast (Any , data .get ("status" ))
314
- self .type = cast (Any , data .get ("type" ))
315
- self .detail = cast (Any , data .get ("detail" ))
316
- self .title = cast (Any , data .get ("title" ))
368
+ self .status = cast (Any , construct_type (type_ = Literal [413 ], value = data .get ("status" )))
369
+ self .type = cast (
370
+ Any ,
371
+ construct_type (
372
+ type_ = Literal ["https://docs.withorb.com/reference/error-responses#413-resource-too-large" ],
373
+ value = data .get ("type" ),
374
+ ),
375
+ )
376
+ self .detail = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("detail" )))
377
+ self .title = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("title" )))
317
378
318
379
319
380
class TooManyRequests (RateLimitError ):
@@ -329,10 +390,16 @@ def __init__(self, message: str, *, body: object, response: httpx.Response) -> N
329
390
data = cast (Mapping [str , object ], body if is_mapping (body ) else {})
330
391
super ().__init__ (message , response = response , body = body )
331
392
332
- self .status = cast (Any , data .get ("status" ))
333
- self .type = cast (Any , data .get ("type" ))
334
- self .detail = cast (Any , data .get ("detail" ))
335
- self .title = cast (Any , data .get ("title" ))
393
+ self .status = cast (Any , construct_type (type_ = Literal [429 ], value = data .get ("status" )))
394
+ self .type = cast (
395
+ Any ,
396
+ construct_type (
397
+ type_ = Literal ["https://docs.withorb.com/reference/error-responses#429-too-many-requests" ],
398
+ value = data .get ("type" ),
399
+ ),
400
+ )
401
+ self .detail = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("detail" )))
402
+ self .title = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("title" )))
336
403
337
404
338
405
class OrbInternalServerError (InternalServerError ):
@@ -348,7 +415,13 @@ def __init__(self, message: str, *, body: object, response: httpx.Response) -> N
348
415
data = cast (Mapping [str , object ], body if is_mapping (body ) else {})
349
416
super ().__init__ (message , response = response , body = body )
350
417
351
- self .status = cast (Any , data .get ("status" ))
352
- self .type = cast (Any , data .get ("type" ))
353
- self .detail = cast (Any , data .get ("detail" ))
354
- self .title = cast (Any , data .get ("title" ))
418
+ self .status = cast (Any , construct_type (type_ = Literal [500 ], value = data .get ("status" )))
419
+ self .type = cast (
420
+ Any ,
421
+ construct_type (
422
+ type_ = Literal ["https://docs.withorb.com/reference/error-responses#500-internal-server-error" ],
423
+ value = data .get ("type" ),
424
+ ),
425
+ )
426
+ self .detail = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("detail" )))
427
+ self .title = cast (Any , construct_type (type_ = Optional [str ], value = data .get ("title" )))
0 commit comments