nifi_sdk_ruby 0.0.3 → 0.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be48d97b56f690c502c1b8723c4867461ec0798c
4
- data.tar.gz: 6a77e0569fb024980fb3fca6c00eb53f04060266
3
+ metadata.gz: 01032e0711255ad4a4a189e1298ff17694276da4
4
+ data.tar.gz: f579d3be582ce5a2d4d24b33b9930b0ad7cc0042
5
5
  SHA512:
6
- metadata.gz: a9edf3dbce0917300ed3fbb1e44e7274656d1623ecca087d7f55a917c49676c5f7757f1e24ee05b10a37a0ab3b76c41f989ee71d6299219e1d76114107bd8793
7
- data.tar.gz: 1fd9b45e1e7dea96ece0f062cacd638bf46cab9a319ec46c14e214cd3a9eec92c67881491f4533966e02c65ffd1d891acf20e7a357b3477eba65879c1a2e7f2e
6
+ metadata.gz: c640f80758ad0f6fca9beb8b8387b1bd93edfed2fa517f5651548af9e5e34086b54351a873377ea1ff248f5675ba898adcc0a79cc9af9fc36d110c0d2694dc94
7
+ data.tar.gz: 5e157bddbda327b4bfd59402bfba7cdd8485e627a53a115f94d55bc0282c2269910efd93ee12b0508d2b295a935b20a47f093d49e0a2dcf3051e12c4319e03a8
data/.gitignore CHANGED
@@ -7,6 +7,7 @@
7
7
  /pkg/*
8
8
  /spec/reports/
9
9
  /tmp/
10
+ .idea/*
10
11
 
11
12
  # rspec failure tracking
12
13
  .rspec_status
data/examples/basic.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'pp'
2
2
 
3
- require '../lib/nifi_sdk_ruby'
3
+ require_relative '../lib/nifi_sdk_ruby'
4
4
 
5
5
  nifi_client = Nifi.new()
6
6
  nifi_client.set_debug true
@@ -40,6 +40,6 @@ puts "\n"
40
40
  puts nifi_client.delete_process_group new_pg['id']
41
41
  puts "\n"
42
42
 
43
- # Upload a template to Root Process Group
43
+ # Upload a template to Root Process Group
44
44
  puts 'Upload template to Root PG'
45
45
  puts nifi_client.upload_template(:path => 'IN.hmStaff.taskStatus.xml')
@@ -1,3 +1,3 @@
1
1
  module NifiSdkRuby
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/nifi_sdk_ruby.rb CHANGED
@@ -50,7 +50,7 @@ class Nifi
50
50
  end
51
51
 
52
52
  if !(!!debug == debug)
53
- abort 'debug msut be a boolean'
53
+ abort 'debug must be a boolean'
54
54
  end
55
55
 
56
56
  @@debug = debug
@@ -66,7 +66,7 @@ class Nifi
66
66
  end
67
67
 
68
68
  if !(!!async == async)
69
- abort 'async msut be a boolean'
69
+ abort 'async must be a boolean'
70
70
  end
71
71
 
72
72
  @@async = async
@@ -149,6 +149,45 @@ class Nifi
149
149
  end
150
150
  end
151
151
 
152
+ def get_process(id = nil)
153
+ if id.nil?
154
+ abort 'id is mandatory.'
155
+ end
156
+
157
+ url = @@base_url + '/processors/' + id
158
+ self.class.http_client(url)
159
+ end
160
+
161
+ def start_process(*args)
162
+ args = args.reduce Hash.new, :merge
163
+ if args[:id].nil? or args[:version].nil?
164
+ abort 'id and version params are mandatory'
165
+ end
166
+
167
+ id = args[:id]
168
+ version = args[:version]
169
+
170
+ params = '{"revision":{"version":'+ version +'},"id":"'+ id +'","component":{"id":"'+ id +
171
+ '","state":"RUNNING"},"status":{"runStatus":"Running"}}'
172
+ base_url = @@base_url + '/processors/' + id
173
+ self.class.http_client(base_url, 'PUT', params)
174
+ end
175
+
176
+ def stop_process(*args)
177
+ args = args.reduce Hash.new, :merge
178
+ if args[:id].nil? or args[:version].nil?
179
+ abort 'id and version params are mandatory'
180
+ end
181
+
182
+ id = args[:id]
183
+ version = args[:version]
184
+
185
+ params = '{"revision":{"version":'+ version +'},"id":"'+ id +'","component":{"id":"'+ id +
186
+ '","state":"STOPPED"},"status":{"runStatus": "Stopped"}}'
187
+ base_url = @@base_url + '/processors/' + id
188
+ self.class.http_client(base_url, 'PUT', params)
189
+ end
190
+
152
191
  def process_group_by_name?(name = nil)
153
192
 
154
193
  if name.nil?
@@ -164,6 +203,29 @@ class Nifi
164
203
  pg.count == 1 ? true : false
165
204
  end
166
205
 
206
+ def create_template_instance(*args)
207
+ args = args.reduce Hash.new, :merge
208
+
209
+ if args[:id].nil? and args[:name].nil?
210
+ abort 'either specify id of the template or it\'s name '
211
+ end
212
+
213
+ if args[:name]
214
+ abort "Could not find template called #{args[:name]}" unless template_by_name?(args[:name])
215
+ id = get_template_by_name(args[:name])[0][0]
216
+ else
217
+ abort "Could not find template with id #{args[:id]}" unless template_by_id?(args[:id])
218
+ id = args[:id]
219
+ end
220
+
221
+ originX = args[:originX] ? args[:originX] : '0.0'
222
+ originY = args[:originY] ? args[:originY] : '0.0'
223
+ process_group = args[:process_group_id] ? args[:process_group_id] : 'root'
224
+ params = '{"templateId": "'+ id +'", "originX": '+ originX +', "originY": '+ originY +'}'
225
+ base_url = @@base_url + "/process-groups/#{process_group}/template-instance"
226
+ self.class.http_client(base_url, 'POSTRAW', params)
227
+ end
228
+
167
229
  def upload_template(*args)
168
230
 
169
231
  args = args.reduce Hash.new, :merge
@@ -249,6 +311,21 @@ class Nifi
249
311
  pg.count == 1 ? true : false
250
312
  end
251
313
 
314
+ def template_by_id?(id = nil)
315
+
316
+ if id.nil?
317
+ abort 'id is mandatory.'
318
+ end
319
+
320
+ res = self.class.exists
321
+
322
+ pg = res.select do |r|
323
+ r['identifier'] == "/templates/#{id}"
324
+ end
325
+
326
+ pg.count == 1 ? true : false
327
+ end
328
+
252
329
  private
253
330
 
254
331
  def self.exists
@@ -285,6 +362,7 @@ class Nifi
285
362
  c.multipart_form_post = true
286
363
  c.post(params)
287
364
  when 'PUT'
365
+ c.headers['Content-Type'] = 'application/json'
288
366
  c.put(params)
289
367
  when 'DELETE'
290
368
  c.delete
@@ -305,3 +383,4 @@ class Nifi
305
383
  end
306
384
  end
307
385
  end
386
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nifi_sdk_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Israel Calvete
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-26 00:00:00.000000000 Z
11
+ date: 2017-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -142,7 +142,6 @@ files:
142
142
  - lib/nifi_sdk_ruby.rb
143
143
  - lib/nifi_sdk_ruby/version.rb
144
144
  - nifi_sdk_ruby.gemspec
145
- - pkg/.gitkeep
146
145
  - release.md
147
146
  homepage: http://rubygems.org/gems/nifi-sdk-ruby
148
147
  licenses:
data/pkg/.gitkeep DELETED
File without changes