logstash-input-toggl 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/logstash/inputs/toggl.rb +8 -9
- data/logstash-input-toggl.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb29322cb2e381ea48dabe689d09bb93bc025073
|
4
|
+
data.tar.gz: 68bd97095796d1b2e34e1a915a8116b289cb3752
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5016d29cfa2dbe98f5e5ef2eaa2087b73b8e000283e751cd2853dc89e044e10829f76f0f02736633c1ee2307d6c64c0f913bf706501f8be3639db913b14c2c8
|
7
|
+
data.tar.gz: 476c02a499feb106c738b18de92fe6d922d8204e2a5c98db0a4192fe08f00903d71a4f9e8c2d709bfed8cfe0a65392a2f5c6ce49aab438bdd4c0910c172f21f9
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "logstash/inputs/base"
|
3
3
|
require "logstash/namespace"
|
4
|
-
require "socket" # for Socket.gethostname
|
5
4
|
|
6
5
|
# Pull time entries from detailed report Toggl API.
|
7
6
|
#
|
@@ -46,6 +45,13 @@ class LogStash::Inputs::Toggl < LogStash::Inputs::Base
|
|
46
45
|
|
47
46
|
@url = "https://toggl.com/reports/api/v2/details?workspace_id=#{ @workspace_id }&user_agent=#{ @user_agent }&#{ addon }"
|
48
47
|
@logger.info? && @logger.info("Registering Toggl Input", :url => @url, :interval => @interval)
|
48
|
+
|
49
|
+
@connection = Faraday.new do |builder|
|
50
|
+
builder.use Faraday::Request::Retry
|
51
|
+
builder.use Faraday::Request::BasicAuthentication, @api_token, 'api_token'
|
52
|
+
builder.use Faraday::Response::Logger
|
53
|
+
builder.use Faraday::Adapter::NetHttp
|
54
|
+
end
|
49
55
|
end # def register
|
50
56
|
|
51
57
|
public
|
@@ -54,19 +60,12 @@ class LogStash::Inputs::Toggl < LogStash::Inputs::Base
|
|
54
60
|
start = Time.now
|
55
61
|
@logger.info? && @logger.info("Polling Toggl", :url => @url, :time => start)
|
56
62
|
|
57
|
-
conn = Faraday.new do |builder|
|
58
|
-
builder.use Faraday::Request::Retry
|
59
|
-
builder.use Faraday::Request::BasicAuthentication, @api_token, 'api_token'
|
60
|
-
builder.use Faraday::Response::Logger
|
61
|
-
builder.use Faraday::Adapter::NetHttp
|
62
|
-
end
|
63
|
-
|
64
63
|
page = 1
|
65
64
|
|
66
65
|
while true
|
67
66
|
new_url = @url + "&page=#{ page }"
|
68
67
|
|
69
|
-
response =
|
68
|
+
response = @connection.get new_url
|
70
69
|
result = JSON.parse(response.body)
|
71
70
|
|
72
71
|
if result["data"].nil? || result["data"].empty?
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-input-toggl'
|
3
|
-
s.version = '0.1.
|
3
|
+
s.version = '0.1.1'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "Pull time entries from a detailed report Toggl API."
|
6
6
|
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
|