infoblox 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  module Infoblox
2
2
  class Network < Resource
3
3
  remote_attr_accessor :network, :extensible_attributes
4
+ remote_attr_writer :auto_create_reversezone
4
5
  attr_accessor :network_view
5
6
 
6
7
  wapi_object "network"
@@ -17,10 +17,24 @@ module Infoblox
17
17
  end
18
18
  end
19
19
 
20
+ ##
21
+ # Define a remote attribute that is write-only
22
+ #
23
+ def self.remote_attr_writer(*args)
24
+ args.each do |a|
25
+ attr_accessor a
26
+ remote_write_only_attrs << a
27
+ end
28
+ end
29
+
20
30
  def self.remote_attrs
21
31
  @remote_attrs ||= []
22
32
  end
23
33
 
34
+ def self.remote_write_only_attrs
35
+ @remote_write_only_attrs ||= []
36
+ end
37
+
24
38
  def self._return_fields
25
39
  self.remote_attrs.join(",")
26
40
  end
@@ -72,10 +86,11 @@ module Infoblox
72
86
  end
73
87
  end
74
88
 
75
- def create
76
- self._ref = connection.post(resource_uri, remote_attribute_hash).body
89
+ def post
90
+ self._ref = connection.post(resource_uri, remote_attribute_hash(write = true)).body
77
91
  true
78
92
  end
93
+ alias_method :create, :post
79
94
 
80
95
  def delete
81
96
  connection.delete(resource_uri).status == 200
@@ -86,18 +101,21 @@ module Infoblox
86
101
  end
87
102
 
88
103
  def put
89
- connection.put(resource_uri, remote_attribute_hash)
104
+ connection.put(resource_uri, remote_attribute_hash(write = true))
90
105
  end
91
106
 
92
107
  def resource_uri
93
108
  self._ref.nil? ? self.class.resource_uri : (BASE_PATH + self._ref)
94
109
  end
95
110
 
96
- def remote_attribute_hash
111
+ def remote_attribute_hash(write=false)
97
112
  {}.tap do |hsh|
98
113
  self.class.remote_attrs.each do |k|
99
114
  hsh[k] = self.send(k)
100
115
  end
116
+ self.class.remote_write_only_attrs.each do |k|
117
+ hsh[k] = self.send(k)
118
+ end if write
101
119
  end
102
120
  end
103
121
 
@@ -1,3 +1,3 @@
1
1
  module Infoblox
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require 'spec_helper'
2
2
  class FooResource < Infoblox::Resource
3
3
  remote_attr_accessor :name, :junction
4
+ remote_attr_writer :do_it
4
5
  attr_accessor :animal
5
6
  wapi_object "foo:animal"
6
7
  end
@@ -32,5 +33,20 @@ describe Infoblox::Resource, "#add_ipv4addr" do
32
33
  FooResource.connection = conn
33
34
  FooResource.all.should eq([])
34
35
  end
36
+
37
+ [:put, :post].each do |operation|
38
+ it "should #{operation} with the right attributes" do
39
+ conn = double
40
+ uri = Infoblox::BASE_PATH + ((operation == :put) ? "abcd" : "foo:animal")
41
+ allow(conn).to receive(operation).with(uri, {:name => "jerry", :junction => "32", :do_it => false}).and_return(FooResponse.new("[]"))
42
+ FooResource.connection = conn
43
+ f = FooResource.new
44
+ f._ref = "abcd" if operation == :put
45
+ f.do_it = false
46
+ f.junction = "32"
47
+ f.name = "jerry"
48
+ f.send(operation)
49
+ end
50
+ end
35
51
  end
36
52
 
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.5
4
+ version: 0.0.6
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-22 00:00:00.000000000 Z
12
+ date: 2013-08-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday