Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Ruby bindings for Forman's rest API
Ruby CSS JavaScript

This branch is 20 commits behind theforeman:master

Failed to load latest commit information.
bin
doc
lib
.gitignore
.yardopts
Gemfile
MIT-LICENSE
README.rdoc
Rakefile
foreman_api.gemspec Update the gemspec
rubygem-foreman_api.spec

README.rdoc

Foreman API bindings for Ruby

Summary

Usage:

require 'foreman_api'
require 'logger' # optional

architectures = ForemanApi::Resources::Architecture.new(
  {
    :logger => Logger.new(STDOUT), # optional
    :base_url => 'http://foreman-url', 
    :username => 'admin', 
    :password => 'changeme'
  })

puts architectures.index.inspect

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 uses OAuth for authentication, you need to provide url, key and secret. Also, it is required to provide user which will be used for the request if oauth_map_users setting in the Foreman instance is set, otherwise 401 error will occur and Foreman log will state “users mapping error”.

When setting base_url make sure it *does not* include trailing slash, otherwise request can be refused with 401.

require 'foreman_api'

architectures = ForemanApi::Resources::Architecture.new(
  {
    :base_url => 'http://foreman-url', 
    :oauth => {
      :consumer_key    => 'katello',
      :consumer_secret => "shhhh" 
    }
  },{
    :headers => {
      :foreman_user => "admin",
    }
  })

puts architectures.index.inspect

License

The bindings are released under MIT license

Something went wrong with that request. Please try again.