Skip to main content

Tools that interact with Agilent's iLab REST architecture.

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

sterns1 EtienneThompson

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.

Files for ua-generic-rest-api, version 2.0.1
Filename, size File type Python version Upload date Hashes
Filename, size ua_generic_rest_api-2.0.1-py3-none-any.whl (5.3 kB) File type Wheel Python version py3 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page