Metadata-Version: 2.1
Name: microclient
Version: 0.4.5
Summary: A library for creating REST API clients quick and painless.
Home-page: https://bitbucket.org/biinsight/microclient/
Author: Szymon Nowak
Author-email: snowak@biinsight.pl
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Description-Content-Type: text/markdown
Requires-Dist: requests
Requires-Dist: loguru

# Microclient
Microclient is a library for building simple python clients for your microservices.

Basic usage:
```python
from microclient import BaseClient, EndpointInfo

class ZOOClient(BaseClient):
    service_name = 'ZOO API'
    endpoints = [
        EndpointInfo("animals", [
            EndpointInfo("cats", "GET"),
            EndpointInfo("dogs", "GET"),
            EndpointInfo("elephants", "GET"),
        ]),
        EndpointInfo("zoo-status", "GET"),
        EndpointInfo("tickets", "GET, POST, DELETE")
    ]
```

Which translates into client like this:
```python
zoo_client = ZooClient('http://localhost:8000')
zoo_client.animals.cats() # sends GET request to http://localhost:8000/animals/cats
zoo_client.tickets.post(data={'amount': 2})  # sends POST request to http://localhost:8000/tickets with json data
```

For now, authorization can be done via Auth Token on client initialization:
```python
zoo_client = ZooClient('http://localhost:8000', auth='some_token')
```
And the token will be appended to every request header. By default the Authorization header prefix is `Token` but it can be set like this:
```python
zoo_client = ZooClient('http://localhost:8000', auth='some_token', auth_prefix="Bearer")
```
Which will send header like this:
`"Authorization": "Bearer some_token"`

## Responses
Every endpoint called on a microclient will return `LazyResponse` object, which is - as the name suggests - lazy loaded. `Lazy Response` has three main properties that are most important:
`data` (preferably JSON response data, but will fallback to byte-string content on decode failure), `status` (integer status code) and `headers` (response headers).


Currently microclient is working with json data only (requests and responses).

