ApiClient#
- class ApiClient(session, api_url, configuration)#
Provides a generic API client for OpenAPI client library builds.
This client handles client-server communication and is invariant across implementations. Specifics of the methods and models for each application are generated from OpenAPI templates and are responsible for interfacing with the public API exposed by the client.
- Parameters:
- session
requests.Session
Base session object that the API client is to use.
- api_url
str
Base URL for the API. All generated endpoint URLs are relative to this address.
- configuration
SessionConfiguration
Configuration options for the API client.
- session
Examples
>>> client = ApiClient(requests.Session(), ... 'http://my-api.com/API/v1.svc', ... SessionConfiguration()) ... <ApiClient url: http://my-api.com/API/v1.svc>
For testing purposes, it is common to configure an API with a self-signed certificate. By default, the
ApiClient
class will not trust self-signed SSL certificates. To allow this, pass a path to the root certificate to theSessionConfiguration
object. For more configuration examples, seeSessionConfiguration
.>>> session_config = SessionConfiguration(cert_store_path='./self-signed-cert.pem') ... ssl_client = ApiClient(requests.Session(), ... 'https://secure-api/API/v1.svc', ... session_config) ... ssl_client <ApiClient url: https://secure-api/API/v1.svc>
Methods
ApiClient.call_api
(resource_path, method[, ...])Make the HTTP request and return the deserialized data.
ApiClient.deserialize
(response, response_type)Deserialize the response into an object.
ApiClient.parameters_to_tuples
(params, ...)Get parameters as a list of tuples, formatting collections.
Build form parameters.
ApiClient.request
(method, url[, ...])Make the HTTP request and return it directly.
Build a JSON POST object.
ApiClient.select_header_accept
(accepts)Return a correctly formatted
Accept
header value from the provided array of accepted content types.Return the preferred
Content-Type
header value from the provided array of valid content types.ApiClient.setup_client
(models)Set up the client for use and register models for serialization and deserialization.
Attributes