Skip to content
This repository has been archived by the owner on Jan 15, 2018. It is now read-only.
/ foreman_api Public archive

[Deprecated][Archived] Ruby bindings for Forman's rest API

License

Notifications You must be signed in to change notification settings

theforeman/foreman_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Foreman API bindings for Ruby

NOTE

Alternatively, you may want to take a look at apipie-bindings. It is the replacement for foreman_api that is used in the Foreman CLI. It has more frequent releases. Additional info at apipie-bindings.

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

About

[Deprecated][Archived] Ruby bindings for Forman's rest API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages