infoblox 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/infoblox/connection.rb +9 -0
- data/lib/infoblox/resource.rb +14 -1
- data/lib/infoblox/version.rb +1 -1
- data/spec/resource_spec.rb +10 -0
- metadata +1 -1
data/lib/infoblox/connection.rb
CHANGED
data/lib/infoblox/resource.rb
CHANGED
@@ -21,11 +21,19 @@ module Infoblox
|
|
21
21
|
@remote_attrs ||= []
|
22
22
|
end
|
23
23
|
|
24
|
+
def self._return_fields
|
25
|
+
self.remote_attrs.join(",")
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.default_params
|
29
|
+
{:_return_fields => self._return_fields}
|
30
|
+
end
|
31
|
+
|
24
32
|
##
|
25
33
|
# Return an array of all records for this resource.
|
26
34
|
#
|
27
35
|
def self.all
|
28
|
-
JSON.parse(connection.get(resource_uri).body).map do |item|
|
36
|
+
JSON.parse(connection.get(resource_uri, default_params).body).map do |item|
|
29
37
|
new(item)
|
30
38
|
end
|
31
39
|
end
|
@@ -40,6 +48,7 @@ module Infoblox
|
|
40
48
|
# {"name~" => "foo.*bar"}
|
41
49
|
#
|
42
50
|
def self.find(params)
|
51
|
+
params = default_params.merge(params)
|
43
52
|
JSON.parse(connection.get(resource_uri, params).body).map do |item|
|
44
53
|
new(item)
|
45
54
|
end
|
@@ -76,6 +85,10 @@ module Infoblox
|
|
76
85
|
connection.get(resource_uri, params)
|
77
86
|
end
|
78
87
|
|
88
|
+
def put
|
89
|
+
connection.put(resource_uri, remote_attribute_hash)
|
90
|
+
end
|
91
|
+
|
79
92
|
def resource_uri
|
80
93
|
self._ref.nil? ? self.class.resource_uri : (BASE_PATH + self._ref)
|
81
94
|
end
|
data/lib/infoblox/version.rb
CHANGED
data/spec/resource_spec.rb
CHANGED
@@ -5,6 +5,8 @@ class FooResource < Infoblox::Resource
|
|
5
5
|
wapi_object "foo:animal"
|
6
6
|
end
|
7
7
|
|
8
|
+
FooResponse = Struct.new(:body)
|
9
|
+
|
8
10
|
describe Infoblox::Resource, "#add_ipv4addr" do
|
9
11
|
it "hashes correctly" do
|
10
12
|
host = FooResource.new
|
@@ -22,5 +24,13 @@ describe Infoblox::Resource, "#add_ipv4addr" do
|
|
22
24
|
f._ref = "lkjlkj"
|
23
25
|
f.resource_uri.should eq(Infoblox::BASE_PATH + "lkjlkj")
|
24
26
|
end
|
27
|
+
|
28
|
+
it "should find with default attributes" do
|
29
|
+
conn = double
|
30
|
+
uri = Infoblox::BASE_PATH + "foo:animal"
|
31
|
+
allow(conn).to receive(:get).with(uri, {:_return_fields => "name,junction"}).and_return(FooResponse.new("[]"))
|
32
|
+
FooResource.connection = conn
|
33
|
+
FooResource.all.should eq([])
|
34
|
+
end
|
25
35
|
end
|
26
36
|
|