joshnabbott / casper_api

Wrapper for the Casper API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Casper API

A work in progress Ruby wrapper for the Casper asset management API.

Installation

In your Gemfile, put the following:

gem 'casper_api', :git => 'git://github.com/factorylabs/casper_api.git'

Don’t forget to bundle your gems!

Usage

Here’s a quick and dirty example of how to use this:

include CasperApi
@casper         = Casper.new('<username>', '<password>')
@joshs_computer = @casper.computers.find('Joshua Abbott') #=> Assuming a computer named "Joshua Abbott" exists, will return this computer and all associated data.

OR

@some_computer = @casper.computers.find(1) #=> Returns computer with the ID of 1.

If you don’t know computer names or IDs you can always grab the full list of computers from Casper and then search the list for what you’re looking for:

@list              = @casper.computers.all #=> Will return a list of all computers with their names and IDs
@joshs_computer_id = @list.search(:name, 'Josh').first.id
@joshs_computer    = @casper.computers.find(@joshs_computer_id)

API Methods

So far there is support for the following calls:

  • Casper#buildings

  • Casper#categories

  • Casper#computer_groups

  • Casper#computers

  • Casper#departments

  • Casper#mobile_devices

Each of these will respond to the “all” and “find” methods. Lists respond to the “search” method.

For more help regarding how the Casper API works check out this link: casper.factorylabs.com:8443/apiFrontPage.rest

Tests

There are none. Please help.

Contributing to casper_api

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2011 Josh N. Abbott. See LICENSE.txt for further details.

About

Wrapper for the Casper API

License:MIT License