Statistics
| Branch: | Tag: | Revision:

root / snf-cyclades-app / synnefo / api / faults.py @ bb54871d

History | View | Annotate | Download (2.1 kB)

1 adee02b8 Giorgos Verigakis
# Copyright 2011 GRNET S.A. All rights reserved.
2 adee02b8 Giorgos Verigakis
# 
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 adee02b8 Giorgos Verigakis
# 
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 adee02b8 Giorgos Verigakis
# 
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 adee02b8 Giorgos Verigakis
# 
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 adee02b8 Giorgos Verigakis
# 
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 d8e50a39 Giorgos Verigakis
def camelCase(s):
35 d8e50a39 Giorgos Verigakis
    return s[0].lower() + s[1:]
36 635cfd6e Faidon Liambotis
37 00b4f1be Faidon Liambotis
38 0a73c22f Giorgos Verigakis
class Fault(Exception):
39 d8e50a39 Giorgos Verigakis
    def __init__(self, message='', details='', name=''):
40 0a73c22f Giorgos Verigakis
        Exception.__init__(self, message, details, name)
41 d8e50a39 Giorgos Verigakis
        self.message = message
42 d8e50a39 Giorgos Verigakis
        self.details = details
43 d8e50a39 Giorgos Verigakis
        self.name = name or camelCase(self.__class__.__name__)
44 00b4f1be Faidon Liambotis
45 d8e50a39 Giorgos Verigakis
class BadRequest(Fault):
46 d8e50a39 Giorgos Verigakis
    code = 400
47 00b4f1be Faidon Liambotis
48 d8e50a39 Giorgos Verigakis
class Unauthorized(Fault):
49 d8e50a39 Giorgos Verigakis
    code = 401
50 00b4f1be Faidon Liambotis
51 d8e50a39 Giorgos Verigakis
class ResizeNotAllowed(Fault):
52 d8e50a39 Giorgos Verigakis
    code = 403
53 14a6a08f Faidon Liambotis
54 d8e50a39 Giorgos Verigakis
class ItemNotFound(Fault):
55 d8e50a39 Giorgos Verigakis
    code = 404
56 00b4f1be Faidon Liambotis
57 5231a38a Giorgos Verigakis
class BuildInProgress(Fault):
58 5231a38a Giorgos Verigakis
    code = 409
59 5231a38a Giorgos Verigakis
60 64938cb0 Giorgos Verigakis
class OverLimit(Fault):
61 64938cb0 Giorgos Verigakis
    code = 413
62 64938cb0 Giorgos Verigakis
63 d8e50a39 Giorgos Verigakis
class ServiceUnavailable(Fault):
64 d8e50a39 Giorgos Verigakis
    code = 503