infoblox 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,6 +17,15 @@ module Infoblox
17
17
  end
18
18
  end
19
19
 
20
+ def put(href, body)
21
+ wrap do
22
+ connection.put do |req|
23
+ req.url href
24
+ req.body = body.to_json
25
+ end
26
+ end
27
+ end
28
+
20
29
  def delete(href)
21
30
  wrap do
22
31
  connection.delete(href)
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Infoblox
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -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
 
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.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: