holistics-cli 0.1.1 → 0.1.2
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/.gitignore +2 -1
- data/CHANGELOG.md +9 -0
- data/README.md +9 -2
- data/lib/holistics/imports.rb +1 -1
- data/lib/holistics/jobs.rb +8 -8
- data/lib/holistics/transforms.rb +2 -3
- data/lib/holistics/utils.rb +1 -1
- data/lib/holistics/version.rb +1 -1
- data/lib/holistics.rb +30 -12
- metadata +3 -3
- data/.byebug_history +0 -183
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef9b9ce12830adf846878dd595dc9c57a10d8322
|
4
|
+
data.tar.gz: 14026763884c485018035f90a23895c70718061f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8154a55fe4ad764e16e1e43116baf633a36798ddc973a670cc74ee2ef600f4de4154b74859e8387682e7aa3cfa809fcf319400763229cb2ab6cd4a8959029e18
|
7
|
+
data.tar.gz: 2588471ece3e5235ee26baa5ca95ae163956d60be5002b6abdea2383ecab9b111c36ebfbc1cddc69e1a756ded98f4a15e6205ca9b9bfe4c7582a9163ffdf36d8
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
## 0.1.2, release 2017-08-17
|
2
|
+
* Bug fixes
|
3
|
+
|
4
|
+
* Change `jobs logs` command options from `--watch` to `--follow` (the same alias is `-f`)
|
5
|
+
|
6
|
+
* Provide options for configuring without prompt `holistics config [TOKEN]`
|
7
|
+
|
8
|
+
## 0.1.1, first release 2017-08-15
|
9
|
+
* Support basic function for jobs, data sources, data imports, data transforms
|
data/README.md
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
# Holistics CLI
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/holistics-cli)
|
4
|
+
|
3
5
|
CommandLine Interface to [Holistics API](https://docs.holistics.io/api/)
|
4
6
|
|
5
7
|
> Dislaim: The official Holistics-CLI is quite limit for me, so I made this gem as an alternative
|
6
8
|
|
9
|
+
:warning: This gem use the same command `holistics` as [Official Holistics-CLI](https://docs.holistics.io/holistics-cli/), so it may confict if both installed.
|
10
|
+
|
7
11
|
## Installation
|
8
12
|
|
9
13
|
$ gem install holistics-cli
|
@@ -13,7 +17,7 @@ CommandLine Interface to [Holistics API](https://docs.holistics.io/api/)
|
|
13
17
|
```
|
14
18
|
$ holistics
|
15
19
|
Commands:
|
16
|
-
holistics config
|
20
|
+
holistics config [TOKEN] # Init or update config
|
17
21
|
holistics help [COMMAND] # Describe available commands or one specific command
|
18
22
|
holistics imports # Import jobs
|
19
23
|
holistics jobs # Submitted jobs
|
@@ -22,6 +26,9 @@ Commands:
|
|
22
26
|
holistics version # Show version information
|
23
27
|
```
|
24
28
|
|
29
|
+
Learn more by help command: `holistics help`
|
30
|
+
|
31
|
+
|
25
32
|
## Development
|
26
33
|
|
27
34
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -38,7 +45,7 @@ The gem is available as open source under the terms of the [MIT License](http://
|
|
38
45
|
|
39
46
|
## Code of Conduct
|
40
47
|
|
41
|
-
Everyone interacting in the Holistics project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
48
|
+
Everyone interacting in the Holistics-CLI project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/pmint93/holistics-cli/blob/master/CODE_OF_CONDUCT.md).
|
42
49
|
|
43
50
|
## Related
|
44
51
|
|
data/lib/holistics/imports.rb
CHANGED
@@ -44,7 +44,7 @@ Examples:
|
|
44
44
|
source: source,
|
45
45
|
destination: destination,
|
46
46
|
created_at: DateTime.parse(item['created_at']).to_formatted_s(:short),
|
47
|
-
last_run: DateTime.parse(item['last_run']).to_formatted_s(:short),
|
47
|
+
last_run: item['last_run'] ? DateTime.parse(item['last_run']).to_formatted_s(:short): nil,
|
48
48
|
last_run_status: last_run_status
|
49
49
|
}
|
50
50
|
end
|
data/lib/holistics/jobs.rb
CHANGED
@@ -26,9 +26,9 @@ Examples:
|
|
26
26
|
created_at: DateTime.parse(item['created_at']).to_formatted_s(:short),
|
27
27
|
source_type: item['source_type'],
|
28
28
|
source_id: item['source_id'],
|
29
|
-
# start_time: DateTime.parse(item['start_time']).to_formatted_s(:short),
|
30
|
-
# end_time: DateTime.parse(item['end_time']).to_formatted_s(:short),
|
31
|
-
duration: Time.at(item['duration']).utc.strftime("%H:%M:%S"),
|
29
|
+
# start_time: item['start_time'] ? DateTime.parse(item['start_time']).to_formatted_s(:short) : nil,
|
30
|
+
# end_time: item['end_time'] ? DateTime.parse(item['end_time']).to_formatted_s(:short) : nil,
|
31
|
+
duration: (item['duration'] < 0 ? nil : Time.at(item['duration']).utc.strftime("%H:%M:%S")),
|
32
32
|
# cancelledable
|
33
33
|
user: item['user']['name'],
|
34
34
|
status: Holistics::Utils.colorize(item['status'])
|
@@ -49,16 +49,16 @@ Examples:
|
|
49
49
|
source_id: item['source_id'],
|
50
50
|
created_at: DateTime.parse(item['created_at']).to_formatted_s(:short),
|
51
51
|
user_id: item['user_id'],
|
52
|
-
start_time: DateTime.parse(item['start_time']).to_formatted_s(:short),
|
53
|
-
end_time: DateTime.parse(item['end_time']).to_formatted_s(:short),
|
52
|
+
start_time: item['start_time'] ? DateTime.parse(item['start_time']).to_formatted_s(:short) : nil,
|
53
|
+
end_time: item['end_time'] ? DateTime.parse(item['end_time']).to_formatted_s(:short) : nil,
|
54
54
|
tenant_id: item['tenant_id'],
|
55
|
-
duration: Time.at(item['duration']).utc.strftime("%H:%M:%S")
|
55
|
+
duration: (item['duration'] < 0 ? nil : Time.at(item['duration']).utc.strftime("%H:%M:%S"))
|
56
56
|
}.each { |k, v| puts "\t" + [k,v].join(": ") }
|
57
57
|
end
|
58
58
|
|
59
59
|
desc 'logs ID', 'Show job logs by ID'
|
60
|
-
method_option :
|
61
|
-
method_option :number, aliases: '-n', desc: '
|
60
|
+
method_option :follow, aliases: '-f', desc: 'Specify if the logs should be streamed', type: :boolean
|
61
|
+
method_option :number, aliases: '-n', desc: 'Only print number of last lines', type: :numeric
|
62
62
|
def logs(id)
|
63
63
|
puts "`jobs logs #{id}` called with options: #{options}" if Holistics.debug?
|
64
64
|
if options[:watch]
|
data/lib/holistics/transforms.rb
CHANGED
@@ -21,7 +21,7 @@ Examples:
|
|
21
21
|
item.slice(*%w{id title owner_name}).merge({
|
22
22
|
mode: item['settings']['mode'],
|
23
23
|
created_at: DateTime.parse(item['created_at']).to_formatted_s(:short),
|
24
|
-
last_run: DateTime.parse(item['last_run']).to_formatted_s(:short)
|
24
|
+
last_run: item['last_run'] ? DateTime.parse(item['last_run']).to_formatted_s(:short) : nil
|
25
25
|
})
|
26
26
|
end
|
27
27
|
)
|
@@ -37,8 +37,7 @@ Examples:
|
|
37
37
|
def execute(id)
|
38
38
|
puts "`transforms execute #{id}` called with options: #{options}" if Holistics.debug?
|
39
39
|
result = @this.execute(id)
|
40
|
-
puts 'Job ID: ' + result['job_id'].to_s.yellow
|
41
|
-
puts 'Status: ' + Holistics::Utils.colorize(result['status'])
|
40
|
+
puts 'Job ID: ' + result['job_id'].to_s.yellow + " Submit: " + Holistics::Utils.colorize(result['status'])
|
42
41
|
invoke 'holistics:jobs:logs', [result['job_id']], { watch: true }
|
43
42
|
end
|
44
43
|
map %w[exec] => :execute
|
data/lib/holistics/utils.rb
CHANGED
@@ -4,7 +4,7 @@ module Holistics
|
|
4
4
|
COLORIZE_MAPPING = {
|
5
5
|
green: %w{active success ok},
|
6
6
|
red: %w{fail failure error cancelled},
|
7
|
-
yellow: %w{new pending unknown}
|
7
|
+
yellow: %w{new running pending unknown}
|
8
8
|
}
|
9
9
|
def colorize(text)
|
10
10
|
color = COLORIZE_MAPPING.find { |color, values| values.include?(text) }
|
data/lib/holistics/version.rb
CHANGED
data/lib/holistics.rb
CHANGED
@@ -51,17 +51,19 @@ module Holistics
|
|
51
51
|
puts "\nHolistics CommandLine Interface version #{Holistics::VERSION}".yellow
|
52
52
|
end
|
53
53
|
|
54
|
-
desc 'config', 'Init or update config'
|
55
|
-
def config
|
56
|
-
token
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
54
|
+
desc 'config [TOKEN]', 'Init or update config'
|
55
|
+
def config(token = nil)
|
56
|
+
unless token
|
57
|
+
current_config = configured? ? read_config : {}
|
58
|
+
current_token = current_config[:token]
|
59
|
+
new_token = ask "Your Holistics token [#{current_token.light_black}]: "
|
60
|
+
new_token = nil if new_token.blank?
|
61
|
+
unless token = new_token || current_token
|
62
|
+
STDERR.puts 'Failed to config, empty token provided !'
|
63
|
+
exit 1
|
64
|
+
end
|
65
|
+
end
|
66
|
+
verify_token(token) do
|
65
67
|
write_config(:token => token)
|
66
68
|
end
|
67
69
|
end
|
@@ -90,12 +92,28 @@ module Holistics
|
|
90
92
|
|
91
93
|
def require_config!
|
92
94
|
unless configured?
|
93
|
-
puts "Missing config, run #{'holistics config'.yellow} to init your"
|
95
|
+
STDERR.puts "Missing config, run #{'holistics config'.yellow} to init your"
|
94
96
|
exit 1
|
95
97
|
end
|
96
98
|
Holistics.client ||= Holistics::Client.new(nil, read_config[:token])
|
97
99
|
end
|
98
100
|
|
101
|
+
def verify_token(token)
|
102
|
+
print 'Verifying token ...'
|
103
|
+
client = Holistics::Client.new(nil, token)
|
104
|
+
status, body = client.get('/users/info.json')
|
105
|
+
if status == 200
|
106
|
+
user_info = JSON.parse(body)
|
107
|
+
puts 'ok'.green
|
108
|
+
puts '- ID: ' + user_info['id'].to_s.yellow
|
109
|
+
puts '- Email: ' + user_info['email']
|
110
|
+
yield if block_given?
|
111
|
+
else
|
112
|
+
STDERR.puts 'Token is invalid'.red
|
113
|
+
exit 1
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
99
117
|
def read_config
|
100
118
|
result = {}
|
101
119
|
File.read(Holistics::CONFIG_FILE).split("\n").map do |line|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: holistics-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thanh Pham Minh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -145,10 +145,10 @@ executables:
|
|
145
145
|
extensions: []
|
146
146
|
extra_rdoc_files: []
|
147
147
|
files:
|
148
|
-
- ".byebug_history"
|
149
148
|
- ".gitignore"
|
150
149
|
- ".rspec"
|
151
150
|
- ".travis.yml"
|
151
|
+
- CHANGELOG.md
|
152
152
|
- CODE_OF_CONDUCT.md
|
153
153
|
- Gemfile
|
154
154
|
- LICENSE.txt
|
data/.byebug_history
DELETED
@@ -1,183 +0,0 @@
|
|
1
|
-
exit
|
2
|
-
c.get('/data_imports')
|
3
|
-
c.get('/')
|
4
|
-
c = @this.instance_variable_get(:@client)
|
5
|
-
exit
|
6
|
-
c.token
|
7
|
-
c = @this.instance_variable_get(:@client)
|
8
|
-
@this.instance_variable_get(:@client).get('/data_imports')
|
9
|
-
@this.instance_variable_get(:@client).get('/')
|
10
|
-
@this.instance_variable_get(:@client)
|
11
|
-
@this.instance_variable_get(@client)
|
12
|
-
@this.instance_var
|
13
|
-
@this
|
14
|
-
@this.client
|
15
|
-
c
|
16
|
-
exit
|
17
|
-
item = @this.find id
|
18
|
-
item
|
19
|
-
c
|
20
|
-
log_lines[(-[line_count, log_lines.length].min)..-1]
|
21
|
-
line_count
|
22
|
-
exit
|
23
|
-
log_lines
|
24
|
-
line_count
|
25
|
-
lien_count
|
26
|
-
exit
|
27
|
-
line_count
|
28
|
-
exit
|
29
|
-
line_count
|
30
|
-
exit
|
31
|
-
line_count
|
32
|
-
exit
|
33
|
-
n
|
34
|
-
exit
|
35
|
-
number
|
36
|
-
log_lines
|
37
|
-
number
|
38
|
-
exit
|
39
|
-
e['logs'].first
|
40
|
-
e['logs']
|
41
|
-
e.keys
|
42
|
-
e = @this.logs(id)
|
43
|
-
exit
|
44
|
-
e = @this.find id
|
45
|
-
exit
|
46
|
-
tp([e])
|
47
|
-
tp(e)
|
48
|
-
e = @this.execute(id)
|
49
|
-
exit
|
50
|
-
ix.concat(12)
|
51
|
-
ix
|
52
|
-
ix.concat([11])
|
53
|
-
ix = [1,2,3]
|
54
|
-
i = [1,2,3]
|
55
|
-
self.errors
|
56
|
-
self
|
57
|
-
self.errors
|
58
|
-
self.errors = 123
|
59
|
-
self.errors
|
60
|
-
errors
|
61
|
-
errors = 123
|
62
|
-
errors
|
63
|
-
exit
|
64
|
-
self.errors
|
65
|
-
errors = 1
|
66
|
-
errors = nil
|
67
|
-
self.errors
|
68
|
-
self
|
69
|
-
errors
|
70
|
-
c
|
71
|
-
exit
|
72
|
-
c
|
73
|
-
exit
|
74
|
-
c
|
75
|
-
exit
|
76
|
-
c
|
77
|
-
exit
|
78
|
-
c
|
79
|
-
exit
|
80
|
-
e.keys
|
81
|
-
item['last_run']
|
82
|
-
e = items.first
|
83
|
-
c
|
84
|
-
exit
|
85
|
-
e['last_run_job']['status']
|
86
|
-
e['last_run_job']['stats']
|
87
|
-
e['last_run_job'].keys
|
88
|
-
e['source_label']
|
89
|
-
e['last_run_job']
|
90
|
-
e.keys
|
91
|
-
e = items.first
|
92
|
-
c
|
93
|
-
exit
|
94
|
-
destination = [item['dest_ds_id']. item['dest_schema_name'], item['dest_table_name']].join('.')
|
95
|
-
item
|
96
|
-
destination = [item['dest_ds_id']. item['dest_schema_name'], item['dest_table_name']].join('.')
|
97
|
-
item
|
98
|
-
destination = [item['dest_ds_id']. item['dest_schema_name'], item['dest_table_name']].join('.')
|
99
|
-
item = e
|
100
|
-
e.keys
|
101
|
-
e = items.first
|
102
|
-
c
|
103
|
-
exit
|
104
|
-
item = items.first
|
105
|
-
item = items.firsr
|
106
|
-
items.first['source_config']['dbtable']
|
107
|
-
items.first['source_config']['db_table']
|
108
|
-
items.first['source_config']['db_table']['ds_id']
|
109
|
-
items.first.keys
|
110
|
-
c
|
111
|
-
items
|
112
|
-
exit
|
113
|
-
e.map { |v| v['source_type']}.uniq
|
114
|
-
x["source_type"]
|
115
|
-
x["dest_schema_name"]
|
116
|
-
x["source_config"]
|
117
|
-
x["title"]
|
118
|
-
x.keys
|
119
|
-
x = e.first
|
120
|
-
e = @this.all
|
121
|
-
e = @this.execute("308")
|
122
|
-
exit
|
123
|
-
ex
|
124
|
-
e = @this.execute("308")
|
125
|
-
exit
|
126
|
-
@this.execute("308")
|
127
|
-
transform_id
|
128
|
-
exit
|
129
|
-
@this.method(:execute).source_location
|
130
|
-
@this
|
131
|
-
e = @this.execute(308)
|
132
|
-
c
|
133
|
-
exit
|
134
|
-
end
|
135
|
-
})
|
136
|
-
mode: v['settings']['mode']
|
137
|
-
v.slice(*%w{ id title owner_name created_at last_run }).merge({
|
138
|
-
@this.all.map do |v|
|
139
|
-
x.slice(*%w{ id title owner_name created_at last_run })
|
140
|
-
x.slice("id")
|
141
|
-
x.slice
|
142
|
-
x.keys
|
143
|
-
x
|
144
|
-
x.splice(%w{ id title owner_name created_at last_run })
|
145
|
-
x.slice(%w{ id title owner_name created_at last_run })
|
146
|
-
x = e.first
|
147
|
-
v = e.first
|
148
|
-
e
|
149
|
-
v = e.first
|
150
|
-
e = @this.all
|
151
|
-
exit
|
152
|
-
puts e.first["schedules"]
|
153
|
-
puts e.first["settings"]["mode"]
|
154
|
-
puts e.first["settings"]
|
155
|
-
puts e.first["tenant_id"]
|
156
|
-
puts e.first["tenant_id]
|
157
|
-
puts e.first["query"]
|
158
|
-
e.first["owner_name"]
|
159
|
-
e.first["description"]
|
160
|
-
e.first["title"]
|
161
|
-
e.first["id"]
|
162
|
-
e.first[:id]
|
163
|
-
e.first.keys
|
164
|
-
e.first
|
165
|
-
e = @this.all
|
166
|
-
@this.all
|
167
|
-
exit
|
168
|
-
JSON.parse(data.body)
|
169
|
-
JSON
|
170
|
-
data.body
|
171
|
-
data = e.all
|
172
|
-
e.all
|
173
|
-
e = Resource.new('data_sources', Holistics.client)
|
174
|
-
exit
|
175
|
-
e.all
|
176
|
-
e.list
|
177
|
-
e
|
178
|
-
e.name
|
179
|
-
e = Resource.new('data_sources', Holistics.client)
|
180
|
-
e = _
|
181
|
-
Resource.new('data_sources', Holistics.client)
|
182
|
-
Resource.new('data_sources')
|
183
|
-
Resource
|