nifi_sdk_ruby 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 339e4cf534f08eb702e3a89a090a9a64ca033ce6
4
+ data.tar.gz: 1db5d0e70bfbb0cd02cec61bf47e6dd99b0d2537
5
+ SHA512:
6
+ metadata.gz: 6f04e42eaabca6534482530890300e3b753bdd7292048a9c83e9f0ea5ec1caa7ab90c7610d26ab6a2af6c5bb6aadf53196b81c013817edad362e34fed04a06d8
7
+ data.tar.gz: 2b7494a8e630440913692e0cc9edbd6813cab454f1d9ab61d56371a4381090cd3b46cffa7360005c6b13199196b306b1188c61898e09863382f7437d63c09628
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at icalvete@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nifi_sdk_ruby.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Israel Calvete
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # NifiSdkRuby
2
+
3
+ A RUBY SDK to use [APACHE NIFI](https://nifi.apache.org/) API.
4
+
5
+ See more at [APACHE NIFI API](https://nifi.apache.org/docs/nifi-docs/rest-api/index.html).
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'nifi_sdk_ruby'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install nifi_sdk_ruby
22
+
23
+ ## Usage
24
+
25
+
26
+ ```
27
+ require '../lib/nifi_sdk_ruby'
28
+
29
+ nifi_client = Nifi.new()
30
+ nifi_client.set_debug(true)
31
+
32
+ # Get the ID of Root Process Group
33
+ pg_root_id = nifi_client.get_process_group(:attr => 'id')
34
+ puts "\n"
35
+ puts "PG Root's ID"
36
+ puts "\n"
37
+ puts pg_root_id
38
+ puts "\n"
39
+
40
+ # Get all attrs of the Process Group with ID 9c3ebb60-015b-1000-1027-b27d47832152 (PG Root's child)
41
+ some_pg = nifi_client.get_process_group(:pg_id => '9c3ebb60-015b-1000-1027-b27d47832152')
42
+ puts "PG 9c3ebb60-015b-1000-1027-b27d47832152`s attrs"
43
+ puts "\n"
44
+ puts some_pg
45
+ puts "\n"
46
+
47
+ ```
48
+
49
+ ## Contributing
50
+
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/icalvete/nifi_sdk_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
52
+
53
+
54
+ ## License
55
+
56
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
57
+
58
+ ## Authors:
59
+
60
+ Israel Calvete Talavera <icalvete@gmail.com>
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "nifi_sdk_ruby"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/examples/basic.rb ADDED
@@ -0,0 +1,21 @@
1
+ require 'pp'
2
+
3
+ require '../lib/nifi_sdk_ruby'
4
+
5
+ nifi_client = Nifi.new()
6
+ nifi_client.set_debug(true)
7
+
8
+ # Get the ID of Root Process Group
9
+ pg_root_id = nifi_client.get_process_group(:attr => 'id')
10
+ puts "\n"
11
+ puts "PG Root's ID"
12
+ puts "\n"
13
+ puts pg_root_id
14
+ puts "\n"
15
+
16
+ # Get all attrs of the Process Group with ID 9c3ebb60-015b-1000-1027-b27d47832152 (PG Root's child)
17
+ some_pg = nifi_client.get_process_group(:pg_id => '9c3ebb60-015b-1000-1027-b27d47832152')
18
+ puts "PG 9c3ebb60-015b-1000-1027-b27d47832152`s attrs"
19
+ puts "\n"
20
+ puts some_pg
21
+ puts "\n"
@@ -0,0 +1,141 @@
1
+ version = File.join(File.dirname(__FILE__), '/nifi_sdk_ruby/version')
2
+ require version
3
+
4
+ require 'pp' if ENV['DEBUG']
5
+ require 'httparty'
6
+ require 'curb'
7
+ require 'json'
8
+
9
+ class Nifi
10
+
11
+ DEFAULT_HOST = 'localhost'
12
+ DEFAULT_SCHEMA = 'http'
13
+ DEFAULT_PORT = '8080'
14
+ DEFAULT_DEBUG = false
15
+ DEFAULT_ACYNC = false
16
+
17
+ @@auth
18
+ @@schema
19
+ @@host
20
+ @@port
21
+ @@base_url
22
+ @@debug
23
+ @@async
24
+ @@sdk_name
25
+ @@sdk_version
26
+
27
+ def initialize(*args)
28
+
29
+ args = args.reduce Hash.new, :merge
30
+
31
+ @@schema = args[:schema] ? args[:schema] : DEFAULT_SCHEMA
32
+ @@host = args[:host] ? args[:host] : DEFAULT_HOST
33
+ @@port = args[:port] ? args[:port] : DEFAULT_PORT
34
+ @@base_url = @@schema + '://' + @@host + ':' + @@port + '/nifi-api'
35
+ @@debug = DEFAULT_DEBUG
36
+ @@async = DEFAULT_ACYNC
37
+ @@sdk_name = 'ruby'
38
+ @@sdk_version = NifiSdkRuby::VERSION
39
+ end
40
+
41
+ def set_debug(debug = nil)
42
+ if debug.nil?
43
+ abort 'missing debug'
44
+ end
45
+
46
+ if !(!!debug == debug)
47
+ abort 'debug msut be a boolean'
48
+ end
49
+
50
+ @@debug = debug
51
+ end
52
+
53
+ def get_debug()
54
+ @@debug
55
+ end
56
+
57
+ def set_async(async = nil)
58
+ if async.nil?
59
+ abort 'missing async'
60
+ end
61
+
62
+ if !(!!async == async)
63
+ abort 'async msut be a boolean'
64
+ end
65
+
66
+ @@async = async
67
+ end
68
+
69
+ def get_async()
70
+ @@async
71
+ end
72
+
73
+ def get_api_key()
74
+ @@api_key
75
+ end
76
+
77
+ def get_schema()
78
+ @@schema
79
+ end
80
+
81
+ def get_host()
82
+ @@host
83
+ end
84
+
85
+ def get_base_url()
86
+ @@base_url
87
+ end
88
+
89
+ def get_process_group(*args)
90
+
91
+ args = args.reduce Hash.new, :merge
92
+
93
+ process_group = args[:pg_id] ? args[:pg_id] : 'root'
94
+
95
+ base_url = @@base_url + "/process-groups/#{process_group}"
96
+ res = self.class.http_client(base_url)
97
+
98
+ if args[:attr]
99
+ return res[args[:attr]]
100
+ end
101
+
102
+ return res
103
+ end
104
+
105
+ private
106
+
107
+ def self.http_client(url, method = 'GET', params = nil, filename = nil)
108
+ c = Curl::Easy.new
109
+ #c.http_auth_types = :basic
110
+ #c.username = @@api_key
111
+ #c.password = ''
112
+ c.url = url
113
+ c.useragent = @@sdk_name + '_' + @@sdk_version
114
+ c.headers['NIFI-SDK-Name'] = @@sdk_name
115
+ c.headers['NIFI-SDK-Version'] = @@sdk_version
116
+ c.ssl_verify_peer = false
117
+ #c.verbose = true
118
+
119
+ case method
120
+ when 'GET'
121
+ c.get
122
+ when 'POSTRAW'
123
+ c.post(params)
124
+ when 'POST'
125
+ c.multipart_form_post = true
126
+ c.post(params)
127
+ when 'PUT'
128
+ c.put(params)
129
+ when 'DELETE'
130
+ c.delete
131
+ else
132
+ abort 'HTTP method not supported.'
133
+ end
134
+
135
+ if c.response_code.to_s.match(/20./) and not c.body_str.empty?
136
+ JSON.parse(c.body_str)
137
+ else
138
+ puts c.body_str
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,3 @@
1
+ module NifiSdkRuby
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'nifi_sdk_ruby/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "nifi_sdk_ruby"
8
+ gem.version = NifiSdkRuby::VERSION
9
+ gem.authors = ["Israel Calvete"]
10
+ gem.email = ["icalvete@gmail.com"]
11
+
12
+ gem.summary = %q{A RUBY SDK to use APACHE NIFI API}
13
+ gem.description = %q{See more at https://nifi.apache.org/ }
14
+ gem.homepage = "http://rubygems.org/gems/nifi-sdk-ruby"
15
+ gem.license = "GNU"
16
+ gem.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|gem|features)/})
18
+ end
19
+ gem.bindir = "exe"
20
+ gem.executables = gem.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ gem.require_paths = ["lib"]
22
+
23
+ gem.add_dependency 'httparty', '>= 0.14.0'
24
+ gem.add_dependency 'curb', '>= 0.9.3'
25
+ gem.add_dependency 'json', '>= 1.8.3'
26
+
27
+ gem.add_development_dependency "bundler", "~> 1.14"
28
+ gem.add_development_dependency "rake", "~> 10.0"
29
+ gem.add_development_dependency "rspec", "~> 3.0"
30
+ end
data/release.md ADDED
@@ -0,0 +1,17 @@
1
+ # How relase a version to rubygems
2
+
3
+ ## adding credentials (only first time)
4
+
5
+ curl -u icalvete https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials; chmod 0600 ~/.gem/credentials
6
+
7
+ ## release version
8
+
9
+ edit lib/nifi_sdk_ruby/version.rb and change the version.
10
+ git add, commit, push
11
+ gem build nifi_sdk_ruby.gemspec
12
+ mv nifi_sdk_ruby-$VERSION.gem pkg
13
+ gem push pkg/fluzo_sdk_ruby-$VERSION.gem
14
+
15
+ ## delete wrong version from rubygems
16
+
17
+ gem yank nifi_sdk_ruby -v $VERSION
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nifi_sdk_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Israel Calvete
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-04-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.14.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.14.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: curb
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.8.3
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.8.3
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.14'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.14'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ description: 'See more at https://nifi.apache.org/ '
98
+ email:
99
+ - icalvete@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - CODE_OF_CONDUCT.md
105
+ - Gemfile
106
+ - LICENSE.txt
107
+ - README.md
108
+ - Rakefile
109
+ - bin/console
110
+ - bin/setup
111
+ - examples/basic.rb
112
+ - lib/nifi_sdk_ruby.rb
113
+ - lib/nifi_sdk_ruby/version.rb
114
+ - nifi_sdk_ruby.gemspec
115
+ - release.md
116
+ homepage: http://rubygems.org/gems/nifi-sdk-ruby
117
+ licenses:
118
+ - GNU
119
+ metadata: {}
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 2.5.1
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: A RUBY SDK to use APACHE NIFI API
140
+ test_files: []