Coder Social home page Coder Social logo

crest's Introduction

"Curl"REST API Command line client

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. NOTE: Be careful as this will store request including password in history

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

crest's People

Contributors

manishtomar avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.