td-client 0.8.47 → 0.8.48
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.
- data/ChangeLog +6 -0
- data/lib/td/client/api.rb +20 -12
- data/lib/td/client/version.rb +1 -1
- metadata +2 -2
data/ChangeLog
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 2012-04-22 version 0.8.48
|
2
|
+
|
3
|
+
* create_schedule now takes :type option
|
4
|
+
* Fix wrong error messages
|
5
|
+
* Ues 'api-import' instead of 'api' on data import
|
6
|
+
|
1
7
|
== 2012-04-09 version 0.8.47
|
2
8
|
|
3
9
|
* Fix HTTP proxy handlig issue which is overwritten with ENV['HTTP_PROXY']
|
data/lib/td/client/api.rb
CHANGED
@@ -16,6 +16,9 @@ end
|
|
16
16
|
|
17
17
|
|
18
18
|
class API
|
19
|
+
DEFAULT_ENDPOINT = 'api.treasure-data.com'
|
20
|
+
DEFAULT_IMPORT_ENDPOINT = 'api-import.treasure-data.com'
|
21
|
+
|
19
22
|
def initialize(apikey, opts={})
|
20
23
|
require 'json'
|
21
24
|
require 'time'
|
@@ -26,7 +29,7 @@ class API
|
|
26
29
|
|
27
30
|
@apikey = apikey
|
28
31
|
|
29
|
-
endpoint = opts[:endpoint] || ENV['TD_API_SERVER'] ||
|
32
|
+
endpoint = opts[:endpoint] || ENV['TD_API_SERVER'] || DEFAULT_ENDPOINT
|
30
33
|
uri = URI.parse(endpoint)
|
31
34
|
|
32
35
|
case uri.scheme
|
@@ -303,7 +306,7 @@ class API
|
|
303
306
|
def delete_table(db, table)
|
304
307
|
code, body, res = post("/v3/table/delete/#{e db}/#{e table}")
|
305
308
|
if code != "200"
|
306
|
-
raise_error("
|
309
|
+
raise_error("Delete table failed", res)
|
307
310
|
end
|
308
311
|
js = checked_json(body, %w[])
|
309
312
|
type = (js['type'] || '?').to_sym
|
@@ -465,7 +468,7 @@ class API
|
|
465
468
|
def kill(job_id)
|
466
469
|
code, body, res = post("/v3/job/kill/#{e job_id}")
|
467
470
|
if code != "200"
|
468
|
-
raise_error("
|
471
|
+
raise_error("Kill job failed", res)
|
469
472
|
end
|
470
473
|
js = checked_json(body, %w[])
|
471
474
|
former_status = js['former_status']
|
@@ -677,7 +680,7 @@ class API
|
|
677
680
|
|
678
681
|
# => start:String
|
679
682
|
def create_schedule(name, opts)
|
680
|
-
params = opts.update({'type'
|
683
|
+
params = opts.update({:type=> opts[:type] || opts['type'] || 'hive'})
|
681
684
|
code, body, res = post("/v3/schedule/create/#{e name}", params)
|
682
685
|
if code != "200"
|
683
686
|
raise_error("Create schedule failed", res)
|
@@ -784,7 +787,11 @@ class API
|
|
784
787
|
else
|
785
788
|
path = "/v3/table/import/#{e db}/#{e table}/#{format}"
|
786
789
|
end
|
787
|
-
|
790
|
+
opts = {}
|
791
|
+
if @host == DEFAULT_ENDPOINT
|
792
|
+
opts[:host] = DEFAULT_IMPORT_ENDPOINT
|
793
|
+
end
|
794
|
+
code, body, res = put(path, stream, size, opts)
|
788
795
|
if code[0] != ?2
|
789
796
|
raise_error("Import failed", res)
|
790
797
|
end
|
@@ -882,7 +889,7 @@ class API
|
|
882
889
|
def show_aggregation_schema(name)
|
883
890
|
code, body, res = get("/v3/aggr/show/#{e name}")
|
884
891
|
if code != "200"
|
885
|
-
raise_error("Show
|
892
|
+
raise_error("Show aggregation schema failed", res)
|
886
893
|
end
|
887
894
|
js = checked_json(body, %w[relation_key logs attrs])
|
888
895
|
relation_key = js['relation_key']
|
@@ -969,7 +976,7 @@ class API
|
|
969
976
|
def list_organizations
|
970
977
|
code, body, res = get("/v3/organization/list")
|
971
978
|
if code != "200"
|
972
|
-
raise_error("List
|
979
|
+
raise_error("List organizations failed", res)
|
973
980
|
end
|
974
981
|
js = checked_json(body, %w[organizations])
|
975
982
|
result = js["organizations"].map {|orginfo|
|
@@ -1079,7 +1086,7 @@ class API
|
|
1079
1086
|
def list_users
|
1080
1087
|
code, body, res = get("/v3/user/list")
|
1081
1088
|
if code != "200"
|
1082
|
-
raise_error("List
|
1089
|
+
raise_error("List users failed", res)
|
1083
1090
|
end
|
1084
1091
|
js = checked_json(body, %w[users])
|
1085
1092
|
result = js["users"].map {|roleinfo|
|
@@ -1373,8 +1380,8 @@ class API
|
|
1373
1380
|
return [response.code, response.body, response]
|
1374
1381
|
end
|
1375
1382
|
|
1376
|
-
def put(url, stream, size)
|
1377
|
-
http, header = new_http
|
1383
|
+
def put(url, stream, size, opts = {})
|
1384
|
+
http, header = new_http(opts)
|
1378
1385
|
|
1379
1386
|
http.read_timeout = 600
|
1380
1387
|
|
@@ -1398,8 +1405,9 @@ class API
|
|
1398
1405
|
return [response.code, response.body, response]
|
1399
1406
|
end
|
1400
1407
|
|
1401
|
-
def new_http
|
1402
|
-
|
1408
|
+
def new_http(opts = {})
|
1409
|
+
host = opts[:host] || @host
|
1410
|
+
http = @http_class.new(host, @port)
|
1403
1411
|
http.open_timeout = 60
|
1404
1412
|
if @ssl
|
1405
1413
|
http.use_ssl = true
|
data/lib/td/client/version.rb
CHANGED
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.
|
4
|
+
version: 0.8.48
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: msgpack
|