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.ResourceDecorator(resource, also_return_response=False)¶ Bases:
objectWraps
bravado_core.resource.Resourceso that accesses to contained operations can be instrumented.
-
class
bravado.client.SwaggerClient(swagger_spec, also_return_response=False)¶ Bases:
objectA client for accessing a Swagger-documented RESTful service.
-
classmethod
from_spec(spec_dict, origin_url=None, http_client=None, config=None)¶ Build a
SwaggerClientfrom 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
SwaggerClientfrom 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)¶
-
classmethod
-
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¶ Bases:
bravado.config.BravadoConfigCreate new instance of BravadoConfig(also_return_response, disable_fallback_results, response_metadata_class)
-
static
from_config_dict(config)¶
-
static
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:
objectAuthenticates 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.AuthenticatorHTTP 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.HttpClientSynchronous 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.FutureAdapterMimics a
concurrent.futures.Futurefor 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)
-
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.IncomingResponseWraps 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:
objectMimics a
concurrent.futures.Futureregardless 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.
-
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:
objectWrapper for a
FutureAdapterthat 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.RequestConfigandbravado.client.REQUEST_OPTIONS_DEFAULTS
-
response(timeout=None, fallback_result=<object 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 (Optional[Union[Any, Callable[[Exception], Any]]]) – 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 (List/Tuple of Exception classes.) – 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_response – bravado_core.response.IncomingResponseRaises: HTTPError
-
bravado.http_future.raise_on_unexpected(http_response)¶ Raise an HTTPError if the response is 5XX.
Parameters: http_response – bravado_core.response.IncomingResponseRaises: 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. Seebravado_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:
objectBravado response object containing the swagger result as well as response metadata.
Variables: - result – Swagger result from the server
- metadata (BravadoResponseMetadata) – metadata for this response including HTTP response
-
incoming_response¶
-
class
bravado.response.BravadoResponseMetadata(incoming_response, swagger_result, start_time, request_end_time, handled_exception_info, request_config)¶ Bases:
objectHTTP 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.ExceptionThis 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.HTTPServerErrorHTTP/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.HTTPClientErrorHTTP/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.HTTPError4xx 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.HTTPClientErrorHTTP/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.IOErrorUnified 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.
-
class
bravado.exception.HTTPErrorType¶ Bases:
typeA metaclass for registering HTTPError subclasses.
-
exception
bravado.exception.HTTPExpectationFailed(response, message=None, swagger_result=None)¶ Bases:
bravado.exception.HTTPClientErrorHTTP/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.HTTPClientErrorHTTP/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.HTTPClientErrorHTTP/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.HTTPRedirectionHTTP/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.HTTPServerErrorHTTP/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.HTTPClientErrorHTTP/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.HTTPServerErrorHTTP/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.HTTPServerErrorHTTP/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.HTTPServerErrorHTTP/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.HTTPClientErrorHTTP/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.HTTPClientErrorHTTP/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.HTTPServerErrorHTTP/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.HTTPClientErrorHTTP/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.HTTPClientErrorHTTP/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.HTTPRedirectionHTTP/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.HTTPRedirectionHTTP/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.HTTPServerErrorHTTP/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.HTTPClientErrorHTTP/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.HTTPServerErrorHTTP/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.HTTPClientErrorHTTP/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.HTTPServerErrorHTTP/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.HTTPRedirectionHTTP/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.HTTPClientErrorHTTP/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.HTTPClientErrorHTTP/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.HTTPRedirectionHTTP/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.HTTPClientErrorHTTP/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.HTTPClientErrorHTTP/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.HTTPClientErrorHTTP/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.HTTPClientErrorHTTP/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.HTTPError3xx 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.HTTPClientErrorHTTP/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.HTTPClientErrorHTTP/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.HTTPRedirectionHTTP/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.HTTPError5xx 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.
Bases:
bravado.exception.HTTPServerErrorHTTP/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.
-
exception
bravado.exception.HTTPTemporaryRedirect(response, message=None, swagger_result=None)¶ Bases:
bravado.exception.HTTPRedirectionHTTP/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.HTTPClientErrorHTTP/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.HTTPClientErrorHTTP/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¶
Bases:
bravado.exception.HTTPClientErrorHTTP/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.
Bases:
bravado.exception.HTTPClientErrorHTTP/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.
-
exception
bravado.exception.HTTPUnprocessableEntity(response, message=None, swagger_result=None)¶ Bases:
bravado.exception.HTTPClientErrorHTTP/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.HTTPClientErrorHTTP/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.HTTPClientErrorHTTP/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.HTTPRedirectionHTTP/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.HTTPServerErrorHTTP/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
HTTPErrorclass will be returned. :type response:bravado_core.response.IncomingResponse:param message: Optional string message :param swagger_result: If the response for this HTTPError isdocumented 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:
objectClass that behaves like the
HttpFuture.response()method as well as aBravadoResponse. Please check the documentation for further information.-
metadata¶
-
result¶
-
-
class
bravado.testing.response_mocks.FallbackResultBravadoResponseMock(exception=BravadoTimeoutError(), metadata=None)¶ Bases:
objectClass that behaves like the
HttpFuture.response()method as well as aBravadoResponse. It will always call thefallback_resultcallback that’s passed to theresponse()method. Please check the documentation for further information.-
metadata¶
-
result¶
-
-
class
bravado.testing.response_mocks.IncomingResponseMock(status_code, **kwargs)¶ Bases:
bravado_core.response.IncomingResponse