Git Product home page Git Product logo

apipie-bindings's Introduction

Apipie Bindings

The Ruby bindings for Apipie documented APIs.

Features

Caching

The bindings cache the apidoc from the server. It has separated caches for each server it connects to. If the server sends the apipie checksum in the headers Apipie-Checksum: <md5> , the bindings can expire the cache and reload updated version before next request. If the server does not send the hashes, the cache does not expire and has to be deleted manually when necessary.

The ability to send checksums comes with Apipie 0.1.1, see the docs on how to set it up.

API introspection

It is possible to list available resources, actions, params, routes and its attributes

Getting started
$ rake install
$ irb
irb> require 'apipie-bindings'

irb> api = ApipieBindings::API.new({:uri => 'http://localhost:3000/', :username => 'admin', :password => :changeme})
Listing resources
irb> api.resources
=> [<Resource :roles>, <Resource :images>, <Resource :reports>, <Resource :hosts>, .... <Resource :architectures>]
Listing actions
irb> api.resource(:roles).actions
=> [<Action roles:index>, <Action roles:show>, <Action roles:create>, <Action roles:update>, <Action roles:destroy>]
Listing routes
irb> api.resource(:architectures).action(:show).routes
=> [<Route /api/architectures/:id>]
Listing params
irb> api.resource(:architectures).action(:show).params
=> [<Param *id (String)>]


irb> api.resource(:architectures).action(:show).params.first.required?
=> true
Calling methods (all the calls bellow are equivalent)
irb> api.resource(:architectures).call(:show, :id => 1)
=> {"name"=>"x86_64", "id"=>1, "created_at"=>"2013-12-03T15:00:08Z", "updated_at"=>"2013-12-03T15:00:08Z"}

irb> api.call(:architectures, :show, :id => 1)
=> {"name"=>"x86_64", "id"=>1, "created_at"=>"2013-12-03T15:00:08Z", "updated_at"=>"2013-12-03T15:00:08Z"}

irb> api.resource(:architectures).action(:show).call(:id => 1)
=> {"name"=>"x86_64", "id"=>1, "created_at"=>"2013-12-03T15:00:08Z", "updated_at"=>"2013-12-03T15:00:08Z"}

Logging

It is possible to set custom (Logger compatible) logger while creating API instance.

ApipieBindings::API.new({:uri => 'http://localhost:3000/', :logger => Logging.logger(STDOUT)})

Add gem awesome_print to your application Gemfile if you want to debug api calls with awesome inspect.

Documentation

there is not much of the library documented yet, but we started to document our API with Yard. The docs are installed with the gem and can be viewed from the docs dir directly or by running yard server --gems or online on rubydoc.info

TODO

  • update docs

License

This project is licensed under the MIT license.

apipie-bindings's People

Contributors

mbacovsky avatar evgeni avatar inecas avatar kbrock avatar ofedoren avatar mmoll avatar alongoldboim avatar komidore64 avatar daviddavis avatar domcleal avatar jrafanie avatar lzap avatar nicklamuro avatar ezr-ondrej avatar rabajaj0509 avatar seanmalloy avatar timogoebel avatar tdevelioglu 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.