https://github.com/mdwheele/bluecat
https://github.com/mdwheele/bluecat
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/mdwheele/bluecat
- Owner: mdwheele
- License: mit
- Created: 2017-04-27T13:51:32.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-27T15:13:55.000Z (about 9 years ago)
- Last Synced: 2025-03-15T07:02:22.864Z (over 1 year ago)
- Language: Ruby
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Bluecat
This gem wraps certain operations with the Bluecat Address Management API via `savon`. I use this specifically to integrate with [Foreman](https://theforeman.org) so there is a lot that this gem cannot do, yet. That said, I am open to pull requests to add more features.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'bluecat'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install bluecat
## Usage
```ruby
require 'bluecat'
require 'pp'
client = Bluecat::Client.new(wsdl: 'https://hostname/Services/API?wsdl')
client.login('api-username', 'api-password')
# This is the object ID of where to start
# your search.
container_id = 1
pp client.ip4_networks(container_id).to_a
client.logout
```
It is a "best practice" (according to Bluecat's documentation) to logout at the end of a session. When I use this in other projects, I might expose it like so:
```ruby
class SomeUseCase
# All access to API happens through this method
def bluecat
username = HammerCLI::Settings.get(:bluecat, :username)
password = HammerCLI::Settings.get(:bluecat, :password)
client = Bluecat::Client.new(wsdl: HammerCLI::Settings.get(:bluecat, :wsdl))
client.login(username, password)
yield client
client.logout
end
def execute
bluecat do |client|
# Do things with the client
client.ip4_networks(@container_id).take(10)
end
end
end
```
In this way, the client will log in and out for every operation. This may not be best for your use-case.
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/mdwheele/bluecat.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).