fluent-plugin-festival 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39f17a14ffb311c60b34d91173456b7f5dcb42ee
4
- data.tar.gz: e2afc237a7290b637d502b2a13d19c94c451da29
3
+ metadata.gz: bbcf0080a756a3a28db069b2a68035e09c77333e
4
+ data.tar.gz: 61642c76c8f8f002f25c1f8531faea27c987dbe4
5
5
  SHA512:
6
- metadata.gz: 0b46e4b7db77cfd24bbd5993f4b4cea7e304e475366fff713562419c7c47a5b23185b0ec25eb827d8d579ee4810c6c5834cab2e4b74e6e6efe85e9a5455659d2
7
- data.tar.gz: 3224d8f695a96136f36c1a0d9a269d48d4d6fb7dc2907cc9e6e2eaddccd91387af682c479a075c9d3d105b7cae80eccf62951b369ef9368f8f1f1fd7a894d283
6
+ metadata.gz: 462dd1a294995d5d706444df5fada12ea58fd3da35e3f7830dc4cb8b745a5896e4db997a0616542d2ddfcfe08e3e564bb8ae82a09770788385ffc6f57930afa7
7
+ data.tar.gz: b5275ddc0aba66472bfc1bc9acc82d69a36255f78e54fcd0fb2a0028d700dd57dc429e1281fde1f54fd5209c1747dc90b8f7e8ca39a3049d4e362cdea8d25cab
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-festival"
7
- spec.version = "0.0.12"
7
+ spec.version = "0.0.13"
8
8
  spec.authors = ["Toyokazu Akiyama"]
9
9
  spec.email = ["toyokazu@gmail.com"]
10
10
 
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.required_ruby_version = '>= 2.2.0'
22
22
 
23
- spec.add_dependency 'fluentd', '~> 0.14.0'
23
+ spec.add_dependency 'fluentd', '>= 0.14.0'
24
24
 
25
25
  spec.add_development_dependency "bundler", "~> 1.14"
26
26
  spec.add_development_dependency "rake", "~> 12.0"
@@ -89,7 +89,13 @@ module Fluent::Plugin
89
89
  def get_data_request(path)
90
90
  #get_data_req = @uri + target_path(type)
91
91
 
92
- get_data_req = @uri + Pathname("/festival/eaas/experimentation/#{WEBrick::HTTPUtils.escape(path)}").cleanpath.to_s
92
+ get_data_req = @uri +
93
+ case @api_type
94
+ when 'sensinact'
95
+ Pathname("/sensinact/providers/#{WEBrick::HTTPUtils.escape(path)}").cleanpath.to_s
96
+ else # default (festival)
97
+ Pathname("/festival/eaas/experimentation/#{WEBrick::HTTPUtils.escape(path)}").cleanpath.to_s
98
+ end
93
99
  #get_data_req.query = URI.encode_www_form(get_data_params)
94
100
  log.debug "#{get_data_req}"
95
101
  # currently time window is automatically updated
@@ -98,18 +104,31 @@ module Fluent::Plugin
98
104
  end
99
105
 
100
106
  def get_data_header
101
- {
102
- "Accept": "application/json",
103
- "X-Auth-Token": @session["access_token"]
107
+ header = {
108
+ "Accept": "application/json"
104
109
  }
110
+ if @api_type == 'festival'
111
+ return header.merge("X-Auth-Token": @session["access_token"])
112
+ end
113
+ header
105
114
  end
106
115
 
107
116
  def resource_type(path)
108
- Pathname(path).basename.to_s
117
+ case @api_type
118
+ when 'sensinact'
119
+ "current_data"
120
+ else
121
+ Pathname(path).basename.to_s
122
+ end
109
123
  end
110
124
 
111
125
  def resource_path(path)
112
- Pathname(path).dirname.to_s
126
+ case @api_type
127
+ when 'sensinact'
128
+ path
129
+ else
130
+ Pathname(path).dirname.to_s
131
+ end
113
132
  end
114
133
 
115
134
  def add_location(result, resource)
@@ -139,7 +158,7 @@ module Fluent::Plugin
139
158
  end
140
159
 
141
160
  def get_data
142
- if !valid_session?
161
+ if !valid_session? && @api_type == 'festival'
143
162
  return nil if create_session.nil?
144
163
  log.debug "session #{@session} created."
145
164
  end
@@ -153,10 +172,22 @@ module Fluent::Plugin
153
172
  get_data_res = @https.get(get_data_request(resource.path), get_data_header)
154
173
  next if !error_handler(get_data_res,"get_data failed.")
155
174
  log.debug "get_data: #{get_data_res.body}"
156
- result = {
157
- "resourceName": resource.path,
158
- "dataValue": JSON.parse(get_data_res.body)["dataValue"]
159
- }
175
+ result =
176
+ case @api_type
177
+ when 'festival'
178
+ {
179
+ "resourceName": resource.path,
180
+ "dataValue": JSON.parse(get_data_res.body)["dataValue"]
181
+ }
182
+ when 'sensinact'
183
+ {
184
+ "resourceName": resource.path,
185
+ "dataValue": JSON.parse(get_data_res.body)["response"]["value"],
186
+ "timestamp": JSON.parse(get_data_res.body)["response"]["timestamp"]
187
+ }
188
+ else
189
+ return nil
190
+ end
160
191
  data << add_location(result, resource)
161
192
  when "historical_data" then
162
193
  log.error "historical_data is not supported yet"
@@ -13,6 +13,8 @@ module Fluent::Plugin
13
13
 
14
14
  desc 'FESTIVAL EaaS API URI'
15
15
  config_param :api_uri, :string, default: 'https://api.festival-project.eu'
16
+ desc 'API Type (festival or sensinact)'
17
+ config_param :api_type, :string, default: 'festival'
16
18
  desc 'email (login_name) for FESTIVAL EaaS API'
17
19
  config_param :email, :string
18
20
  desc 'password for FESTIVAL EaaS API'
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-festival
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toyokazu Akiyama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-31 00:00:00.000000000 Z
11
+ date: 2018-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.14.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.14.0
27
27
  - !ruby/object:Gem::Dependency
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  requirements: []
107
107
  rubyforge_project:
108
- rubygems_version: 2.6.8
108
+ rubygems_version: 2.6.14.1
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: Fluent Input/Output plugin for FESTIVAL platform