root / snf-cyclades-app / synnefo / api / faults.py @ 64cdd31b
History | View | Annotate | Download (2.3 kB)
1 | e440e835 | Christos Stavrakakis | # Copyright 2011, 2012, 2013 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | e440e835 | Christos Stavrakakis | #
|
3 | adee02b8 | Giorgos Verigakis | # Redistribution and use in source and binary forms, with or
|
4 | adee02b8 | Giorgos Verigakis | # without modification, are permitted provided that the following
|
5 | adee02b8 | Giorgos Verigakis | # conditions are met:
|
6 | e440e835 | Christos Stavrakakis | #
|
7 | adee02b8 | Giorgos Verigakis | # 1. Redistributions of source code must retain the above
|
8 | adee02b8 | Giorgos Verigakis | # copyright notice, this list of conditions and the following
|
9 | adee02b8 | Giorgos Verigakis | # disclaimer.
|
10 | e440e835 | Christos Stavrakakis | #
|
11 | adee02b8 | Giorgos Verigakis | # 2. Redistributions in binary form must reproduce the above
|
12 | adee02b8 | Giorgos Verigakis | # copyright notice, this list of conditions and the following
|
13 | adee02b8 | Giorgos Verigakis | # disclaimer in the documentation and/or other materials
|
14 | adee02b8 | Giorgos Verigakis | # provided with the distribution.
|
15 | e440e835 | Christos Stavrakakis | #
|
16 | adee02b8 | Giorgos Verigakis | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | adee02b8 | Giorgos Verigakis | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | adee02b8 | Giorgos Verigakis | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | adee02b8 | Giorgos Verigakis | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | adee02b8 | Giorgos Verigakis | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | adee02b8 | Giorgos Verigakis | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | adee02b8 | Giorgos Verigakis | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | adee02b8 | Giorgos Verigakis | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | adee02b8 | Giorgos Verigakis | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | adee02b8 | Giorgos Verigakis | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | adee02b8 | Giorgos Verigakis | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | adee02b8 | Giorgos Verigakis | # POSSIBILITY OF SUCH DAMAGE.
|
28 | e440e835 | Christos Stavrakakis | #
|
29 | adee02b8 | Giorgos Verigakis | # The views and conclusions contained in the software and
|
30 | adee02b8 | Giorgos Verigakis | # documentation are those of the authors and should not be
|
31 | adee02b8 | Giorgos Verigakis | # interpreted as representing official policies, either expressed
|
32 | adee02b8 | Giorgos Verigakis | # or implied, of GRNET S.A.
|
33 | 00b4f1be | Faidon Liambotis | |
34 | e440e835 | Christos Stavrakakis | |
35 | d8e50a39 | Giorgos Verigakis | def camelCase(s): |
36 | d8e50a39 | Giorgos Verigakis | return s[0].lower() + s[1:] |
37 | 635cfd6e | Faidon Liambotis | |
38 | 00b4f1be | Faidon Liambotis | |
39 | 0a73c22f | Giorgos Verigakis | class Fault(Exception): |
40 | d8e50a39 | Giorgos Verigakis | def __init__(self, message='', details='', name=''): |
41 | 0a73c22f | Giorgos Verigakis | Exception.__init__(self, message, details, name) |
42 | d8e50a39 | Giorgos Verigakis | self.message = message
|
43 | d8e50a39 | Giorgos Verigakis | self.details = details
|
44 | d8e50a39 | Giorgos Verigakis | self.name = name or camelCase(self.__class__.__name__) |
45 | 00b4f1be | Faidon Liambotis | |
46 | e440e835 | Christos Stavrakakis | |
47 | d8e50a39 | Giorgos Verigakis | class BadRequest(Fault): |
48 | d8e50a39 | Giorgos Verigakis | code = 400
|
49 | 00b4f1be | Faidon Liambotis | |
50 | e440e835 | Christos Stavrakakis | |
51 | d8e50a39 | Giorgos Verigakis | class Unauthorized(Fault): |
52 | d8e50a39 | Giorgos Verigakis | code = 401
|
53 | 00b4f1be | Faidon Liambotis | |
54 | e440e835 | Christos Stavrakakis | |
55 | d8e50a39 | Giorgos Verigakis | class ResizeNotAllowed(Fault): |
56 | d8e50a39 | Giorgos Verigakis | code = 403
|
57 | 14a6a08f | Faidon Liambotis | |
58 | e440e835 | Christos Stavrakakis | |
59 | 17c2ed57 | Christos Stavrakakis | class Forbidden(Fault): |
60 | 17c2ed57 | Christos Stavrakakis | code = 403
|
61 | 17c2ed57 | Christos Stavrakakis | |
62 | e440e835 | Christos Stavrakakis | |
63 | d8e50a39 | Giorgos Verigakis | class ItemNotFound(Fault): |
64 | d8e50a39 | Giorgos Verigakis | code = 404
|
65 | 00b4f1be | Faidon Liambotis | |
66 | e440e835 | Christos Stavrakakis | |
67 | 5231a38a | Giorgos Verigakis | class BuildInProgress(Fault): |
68 | 5231a38a | Giorgos Verigakis | code = 409
|
69 | 5231a38a | Giorgos Verigakis | |
70 | e440e835 | Christos Stavrakakis | |
71 | 64938cb0 | Giorgos Verigakis | class OverLimit(Fault): |
72 | 64938cb0 | Giorgos Verigakis | code = 413
|
73 | 64938cb0 | Giorgos Verigakis | |
74 | e440e835 | Christos Stavrakakis | |
75 | 08b079e2 | Stavros Sachtouris | class BadMediaType(Fault): |
76 | 08b079e2 | Stavros Sachtouris | code = 415
|
77 | 0196d9a3 | Christos Stavrakakis | |
78 | e440e835 | Christos Stavrakakis | |
79 | 0196d9a3 | Christos Stavrakakis | class NetworkInUse(Fault): |
80 | 0196d9a3 | Christos Stavrakakis | code = 421
|
81 | 0196d9a3 | Christos Stavrakakis | |
82 | e440e835 | Christos Stavrakakis | |
83 | 0196d9a3 | Christos Stavrakakis | class ServiceUnavailable(Fault): |
84 | 0196d9a3 | Christos Stavrakakis | code = 503 |