Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

HTTP client

Project Description

cdumay-rest-client

This library is a basic REST client with exception formatting.

Quickstart

First, install cdumay-rest-client using pip:

$ pip install flask-zookeeper

Next, add a RESTClient instance to your code:

import json, sys
from cdumay_rest_client.client import RESTClient

client = RESTClient(server="http://jsonplaceholder.typicode.com")
json.dump(
    client.do_request(method="GET", path="/posts/1"),
    sys.stdout,
    sort_keys=True,
    indent=4,
    separators=(',', ': ')
)

Result:

{
    "body": "quia et suscipit\nsuscipit recusandae [...]",
    "id": 1,
    "title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
    "userId": 1
}

Exception

You can use marshmallow to serialize exceptions:

import json, sys
from cdumay_rest_client.client import RESTClient
from cdumay_rest_client.exceptions import HTTPException, HTTPExceptionValidator

try:
    client = RESTClient(server="http://jsonplaceholder.typicode.com")
    data = client.do_request(method="GET", path="/me")
except HTTPException as exc:
    data = HTTPExceptionValidator().dump(exc).data

json.dump(data, sys.stdout, sort_keys=True, indent=4, separators=(',', ': '))

Result:

{
    "code": 404,
    "extra": {},
    "message": "Not Found"
}

License

Apache License 2.0

Release History

Release History

This version
History Node

0.0.21

History Node

0.0.19

History Node

0.0.18

History Node

0.0.17

History Node

0.0.16

History Node

0.0.15

History Node

0.0.14

History Node

0.0.13

History Node

0.0.12

History Node

0.0.11

History Node

0.0.10

History Node

0.0.9

History Node

0.0.8

History Node

0.0.7

History Node

0.0.5

History Node

0.0.4

History Node

0.0.3

History Node

0.0.2

History Node

0.0.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
cdumay-rest-client-0.0.21.tar.gz (4.7 kB) Copy SHA256 Checksum SHA256 Source Aug 18, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting