Generic Connector so you can create simple and readable classes for accessing APIs.
Project description
Base API Connector
Helps create a simple API Connector where all you have to do is define the resources and possible commands in a config.
Example
First import the GenericAPIConnector class:
from base_api_connector import GenericAPIConnector
Then, define a base_api_url and a resource_config like this:
class ImplementedAPIConnector(GenericAPIConnector):
base_api_url = 'http://127.0.0.1:8000/api/'
resource_config = {
'reports': {
'commands': ('create', 'retrieve', 'update'),
'data': {
'content': {},
'author': {'required': True},
}
}
'users': {
'commands': 'all',
'data': {
'name': {'required': True}
}
},
...
}
This will generate the following attributes when you use this class:
conn = ImplementedAPIConnector()
conn.reports.create(data)
conn.reports.retrieve(id)
conn.reports update(id, data)
conn.users.list()
conn.users.create(data)
conn.users.retrieve(id)
conn.users.update(id, data)
conn.users.delete(id)
Those methods return a regular Response object from the requests module.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for base_api_connector-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b65499b2cc9a7b14c3af721e49d470027b2deda764d0266c1a4d7bbe17dfda4b |
|
MD5 | 66d43b3f5cf3c7e9e67fcc3dcb74999c |
|
BLAKE2b-256 | e7a30aa51c21c7ce40c45d976617484b78e3b2901ec1cad683db1ccc5c432511 |