eater.api package

Submodules

eater.api.base module

eater.api.base

Base Eater API classes and utilities.

class eater.api.base.BaseEater[source]

Bases: abc.ABC

Base Eater class.

request_cls

A schematics model that represents the API request.

response_cls

A schematics model that represents the API response.

eater.api.http module

eater.api

Eater API classes and utilities.

class eater.api.http.HTTPEater(*, session: requests.sessions.Session = None, auth: tuple = None, headers: requests.structures.CaseInsensitiveDict = None)[source]

Bases: eater.api.base.BaseEater

Eat JSON HTTP APIs for breakfast.

create_request_model(request_model: schematics.models.Model = None, **kwargs) → schematics.models.Model[source]

Create the request model either from kwargs or request_model.

create_response_model(response: requests.models.Response, request_model: schematics.models.Model) → schematics.models.Model[source]

Given a requests Response object, return the response model.

Parameters:
  • response – A requests.Response object representing the response from the API.
  • request_model – The model used to generate the request.
create_session(auth: tuple = None, headers: requests.structures.CaseInsensitiveDict = None) → requests.sessions.Session[source]

Create an instance of a requests Session.

get_request_kwargs(request_model: schematics.models.Model, **kwargs) → dict[source]

Retrieve a dict of kwargs to supply to requests.

method = 'get'

The HTTP method to use to make the API call.

request(*, request_model: schematics.models.Model = None, **kwargs) → schematics.models.Model[source]

Make a HTTP request of of type method.

session = None

An instance of requests Session

url

Returns the URL to the endpoint.

Module contents