Giter Site home page Giter Site logo

gohit's Introduction

gohit

Run curl commands from yaml files.

Download current version 0.1.0

  • Define your API:
headers:
  - 'Accept: application/vnd.github.v3+json'

url: https://api.github.com

options:
  - '--compress'

endpoints:
  get_repo:
    path: /repos/{owner}/{repo}
  get_user:
    path: /users/{username}
    options:
      - '--silent'

requests:
  show_sconsify:
    endpoint: get_repo
    owner: fabiofalci
    repo: sconsify
  show_fabio:
    endpoint: get_user
    username: fabiofalci
  • Show requests:
$ gohit -f github.yaml requests
Request show_fabio:
curl https://api.github.com/users/fabiofalci \
        -H 'Accept: application/vnd.github.v3+json' \
        --compress \
        --silent \
        -XGET

Request show_sconsify:
curl https://api.github.com/repos/fabiofalci/sconsify \
        -H 'Accept: application/vnd.github.v3+json' \
        --compress \
        -XGET

  • Execute a request:
$ gohit -f github.yaml run show_sconsify
{
  "id": 21726337,
  "name": "sconsify",
  "full_name": "fabiofalci/sconsify",
  "network_count": 14,
  ....
  "subscribers_count": 24
}

yaml file spec

# list of files to be imported
files:
  - 'api.yaml'
  - 'api-security-token.yaml'

# list of headers
headers:
  - 'Accept: application/vnd.github.v3+json'

# curl url
url: https://api.github.com

# list of any other curl option
options:
  - '--compress'

# global variables
variables:
  name: value1
  date: value2


# endpoint definitions
endpoints:

  # endpoint name
  get_repo:

    # endpoint path
    path: /repos/{owner}/{repo}

    # http method
    method: GET

    # query string
    query: name={name}&date={date}

    # any other curl option
    options:
      - '--silent'

# request definitions
requests:

  # request name
  show_sconsify:

    # endpoint name
    endpoint: get_repo

    # local variables
    owner: fabiofalci
    repo: sconsify

Environments

You can define one basic api file and then import it from different environment files:

api.yaml

url: https://{env}.my-api.com

endpoints:
  get_something:
    path: /something/{id}

api-staging.yaml

files:
  - 'api.yaml'

variables:
  env: dev

requests:
  get_something_123:
    endpoint: get_something
    id: 123

api-uat.yaml

files:
  - 'api.yaml'

variables:
  env: uat

requests:
  get_something_456:
    endpoint: get_something
    id: 456

gohit's People

Contributors

fabiofalci 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.