Exemplo n.º 1
0
    def __init__(self, title, description, retry_after, **kwargs):
        """Initialize

        Args:
            title: Human-friendly error title. Set to None if you wish Falcon
                to return an empty response body (all remaining args will
                be ignored except for headers.) Do this only when you don't
                wish to disclose sensitive information about why a request was
                refused, or if the status and headers are self-descriptive.
            description: Human-friendly description of the error, along with a
                helpful suggestion or two (default None).
            retry_after: Value for the Retry-After header. If a date object,
                will serialize as an HTTP date. Otherwise, a non-negative int
                is expected, representing the number of seconds to wait. See
                also: http://goo.gl/DIrWr
            headers: A dictionary of extra headers to return in the
                response to the client (default None).
            href: A URL someone can visit to find out more information
                (default None).
            href_rel: If href is given, use this value for the rel
                attribute (default 'doc').
            href_text: If href is given, use this as the friendly
                title/description for the link (defaults to "API documentation
                for this error").
            code: An internal code that customers can reference in their
                support request or to help them when searching for knowledge
                base articles related to this error.
        """

        headers = kwargs.setdefault('headers', {})
        headers['Retry-After'] = str(retry_after)
        HTTPError.__init__(self, status.HTTP_503, title, description, **kwargs)
Exemplo n.º 2
0
    def __init__(self, title, description, retry_after, **kwargs):
        """Initialize

        Args:
            title: Human-friendly error title. Set to None if you wish Falcon
                to return an empty response body (all remaining args will
                be ignored except for headers.) Do this only when you don't
                wish to disclose sensitive information about why a request was
                refused, or if the status and headers are self-descriptive.
            description: Human-friendly description of the error, along with a
                helpful suggestion or two (default None).
            retry_after: Value for the Retry-After header. If a date object,
                will serialize as an HTTP date. Otherwise, a non-negative int
                is expected, representing the number of seconds to wait. See
                also: http://goo.gl/DIrWr
            headers: A dictionary of extra headers to return in the
                response to the client (default None).
            href: A URL someone can visit to find out more information
                (default None).
            href_rel: If href is given, use this value for the rel
                attribute (default 'doc').
            href_text: If href is given, use this as the friendly
                title/description for the link (defaults to "API documentation
                for this error").
            code: An internal code that customers can reference in their
                support request or to help them when searching for knowledge
                base articles related to this error.
        """

        headers = kwargs.setdefault('headers', {})
        headers['Retry-After'] = str(retry_after)
        HTTPError.__init__(self, status.HTTP_503, title, description, **kwargs)
Exemplo n.º 3
0
    def __init__(self, title, description, retry_after, **kwargs):
        """Initialize

        """

        headers = kwargs.setdefault('headers', {})
        headers['Retry-After'] = str(retry_after)
        HTTPError.__init__(self, status.HTTP_503, title, description, **kwargs)
Exemplo n.º 4
0
    def __init__(self, title, description, **kwargs):
        headers = kwargs.setdefault('headers', {})

        scheme = kwargs.pop('scheme', None)
        if scheme is not None:
            headers['WWW-Authenticate'] = scheme

        HTTPError.__init__(self, status.HTTP_401, title, description, **kwargs)
Exemplo n.º 5
0
    def __init__(self, title, description, **kwargs):
        """Initialize

        Args:
            Same as for HTTPError, except status is set for you.

        """
        HTTPError.__init__(self, status.HTTP_400, title, description, **kwargs)
Exemplo n.º 6
0
    def __init__(self, title, description, **kwargs):
        """Initialize

        Args:
            Same as for HTTPError, except status is set for you.

        """
        HTTPError.__init__(self, status.HTTP_400, title, description, **kwargs)
Exemplo n.º 7
0
    def __init__(self, title, description, retry_after, **kwargs):
        """Initialize

        """

        headers = kwargs.setdefault('headers', {})
        headers['Retry-After'] = str(retry_after)
        HTTPError.__init__(self, status.HTTP_503, title, description, **kwargs)
Exemplo n.º 8
0
    def __init__(self, title, description, **kwargs):
        headers = kwargs.setdefault("headers", {})

        scheme = kwargs.pop("scheme", None)
        if scheme is not None:
            headers["WWW-Authenticate"] = scheme

        HTTPError.__init__(self, status.HTTP_401, title, description, **kwargs)
Exemplo n.º 9
0
    def __init__(self, title, description, **kwargs):
        headers = kwargs.setdefault('headers', {})

        scheme = kwargs.pop('scheme', None)
        if scheme is not None:
            headers['WWW-Authenticate'] = scheme

        HTTPError.__init__(self, status.HTTP_401, title, description, **kwargs)
Exemplo n.º 10
0
    def __init__(self, description, **kwargs):
        """Initialize

        Args:
            description: Human-friendly description of the error, along with a
                helpful suggestion or two.

        The remaining (optional) args are the same as for HTTPError.

        """

        HTTPError.__init__(self, status.HTTP_415, 'Unsupported media type',
                           description, **kwargs)
Exemplo n.º 11
0
    def __init__(self, description, **kwargs):
        """Initialize

        Args:
            description: Human-friendly description of the error, along with a
                helpful suggestion or two.

        The remaining (optional) args are the same as for HTTPError.

        """

        HTTPError.__init__(self, status.HTTP_415, 'Unsupported media type',
                           description, **kwargs)
Exemplo n.º 12
0
    def __init__(self, allowed_methods, **kwargs):
        """Initilize with allowed methods

        Args:
            allowed_methods: A list of allowed HTTP methods for this resource,
                such as ['GET', 'POST', 'HEAD'].

        The remaining (optional) args are the same as for HTTPError.

        """
        headers = kwargs.setdefault('headers', {})
        headers['Allow'] = ', '.join(allowed_methods)

        HTTPError.__init__(self, status.HTTP_405, None, **kwargs)
Exemplo n.º 13
0
    def __init__(self, allowed_methods, **kwargs):
        """Initilize with allowed methods

        Args:
            allowed_methods: A list of allowed HTTP methods for this resource,
                such as ['GET', 'POST', 'HEAD'].

        The remaining (optional) args are the same as for HTTPError.

        """
        headers = kwargs.setdefault('headers', {})
        headers['Allow'] = ', '.join(allowed_methods)

        HTTPError.__init__(self, status.HTTP_405, None, **kwargs)
Exemplo n.º 14
0
    def __init__(self, resource_length, media_type=None):
        """Initialize

        Args:
            resource_length: The maximum value for the last-byte-pos of a
                range request. Used to set the Content-Range header.
            media_type: Media type to use as the value of the Content-Type
                header, or None to use the default passed to the API
                initializer.

        """

        headers = {'Content-Range': 'bytes */' + str(resource_length)}
        if media_type is not None:
            headers['Content-Type'] = media_type

        HTTPError.__init__(self, status.HTTP_416, None, None, headers=headers)
Exemplo n.º 15
0
    def __init__(self, resource_length, media_type=None):
        """Initialize

        Args:
            resource_length: The maximum value for the last-byte-pos of a
                range request. Used to set the Content-Range header.
            media_type: Media type to use as the value of the Content-Type
                header, or None to use the default passed to the API
                initializer.

        """

        headers = {'Content-Range': 'bytes */' + str(resource_length)}
        if media_type is not None:
            headers['Content-Type'] = media_type

        HTTPError.__init__(self, status.HTTP_416, None, None, headers=headers)
Exemplo n.º 16
0
    def __init__(self, title, description, scheme=None, **kwargs):
        """Initialize

        Args:
            title: Human-friendly error title
            description: Human-friendly description of the error, along with a
                helpful suggestion or two.
            scheme: Authentication scheme to use as the value of the
                WWW-Authenticate header in the response (default None).

        The remaining (optional) args are the same as for HTTPError.


        """
        headers = kwargs.setdefault('headers', {})
        if scheme is not None:
            headers['WWW-Authenticate'] = scheme

        HTTPError.__init__(self, status.HTTP_401, title, description, **kwargs)
Exemplo n.º 17
0
    def __init__(self, allowed_methods, **kwargs):
        HTTPError.__init__(self, status.HTTP_405, 'Method not allowed',
                           **kwargs)

        if kwargs:
            title = 'Method not allowed'
        else:
            # NOTE(kgriffs): Trigger an empty body in the response; 405
            # responses don't usually have bodies, so we only send one
            # if the caller indicates they want one, by way of specifying
            # a description, href, and/or other details.
            title = None

        # NOTE(kgriffs): Inject the "Allow" header so it will be included
        # in the HTTP response.
        headers = kwargs.setdefault('headers', {})
        headers['Allow'] = ', '.join(allowed_methods)

        HTTPError.__init__(self, status.HTTP_405, title, **kwargs)
Exemplo n.º 18
0
    def __init__(self, title, description, scheme=None, **kwargs):
        """Initialize

        Args:
            title: Human-friendly error title
            description: Human-friendly description of the error, along with a
                helpful suggestion or two.
            scheme: Authentication scheme to use as the value of the
                WWW-Authenticate header in the response (default None).

        The remaining (optional) args are the same as for HTTPError.


        """
        headers = kwargs.setdefault('headers', {})
        if scheme is not None:
            headers['WWW-Authenticate'] = scheme

        HTTPError.__init__(self, status.HTTP_401, title, description, **kwargs)
Exemplo n.º 19
0
    def __init__(self, allowed_methods, **kwargs):
        HTTPError.__init__(self, status.HTTP_405, 'Method not allowed',
                           **kwargs)

        if kwargs:
            title = 'Method not allowed'
        else:
            # NOTE(kgriffs): Trigger an empty body in the response; 405
            # responses don't usually have bodies, so we only send one
            # if the caller indicates they want one, by way of specifying
            # a description, href, and/or other details.
            title = None

        # NOTE(kgriffs): Inject the "Allow" header so it will be included
        # in the HTTP response.
        headers = kwargs.setdefault('headers', {})
        headers['Allow'] = ', '.join(allowed_methods)

        HTTPError.__init__(self, status.HTTP_405, title, **kwargs)
Exemplo n.º 20
0
    def __init__(self, allowed_methods, **kwargs):
        HTTPError.__init__(self, status.HTTP_405, 'Method not allowed',
                           **kwargs)

        # NOTE(kgriffs): Trigger an empty body in the response; 405
        # responses don't usually have bodies, so we only send one
        # if the caller indicates they want one by providing some
        # details in the kwargs.
        if kwargs:
            title = 'Method not allowed'
            self._has_representation = True
        else:
            title = None
            self._has_representation = False

        # NOTE(kgriffs): Inject the "Allow" header so it will be included
        # in the HTTP response.
        headers = kwargs.setdefault('headers', {})
        headers['Allow'] = ', '.join(allowed_methods)

        HTTPError.__init__(self, status.HTTP_405, title=title, **kwargs)
Exemplo n.º 21
0
 def __init__(self, title, description, **kwargs):
     HTTPError.__init__(self, '400 Bad Request', title, description,
                        **kwargs)
Exemplo n.º 22
0
    def __init__(self):
        """Initialize"""

        HTTPError.__init__(self, status.HTTP_404, None, None)
Exemplo n.º 23
0
    def __init__(self, allowed_methods, **kwargs):
        headers = kwargs.setdefault('headers', {})
        headers['Allow'] = ', '.join(allowed_methods)

        HTTPError.__init__(self, status.HTTP_405, None, **kwargs)
Exemplo n.º 24
0
 def __init__(self, resource_length):
     headers = {'Content-Range': 'bytes */' + str(resource_length)}
     HTTPError.__init__(self, status.HTTP_416, headers=headers)
Exemplo n.º 25
0
    def __init__(self, resource_length, media_type=None):
        headers = {'Content-Range': 'bytes */' + str(resource_length)}
        if media_type is not None:
            headers['Content-Type'] = media_type

        HTTPError.__init__(self, status.HTTP_416, None, None, headers=headers)
Exemplo n.º 26
0
 def __init__(self, allowed_methods):
     headers = {'Allow': ', '.join(allowed_methods)}
     HTTPError.__init__(self, status.HTTP_405, headers=headers)
Exemplo n.º 27
0
 def __init__(self, description, **kwargs):
     HTTPError.__init__(self, status.HTTP_406, 'Media type not acceptable',
                        description, **kwargs)
Exemplo n.º 28
0
 def __init__(self, title, description, **kwargs):
     HTTPError.__init__(self, status.HTTP_426, "Upgrade Required", description, **kwargs)
Exemplo n.º 29
0
    def __init__(self, resource_length, media_type=None):
        headers = {"Content-Range": "bytes */" + str(resource_length)}
        if media_type is not None:
            headers["Content-Type"] = media_type

        HTTPError.__init__(self, status.HTTP_416, None, None, headers=headers)
Exemplo n.º 30
0
 def __init__(self, description, **kwargs):
     HTTPError.__init__(self, HTTP_415, 'Unsupported Media Type',
                        description, **kwargs)
Exemplo n.º 31
0
    def __init__(self):
        """Initialize"""

        HTTPError.__init__(self, status.HTTP_404, None, None)
Exemplo n.º 32
0
 def __init__(self, title, description, retry_after, **kwargs):
     headers = kwargs.setdefault("headers", {})
     headers["Retry-After"] = str(retry_after)
     HTTPError.__init__(self, status.HTTP_503, title, description, **kwargs)
Exemplo n.º 33
0
 def __init__(self, description, **kwargs):
     HTTPError.__init__(self, status.HTTP_415, 'Unsupported media type',
                        description, **kwargs)
Exemplo n.º 34
0
 def __init__(self, title, description, **kwargs):
     HTTPError.__init__(self, status.HTTP_403, title, description, **kwargs)
Exemplo n.º 35
0
 def __init__(self, title, description, **kwargs):
     HTTPError.__init__(self, '422 Unprocessable Entity', title,
                        description, **kwargs)
Exemplo n.º 36
0
 def __init__(self, description, **kwargs):
     HTTPError.__init__(self, status.HTTP_415, "Unsupported Media Type", description, **kwargs)
Exemplo n.º 37
0
 def __init__(self, title, description, **kwargs):
     HTTPError.__init__(self, HTTP_400, title, description, **kwargs)
Exemplo n.º 38
0
    def __init__(self, title, description, scheme=None, **kwargs):
        headers = kwargs.setdefault('headers', {})
        if scheme is not None:
            headers['WWW-Authenticate'] = scheme

        HTTPError.__init__(self, HTTP_401, title, description, **kwargs)
Exemplo n.º 39
0
 def __init__(self, allowed_methods):
     headers = {"Allow": ", ".join(allowed_methods)}
     HTTPError.__init__(self, status.HTTP_405, headers=headers)
Exemplo n.º 40
0
    def __init__(self, allowed_methods, **kwargs):
        headers = kwargs.setdefault("headers", {})
        headers["Allow"] = ", ".join(allowed_methods)

        HTTPError.__init__(self, status.HTTP_405, None, **kwargs)
Exemplo n.º 41
0
 def __init__(self, description, **kwargs):
     HTTPError.__init__(self, status.HTTP_415, 'Unsupported media type',
                        description, **kwargs)
Exemplo n.º 42
0
 def __init__(self):
     HTTPError.__init__(self, status.HTTP_404, None, None)
Exemplo n.º 43
0
 def __init__(self):
     HTTPError.__init__(self, HTTP_404, None, None)
Exemplo n.º 44
0
    def __init__(self, allowed_methods, **kwargs):
        headers = kwargs.setdefault('headers', {})
        headers['Allow'] = ', '.join(allowed_methods)

        HTTPError.__init__(self, status.HTTP_405, None, **kwargs)
Exemplo n.º 45
0
 def __init__(self, description, **kwargs):
     HTTPError.__init__(self, status.HTTP_406, 'Media type not acceptable',
                        description, **kwargs)
Exemplo n.º 46
0
 def __init__(self):
     HTTPError.__init__(self, status.HTTP_404, None, None)
Exemplo n.º 47
0
 def __init__(self, resource_length):
     headers = {'Content-Range': 'bytes */' + str(resource_length)}
     HTTPError.__init__(self, status.HTTP_416, headers=headers)
Exemplo n.º 48
0
 def __init__(self, title, description, **kwargs):
     HTTPError.__init__(self, '422 Unprocessable Entity', title, description, **kwargs)
Exemplo n.º 49
0
 def __init__(self, title, description, **kwargs):
     HTTPError.__init__(self, status.HTTP_403, title, description, **kwargs)
Exemplo n.º 50
0
 def __init__(self, title, description, **kwargs):
     HTTPError.__init__(self, '400 Bad Request', title, description, **kwargs)