Class: Bluecat::Client
- Inherits:
-
Object
- Object
- Bluecat::Client
- Defined in:
- lib/bluecat/client.rb
Instance Method Summary collapse
-
#initialize(wsdl: '') ⇒ Client
constructor
A new instance of Client.
- #ip4_networks(container_id) ⇒ Object
- #login(username, password) ⇒ Object
- #logout ⇒ Object
- #ops ⇒ Object
Constructor Details
#initialize(wsdl: '') ⇒ Client
Returns a new instance of Client.
5 6 7 |
# File 'lib/bluecat/client.rb', line 5 def initialize(wsdl: '') @client ||= Savon.client(wsdl: wsdl, ssl_verify_mode: :none) end |
Instance Method Details
#ip4_networks(container_id) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/bluecat/client.rb', line 13 def ip4_networks(container_id) start = 0 count = 10 Enumerator.new do |yielder| loop do response = @client.call(:get_ip4_networks_by_hint, message: { container_id: container_id, start: start, count: count, options: '' }, cookies: @cookies) retval = response.body[:get_ip4_networks_by_hint_response][:return] raise StopIteration if retval == nil # Last item will be hash if not more than one. Make it an array. retval[:item] = [retval[:item]] unless retval[:item].is_a?(Array) retval[:item].each do | item | range = item[:properties].split('|')[0].split('=')[1] yielder.yield({ id: item[:id], name: item[:name], ip_range: range }) end start += count end end end |
#login(username, password) ⇒ Object
37 38 39 40 |
# File 'lib/bluecat/client.rb', line 37 def login(username, password) response = @client.call(:login, message: { username: username, password: password }) @cookies = response.http. end |
#logout ⇒ Object
42 43 44 |
# File 'lib/bluecat/client.rb', line 42 def logout @client.call(:logout, cookies: @cookies) end |
#ops ⇒ Object
9 10 11 |
# File 'lib/bluecat/client.rb', line 9 def ops @client.operations end |