td-client 0.8.11 → 0.8.12

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,4 +1,9 @@
1
1
 
2
+ == 2012-03-12 version 0.8.12
3
+
4
+ * Client#run_schedule returns an array of ScheduledJob
5
+
6
+
2
7
  == 2012-03-01 version 0.8.11
3
8
 
4
9
  * Use data/ca-bundle.crt for SSL connections
data/lib/td/client.rb CHANGED
@@ -153,6 +153,12 @@ class Client
153
153
  @api.kill(job_id)
154
154
  end
155
155
 
156
+ # => Job
157
+ def export(db_name, tbl_name, storage_type, opts={})
158
+ job_id = @api.export(db_name, tbl_name, storage_type, opts)
159
+ Job.new(self, job_id, :export, nil)
160
+ end
161
+
156
162
  # => first_time:Time
157
163
  def create_schedule(name, opts)
158
164
  raise ArgumentError, "'cron' option is required" unless opts[:cron] || opts['cron']
@@ -189,10 +195,12 @@ class Client
189
195
  }
190
196
  end
191
197
 
192
- # TODO nil -> [ScheduledJob] or [Job]
198
+ # [ScheduledJob]
193
199
  def run_schedule(name, time, num)
194
- @api.run_schedule(name, time, num)
195
- nil
200
+ results = @api.run_schedule(name, time, num)
201
+ results.map {|job_id,type,scheduled_at|
202
+ ScheduledJob.new(self, scheduled_at, job_id, type, nil)
203
+ }
196
204
  end
197
205
 
198
206
  # => time:Flaot
data/lib/td/client/api.rb CHANGED
@@ -370,6 +370,21 @@ class API
370
370
  return js['job_id'].to_s
371
371
  end
372
372
 
373
+ ####
374
+ ## Export API
375
+ ##
376
+
377
+ # => jobId:String
378
+ def export(db, tbl, storage_type, opts={})
379
+ params = opts.dup
380
+ params['storage_type'] = storage_type
381
+ code, body, res = post("/v3/export/run/#{e db}/#{e tbl}", params)
382
+ if code != "200"
383
+ raise_error("Export failed", res)
384
+ end
385
+ js = checked_json(body, %w[job_id])
386
+ return js['job_id'].to_s
387
+ end
373
388
 
374
389
  ####
375
390
  ## Schedule API
@@ -462,7 +477,8 @@ class API
462
477
  js['jobs'].each {|m|
463
478
  job_id = m['job_id']
464
479
  scheduled_at = m['scheduled_at']
465
- result << [job_id, scheduled_at]
480
+ type = (m['type'] || '?').to_sym
481
+ result << [job_id, type, scheduled_at]
466
482
  }
467
483
  return result
468
484
  end
@@ -83,7 +83,11 @@ class Table < Model
83
83
  end
84
84
 
85
85
  def import(format, stream, size)
86
- @api.import(@db_name, @table_name, format, stream, size)
86
+ @client.import(@db_name, @table_name, format, stream, size)
87
+ end
88
+
89
+ def export(storage_type, opts={})
90
+ @client.export(@db_name, @table_name, storage_type, opts)
87
91
  end
88
92
  end
89
93
 
@@ -1,5 +1,5 @@
1
1
  module TreasureData
2
2
 
3
- VERSION = '0.8.11'
3
+ VERSION = '0.8.12'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: td-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.11
4
+ version: 0.8.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-02 00:00:00.000000000Z
12
+ date: 2012-03-12 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: msgpack
16
- requirement: &12094460 !ruby/object:Gem::Requirement
16
+ requirement: &70219943379240 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.4.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *12094460
24
+ version_requirements: *70219943379240
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: json
27
- requirement: &12091360 !ruby/object:Gem::Requirement
27
+ requirement: &70219943378640 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.4.3
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *12091360
35
+ version_requirements: *70219943378640
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &12090880 !ruby/object:Gem::Requirement
38
+ requirement: &70219943377980 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 2.8.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *12090880
46
+ version_requirements: *70219943377980
47
47
  description:
48
48
  email:
49
49
  executables: []
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  version: '0'
83
83
  requirements: []
84
84
  rubyforge_project:
85
- rubygems_version: 1.8.10
85
+ rubygems_version: 1.8.12
86
86
  signing_key:
87
87
  specification_version: 3
88
88
  summary: Treasure Data API library for Ruby