Giter Site home page Giter Site logo

foreman_api's Introduction

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

foreman_api's People

Contributors

ares avatar inecas avatar jhadvig avatar lzap avatar mbacovsky avatar pitr-ch avatar xsuchy 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.