pyneric.requests

Helpers for the requests library.

pyneric.requests.SUPPORTED_METHODS = (Method(token='GET', description='Transfer a current representation of the target resource.', safe=True, idempotent=True, cacheable=True), Method(token='OPTIONS', description='Describe the communication options for the target resource.', safe=True, idempotent=True, cacheable=False), Method(token='HEAD', description='Same as GET, but only transfer the status line and header section.', safe=True, idempotent=True, cacheable=True), Method(token='POST', description='Perform resource-specific processing on the request payload.', safe=False, idempotent=False, cacheable=True), Method(token='PUT', description='Replace all current representations of the target resource with the request payload.', safe=False, idempotent=True, cacheable=False), Method(token='PATCH', description='Modify the target resource with the request payload.', safe=False, idempotent=False, cacheable=False), Method(token='DELETE', description='Remove all current representations of the target resource.', safe=False, idempotent=True, cacheable=False))

The HTTP methods supported by requests as functions.

These are also exposed as methods in RequestHandler.

class pyneric.requests.RequestHandler[source]

Bases: object

Base class for handlers of request calls.

request(method, url, **kwargs)[source]

Make an HTTP request using requests.request.

Parameters:
  • method (string) – request call argument
  • url (string) – request call argument
  • kwargs – request call keyword arguments
Returns:

result of the request

Return type:

dependent on implementation; Response by default

This can be overridden in a subclass, but the most common use case is to extend it.

delete(url, **kwargs)

Call request() with method ‘DELETE’.

get(url, **kwargs)

Call request() with method ‘GET’.

head(url, **kwargs)

Call request() with method ‘HEAD’.

options(url, **kwargs)

Call request() with method ‘OPTIONS’.

patch(url, **kwargs)

Call request() with method ‘PATCH’.

post(url, **kwargs)

Call request() with method ‘POST’.

put(url, **kwargs)

Call request() with method ‘PUT’.