infoblox 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA512:
3
+ data.tar.gz: fe70db9970416b97a4b479ee0a038d400ceb8760206912a169a473b567305108cd12f2584345e571d391c2fb3b4e94f3fe98ee739d35f66e389718b3b47515b9
4
+ metadata.gz: 32e97f4d1181671747fc75e5f6d2bf0bb6c444bbe3bf23ad68dba24312fb9c0308a5e8a26ab17479e8eb355fcbb0a780515493e2dd9b3d5b89c0cd1d99034ee3
5
+ SHA1:
6
+ data.tar.gz: 0894fe3f72ec58287022a14e6a05dfd1a566054e
7
+ metadata.gz: 7e4f651a69f6130d8616bcf16e7e3bf5c234699b
data/README.md CHANGED
@@ -25,24 +25,37 @@ An instance of the `Infoblox::Connection` class is necessary:
25
25
  connection = Infoblox::Connection.new(username: '', password: '', host: '')
26
26
 
27
27
  ## Reading
28
- Each resource class implements `all` and `find`. You can use the `_max_results` and `_return_fields` parameters for both of these methods. See the Infoblox WAPI documentation on how to use these parameters.
28
+ Each resource class implements `.all`, `.find`, and `#get`.
29
29
 
30
+ ### `.find`
31
+ Use find when you don't know what you are looking for or you don't have a `_ref` saved (see `get` below). Use `_max_results` to limit / expand the number of returned results.
32
+
33
+ # You can find hosts that match a regular expression:
34
+ Infoblox::Host.find(connection, {"name~" => "demo[0-9]{1,}-web.domain"})
35
+ # => [...]
36
+
37
+ ### `.all`
38
+ Show all results (note that this is limited by `_max_results`). Use this cautiously when you have a large potential set of results.
39
+
30
40
  # Find all networks. Note that this is limited to 1000 objects, as per the
31
41
  # Infoblox WAPI documentation.
32
42
  Infoblox::Network.all(connection)
33
43
  # => [...]
34
-
44
+
35
45
  # If you want more than 1,000 records, use `_max_results`:
36
46
  Infoblox::Network.all(connection, _max_results: 7890)
37
47
 
38
- # You can find hosts that match a regular expression:
39
- Infoblox::Host.find(connection, {"name~" => "demo[0-9]{1,}-web.domain"})
40
- # => [...]
41
-
42
48
  The usage of search parameters is well-documented in the Infoblox WAPI documentation, and this client supports them fully.
43
49
 
50
+ ### `#get`
51
+ Use this when you have saved a reference (`_ref`) and want to load it later.
52
+
53
+ host = Infoblox::Host.new(:connection => c, :_ref => ref).get
54
+ puts host.name
55
+ # => foo.bar
56
+
44
57
  ## Searching
45
- You can also search across the Infoblox cluster using the `Infoblox::Search` resource. The response will contain any number of `Infoblox::Resource` subclass instances.
58
+ You can also search across all Infoblox resource types using the `Infoblox::Search` resource. The response will contain any number of `Infoblox::Resource` subclass instances.
46
59
 
47
60
  result = Infoblox::Search.find(connection, "search_string~" => "webserver-")
48
61
  # => [#<Infoblox::Host>, #<Infoblox::Ptr>, ...]
@@ -183,6 +196,7 @@ To run the tests:
183
196
 
184
197
  To run the integration tests (you will be prompted for your Infoblox credentials):
185
198
 
199
+ INTEGRATION=true bundle
186
200
  INTEGRATION=true rspec
187
201
 
188
202
  Please note that the integration tests do not work in Ruby 1.8.7, but the unit tests function normally.
@@ -125,17 +125,7 @@ module Infoblox
125
125
  end
126
126
 
127
127
  def initialize(attrs={})
128
- attrs.each do |k,v|
129
- # Some things have specialized writers,
130
- # like Host
131
- if respond_to?("#{k}=")
132
- send("#{k}=", v)
133
-
134
- # Some things don't have writers (i.e. remote_attr_reader fields)
135
- else
136
- instance_variable_set("@#{k}", v)
137
- end
138
- end
128
+ load_attributes(attrs)
139
129
  end
140
130
 
141
131
  def post
@@ -148,8 +138,10 @@ module Infoblox
148
138
  connection.delete(resource_uri).status == 200
149
139
  end
150
140
 
151
- def get(params={})
152
- connection.get(resource_uri, params)
141
+ def get(params=self.class.default_params)
142
+ response = connection.get(resource_uri, params).body
143
+ load_attributes(JSON.parse(response))
144
+ self
153
145
  end
154
146
 
155
147
  def put
@@ -179,6 +171,20 @@ module Infoblox
179
171
  def unquote(str)
180
172
  str.gsub(/\A['"]+|['"]+\Z/, "")
181
173
  end
174
+
175
+ def load_attributes(attrs)
176
+ attrs.each do |k,v|
177
+ # Some things have specialized writers,
178
+ # like Host
179
+ if respond_to?("#{k}=")
180
+ send("#{k}=", v)
181
+
182
+ # Some things don't have writers (i.e. remote_attr_reader fields)
183
+ else
184
+ instance_variable_set("@#{k}", v)
185
+ end
186
+ end
187
+ end
182
188
  end
183
189
 
184
190
  end
@@ -1,3 +1,3 @@
1
1
  module Infoblox
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -10,7 +10,7 @@ if ENV['INTEGRATION']
10
10
  it 'should create, update, and destroy' do
11
11
  failure = false
12
12
  each_version do
13
- @host = Infoblox::Host.new(connection: connection)
13
+ @host = Infoblox::Host.new(:connection => connection)
14
14
  begin
15
15
  @host.add_ipv4addr('10.30.30.30')
16
16
  @host.name = "poc-infobloxgem-test1.ep.gdi"
@@ -90,6 +90,19 @@ describe Infoblox::Resource, "#add_ipv4addr" do
90
90
  expect(f.sect).to eq(:larry)
91
91
  end
92
92
 
93
+ it 'should load attributes on get' do
94
+ conn = double
95
+ uri = Infoblox.base_path + "a:ref:that:is:fake"
96
+ json = {:name => "john", :junction => "hi", :extattrs => {"foo" => 3}}.to_json
97
+ response = FooResponse.new(json)
98
+ expect(conn).to receive(:get).with(uri, FooResource.default_params).and_return(response)
99
+ f = FooResource.new(:connection => conn, :_ref => "a:ref:that:is:fake")
100
+ f.get
101
+ expect(f.name).to eq("john")
102
+ expect(f.junction).to eq("hi")
103
+ expect(f.extattrs).to eq({"foo" => 3})
104
+ end
105
+
93
106
  it 'should map wapi objects to classes' do
94
107
  @expected = {}
95
108
  ObjectSpace.each_object(Class) do |p|
metadata CHANGED
@@ -1,119 +1,87 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: infoblox
3
- version: !ruby/object:Gem::Version
4
- version: 0.4.1
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - Billy Reisinger
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-06-18 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: faraday
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
11
+
12
+ date: 2015-08-11 00:00:00 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ prerelease: false
16
+ requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - &id002
19
+ - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: "0"
22
22
  type: :runtime
23
+ name: json
24
+ version_requirements: *id001
25
+ - !ruby/object:Gem::Dependency
23
26
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: faraday_middleware
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
27
+ requirement: &id003 !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - *id002
38
30
  type: :runtime
31
+ name: faraday
32
+ version_requirements: *id003
33
+ - !ruby/object:Gem::Dependency
39
34
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: rspec
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
35
+ requirement: &id004 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - *id002
38
+ type: :runtime
39
+ name: faraday_middleware
40
+ version_requirements: *id004
41
+ - !ruby/object:Gem::Dependency
55
42
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- - !ruby/object:Gem::Dependency
63
- name: bundler
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ~>
68
- - !ruby/object:Gem::Version
69
- version: '1.3'
43
+ requirement: &id005 !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - *id002
70
46
  type: :development
47
+ name: rspec
48
+ version_requirements: *id005
49
+ - !ruby/object:Gem::Dependency
71
50
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
51
+ requirement: &id006 !ruby/object:Gem::Requirement
52
+ requirements:
75
53
  - - ~>
76
- - !ruby/object:Gem::Version
77
- version: '1.3'
78
- - !ruby/object:Gem::Dependency
79
- name: rake
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
54
+ - !ruby/object:Gem::Version
55
+ version: "1.3"
86
56
  type: :development
57
+ name: bundler
58
+ version_requirements: *id006
59
+ - !ruby/object:Gem::Dependency
87
60
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: pry
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
61
+ requirement: &id007 !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - *id002
102
64
  type: :development
65
+ name: rake
66
+ version_requirements: *id007
67
+ - !ruby/object:Gem::Dependency
103
68
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
69
+ requirement: &id008 !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - *id002
72
+ type: :development
73
+ name: pry
74
+ version_requirements: *id008
110
75
  description: A Ruby wrapper to the Infoblox WAPI
111
- email:
76
+ email:
112
77
  - billy.reisinger@govdelivery.com
113
78
  executables: []
79
+
114
80
  extensions: []
81
+
115
82
  extra_rdoc_files: []
116
- files:
83
+
84
+ files:
117
85
  - .gitignore
118
86
  - .rspec
119
87
  - .travis.yml
@@ -154,38 +122,29 @@ files:
154
122
  - spec/search_spec.rb
155
123
  - spec/spec_helper.rb
156
124
  homepage: https://github.com/govdelivery/infoblox
157
- licenses:
125
+ licenses:
158
126
  - MIT
127
+ metadata: {}
128
+
159
129
  post_install_message:
160
130
  rdoc_options: []
161
- require_paths:
131
+
132
+ require_paths:
162
133
  - lib
163
- required_ruby_version: !ruby/object:Gem::Requirement
164
- none: false
165
- requirements:
166
- - - ! '>='
167
- - !ruby/object:Gem::Version
168
- version: '0'
169
- segments:
170
- - 0
171
- hash: 1017556541912433420
172
- required_rubygems_version: !ruby/object:Gem::Requirement
173
- none: false
174
- requirements:
175
- - - ! '>='
176
- - !ruby/object:Gem::Version
177
- version: '0'
178
- segments:
179
- - 0
180
- hash: 1017556541912433420
134
+ required_ruby_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - *id002
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - *id002
181
140
  requirements: []
141
+
182
142
  rubyforge_project:
183
- rubygems_version: 1.8.25
143
+ rubygems_version: 2.0.17
184
144
  signing_key:
185
- specification_version: 3
186
- summary: This gem is a Ruby interface to the Infoblox WAPI. Using the gem, you can
187
- query, create, update, and delete DNS records in your Infoblox instance.
188
- test_files:
145
+ specification_version: 4
146
+ summary: This gem is a Ruby interface to the Infoblox WAPI. Using the gem, you can query, create, update, and delete DNS records in your Infoblox instance.
147
+ test_files:
189
148
  - spec/connection_spec.rb
190
149
  - spec/host_ipv4addr_spec.rb
191
150
  - spec/host_spec.rb