infoblox 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -42,6 +42,14 @@ Find hosts (fuzzy matches on host name):
42
42
 
43
43
  client.find_host_by_name("build-")
44
44
 
45
+ One can also use the resource classes directly to run arbitrary query logic:
46
+
47
+ Infoblox::Network.find({"_return_fields" => "extensible_attributes"})
48
+ # => [...]
49
+
50
+ Infoblox::Host.find({"name~" => "demo[0-9]{1,}-web.domain"})
51
+ # => [...]
52
+
45
53
  ## Contributing
46
54
 
47
55
  1. Fork it
data/lib/infoblox/host.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  module Infoblox
2
2
  class Host < Resource
3
- remote_attr_accessor :ipv4addrs, :name, :configure_for_dns
3
+ remote_attr_accessor :ipv4addrs, :name, :configure_for_dns,
4
+ :extensible_attributes
4
5
  attr_accessor :view
5
6
 
6
7
  wapi_object "record:host"
@@ -1,6 +1,6 @@
1
1
  module Infoblox
2
2
  class Network < Resource
3
- remote_attr_accessor :network
3
+ remote_attr_accessor :network, :extensible_attributes
4
4
  attr_accessor :network_view
5
5
 
6
6
  wapi_object "network"
@@ -6,6 +6,10 @@ module Infoblox
6
6
  obj.nil? ? @wapi_object : @wapi_object = obj
7
7
  end
8
8
 
9
+ ##
10
+ # Define a writeable remote attribute, i.e. one that
11
+ # should show up in post / put operations.
12
+ #
9
13
  def self.remote_attr_accessor(*args)
10
14
  args.each do |a|
11
15
  attr_accessor a
@@ -17,12 +21,24 @@ module Infoblox
17
21
  @remote_attrs ||= []
18
22
  end
19
23
 
24
+ ##
25
+ # Return an array of all records for this resource.
26
+ #
20
27
  def self.all
21
28
  JSON.parse(connection.get(resource_uri).body).map do |item|
22
29
  new(item)
23
30
  end
24
31
  end
25
32
 
33
+ ##
34
+ # Find resources with query parameters.
35
+ #
36
+ # Example: return extensible attributes for every resource.
37
+ # {"_return_fields" => "extensible_attributes"}
38
+ #
39
+ # Example: filter resources by name.
40
+ # {"name~" => "foo.*bar"}
41
+ #
26
42
  def self.find(params)
27
43
  JSON.parse(connection.get(resource_uri, params).body).map do |item|
28
44
  new(item)
@@ -56,8 +72,8 @@ module Infoblox
56
72
  connection.delete(resource_uri).status == 200
57
73
  end
58
74
 
59
- def get
60
- connection.get(resource_uri)
75
+ def get(params={})
76
+ connection.get(resource_uri, params)
61
77
  end
62
78
 
63
79
  def resource_uri
@@ -1,3 +1,3 @@
1
1
  module Infoblox
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infoblox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-20 00:00:00.000000000 Z
12
+ date: 2013-08-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday