Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Console HTTP API tool

Project description

desman

Desman is console HTTP API requests tool. Desman uses .yml files to save request information. You can use enviroment files wich are also .yml files, to substitute variables to request.

Installation

Pip

pip install desman

Docker on Unix-like

Desman can be installed as .sh script running docker image:

sudo curl -L --fail https://raw.githubusercontent.com/kirillsulim/desman/master/scripts/run/run.sh -o /usr/local/bin/desman
sudo chmod +x /usr/local/bin/desman

Default tag in script is latest. If you want to fix specific version, change corresponding variable in script.

Docken on Windows

Desman can be installed as .ps1 script running docker image. Download script and set required permissions. Default tag in script is latest. If you want to fix specific version, change corresponding variable in script.

How to use

Simple request

Create .yml file with request description:

method: get
url: http://host.com/

then pass file path to desman

desman path/to/file.yml

and desman prints the body of response to console.

Request with parameters

Query parameters can be passed in url

method: get
url: http://host.com/?param=value

or be passed separately

method: get
url: http://host.com/
params:
  param: value

Headers

Headers can be passed in headers field

method: get
url: http://host.com/
headers:
  Authorization: Bearer some-auth-token
params:
  param: value

Body

Body content can be passed in body field in request file

method: post
url: http://host.com/post
headers:
  Authorization: Bearer some-auth-token
body: |
  {
      "stringField": "JSON value",
      "nestedObject": {
          "nestedField": [1, 2, 3]
      }
  }

Output parameters

The output of HTTP response is controlled by these optional paramters:

  • -s print status of response
  • -H print heafers of response
  • -b print body of response

If none of these parameters are passed desman prints only body of response.

Using environments

All request files are Jinja2 templates.

# request.yml
method: post
url: http://{{server.host}}:{{server.port}}/post
headers:
  Authorization: Bearer {{my-token}}
body: |
  {
      "stringField": "JSON value",
      "nestedObject": {
          "nestedField": [1, 2, 3]
      }
  }

Variables are substituted from enviroment .yml files

# env.yml
server:
  host: host.com
  port: 8080
my-token: "some-auth-token"

which are passed in optional parameter -e

desman -e env.yml request.yml

You can use many enviroment files. If they have similar fields desman will use the last occurence of value.

With many enviroment files

# env.yml
server:
  host: host.com
  port: 8080
my-token: "some-auth-token"
# new-token.yml
my-token: "new-token"

if both passed as

desman -e env.yml -e new-token.yml request.yml

request will be performed with Authorization: Bearer new-token header.

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 desman, version 1.0.5
Filename, size File type Python version Upload date Hashes
Filename, size desman-1.0.5-py3-none-any.whl (4.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size desman-1.0.5.tar.gz (3.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page