holistics 0.0.7 → 0.0.8
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 +4 -4
- data/bin/holistics +1 -1
- data/lib/holistics/api_client.rb +12 -13
- data/lib/holistics/version.rb +2 -2
- data/lib/holistics.rb +34 -33
- 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: 66b023c2e0d7da99e00b5577457ce8a2c3ba5f1d
|
4
|
+
data.tar.gz: 317efca7f9469d5ab87054dee66cf00b6aa21a5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bef183d58afbd0431b11b0bf9d3156b04ae53260124da046b03b857db5d6eebe15ac27e814f14e5caf75788cd70ce015e0b0689c267c319add604a666d20a783
|
7
|
+
data.tar.gz: 40b222ae0c41ba15087469e3d1aeea911dde0dc880a505e8b5a105c5561cfc55f708760ed9a716d25e8d3e0a0fa6f76df2dd0c1afb2b231dc2a353c1c7793e45
|
data/bin/holistics
CHANGED
data/lib/holistics/api_client.rb
CHANGED
@@ -27,14 +27,14 @@ module Holistics
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def holistics_authenticate(token)
|
30
|
-
url = api_url_for('users/info.json', token)
|
30
|
+
url = api_url_for('users/info.json', {}, token)
|
31
31
|
response = HTTParty.get(url)
|
32
32
|
return response, (response.code == 200)
|
33
33
|
end
|
34
34
|
|
35
35
|
def job_show options
|
36
36
|
job_id = options[:job_id]
|
37
|
-
|
37
|
+
tail_logs(job_id)
|
38
38
|
end
|
39
39
|
|
40
40
|
def ds_list
|
@@ -62,20 +62,17 @@ module Holistics
|
|
62
62
|
job_id = parsed['job_id']
|
63
63
|
|
64
64
|
puts "Job submitted. Job ID: #{job_id}."
|
65
|
-
|
65
|
+
tail_logs(job_id)
|
66
66
|
end
|
67
67
|
|
68
|
-
def
|
68
|
+
def tail_logs(job_id)
|
69
69
|
last_id = 0
|
70
70
|
while true
|
71
|
-
|
72
|
-
parsed = JSON.parse(response.body)
|
73
|
-
|
71
|
+
parsed = fetch_job_details(job_id, last_id)
|
74
72
|
logs = parsed['logs']
|
75
|
-
|
76
73
|
logs.each { |log| print_log(log) }
|
77
|
-
|
78
74
|
last_id = logs.last['id'] if logs.size > 0
|
75
|
+
|
79
76
|
break unless parsed['has_more']
|
80
77
|
|
81
78
|
sleep 0.5
|
@@ -83,7 +80,8 @@ module Holistics
|
|
83
80
|
end
|
84
81
|
|
85
82
|
def fetch_job_details(job_id, last_id = 0)
|
86
|
-
HTTParty.get(api_url_for("jobs/#{job_id}.json
|
83
|
+
response = HTTParty.get(api_url_for("jobs/#{job_id}/logs.json", last_id: last_id))
|
84
|
+
JSON.parse(response.body)
|
87
85
|
end
|
88
86
|
|
89
87
|
def submit_transport_job(params)
|
@@ -142,12 +140,13 @@ module Holistics
|
|
142
140
|
File.expand_path('~/.holistics.yml', __FILE__)
|
143
141
|
end
|
144
142
|
|
145
|
-
def api_url_for(path, token = nil)
|
146
|
-
|
143
|
+
def api_url_for(path, params = {}, token = nil)
|
144
|
+
params[:_utoken] = token || get_token_from_gconfig
|
145
|
+
"#{server_url}#{path}?#{URI.encode_www_form(params)}"
|
147
146
|
end
|
148
147
|
|
149
148
|
def print_log log
|
150
|
-
ts = Time.parse(log['
|
149
|
+
ts = Time.parse(log['timestamp'])
|
151
150
|
Holistics.logger.log(log['level'], log['message'], timestamp: ts)
|
152
151
|
end
|
153
152
|
|
data/lib/holistics/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = '0.0.
|
1
|
+
module Holistics
|
2
|
+
VERSION = '0.0.8'
|
3
3
|
end
|
data/lib/holistics.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'holistics/api_client'
|
3
|
+
require 'holistics/custom_logger'
|
3
4
|
require 'vcr'
|
4
5
|
|
5
6
|
module Holistics
|
@@ -7,57 +8,57 @@ module Holistics
|
|
7
8
|
Pathname.new(__FILE__).parent.parent
|
8
9
|
end
|
9
10
|
|
10
|
-
def logger
|
11
|
+
def self.logger
|
11
12
|
@logger ||= CustomLogger.new(STDOUT)
|
12
13
|
end
|
13
14
|
|
14
|
-
end
|
15
|
-
|
16
15
|
# Right now we can't do `holistics ds:list`
|
17
16
|
# Known issue: https://github.com/erikhuda/thor/issues/249
|
18
17
|
# Either we use other libs, or figure out an elegant way to do it without
|
19
18
|
|
20
|
-
class HolisticsRunner < Thor
|
21
19
|
|
22
|
-
|
23
|
-
desc: 'Set the logging verbosity. Values range from 1 (log everything) to 6 (log nothing)'
|
20
|
+
class HolisticsRunner < Thor
|
24
21
|
|
25
|
-
|
26
|
-
|
27
|
-
end
|
22
|
+
method_option :verbosity, aliases: '-v', type: :numeric, default: 2, required: false,
|
23
|
+
desc: 'Set the logging verbosity. Values range from 1 (log everything) to 6 (log nothing)'
|
28
24
|
|
29
|
-
|
25
|
+
def initialize(args=[], options={}, config={})
|
26
|
+
super(args, options, config)
|
27
|
+
end
|
30
28
|
|
31
|
-
|
32
|
-
client = ApiClient.new
|
33
|
-
client.login(token)
|
34
|
-
end
|
29
|
+
desc 'login [auth_token]', 'Perform authentication'
|
35
30
|
|
31
|
+
def login token
|
32
|
+
client = ApiClient.new
|
33
|
+
client.login(token)
|
34
|
+
end
|
36
35
|
|
37
|
-
desc 'ds_list', 'List all data sources'
|
38
36
|
|
39
|
-
|
40
|
-
ApiClient.new.ds_list
|
41
|
-
end
|
37
|
+
desc 'ds_list', 'List all data sources'
|
42
38
|
|
39
|
+
def ds_list
|
40
|
+
ApiClient.new.ds_list
|
41
|
+
end
|
43
42
|
|
44
|
-
method_option :from_ds_id, aliases: '-s', type: :string, required: false, desc: 'From data source'
|
45
|
-
method_option :dest_ds_id, aliases: '-d', type: :string, required: false, desc: 'To data source'
|
46
|
-
method_option :from_table_name, aliases: '-t', type: :string, required: false, desc: 'The table to copy over'
|
47
|
-
method_option :dest_table_name, aliases: '-n', type: :string, required: false, desc: '(optional) Rename destination table. Please specify fully qualified name'
|
48
|
-
method_option :config_path, aliases: '-c', type: :string, required: false, desc: 'Path to transport config (JSON/YML)̄ file'
|
49
|
-
desc 'transport', 'Submit a data transport job'
|
50
43
|
|
51
|
-
|
52
|
-
|
53
|
-
|
44
|
+
method_option :from_ds_id, aliases: '-s', type: :string, required: false, desc: 'From data source'
|
45
|
+
method_option :dest_ds_id, aliases: '-d', type: :string, required: false, desc: 'To data source'
|
46
|
+
method_option :from_table_name, aliases: '-t', type: :string, required: false, desc: 'The table to copy over'
|
47
|
+
method_option :dest_table_name, aliases: '-n', type: :string, required: false, desc: '(optional) Rename destination table. Please specify fully qualified name'
|
48
|
+
method_option :config_path, aliases: '-c', type: :string, required: false, desc: 'Path to transport config (JSON/YML)̄ file'
|
49
|
+
desc 'transport', 'Submit a data transport job'
|
54
50
|
|
51
|
+
def transport
|
52
|
+
ApiClient.new.send_transport(options.dup)
|
53
|
+
end
|
55
54
|
|
56
|
-
method_option :job_id, aliases: '-j', type: :string, required: true, desc: 'Job ID'
|
57
|
-
desc 'job_show', 'Show job log'
|
58
55
|
|
59
|
-
|
60
|
-
|
61
|
-
end
|
56
|
+
method_option :job_id, aliases: '-j', type: :string, required: true, desc: 'Job ID'
|
57
|
+
desc 'job_show', 'Show job log'
|
62
58
|
|
63
|
-
|
59
|
+
def job_show
|
60
|
+
ApiClient.new.job_show(options.dup)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|