Foreman API bindings for Ruby

Summary

require 'foreman_api'
architectures = ForemanApi::Resources::Architecture.new(:base_url => 'http://localhost:3000', 
                                                        :username => 'admin', 
                                                        :password => 'changeme')

pp architectures.index
[[{"architecture"=>{"id"=>5, "name"=>"i386"}},
  {"architecture"=>{"id"=>9, "name"=>"ppc"}},
  {"architecture"=>{"id"=>14, "name"=>"x86_64"}}],
 "[{\"architecture\":{\"name\":\"i386\",\"id\":5}},{\"architecture\":{\"name\":\"ppc\",\"id\":9}},{\"architecture\":{\"name\":\"x86_64\",\"id\":14}}]"]
=> nil

Description

This gem contains Foreman API bindings for the Ruby language. The bindings are generated from API documentation using Apidoc tool.

The bindings brings support for new versioned API which is not complete yet. The number of supported controllers is limited but more are coming soon.

Regenerating bindings

The code for generating the bindings is a part of this repo. The generator needs a running Foreman instance to load the apidoc.json.

Usage:

bin/generate.rb -h
Script for generating API bindings for Foreman API from Apipie docs.
    -u, --url FOREMAN_APIDOC_URL     By default http://localhost:3000/apidoc
    -h, --help

Only files under lib/foreman_api/resources are touched by the generator.

Authentication

Foreman API supports authentication with username/password and OAuth. For use of OAuth with the bindings you only have to change the params

architectures = ForemanApi::Resources::Architecture.new(:base_url => 'http://localhost:3000', 
                                                        :oauth    => { :consumer_key    => 'mykey',
                                                                       :consumer_secret => 'shhhh' })

License

The bindings are released under MIT license