REST API cheat sheats
This repo is crated as a source for the REST API blogpost series on the http://karneliuk.com. It intends to cover the interaction with the various applications via REST API. The primary focus is the network automation and programmability, as all the recent topics on the http://karneliuk.com were built around REST API.
- Ansible (2.8)
- Bash (4.2)
- Postman (1.18)
- Python (3.7)
It might be that provided scripts are working in other versions, but it was not tested and therefore not guaranteed. In general all the information is provided on the AS-IS basis.
Python 3.7 version was used, and all the tests were performed in the virtual environment (venv). To get it running perform:
python3.7 -m venv vevin the folder with the scripts to create the virtual environment.
source venv/bin/activeto enter the virtual environment context.
pip install --upgrade pipto update the pip to the latest version.
pip install -r requirements.txtto install the used (or potentially used in the near future) Python libraries.
Execution (e.g. the simplest GET request):
- For Ansible playbooks:
ansible-playbook rest_get.yml -i ansible_hosts.yml
- For Bash:
- For Postman: import proper Postman collection and use it.
- For Python:
python rest_get.pyfrom the virtual environment context. For further details read the official articles at http://karneliuk.com/tag/rest-api/.
The REST API with Ansbile was extensivly used in the two my big projects:
- Service Provider Fabric (https://github.com/akarneliuk/service_provider_fabric)
- Data Centre Fabric (https://github.com/akarneliuk/data_center_fabric)