Skip to main content

CLI to access RESTful service

Project description

A generic CLI to access any RESTful service with a little bit of configuration. Think of it as something in between curl and proper CLI.

Features:

  • Replace parts of JSON request body while sending the request using simple object.property[index] notation

  • Print only part of JSON response using above described notation

  • History: Previously sent request are stored and can be resent using --last option

  • Templates: Store preset requests of a particular URL and send them using --template option

  • Service config: Store common headers, URL prefix, preset requests of a particular service in config

It has options similar to curl to fetch and provide request body. -d, -H and -d are same as curl. -X is changed to -m. Currently, the tool uses requests to send HTTP requests. In future, it may just be wrapper on top of curl delegating all options to curl.

Sample usage:

With following configuration in ~/.crest/raxid/config.py:

tokens_request = {
    "auth": {
        "passwordCredentials":{
            "username":"REPLACE_USERNAME",
            "password":"REPLACE_PASSWORD"
        }
    }
}
config = {
    "name": "raxid",
    "description": "Rackspace Identity Service",
    "uriprefix": "https://identity.api.rackspacecloud.com/v2.0",
    "headers": {
        "accept": "application/json",
        "content-type": "application/json"
    },
    "resources": {
        "tokens/?$": {
            "templates": {"default": tokens_request},
            "aliases": {
                "username": "auth.passwordCredentials.username",
                "password": "auth.passwordCredentials.password",
            },
            "help": "Authenticate via username/password"
        }
    }
}

one can authenticate to Rackspace Identity Service and extract token using following command:

crest -s raxid tokens -m post -t -r username=myuname -r password=mypwd -o access.token.id

For more details check usage

Installation

pip install crest
mkdir -p ~/.crest/generic_history  # for --history and --service to work

Thanks

Thanks to Rackspace for having a culture of hacking on side projects and allowing me to work on this, and having an excellent open source employee contribution policy

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

crest-0.0.1.tar.gz (7.6 kB view details)

Uploaded Source

File details

Details for the file crest-0.0.1.tar.gz.

File metadata

  • Download URL: crest-0.0.1.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for crest-0.0.1.tar.gz
Algorithm Hash digest
SHA256 6552b1804f13b840118d46bbb136f28397b52530d9e767043adb089719765691
MD5 1ce16be4514e382e97cdcd98d8e1f249
BLAKE2b-256 f87da7c89fdf295cc689fb1d365d50354a9b773abb0c4c5b65bf23f9a9a4c331

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page