bravado Package

bravado Package

client Module

The SwaggerClient provides an interface for making API calls based on a swagger spec, and returns responses of python objects which build from the API response.

Structure Diagram:

+---------------------+
|                     |
|    SwaggerClient    |
|                     |
+------+--------------+
       |
       |  has many
       |
+------v--------------+
|                     |
|     Resource        +------------------+
|                     |                  |
+------+--------------+         has many |
       |                                 |
       |  has many                       |
       |                                 |
+------v--------------+           +------v--------------+
|                     |           |                     |
|     Operation       |           |    SwaggerModel     |
|                     |           |                     |
+------+--------------+           +---------------------+
       |
       |  uses
       |
+------v--------------+
|                     |
|     HttpClient      |
|                     |
+---------------------+

To get a client

client = bravado.client.SwaggerClient.from_url(swagger_spec_url)
class bravado.client.CallableOperation(operation, also_return_response=False)

Bases: object

class bravado.client.ResourceDecorator(resource, also_return_response=False)

Bases: object

Wraps bravado_core.resource.Resource so that accesses to contained operations can be instrumented.

class bravado.client.SwaggerClient(swagger_spec, also_return_response=False)

Bases: object

A client for accessing a Swagger-documented RESTful service.

classmethod from_spec(spec_dict, origin_url=None, http_client=None, config=None)

Build a SwaggerClient from a Swagger spec in dict form.

Parameters:
  • spec_dict – a dict with a Swagger spec in json-like form
  • origin_url (str) – the url used to retrieve the spec_dict
  • config – Configuration dict - see spec.CONFIG_DEFAULTS
Return type:

bravado_core.spec.Spec

classmethod from_url(spec_url, http_client=None, request_headers=None, config=None)

Build a SwaggerClient from a url to the Swagger specification for a RESTful API.

Parameters:
  • spec_url (str) – url pointing at the swagger API specification
  • http_client (bravado.http_client.HttpClient) – an HTTP client used to perform requests
  • request_headers (dict) – Headers to pass with http requests
  • config – Config dict for bravado and bravado_core. See CONFIG_DEFAULTS in :module:`bravado_core.spec`. See CONFIG_DEFAULTS in :module:`bravado.client`.
Return type:

bravado_core.spec.Spec

get_model(model_name)
bravado.client.construct_params(operation, request, op_kwargs)

Given the parameters passed to the operation invocation, validates and marshals the parameters into the provided request dict.

Parameters:op_kwargs – the kwargs passed to the operation invocation
Raises:SwaggerMappingError on extra parameters or when a required parameter is not supplied.
bravado.client.construct_request(operation, request_options, **op_kwargs)

Construct the outgoing request dict.

Parameters:
  • request_options – _request_options passed into the operation invocation.
  • op_kwargs – parameter name/value pairs to passed to the invocation of the operation.
Returns:

request in dict form

bravado.client.inject_headers_for_remote_refs(request_callable, request_headers)

Inject request_headers only when the request is to retrieve the remote refs in the swagger spec (vs being a request for a service call).

Parameters:
  • request_callable – method on http_client to make a http request
  • request_headers – headers to inject when retrieving remote refs

config Module

class bravado.config.BravadoConfig(also_return_response, disable_fallback_results, response_metadata_class)

Bases: tuple

Create new instance of BravadoConfig(also_return_response, disable_fallback_results, response_metadata_class)

also_return_response

Alias for field number 0

disable_fallback_results

Alias for field number 1

response_metadata_class

Alias for field number 2

class bravado.config.RequestConfig(request_options, also_return_response_default)

Bases: object

additional_properties = {}
also_return_response = False
connect_timeout = None
force_fallback_result = False
headers = {}
response_callbacks = []
timeout = None
use_msgpack = False
bravado.config.bravado_config_from_config_dict(config_dict)

requests_client Module

class bravado.requests_client.ApiKeyAuthenticator(host, api_key, param_name=u'api_key', param_in=u'query')

Bases: bravado.requests_client.Authenticator

?api_key authenticator.

This authenticator adds an API key via query parameter or header.

Parameters:
  • host – Host to authenticate for.
  • api_key – API key.
  • param_name – Query parameter specifying the API key.
  • param_in – How to send the API key. Can be ‘query’ or ‘header’.
apply(request)

Apply authentication to a request.

Parameters:request – Request to add authentication information to.
class bravado.requests_client.Authenticator(host)

Bases: object

Authenticates requests.

Parameters:host – Host to authenticate for.
apply(request)

Apply authentication to a request.

Parameters:request – Request to add authentication information to.
matches(url)

Returns true if this authenticator applies to the given url.

Parameters:url – URL to check.
Returns:True if matches host, port and scheme, False otherwise.
class bravado.requests_client.BasicAuthenticator(host, username, password)

Bases: bravado.requests_client.Authenticator

HTTP Basic authenticator.

Parameters:
  • host – Host to authenticate for.
  • username – Username.
  • password – Password
apply(request)

Apply authentication to a request.

Parameters:request – Request to add authentication information to.
class bravado.requests_client.RequestsClient(ssl_verify=True, ssl_cert=None)

Bases: bravado.http_client.HttpClient

Synchronous HTTP client implementation.

Parameters:
  • ssl_verify – Set to False to disable SSL certificate validation. Provide the path to a CA bundle if you need to use a custom one.
  • ssl_cert – Provide a client-side certificate to use. Either a sequence of strings pointing to the certificate (1) and the private key (2), or a string pointing to the combined certificate and key.
apply_authentication(request)
authenticated_request(request_params)
request(request_params, operation=None, request_config=None)
Parameters:
  • request_params (dict) – complete request data.
  • operation (bravado_core.operation.Operation) – operation that this http request is for. Defaults to None - in which case, we’re obviously just retrieving a Swagger Spec.
  • request_config (RequestConfig) – per-request configuration
Returns:

HTTP Future object

Return type:

class:bravado_core.http_future.HttpFuture

separate_params(request_params)

Splits the passed in dict of request_params into two buckets.

  • sanitized_params are valid kwargs for constructing a requests.Request(..)
  • misc_options are things like timeouts which can’t be communicated to the Requests library via the requests.Request(…) constructor.
Parameters:request_params – kitchen sink of request params. Treated as a read-only dict.
Returns:tuple(sanitized_params, misc_options)
set_api_key(host, api_key, param_name=u'api_key', param_in=u'query')
set_basic_auth(host, username, password)
class bravado.requests_client.RequestsFutureAdapter(session, request, misc_options)

Bases: bravado.http_future.FutureAdapter

Mimics a concurrent.futures.Future for the purposes of making HTTP calls with the Requests library in a future-y sort of way.

Kicks API call for Requests client

Parameters:
  • session – session object to use for making the request
  • request – dict containing API request parameters
  • misc_options (dict) – misc options to apply when sending a HTTP request. e.g. timeout, connect_timeout, etc
build_timeout(result_timeout)

Build the appropriate timeout object to pass to session.send(…) based on connect_timeout, the timeout passed to the service call, and the timeout passed to the result call.

Parameters:result_timeout – timeout that was passed into future.result(..)
Returns:timeout
Return type:float or tuple(connect_timeout, timeout)
cancel()

Must implement a cancel method which terminates any ongoing network request.

connection_errors = (<class 'requests.exceptions.ConnectionError'>,)
result(timeout=None)

Blocking call to wait for API response

Parameters:timeout (float) – timeout in seconds to wait for response. Defaults to None to wait indefinitely.
Returns:raw response from the server
Return type:dict
timeout_errors = (<class 'requests.exceptions.ReadTimeout'>,)
class bravado.requests_client.RequestsResponseAdapter(requests_lib_response)

Bases: bravado_core.response.IncomingResponse

Wraps a requests.models.Response object to provide a uniform interface to the response innards.

headers
json(**kwargs)
Returns:response content in a json-like form
Return type:int, float, double, string, unicode, list, dict
raw_bytes
reason
status_code
text

fido_client Module

http_future Module

class bravado.http_future.FutureAdapter

Bases: typing.Generic

Mimics a concurrent.futures.Future regardless of which client is performing the request, whether it is synchronous or actually asynchronous.

This adapter must be implemented by all bravado clients such as FidoClient or RequestsClient to wrap the object returned by their ‘request’ method.

cancel()

Must implement a cancel method which terminates any ongoing network request.

connection_errors = ()
result(timeout=None)

Must implement a result method which blocks on result retrieval.

Parameters:timeout – maximum time to wait on result retrieval. Defaults to None which means blocking undefinitely.
timeout_errors = ()
class bravado.http_future.HttpFuture(future, response_adapter, operation=None, request_config=None)

Bases: typing.Generic

Wrapper for a FutureAdapter that returns an HTTP response.

Parameters:
  • future – The future object to wrap.
  • response_adapter (type that is a subclass of bravado_core.response.IncomingResponse.) – Adapter type which exposes the innards of the HTTP response in a non-http client specific way.
  • request_config (RequestConfig) – See bravado.config.RequestConfig and bravado.client.REQUEST_OPTIONS_DEFAULTS
cancel()
response(timeout=None, fallback_result=<bravado.http_future._SENTINEL object>, exceptions_to_catch=(<class 'bravado.exception.BravadoTimeoutError'>, <class 'bravado.exception.BravadoConnectionError'>, <class 'bravado.exception.HTTPServerError'>))

Blocking call to wait for the HTTP response.

Parameters:
  • timeout (float) – Number of seconds to wait for a response. Defaults to None which means wait indefinitely.
  • fallback_result – either the swagger result or a callable that accepts an exception as argument and returns the swagger result to use in case of errors
  • exceptions_to_catch – Exception classes to catch and call fallback_result with. Has no effect if fallback_result is not provided. By default, fallback_result will be called for read timeout and server errors (HTTP 5XX).
Returns:

A BravadoResponse instance containing the swagger result and response metadata.

result(timeout=None)

DEPRECATED: please use the response() method instead.

Blocking call to wait for and return the unmarshalled swagger result.

Parameters:timeout (float) – Number of seconds to wait for a response. Defaults to None which means wait indefinitely.
Returns:Depends on the value of also_return_response sent in to the constructor.
bravado.http_future.raise_on_expected(http_response)

Raise an HTTPError if the response is non-2XX and matches a response in the swagger spec.

Parameters:http_responsebravado_core.response.IncomingResponse
Raises:HTTPError
bravado.http_future.raise_on_unexpected(http_response)

Raise an HTTPError if the response is 5XX.

Parameters:http_responsebravado_core.response.IncomingResponse
Raises:HTTPError
bravado.http_future.reraise_errors(func)
bravado.http_future.unmarshal_response(incoming_response, operation, response_callbacks=None)

So the http_client is finished with its part of processing the response. This hands the response over to bravado_core for validation and unmarshalling and then runs any response callbacks. On success, the swagger_result is available as incoming_response.swagger_result. :type incoming_response: bravado_core.response.IncomingResponse :type operation: bravado_core.operation.Operation :type response_callbacks: list of callable. See

bravado_core.client.REQUEST_OPTIONS_DEFAULTS.
Raises:

HTTPError - On 5XX status code, the HTTPError has minimal information. - On non-2XX status code with no matching response, the HTTPError

contains a detailed error message.

  • On non-2XX status code with a matching response, the HTTPError
    contains the return value.
bravado.http_future.unmarshal_response_inner(response, op)

Unmarshal incoming http response into a value based on the response specification. :type response: bravado_core.response.IncomingResponse :type op: bravado_core.operation.Operation :returns: value where type(value) matches response_spec[‘schema’][‘type’]

if it exists, None otherwise.

response Module

class bravado.response.BravadoResponse(result, metadata)

Bases: typing.Generic

Bravado response object containing the swagger result as well as response metadata.

Variables:
incoming_response
class bravado.response.BravadoResponseMetadata(incoming_response, swagger_result, start_time, request_end_time, handled_exception_info, request_config)

Bases: typing.Generic

HTTP response metadata.

NOTE: The elapsed_time attribute might be slightly lower than the actual time spent since calling the operation object, as we only start measuring once the call to HTTPClient.request returns. Nevertheless, it should be accurate enough for logging and debugging, i.e. determining what went on and how much time was spent waiting for the response.

Variables:
  • start_time (float) – monotonic timestamp at which the future was created
  • request_end_time (float) – monotonic timestamp at which we received the HTTP response
  • processing_end_time (float) – monotonic timestamp at which processing the response ended
  • handled_exception_info (tuple) – 3-tuple of exception class, exception instance and string representation of the traceback in case an exception was caught during request processing.
Parameters:
  • incoming_response – a subclass of bravado_core.response.IncomingResponse.
  • swagger_result – the unmarshalled result that is being returned to the user.
  • start_time – monotonic timestamp indicating when the HTTP future was created. Depending on the internal operation of the HTTP client used, this is either before the HTTP request was initiated (default client) or right after the HTTP request was sent (e.g. bravado-asyncio / fido).
  • request_end_time – monotonic timestamp indicating when we received the incoming response, excluding unmarshalling, validation or potential fallback result processing.
  • handled_exception_info – sys.exc_info() data if an exception was caught and handled as part of a fallback response; note that the third element in the list is a string representation of the traceback, not a traceback object.
  • request_config (RequestConfig) – namedtuple containing the request options that were used for making this request.
elapsed_time
headers
incoming_response
is_fallback_result
request_elapsed_time
status_code

exception Module

exception bravado.exception.BravadoConnectionError

Bases: exceptions.OSError

exception bravado.exception.BravadoTimeoutError

Bases: exceptions.OSError

exception bravado.exception.ForcedFallbackResultError

Bases: exceptions.Exception

This exception will be handled if the option to force returning a fallback result is used.

exception bravado.exception.HTTPBadGateway(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPServerError

HTTP/502 - Bad Gateway

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 502
exception bravado.exception.HTTPBadRequest(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/400 - Bad Request

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 400
exception bravado.exception.HTTPClientError(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPError

4xx responses.

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
exception bravado.exception.HTTPConflict(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/409 - Conflict

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 409
exception bravado.exception.HTTPError(response, message=None, swagger_result=None)

Bases: exceptions.IOError

Unified HTTPError used across all http_client implementations.

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = None
class bravado.exception.HTTPErrorType

Bases: type

A metaclass for registering HTTPError subclasses.

exception bravado.exception.HTTPExpectationFailed(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/417 - Expectation Failed

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 417
exception bravado.exception.HTTPFailedDependency(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/424 - Failed Dependency

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 424
exception bravado.exception.HTTPForbidden(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/403 - Forbidden

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 403
exception bravado.exception.HTTPFound(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPRedirection

HTTP/302 - Found

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 302
exception bravado.exception.HTTPGatewayTimeout(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPServerError

HTTP/504 - Gateway Timeout

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 504
exception bravado.exception.HTTPGone(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/410 - Gone

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 410
exception bravado.exception.HTTPHTTPVersionNotSupported(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPServerError

HTTP/505 - HTTP Version Not Supported

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 505
exception bravado.exception.HTTPInsufficientStorage(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPServerError

HTTP/507 - Insufficient Storage

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 507
exception bravado.exception.HTTPInternalServerError(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPServerError

HTTP/500 - Internal Server Error

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 500
exception bravado.exception.HTTPLengthRequired(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/411 - Length Required

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 411
exception bravado.exception.HTTPLocked(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/423 - Locked

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 423
exception bravado.exception.HTTPLoopDetected(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPServerError

HTTP/508 - Loop Detected

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 508
exception bravado.exception.HTTPMethodNotAllowed(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/405 - Method Not Allowed

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 405
exception bravado.exception.HTTPMisdirectedRequest(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/421 - Misdirected Request

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 421
exception bravado.exception.HTTPMovedPermanently(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPRedirection

HTTP/301 - Moved Permanently

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 301
exception bravado.exception.HTTPMultipleChoices(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPRedirection

HTTP/300 - Multiple Choices

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 300
exception bravado.exception.HTTPNetworkAuthenticationRequired(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPServerError

HTTP/511 - Network Authentication Required

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 511
exception bravado.exception.HTTPNotAcceptable(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/406 - Not Acceptable

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 406
exception bravado.exception.HTTPNotExtended(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPServerError

HTTP/510 - Not Extended

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 510
exception bravado.exception.HTTPNotFound(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/404 - Not Found

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 404
exception bravado.exception.HTTPNotImplemented(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPServerError

HTTP/501 - Not Implemented

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 501
exception bravado.exception.HTTPNotModified(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPRedirection

HTTP/304 - Not Modified

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 304
exception bravado.exception.HTTPPayloadTooLarge(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/413 - Payload Too Large

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 413
exception bravado.exception.HTTPPaymentRequired(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/402 - Payment Required

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 402
exception bravado.exception.HTTPPermanentRedirect(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPRedirection

HTTP/308 - Permanent Redirect

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 308
exception bravado.exception.HTTPPreconditionFailed(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/412 - Precondition Failed

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 412
exception bravado.exception.HTTPPreconditionRequired(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/428 - Precondition Required

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 428
exception bravado.exception.HTTPProxyAuthenticationRequired(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/407 - Proxy Authentication Required

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 407
exception bravado.exception.HTTPRangeNotSatisfiable(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/416 - Range Not Satisfiable

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 416
exception bravado.exception.HTTPRedirection(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPError

3xx responses.

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
exception bravado.exception.HTTPRequestHeaderFieldsTooLarge(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/431 - Request Header Fields Too Large

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 431
exception bravado.exception.HTTPRequestTimeout(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/408 - Request Timeout

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 408
exception bravado.exception.HTTPSeeOther(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPRedirection

HTTP/303 - See Other

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 303
exception bravado.exception.HTTPServerError(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPError

5xx responses.

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
exception bravado.exception.HTTPServiceUnavailable(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPServerError

HTTP/503 - Service Unavailable

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 503
exception bravado.exception.HTTPTemporaryRedirect(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPRedirection

HTTP/307 - Temporary Redirect

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 307
exception bravado.exception.HTTPTooManyRequests(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/429 - Too Many Requests

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 429
exception bravado.exception.HTTPURITooLong(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/414 - URI Too Long

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 414
exception bravado.exception.HTTPUnauthorized(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/401 - Unauthorized

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 401
exception bravado.exception.HTTPUnavailableForLegalReasons(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/451 - Unavailable For Legal Reasons

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 451
exception bravado.exception.HTTPUnprocessableEntity(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/422 - Unprocessable Entity

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 422
exception bravado.exception.HTTPUnsupportedMediaType(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/415 - Unsupported Media Type

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 415
exception bravado.exception.HTTPUpgradeRequired(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPClientError

HTTP/426 - Upgrade Required

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 426
exception bravado.exception.HTTPUseProxy(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPRedirection

HTTP/305 - Use Proxy

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 305
exception bravado.exception.HTTPVariantAlsoNegotiates(response, message=None, swagger_result=None)

Bases: bravado.exception.HTTPServerError

HTTP/506 - Variant Also Negotiates

Parameters:
  • message – Optional string message
  • swagger_result – If the response for this HTTPError is documented in the swagger spec, then this should be the result value of the response.
status_code = 506
bravado.exception.make_http_exception(response, message=None, swagger_result=None)

Return an HTTP exception class based on the response. If a specific class doesn’t exist for a particular HTTP status code, a more general HTTPError class will be returned. :type response: bravado_core.response.IncomingResponse :param message: Optional string message :param swagger_result: If the response for this HTTPError is

documented in the swagger spec, then this should be the result value of the response.
Returns:An HTTP exception class that can be raised

testing Module

class bravado.testing.response_mocks.BravadoResponseMock(result, metadata=None)

Bases: typing.Generic

Class that behaves like the HttpFuture.response() method as well as a BravadoResponse. Please check the documentation for further information.

metadata
result
class bravado.testing.response_mocks.FallbackResultBravadoResponseMock(exception=BravadoTimeoutError(), metadata=None)

Bases: object

Class that behaves like the HttpFuture.response() method as well as a BravadoResponse. It will always call the fallback_result callback that’s passed to the response() method. Please check the documentation for further information.

metadata
result
class bravado.testing.response_mocks.IncomingResponseMock(status_code, **kwargs)

Bases: bravado_core.response.IncomingResponse