td-client 1.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/data/ca-bundle.crt +3448 -0
- data/lib/td-client.rb +1 -0
- data/lib/td/client.rb +606 -0
- data/lib/td/client/api.rb +707 -0
- data/lib/td/client/api/access_control.rb +74 -0
- data/lib/td/client/api/account.rb +45 -0
- data/lib/td/client/api/bulk_import.rb +184 -0
- data/lib/td/client/api/bulk_load.rb +172 -0
- data/lib/td/client/api/database.rb +50 -0
- data/lib/td/client/api/export.rb +38 -0
- data/lib/td/client/api/import.rb +38 -0
- data/lib/td/client/api/job.rb +390 -0
- data/lib/td/client/api/partial_delete.rb +27 -0
- data/lib/td/client/api/result.rb +46 -0
- data/lib/td/client/api/schedule.rb +120 -0
- data/lib/td/client/api/server_status.rb +21 -0
- data/lib/td/client/api/table.rb +132 -0
- data/lib/td/client/api/user.rb +134 -0
- data/lib/td/client/api_error.rb +37 -0
- data/lib/td/client/compat_gzip_reader.rb +22 -0
- data/lib/td/client/model.rb +816 -0
- data/lib/td/client/version.rb +5 -0
- data/lib/td/core_ext/openssl/ssl/sslcontext/set_params.rb +18 -0
- data/spec/spec_helper.rb +63 -0
- data/spec/td/client/access_control_api_spec.rb +37 -0
- data/spec/td/client/account_api_spec.rb +34 -0
- data/spec/td/client/api_error_spec.rb +77 -0
- data/spec/td/client/api_spec.rb +269 -0
- data/spec/td/client/api_ssl_connection_spec.rb +109 -0
- data/spec/td/client/bulk_import_spec.rb +199 -0
- data/spec/td/client/bulk_load_spec.rb +401 -0
- data/spec/td/client/db_api_spec.rb +123 -0
- data/spec/td/client/export_api_spec.rb +51 -0
- data/spec/td/client/import_api_spec.rb +148 -0
- data/spec/td/client/job_api_spec.rb +833 -0
- data/spec/td/client/model_job_spec.rb +136 -0
- data/spec/td/client/model_schedule_spec.rb +26 -0
- data/spec/td/client/model_schema_spec.rb +134 -0
- data/spec/td/client/partial_delete_api_spec.rb +58 -0
- data/spec/td/client/result_api_spec.rb +77 -0
- data/spec/td/client/sched_api_spec.rb +109 -0
- data/spec/td/client/server_status_api_spec.rb +25 -0
- data/spec/td/client/spec_resources.rb +99 -0
- data/spec/td/client/table_api_spec.rb +226 -0
- data/spec/td/client/user_api_spec.rb +118 -0
- data/spec/td/client_sched_spec.rb +79 -0
- data/spec/td/client_spec.rb +46 -0
- metadata +271 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'td/client/spec_resources'
|
3
|
+
|
4
|
+
describe 'Schedule Command' do
|
5
|
+
include_context 'spec symbols'
|
6
|
+
include_context 'common helper'
|
7
|
+
|
8
|
+
let :api do
|
9
|
+
API.new(nil)
|
10
|
+
end
|
11
|
+
|
12
|
+
let :client do
|
13
|
+
client = TreasureData::Client.new('dummy')
|
14
|
+
client.instance_variable_set('@api', api)
|
15
|
+
client
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'create' do
|
19
|
+
let :opts do
|
20
|
+
{:database => db_name, :cron => '', :type => 'hive', :query => 'select 1;'}
|
21
|
+
end
|
22
|
+
|
23
|
+
before do
|
24
|
+
stub_api_request(:post, "/v3/schedule/create/#{e(sched_name)}").
|
25
|
+
with(:body => opts).
|
26
|
+
to_return(:body => {'name' => sched_name, 'start' => start}.to_json)
|
27
|
+
end
|
28
|
+
context 'start is now' do
|
29
|
+
let (:start){ Time.now.round }
|
30
|
+
it 'returns Time object' do
|
31
|
+
expect(client.create_schedule(sched_name, opts)).to eq(start)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'start is nil' do
|
36
|
+
let (:start){ nil }
|
37
|
+
it do
|
38
|
+
expect(client.create_schedule(sched_name, opts)).to eq(start)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'history' do
|
44
|
+
let :opts do
|
45
|
+
{'database' => db_name}
|
46
|
+
end
|
47
|
+
|
48
|
+
let :history do
|
49
|
+
['history', 'scheduled_at', 'job_id', 'type', 'database', 'status', 'query', 'start_at', 'end_at', 'result', 'priority'].inject({}) { |r, e|
|
50
|
+
r[e] = e
|
51
|
+
r
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'returns scheduled_job' do
|
56
|
+
h = history; h['scheduled_at'] = '2015-02-17 14:16:00 +0900'
|
57
|
+
stub_api_request(:get, "/v3/schedule/history/#{e(sched_name)}?from=0&to=19").
|
58
|
+
to_return(:body => {'count' => 1, 'history' => [h]}.to_json)
|
59
|
+
|
60
|
+
client.history(sched_name, 0, 19).each do |scheduled_job|
|
61
|
+
expect(scheduled_job.scheduled_at.xmlschema).to eq(Time.parse('2015-02-17T14:16:00+09:00').xmlschema) #avoid depending on CI's Locale
|
62
|
+
expect(scheduled_job.job_id).to eq('job_id')
|
63
|
+
expect(scheduled_job.status).to eq('status')
|
64
|
+
expect(scheduled_job.priority).to eq('priority')
|
65
|
+
expect(scheduled_job.result_url).to eq('result')
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'works when scheduled_at == ""' do
|
70
|
+
h = history; h['scheduled_at'] = ''
|
71
|
+
stub_api_request(:get, "/v3/schedule/history/#{e(sched_name)}?from=0&to=19").
|
72
|
+
to_return(:body => {'count' => 1, 'history' => [h]}.to_json)
|
73
|
+
|
74
|
+
client.history(sched_name, 0, 19).each do |scheduled_job|
|
75
|
+
expect(scheduled_job.scheduled_at).to eq(nil)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'td/client/spec_resources'
|
3
|
+
|
4
|
+
describe 'Command' do
|
5
|
+
include_context 'spec symbols'
|
6
|
+
include_context 'common helper'
|
7
|
+
include_context 'job resources'
|
8
|
+
|
9
|
+
before do
|
10
|
+
stub_api_request(:post, "/v3/user/authenticate").
|
11
|
+
to_return(:body => {'apikey' => 'apikey'}.to_json)
|
12
|
+
end
|
13
|
+
|
14
|
+
let :client do
|
15
|
+
Client.authenticate('user', 'password')
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#job' do
|
19
|
+
before do
|
20
|
+
stub_api_request(:get, "/v3/job/list").to_return(:body => {'jobs' => raw_jobs}.to_json)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'return jobs created with API result' do
|
24
|
+
jobs = client.jobs
|
25
|
+
|
26
|
+
expect(jobs).to be_kind_of Array
|
27
|
+
jobs.each.with_index do |job, i|
|
28
|
+
expect(job.job_id).to eq raw_jobs[i]['job_id']
|
29
|
+
expect(job.type).to eq raw_jobs[i]['type']
|
30
|
+
expect(job.status).to eq raw_jobs[i]['status']
|
31
|
+
expect(job.query).to eq raw_jobs[i]['query']
|
32
|
+
expect(job.start_at).to eq Time.parse(raw_jobs[i]['start_at'])
|
33
|
+
expect(job.end_at).to eq Time.parse(raw_jobs[i]['end_at'])
|
34
|
+
expect(job.cpu_time).to eq raw_jobs[i]['cpu_time']
|
35
|
+
expect(job.result_size).to eq raw_jobs[i]['result_size']
|
36
|
+
expect(job.result_url).to eq raw_jobs[i]['result_url']
|
37
|
+
expect(job.priority).to eq raw_jobs[i]['priority']
|
38
|
+
expect(job.retry_limit).to eq raw_jobs[i]['retry_limit']
|
39
|
+
expect(job.org_name).to eq raw_jobs[i]['organization']
|
40
|
+
expect(job.db_name).to eq raw_jobs[i]['database']
|
41
|
+
expect(job.duration).to eq raw_jobs[i]['duration']
|
42
|
+
expect(job.num_records).to eq raw_jobs[i]['num_records']
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,271 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: td-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: java
|
6
|
+
authors:
|
7
|
+
- Treasure Data, Inc.
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 0.5.6
|
19
|
+
- - "<"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2'
|
22
|
+
name: msgpack
|
23
|
+
prerelease: false
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.5.6
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '2.7'
|
39
|
+
name: httpclient
|
40
|
+
prerelease: false
|
41
|
+
type: :runtime
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '2.7'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - "~>"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '3.0'
|
53
|
+
name: rspec
|
54
|
+
prerelease: false
|
55
|
+
type: :development
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
name: coveralls
|
68
|
+
prerelease: false
|
69
|
+
type: :development
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '1.16'
|
81
|
+
name: webmock
|
82
|
+
prerelease: false
|
83
|
+
type: :development
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '1.16'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
requirement: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 0.5.4
|
95
|
+
name: simplecov
|
96
|
+
prerelease: false
|
97
|
+
type: :development
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 0.5.4
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
requirement: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
name: rake
|
110
|
+
prerelease: false
|
111
|
+
type: :development
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
requirement: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
name: yard
|
124
|
+
prerelease: false
|
125
|
+
type: :development
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
requirement: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - "<"
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '1.7'
|
137
|
+
name: tins
|
138
|
+
prerelease: false
|
139
|
+
type: :development
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - "<"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '1.7'
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
requirement: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - "<"
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '1.5'
|
151
|
+
name: public_suffix
|
152
|
+
prerelease: false
|
153
|
+
type: :development
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - "<"
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '1.5'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - "<"
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '1.4'
|
165
|
+
name: term-ansicolor
|
166
|
+
prerelease: false
|
167
|
+
type: :development
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - "<"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '1.4'
|
173
|
+
description: Treasure Data API library for Ruby
|
174
|
+
email: support@treasure-data.com
|
175
|
+
executables: []
|
176
|
+
extensions: []
|
177
|
+
extra_rdoc_files: []
|
178
|
+
files:
|
179
|
+
- data/ca-bundle.crt
|
180
|
+
- lib/td-client.rb
|
181
|
+
- lib/td/client.rb
|
182
|
+
- lib/td/client/api.rb
|
183
|
+
- lib/td/client/api/access_control.rb
|
184
|
+
- lib/td/client/api/account.rb
|
185
|
+
- lib/td/client/api/bulk_import.rb
|
186
|
+
- lib/td/client/api/bulk_load.rb
|
187
|
+
- lib/td/client/api/database.rb
|
188
|
+
- lib/td/client/api/export.rb
|
189
|
+
- lib/td/client/api/import.rb
|
190
|
+
- lib/td/client/api/job.rb
|
191
|
+
- lib/td/client/api/partial_delete.rb
|
192
|
+
- lib/td/client/api/result.rb
|
193
|
+
- lib/td/client/api/schedule.rb
|
194
|
+
- lib/td/client/api/server_status.rb
|
195
|
+
- lib/td/client/api/table.rb
|
196
|
+
- lib/td/client/api/user.rb
|
197
|
+
- lib/td/client/api_error.rb
|
198
|
+
- lib/td/client/compat_gzip_reader.rb
|
199
|
+
- lib/td/client/model.rb
|
200
|
+
- lib/td/client/version.rb
|
201
|
+
- lib/td/core_ext/openssl/ssl/sslcontext/set_params.rb
|
202
|
+
- spec/spec_helper.rb
|
203
|
+
- spec/td/client/access_control_api_spec.rb
|
204
|
+
- spec/td/client/account_api_spec.rb
|
205
|
+
- spec/td/client/api_error_spec.rb
|
206
|
+
- spec/td/client/api_spec.rb
|
207
|
+
- spec/td/client/api_ssl_connection_spec.rb
|
208
|
+
- spec/td/client/bulk_import_spec.rb
|
209
|
+
- spec/td/client/bulk_load_spec.rb
|
210
|
+
- spec/td/client/db_api_spec.rb
|
211
|
+
- spec/td/client/export_api_spec.rb
|
212
|
+
- spec/td/client/import_api_spec.rb
|
213
|
+
- spec/td/client/job_api_spec.rb
|
214
|
+
- spec/td/client/model_job_spec.rb
|
215
|
+
- spec/td/client/model_schedule_spec.rb
|
216
|
+
- spec/td/client/model_schema_spec.rb
|
217
|
+
- spec/td/client/partial_delete_api_spec.rb
|
218
|
+
- spec/td/client/result_api_spec.rb
|
219
|
+
- spec/td/client/sched_api_spec.rb
|
220
|
+
- spec/td/client/server_status_api_spec.rb
|
221
|
+
- spec/td/client/spec_resources.rb
|
222
|
+
- spec/td/client/table_api_spec.rb
|
223
|
+
- spec/td/client/user_api_spec.rb
|
224
|
+
- spec/td/client_sched_spec.rb
|
225
|
+
- spec/td/client_spec.rb
|
226
|
+
homepage: http://treasuredata.com/
|
227
|
+
licenses: []
|
228
|
+
metadata: {}
|
229
|
+
post_install_message:
|
230
|
+
rdoc_options: []
|
231
|
+
require_paths:
|
232
|
+
- lib
|
233
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
234
|
+
requirements:
|
235
|
+
- - ">="
|
236
|
+
- !ruby/object:Gem::Version
|
237
|
+
version: '0'
|
238
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
239
|
+
requirements:
|
240
|
+
- - ">="
|
241
|
+
- !ruby/object:Gem::Version
|
242
|
+
version: '0'
|
243
|
+
requirements: []
|
244
|
+
rubyforge_project:
|
245
|
+
rubygems_version: 2.4.8
|
246
|
+
signing_key:
|
247
|
+
specification_version: 4
|
248
|
+
summary: Treasure Data API library for Ruby
|
249
|
+
test_files:
|
250
|
+
- spec/td/client_sched_spec.rb
|
251
|
+
- spec/td/client_spec.rb
|
252
|
+
- spec/td/client/access_control_api_spec.rb
|
253
|
+
- spec/td/client/account_api_spec.rb
|
254
|
+
- spec/td/client/api_error_spec.rb
|
255
|
+
- spec/td/client/api_spec.rb
|
256
|
+
- spec/td/client/api_ssl_connection_spec.rb
|
257
|
+
- spec/td/client/bulk_import_spec.rb
|
258
|
+
- spec/td/client/bulk_load_spec.rb
|
259
|
+
- spec/td/client/db_api_spec.rb
|
260
|
+
- spec/td/client/export_api_spec.rb
|
261
|
+
- spec/td/client/import_api_spec.rb
|
262
|
+
- spec/td/client/job_api_spec.rb
|
263
|
+
- spec/td/client/model_job_spec.rb
|
264
|
+
- spec/td/client/model_schedule_spec.rb
|
265
|
+
- spec/td/client/model_schema_spec.rb
|
266
|
+
- spec/td/client/partial_delete_api_spec.rb
|
267
|
+
- spec/td/client/result_api_spec.rb
|
268
|
+
- spec/td/client/sched_api_spec.rb
|
269
|
+
- spec/td/client/server_status_api_spec.rb
|
270
|
+
- spec/td/client/table_api_spec.rb
|
271
|
+
- spec/td/client/user_api_spec.rb
|