Provides basic REST API Implementation for GET, PUT, and POST, and DELETE.
Project description
UA-Generic-Rest-Api
Provides basic REST API Implementation for GET, PUT, and POST, and DELETE.
Motivation
Was designed to remove similarities among REST API implementations by creating a generic REST API that classes can be extended and override for specific needs.
Features
- GET - Implementation of GET which can single GET, batch GET, single GET with query, and GET every page on a paginated endpoint.
- Batch gets with queries are unavailable as there is no way to give each get a unique query. Because of this the feature was not included.
- PUT - Basic implementation of PUT which puts the payload to the given endpoint.
- POST - Basic implementation of POST which posts the payload to the given endpoint.
- DELETE - Basic implementation of DELETE which deletes the given endpoint.
Code Example
from ua_generic_rest_api import GenericRestApi
class SpecificRestApi(GenericRestApi):
# Replace '...' with any other initialization arguments.
def __init__(self, ...):
# host, header_info, page_query, and page_tag are site specific.
# Set them to your own values.
super().__init__(host, header_info, page_query, page_tag=page_tag)
# Can override GET, PUT, POST, or DELETE here.
- host - The base url for the endpoint that is to be gotten.
- header_info - Any information to be added to a request header such as Authorization or Content-Type.
- Should be in the form of a dictionary, such as {"Authorization": None, "Content-Type": "text/xml"}.
- page_query - The tag to use when querying for specific pages.
- For example, for sites queried with the tag "?page=", page_query should be "page".
- page_tag - The tag name of paginated endpoints to search for when getting data.
- For sites paginated with the tag "page", page_tag should be "page".
Installation
pip install ua-generic-rest-api
pip install -r requirements.txt
Tests
- Tests are only necessary when wanting to make changes to the module.
pip install --update node
cd ./ua_generic_rest_api
cd ./tests
nosetests test_generic_rest_api.py
Credits
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ua_generic_rest_api-2.0.6.tar.gz
.
File metadata
- Download URL: ua_generic_rest_api-2.0.6.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.9.18 Linux/6.2.0-36-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1400e213dfbbd56d630e54822cc3b8483bd44300146e6b2bb07c3ceff4f49dc4 |
|
MD5 | 8e5999081b94414af5e5116c031e5ec3 |
|
BLAKE2b-256 | 84151a92ff26530921aa27c36638eda0e217e669c623de0091483bb8a9e3d03e |
File details
Details for the file ua_generic_rest_api-2.0.6-py3-none-any.whl
.
File metadata
- Download URL: ua_generic_rest_api-2.0.6-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.9.18 Linux/6.2.0-36-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5cbe9e9ee092f56d6cd3054212df02498988a683e507dc64b00d9dac8dacc8c4 |
|
MD5 | caff5aa24e16359eb446728decea5369 |
|
BLAKE2b-256 | df910d5c344389f854bdbe49ccc3310ace8ef404b4e581f78650080e97444e6c |