Hermes cURL is a lightweight wrapper on top of cURL that provides reusable HTTP request configurations in YAML.
Project description
Hermes cURL
Hermes cURL is a lightweight wrapper on top of cURL that provides reusable HTTP request configurations in YAML. Configuration files can import attributes from other files which allows for common settings such as hostnames and authentication headers to be shared by multiple cURL calls.
Usage
Set up a base configuration for an entire API:
# api_base.yml
headers:
Authorization: Token MySecretAPIToken
Content-Type: application/json
host: localhost:5000
curl_flags:
"--location":
Set up a configuration for a specific endpoint and import our the base settings:
# api.yml
from: api_base.yml
method: PUT
path: /my/api
body: >
{"hello": "world"}
Run the hermes
command:
$ hermes api.yml
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 128 100 112 100 16 3960 565 --:--:-- --:--:-- --:--:-- 4000
{
"msg": "hello Mr world"
}
See examples for a working example.
Installation
python3 -m pip install hermes-curl
Configuration file reference
Options
from
(optional): specify a path to another configuration file to inherit configurations from. This path is relative to the current file.path
(requires): path on the server to send the request to, including any query params.method
(required): HTTP method to use.host
(required): server host, including protocol and port.headers
(optional): dictionary of headers in the form. ExHeader: value
.body
(optional): request body.curl_flags
(optional): a dictionary with any other curl flags to add. Ex"--cacert: certfile"
.template_defaults
(optional): a dictionary of default template variables.
Config Inheritance
Configurations are merged in the following fashion:
- Dictionaries are merged. Values set in child configs having precedence and override any values from the parent configuration.
path
is concatenated, so settingpath: /foo/
in the parent andpath: /bar/
in the child will result inpath: /foo/bar/
- All other top level configurations use whatever value is set in the child configuration.
This includes
method
,body
, andhost
.
Template Variables
Configurations can contain variables using the {variable_name}
syntax. Variables can
be passed into the configuration by either setting -t variable_name=value
on the cli
or by setting template_defaults
in the configuration. Values passed on the cli have
precedence over values set in template_defaults.
Example
host: http://localhost/
path: api/thing/{pk}/
method: GET
template_defaults:
pk: 1
Running hermes -t pk=2 example.yml
will GET http://localhost/api/thing/2/
and running
hermes example.yml
will GET http://localhost/api/thing/1/
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 Distribution
Built Distribution
File details
Details for the file hermes_curl-1.0.4.tar.gz
.
File metadata
- Download URL: hermes_curl-1.0.4.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e00699a1b89f00b76d8b3703e03d7ad5c4060ba0b864b6d0cbeb06c9b496e5b4 |
|
MD5 | b476b921b73a72cbdc0b2d6f108f90ef |
|
BLAKE2b-256 | 19ff9adf10e45b70c3fca0a8ade66c2b5f78d92b2af0c62c30781febc3392afb |
File details
Details for the file hermes_curl-1.0.4-py3-none-any.whl
.
File metadata
- Download URL: hermes_curl-1.0.4-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 283df9ab74de370f64e417bb32211ec30e50a129965c0bc598301e437b9e7760 |
|
MD5 | a6da71ba9fdc5e9deb2a7f14956f7a0d |
|
BLAKE2b-256 | a471e5330158d86ed2cc5b9ad7c45b952c593133230a76a34a52467cd044cbd0 |