td 0.10.92 → 0.10.93

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,10 +1,21 @@
1
+ == 2013-11-14 version 0.10.93
2
+
3
+ * Improve import:prepare command. 'all-string' option is added.
4
+ * Fix import:prepare command. NumberFormatException often occurs. (When sample method in CSVFileReader class is executed. SimpleDateFormat objects are used in non synchronized block.)
5
+ * Fix import:prepare command. There are incompatibility with bulk_import command regarding 'NULL' string.
6
+ * Fix import:prepare command. NullPointerException occurs when unknown column type is specified as 'column-types' option.
7
+ * Support item type in table:create
8
+ * Remove organization, role and ip_limit subcommands
9
+ * Enable query result download even if job status is error
10
+
11
+
1
12
  == 2013-11-05 version 0.10.92
2
13
 
3
- * Improves import commands. It can parse string values of 'HH:mm:ss' time format automatically without specifying '%T' and transfer into long unix timestamp.
4
- * Improves import commands. It can parse string values of 'yyyy/MM/dd HH:mm:ss' time format automatically without specifying 'time-format' and transfer into long unix timestamp.
5
- * Improves import commands. It can parse string values of 'yyyy/MM/dd HH:mm:ss Z' time format automatically without specifying 'time-format' and transfer into long unix timestamp.
6
- * Adds 'regex' to source file format option of import:prepare command.
7
- * Fix import:upload command. NullPointerException often occurrs when data files are uploaded.
14
+ * Improve import commands. It can parse string values of 'HH:mm:ss' time format automatically without specifying '%T' and transfer into long unix timestamp.
15
+ * Improve import commands. It can parse string values of 'yyyy/MM/dd HH:mm:ss' time format automatically without specifying 'time-format' and transfer into long unix timestamp.
16
+ * Improve import commands. It can parse string values of 'yyyy/MM/dd HH:mm:ss Z' time format automatically without specifying 'time-format' and transfer into long unix timestamp.
17
+ * Add 'regex' to source file format option of import:prepare command.
18
+ * Fix import:upload command. NullPointerException often occurs when data files are uploaded.
8
19
 
9
20
 
10
21
  == 2013-10-04 version 0.10.91
@@ -19,11 +19,11 @@ if [ -n "$chrev" ];then
19
19
  fi
20
20
 
21
21
  revname="$(git show --pretty=format:'%H %ad' | head -n 1)"
22
- vername="0.3.1-SNAPSHOT"
22
+ vername="0.4.1-SNAPSHOT"
23
23
 
24
24
  mvn package -Dmaven.test.skip=true || exit 1
25
25
  echo "copy td-import-${vername}.jar"
26
- cp target/td-import-${vername}.jar ../../java/td-import.jar
26
+ cp target/td-import-${vername}-jar-with-dependencies.jar ../../java/td-import.jar
27
27
  echo "copy logging.properties"
28
28
  cp src/test/resources/java/logging.properties ../../java/logging.properties
29
29
  echo "create VERSION file"
data/java/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1-SNAPSHOT
1
+ 0.4.1-SNAPSHOT
@@ -1 +1 @@
1
- d8f0fb80d14729cc8881a7e1aa074a51fdc34407 Tue Nov 5 14:08:52 2013 +0900
1
+ 466a09aef2fb634defffbe117cec80777772d7a2 Thu Nov 14 15:35:00 2013 +0900
data/java/td-import.jar CHANGED
Binary file
@@ -10,13 +10,11 @@ module Command
10
10
  bis = client.bulk_imports
11
11
 
12
12
  rows = []
13
- has_org = false
14
13
  bis.each {|bi|
15
- rows << {:Name=>bi.name, :Table=>"#{bi.database}.#{bi.table}", :Status=>bi.status.to_s.capitalize, :Frozen=>bi.upload_frozen? ? 'Frozen' : '', :JobID=>bi.job_id, :"Valid Parts"=>bi.valid_parts, :"Error Parts"=>bi.error_parts, :"Valid Records"=>bi.valid_records, :"Error Records"=>bi.error_records, :Organization=>bi.org_name}
16
- has_org = true if bi.org_name
14
+ rows << {:Name=>bi.name, :Table=>"#{bi.database}.#{bi.table}", :Status=>bi.status.to_s.capitalize, :Frozen=>bi.upload_frozen? ? 'Frozen' : '', :JobID=>bi.job_id, :"Valid Parts"=>bi.valid_parts, :"Error Parts"=>bi.error_parts, :"Valid Records"=>bi.valid_records, :"Error Records"=>bi.error_records}
17
15
  }
18
16
 
19
- puts cmd_render_table(rows, :fields => gen_table_fields(has_org, [:Name, :Table, :Status, :Frozen, :JobID, :"Valid Parts", :"Error Parts", :"Valid Records", :"Error Records"]), :max_width=>200)
17
+ puts cmd_render_table(rows, :fields => [:Name, :Table, :Status, :Frozen, :JobID, :"Valid Parts", :"Error Parts", :"Valid Records", :"Error Records"], :max_width=>200)
20
18
 
21
19
  if rows.empty?
22
20
  $stderr.puts "There are no bulk import sessions."
@@ -25,12 +23,6 @@ module Command
25
23
  end
26
24
 
27
25
  def bulk_import_create(op)
28
- org = nil
29
-
30
- op.on('-g', '--org ORGANIZATION', "create the bulk import session under this organization") {|s|
31
- org = s
32
- }
33
-
34
26
  name, db_name, table_name = op.cmd_parse
35
27
 
36
28
  client = get_client
@@ -38,7 +30,6 @@ module Command
38
30
  table = get_table(client, db_name, table_name)
39
31
 
40
32
  opts = {}
41
- opts['organization'] = org if org
42
33
  client.create_bulk_import(name, db_name, table_name, opts)
43
34
 
44
35
  $stderr.puts "Bulk import session '#{name}' is created."
@@ -73,7 +64,6 @@ module Command
73
64
  exit 1
74
65
  end
75
66
 
76
- $stderr.puts "Organization : #{bi.org_name}"
77
67
  $stderr.puts "Name : #{bi.name}"
78
68
  $stderr.puts "Database : #{bi.database}"
79
69
  $stderr.puts "Table : #{bi.table}"
@@ -42,14 +42,6 @@ module Command
42
42
  Hirb::Helpers::Table.render(rows, *opts)
43
43
  end
44
44
 
45
- def gen_table_fields(has_org, fields)
46
- if has_org
47
- fields.unshift(:Organization)
48
- else
49
- fields
50
- end
51
- end
52
-
53
45
  def normalized_message
54
46
  <<EOS
55
47
  Your event has large number larger than 2^64.
data/lib/td/command/db.rb CHANGED
@@ -30,12 +30,10 @@ module Command
30
30
  dbs = client.databases
31
31
 
32
32
  rows = []
33
- has_org = false
34
33
  dbs.each {|db|
35
- rows << {:Name=>db.name, :Count=>db.count, :Organization=>db.org_name}
36
- has_org = true if db.org_name
34
+ rows << {:Name=>db.name, :Count=>db.count}
37
35
  }
38
- puts cmd_render_table(rows, :fields => gen_table_fields(has_org, [:Name, :Count]))
36
+ puts cmd_render_table(rows, :fields => [:Name, :Count])
39
37
 
40
38
  if dbs.empty?
41
39
  $stderr.puts "There are no databases."
@@ -44,12 +42,6 @@ module Command
44
42
  end
45
43
 
46
44
  def db_create(op)
47
- org = nil
48
-
49
- op.on('-g', '--org ORGANIZATION', "create the database under this organization") {|s|
50
- org = s
51
- }
52
-
53
45
  db_name = op.cmd_parse
54
46
 
55
47
  API.validate_database_name(db_name)
@@ -57,7 +49,6 @@ module Command
57
49
  client = get_client
58
50
 
59
51
  opts = {}
60
- opts['organization'] = org if org
61
52
  begin
62
53
  client.create_database(db_name, opts)
63
54
  rescue AlreadyExistsError
@@ -4,7 +4,6 @@ module Command
4
4
  SUPPORTED_FORMATS = %W[json.gz line-json.gz]
5
5
 
6
6
  def table_export(op)
7
- org = nil
8
7
  from = nil
9
8
  to = nil
10
9
  s3_bucket = nil
@@ -12,9 +11,6 @@ module Command
12
11
  aws_secret_access_key = nil
13
12
  file_format = nil
14
13
 
15
- op.on('-g', '--org ORGANIZATION', "export the data under this organization") {|s|
16
- org = s
17
- }
18
14
  op.on('-f', '--from TIME', 'export data which is newer than or same with the TIME') {|s|
19
15
  from = export_parse_time(s)
20
16
  }
@@ -59,7 +55,6 @@ module Command
59
55
  client = get_ssl_client
60
56
 
61
57
  s3_opts = {}
62
- s3_opts['organization'] = org if org
63
58
  s3_opts['from'] = from.to_s if from
64
59
  s3_opts['to'] = to.to_s if to
65
60
  s3_opts['file_format'] = file_format
@@ -69,16 +69,14 @@ module Command
69
69
  jobs = client.jobs(skip, skip+max-1, status, conditions)
70
70
 
71
71
  rows = []
72
- has_org = false
73
72
  jobs.each {|job|
74
73
  start = job.start_at
75
74
  elapsed = cmd_format_elapsed(start, job.end_at)
76
75
  priority = job_priority_name_of(job.priority)
77
- rows << {:JobID => job.job_id, :Database => job.db_name, :Status => job.status, :Type => job.type, :Query => job.query.to_s, :Start => (start ? start.localtime : ''), :Elapsed => elapsed, :Priority => priority, :Result => job.result_url, :Organization => job.org_name}
78
- has_org = true if job.org_name
76
+ rows << {:JobID => job.job_id, :Database => job.db_name, :Status => job.status, :Type => job.type, :Query => job.query.to_s, :Start => (start ? start.localtime : ''), :Elapsed => elapsed, :Priority => priority, :Result => job.result_url}
79
77
  }
80
78
 
81
- puts cmd_render_table(rows, :fields => gen_table_fields(has_org, [:JobID, :Status, :Start, :Elapsed, :Priority, :Result, :Type, :Database, :Query]), :max_width => 140)
79
+ puts cmd_render_table(rows, :fields => [:JobID, :Status, :Start, :Elapsed, :Priority, :Result, :Type, :Database, :Query], :max_width => 140)
82
80
  end
83
81
 
84
82
  def job_show(op)
@@ -117,28 +115,34 @@ module Command
117
115
 
118
116
  job = client.job(job_id)
119
117
 
120
- puts "Organization : #{job.org_name}"
121
- puts "JobID : #{job.job_id}"
122
- #puts "URL : #{job.url}"
123
- puts "Status : #{job.status}"
124
- puts "Type : #{job.type}"
125
- puts "Priority : #{job_priority_name_of(job.priority)}"
126
- puts "Retry limit : #{job.retry_limit}"
127
- puts "Result : #{job.result_url}"
128
- puts "Database : #{job.db_name}"
129
- puts "Query : #{job.query}"
118
+ puts "JobID : #{job.job_id}"
119
+ #puts "URL : #{job.url}"
120
+ puts "Status : #{job.status}"
121
+ puts "Type : #{job.type}"
122
+ puts "Priority : #{job_priority_name_of(job.priority)}"
123
+ puts "Retry limit : #{job.retry_limit}"
124
+ puts "Result : #{job.result_url}"
125
+ puts "Database : #{job.db_name}"
126
+ puts "Query : #{job.query}"
130
127
 
131
128
  if wait && !job.finished?
132
129
  wait_job(job)
133
- if job.success? && [:hive, :pig, :impala].include?(job.type) && !exclude
134
- puts "Result :"
135
- show_result(job, output, format, render_opts)
130
+ if [:hive, :pig, :impala].include?(job.type) && !exclude
131
+ puts "Result :"
132
+ begin
133
+ show_result(job, output, format, render_opts)
134
+ rescue TreasureData::NotFoundError => e
135
+ # Got 404 because result not found.
136
+ end
136
137
  end
137
138
 
138
139
  else
139
- if job.success? && [:hive, :pig, :impala].include?(job.type) && !exclude
140
- puts "Result :"
141
- show_result(job, output, format, render_opts)
140
+ if [:hive, :pig, :impala].include?(job.type) && !exclude
141
+ puts "Result :"
142
+ begin
143
+ show_result(job, output, format, render_opts)
144
+ rescue TreasureData::NotFoundError => e
145
+ end
142
146
  end
143
147
 
144
148
  if verbose
@@ -127,7 +127,7 @@ module List
127
127
  LIST = []
128
128
  COMMAND = {}
129
129
  GUESS = {}
130
- HELP_EXCLUDE = [/^help/, /^account/, /^aggr/, /^update/, /^user/, /^ip_limit/, /^role/, /^org/, /^acl/]
130
+ HELP_EXCLUDE = [/^help/, /^account/, /^aggr/, /^update/, /^user/, /^acl/]
131
131
  USAGE_EXCLUDE = [/bulk_import:upload_part\z/, /bulk_import:delete_part\z/]
132
132
 
133
133
  def self.add_list(name, args, description, *examples)
@@ -302,28 +302,11 @@ module List
302
302
  add_list 'user:apikey:remove', %w[name apikey], 'Remove an API key from an user'
303
303
  add_list 'user:password:change', %w[name], 'Change password'
304
304
 
305
- add_list 'role:list', %w[], 'Show list of roles'
306
- add_list 'role:show', %w[name], 'Show a role'
307
- add_list 'role:create', %w[name], 'Create a role'
308
- add_list 'role:delete', %w[name], 'Delete a role'
309
- add_list 'role:grant', %w[name user], 'Grant role to an user'
310
- add_list 'role:revoke', %w[name user], 'Revoke role from an user'
311
-
312
- add_list 'org:list', %w[], 'Show list of organizations'
313
- add_list 'org:show', %w[name], 'Show an organizations'
314
- add_list 'org:create', %w[name], 'Create an organizations'
315
- add_list 'org:delete', %w[name], 'Delete an organizations'
316
-
317
305
  add_list 'acl:list', %w[], 'Show list of access controls'
318
306
  add_list 'acl:grant', %w[subject action scope], 'Grant an access control'
319
307
  add_list 'acl:revoke', %w[subject action scope], 'Revoke an access control'
320
308
  # TODO acl:test
321
309
 
322
- add_list 'ip_limit:list', %w[], 'Show list of all IP range limitations'
323
- add_list 'ip_limit:show', %w[org], "Show list of org's IP range limitations"
324
- add_list 'ip_limit:set', %w[org ip_range_], 'Set an IP range limitation'
325
- add_list 'ip_limit:delete', %w[org], 'Delete an IP range limitation'
326
-
327
310
  add_list 'aggr:list', %w[], 'Show list of aggregation schemas'
328
311
  add_list 'aggr:show', %w[name], 'Describe a aggregation schema'
329
312
  add_list 'aggr:create', %w[name relation_key], 'Create a aggregation schema'
@@ -388,20 +371,9 @@ module List
388
371
  add_alias 'user:apikey', 'user:apikey:list'
389
372
  add_alias 'user:apikeys', 'user:apikey:list'
390
373
 
391
- add_alias 'role', 'role:show'
392
- add_alias 'roles', 'role:list'
393
-
394
- add_alias 'org', 'org:show'
395
- add_alias 'orgs', 'org:list'
396
- add_alias 'organization', 'org:create'
397
- add_alias 'organization', 'org:delete'
398
- add_alias 'organization', 'org:list'
399
-
400
374
  add_alias 'acl', 'acl:list'
401
375
  add_alias 'acls', 'acl:list'
402
376
 
403
- add_alias 'ip_limits', 'ip_limit:list'
404
-
405
377
  add_alias 'aggr', 'aggr:show'
406
378
  add_alias 'aggrs', 'aggr:list'
407
379
 
@@ -3,7 +3,6 @@ module TreasureData
3
3
  module Command
4
4
 
5
5
  def query(op)
6
- org = nil
7
6
  db_name = nil
8
7
  wait = false
9
8
  output = nil
@@ -19,9 +18,6 @@ module Command
19
18
  type = nil
20
19
  exclude = false
21
20
 
22
- op.on('-g', '--org ORGANIZATION', "issue the query under this organization") {|s|
23
- org = s
24
- }
25
21
  op.on('-d', '--database DB_NAME', 'use the database (required)') {|s|
26
22
  db_name = s
27
23
  }
@@ -100,7 +96,6 @@ module Command
100
96
  get_database(client, db_name)
101
97
 
102
98
  opts = {}
103
- opts['organization'] = org if org
104
99
  opts['sampling_all'] = sampling_all if sampling_all
105
100
  opts['type'] = type if type
106
101
  job = client.query(db_name, sql, result_url, priority, retry_limit, opts)
@@ -114,7 +109,10 @@ module Command
114
109
  puts "Status : #{job.status}"
115
110
  if job.success? && !exclude
116
111
  puts "Result :"
117
- show_result(job, output, format, render_opts)
112
+ begin
113
+ show_result(job, output, format, render_opts)
114
+ rescue TreasureData::NotFoundError => e
115
+ end
118
116
  end
119
117
  end
120
118
  end
@@ -16,9 +16,8 @@ module Command
16
16
  exit 1
17
17
  end
18
18
 
19
- puts "Organization : #{r.org_name}"
20
- puts "Name : #{r.name}"
21
- puts "URL : #{r.url}"
19
+ puts "Name : #{r.name}"
20
+ puts "URL : #{r.url}"
22
21
  end
23
22
 
24
23
  def result_list(op)
@@ -29,16 +28,14 @@ module Command
29
28
  rs = client.results
30
29
 
31
30
  rows = []
32
- has_org = false
33
31
  rs.each {|r|
34
- rows << {:Name => r.name, :URL => r.url, :Organization => r.org_name}
35
- has_org = true if r.org_name
32
+ rows << {:Name => r.name, :URL => r.url}
36
33
  }
37
34
  rows = rows.sort_by {|map|
38
35
  map[:Name]
39
36
  }
40
37
 
41
- puts cmd_render_table(rows, :fields => gen_table_fields(has_org, [:Name, :URL]))
38
+ puts cmd_render_table(rows, :fields => [:Name, :URL])
42
39
 
43
40
  if rs.empty?
44
41
  $stderr.puts "There are no result URLs."
@@ -47,13 +44,9 @@ module Command
47
44
  end
48
45
 
49
46
  def result_create(op)
50
- org = nil
51
47
  result_user = nil
52
48
  result_ask_password = false
53
49
 
54
- op.on('-g', '--org ORGANIZATION', "create the result under this organization") {|s|
55
- org = s
56
- }
57
50
  op.on('-u', '--user NAME', 'set user name for authentication') {|s|
58
51
  result_user = s
59
52
  }
@@ -70,7 +63,6 @@ module Command
70
63
  url = build_result_url(url, result_user, result_ask_password)
71
64
 
72
65
  opts = {}
73
- opts['organization'] = org if org
74
66
  begin
75
67
  client.create_result(name, url, opts)
76
68
  rescue AlreadyExistsError
@@ -12,22 +12,19 @@ module Command
12
12
  scheds = client.schedules
13
13
 
14
14
  rows = []
15
- has_org = false
16
15
  scheds.each {|sched|
17
- rows << {:Name => sched.name, :Cron => sched.cron, :Timezone => sched.timezone, :Delay => sched.delay, :Priority => job_priority_name_of(sched.priority), :Result => sched.result_url, :Database => sched.database, :Query => sched.query, :"Next schedule" => sched.next_time ? sched.next_time.localtime : nil, :Organization => sched.org_name }
18
- has_org = true if sched.org_name
16
+ rows << {:Name => sched.name, :Cron => sched.cron, :Timezone => sched.timezone, :Delay => sched.delay, :Priority => job_priority_name_of(sched.priority), :Result => sched.result_url, :Database => sched.database, :Query => sched.query, :"Next schedule" => sched.next_time ? sched.next_time.localtime : nil}
19
17
  }
20
18
  rows = rows.sort_by {|map|
21
19
  map[:Name]
22
20
  }
23
21
 
24
- puts cmd_render_table(rows, :fields => gen_table_fields(has_org, [:Name, :Cron, :Timezone, :"Next schedule", :Delay, :Priority, :Result, :Database, :Query]), :max_width=>500)
22
+ puts cmd_render_table(rows, :fields => [:Name, :Cron, :Timezone, :"Next schedule", :Delay, :Priority, :Result, :Database, :Query], :max_width=>500)
25
23
  end
26
24
 
27
25
  def sched_create(op)
28
26
  require 'td/command/job' # job_priority_id_of
29
27
 
30
- org = nil
31
28
  db_name = nil
32
29
  timezone = nil
33
30
  delay = 0
@@ -39,9 +36,6 @@ module Command
39
36
  retry_limit = nil
40
37
  type = nil
41
38
 
42
- op.on('-g', '--org ORGANIZATION', "create the schedule under this organization") {|s|
43
- org = s
44
- }
45
39
  op.on('-d', '--database DB_NAME', 'use the database (required)') {|s|
46
40
  db_name = s
47
41
  }
@@ -105,7 +99,7 @@ module Command
105
99
  get_database(client, db_name)
106
100
 
107
101
  begin
108
- first_time = client.create_schedule(name, :cron=>cron, :query=>sql, :database=>db_name, :result=>result_url, :timezone=>timezone, :delay=>delay, :priority=>priority, :retry_limit=>retry_limit, :organization=>org, :type=>type)
102
+ first_time = client.create_schedule(name, :cron=>cron, :query=>sql, :database=>db_name, :result=>result_url, :timezone=>timezone, :delay=>delay, :priority=>priority, :retry_limit=>retry_limit, :type=>type)
109
103
  rescue AlreadyExistsError
110
104
  cmd_debug_error $!
111
105
  $stderr.puts "Schedule '#{name}' already exists."
@@ -243,17 +237,16 @@ module Command
243
237
 
244
238
  scheds = client.schedules
245
239
  if s = scheds.find {|s| s.name == name }
246
- puts "Organization : #{s.org_name}"
247
- puts "Name : #{s.name}"
248
- puts "Cron : #{s.cron}"
249
- puts "Timezone : #{s.timezone}"
250
- puts "Delay : #{s.delay} sec"
251
- puts "Next : #{s.next_time}"
252
- puts "Result : #{s.result_url}"
253
- puts "Priority : #{job_priority_name_of(s.priority)}"
254
- puts "Retry limit : #{s.retry_limit}"
255
- puts "Database : #{s.database}"
256
- puts "Query : #{s.query}"
240
+ puts "Name : #{s.name}"
241
+ puts "Cron : #{s.cron}"
242
+ puts "Timezone : #{s.timezone}"
243
+ puts "Delay : #{s.delay} sec"
244
+ puts "Next : #{s.next_time}"
245
+ puts "Result : #{s.result_url}"
246
+ puts "Priority : #{job_priority_name_of(s.priority)}"
247
+ puts "Retry limit : #{s.retry_limit}"
248
+ puts "Database : #{s.database}"
249
+ puts "Query : #{s.query}"
257
250
  end
258
251
 
259
252
  rows = []
@@ -13,6 +13,31 @@ module Command
13
13
  ]
14
14
 
15
15
  def table_create(op)
16
+ type = nil
17
+ primary_key = nil
18
+ primary_key_type = nil
19
+
20
+ op.on('-T', '--type TYPE', 'set table type (log or item)') {|s|
21
+ unless ['item', 'log'].include?(s)
22
+ raise "Unknown table type #{s.dump}. Supported types: log and item"
23
+ end
24
+ type = s.to_sym
25
+ }
26
+ op.on('--primary-key PRIMARY_KEY_AND_TYPE', '[primary key]:[primary key type]') {|s|
27
+ unless /\A[\w]+:(string|int)\z/ =~ s
28
+ $stderr.puts "--primary-key PRIMARY_KEY_AND_TYPE is required, and should be in the format [primary key]:[primary key type]"
29
+ exit 1
30
+ end
31
+
32
+ args = s.split(':')
33
+ if args.length != 2
34
+ # this really shouldn't happen with the above regex
35
+ exit 1
36
+ end
37
+ primary_key = args[0]
38
+ primary_key_type = args[1]
39
+ }
40
+
16
41
  db_name, table_name = op.cmd_parse
17
42
 
18
43
  #API.validate_database_name(db_name)
@@ -24,10 +49,19 @@ module Command
24
49
  $stderr.puts " For a list of all reserved keywords, see our FAQ: http://docs.treasure-data.com/articles/faq"
25
50
  end
26
51
 
52
+ if type == :item && (primary_key.nil? || primary_key_type.nil?)
53
+ $stderr.puts "for TYPE 'item', the primary-key is required"
54
+ exit 1
55
+ end
56
+
27
57
  client = get_client
28
58
 
29
59
  begin
30
- client.create_log_table(db_name, table_name)
60
+ if type == :item
61
+ client.create_item_table(db_name, table_name, primary_key, primary_key_type)
62
+ else
63
+ client.create_log_table(db_name, table_name)
64
+ end
31
65
  rescue NotFoundError
32
66
  cmd_debug_error $!
33
67
  $stderr.puts "Database '#{db_name}' does not exist."
@@ -294,14 +328,10 @@ module Command
294
328
  end
295
329
 
296
330
  def table_partial_delete(op)
297
- org = nil
298
331
  from = nil
299
332
  to = nil
300
333
  wait = false
301
334
 
302
- op.on('-g', '--org ORGANIZATION', "delete data partially under this organization") {|s|
303
- org = s
304
- }
305
335
  op.on('-t', '--to TIME', 'end time of logs to delete') {|s|
306
336
  if s.to_i.to_s == s
307
337
  # UNIX time
@@ -345,7 +375,6 @@ module Command
345
375
  table = get_table(client, db_name, table_name)
346
376
 
347
377
  opts = {}
348
- opts['organization'] = org if org
349
378
  job = client.partial_delete(db_name, table_name, to, from, opts)
350
379
 
351
380
  $stderr.puts "Partial delete job #{job.job_id} is queued."
@@ -15,10 +15,8 @@ module Command
15
15
  exit 1
16
16
  end
17
17
 
18
- $stderr.puts "Name : #{user.name}"
19
- $stderr.puts "Organization : #{user.org_name}"
20
- $stderr.puts "Email : #{user.email}"
21
- $stderr.puts "Roles : #{user.role_names.join(', ')}"
18
+ $stderr.puts "Name : #{user.name}"
19
+ $stderr.puts "Email : #{user.email}"
22
20
  end
23
21
 
24
22
  def user_list(op)
@@ -30,10 +28,10 @@ module Command
30
28
 
31
29
  rows = []
32
30
  users.each {|user|
33
- rows << {:Name => user.name, :Organization => user.org_name, :Email => user.email, :Roles => user.role_names.join(',')}
31
+ rows << {:Name => user.name, :Email => user.email}
34
32
  }
35
33
 
36
- puts cmd_render_table(rows, :fields => [:Name, :Organization, :Email, :Roles])
34
+ puts cmd_render_table(rows, :fields => [:Name, :Email])
37
35
 
38
36
  if rows.empty?
39
37
  $stderr.puts "There are no users."
@@ -42,18 +40,8 @@ module Command
42
40
  end
43
41
 
44
42
  def user_create(op)
45
- org = nil
46
43
  email = nil
47
44
  random_password = false
48
- create_org = nil
49
-
50
- op.on('-g', '--org ORGANIZATION', "create the user under this organization") {|s|
51
- org = s
52
- }
53
-
54
- op.on('-G', "create the user under the a new organization", TrueClass) {|b|
55
- create_org = b
56
- }
57
45
 
58
46
  op.on('-e', '--email EMAIL', "Use this email address to identify the user") {|s|
59
47
  email = s
@@ -127,25 +115,9 @@ module Command
127
115
  end
128
116
 
129
117
  client = get_client(:ssl => true)
118
+ client.add_user(name, nil, email, password)
130
119
 
131
- if create_org
132
- org ||= name
133
- client.create_organization(org)
134
- end
135
-
136
- begin
137
- client.add_user(name, org, email, password)
138
- ensure
139
- if create_org
140
- client.delete_organization(org)
141
- end
142
- end
143
-
144
- if create_org
145
- $stderr.puts "Organization '#{org}' and user '#{name}' are created."
146
- else
147
- $stderr.puts "User '#{name}' is created."
148
- end
120
+ $stderr.puts "User '#{name}' is created."
149
121
  $stderr.puts "Use '#{$prog} user:apikeys #{name}' to show the API key."
150
122
  end
151
123
 
data/lib/td/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module TreasureData
2
2
 
3
- VERSION = '0.10.92'
3
+ VERSION = '0.10.93'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,32 +1,34 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: td
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.92
4
+ version: 0.10.93
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Treasure Data, Inc.
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-11-05 00:00:00.000000000 Z
12
+ date: 2013-11-14 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: msgpack
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '>='
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: 0.4.4
20
- - - '!='
22
+ - - ! '!='
21
23
  - !ruby/object:Gem::Version
22
24
  version: 0.5.0
23
- - - '!='
25
+ - - ! '!='
24
26
  - !ruby/object:Gem::Version
25
27
  version: 0.5.1
26
- - - '!='
28
+ - - ! '!='
27
29
  - !ruby/object:Gem::Version
28
30
  version: 0.5.2
29
- - - '!='
31
+ - - ! '!='
30
32
  - !ruby/object:Gem::Version
31
33
  version: 0.5.3
32
34
  - - <
@@ -35,20 +37,21 @@ dependencies:
35
37
  type: :runtime
36
38
  prerelease: false
37
39
  version_requirements: !ruby/object:Gem::Requirement
40
+ none: false
38
41
  requirements:
39
- - - '>='
42
+ - - ! '>='
40
43
  - !ruby/object:Gem::Version
41
44
  version: 0.4.4
42
- - - '!='
45
+ - - ! '!='
43
46
  - !ruby/object:Gem::Version
44
47
  version: 0.5.0
45
- - - '!='
48
+ - - ! '!='
46
49
  - !ruby/object:Gem::Version
47
50
  version: 0.5.1
48
- - - '!='
51
+ - - ! '!='
49
52
  - !ruby/object:Gem::Version
50
53
  version: 0.5.2
51
- - - '!='
54
+ - - ! '!='
52
55
  - !ruby/object:Gem::Version
53
56
  version: 0.5.3
54
57
  - - <
@@ -57,6 +60,7 @@ dependencies:
57
60
  - !ruby/object:Gem::Dependency
58
61
  name: yajl-ruby
59
62
  requirement: !ruby/object:Gem::Requirement
63
+ none: false
60
64
  requirements:
61
65
  - - ~>
62
66
  - !ruby/object:Gem::Version
@@ -64,6 +68,7 @@ dependencies:
64
68
  type: :runtime
65
69
  prerelease: false
66
70
  version_requirements: !ruby/object:Gem::Requirement
71
+ none: false
67
72
  requirements:
68
73
  - - ~>
69
74
  - !ruby/object:Gem::Version
@@ -71,20 +76,23 @@ dependencies:
71
76
  - !ruby/object:Gem::Dependency
72
77
  name: hirb
73
78
  requirement: !ruby/object:Gem::Requirement
79
+ none: false
74
80
  requirements:
75
- - - '>='
81
+ - - ! '>='
76
82
  - !ruby/object:Gem::Version
77
83
  version: 0.4.5
78
84
  type: :runtime
79
85
  prerelease: false
80
86
  version_requirements: !ruby/object:Gem::Requirement
87
+ none: false
81
88
  requirements:
82
- - - '>='
89
+ - - ! '>='
83
90
  - !ruby/object:Gem::Version
84
91
  version: 0.4.5
85
92
  - !ruby/object:Gem::Dependency
86
93
  name: parallel
87
94
  requirement: !ruby/object:Gem::Requirement
95
+ none: false
88
96
  requirements:
89
97
  - - ~>
90
98
  - !ruby/object:Gem::Version
@@ -92,6 +100,7 @@ dependencies:
92
100
  type: :runtime
93
101
  prerelease: false
94
102
  version_requirements: !ruby/object:Gem::Requirement
103
+ none: false
95
104
  requirements:
96
105
  - - ~>
97
106
  - !ruby/object:Gem::Version
@@ -99,6 +108,7 @@ dependencies:
99
108
  - !ruby/object:Gem::Dependency
100
109
  name: td-client
101
110
  requirement: !ruby/object:Gem::Requirement
111
+ none: false
102
112
  requirements:
103
113
  - - ~>
104
114
  - !ruby/object:Gem::Version
@@ -106,6 +116,7 @@ dependencies:
106
116
  type: :runtime
107
117
  prerelease: false
108
118
  version_requirements: !ruby/object:Gem::Requirement
119
+ none: false
109
120
  requirements:
110
121
  - - ~>
111
122
  - !ruby/object:Gem::Version
@@ -113,6 +124,7 @@ dependencies:
113
124
  - !ruby/object:Gem::Dependency
114
125
  name: td-logger
115
126
  requirement: !ruby/object:Gem::Requirement
127
+ none: false
116
128
  requirements:
117
129
  - - ~>
118
130
  - !ruby/object:Gem::Version
@@ -120,6 +132,7 @@ dependencies:
120
132
  type: :runtime
121
133
  prerelease: false
122
134
  version_requirements: !ruby/object:Gem::Requirement
135
+ none: false
123
136
  requirements:
124
137
  - - ~>
125
138
  - !ruby/object:Gem::Version
@@ -127,6 +140,7 @@ dependencies:
127
140
  - !ruby/object:Gem::Dependency
128
141
  name: rubyzip
129
142
  requirement: !ruby/object:Gem::Requirement
143
+ none: false
130
144
  requirements:
131
145
  - - ~>
132
146
  - !ruby/object:Gem::Version
@@ -134,6 +148,7 @@ dependencies:
134
148
  type: :runtime
135
149
  prerelease: false
136
150
  version_requirements: !ruby/object:Gem::Requirement
151
+ none: false
137
152
  requirements:
138
153
  - - ~>
139
154
  - !ruby/object:Gem::Version
@@ -141,6 +156,7 @@ dependencies:
141
156
  - !ruby/object:Gem::Dependency
142
157
  name: rake
143
158
  requirement: !ruby/object:Gem::Requirement
159
+ none: false
144
160
  requirements:
145
161
  - - ~>
146
162
  - !ruby/object:Gem::Version
@@ -148,6 +164,7 @@ dependencies:
148
164
  type: :development
149
165
  prerelease: false
150
166
  version_requirements: !ruby/object:Gem::Requirement
167
+ none: false
151
168
  requirements:
152
169
  - - ~>
153
170
  - !ruby/object:Gem::Version
@@ -155,6 +172,7 @@ dependencies:
155
172
  - !ruby/object:Gem::Dependency
156
173
  name: rspec
157
174
  requirement: !ruby/object:Gem::Requirement
175
+ none: false
158
176
  requirements:
159
177
  - - ~>
160
178
  - !ruby/object:Gem::Version
@@ -162,6 +180,7 @@ dependencies:
162
180
  type: :development
163
181
  prerelease: false
164
182
  version_requirements: !ruby/object:Gem::Requirement
183
+ none: false
165
184
  requirements:
166
185
  - - ~>
167
186
  - !ruby/object:Gem::Version
@@ -169,6 +188,7 @@ dependencies:
169
188
  - !ruby/object:Gem::Dependency
170
189
  name: simplecov
171
190
  requirement: !ruby/object:Gem::Requirement
191
+ none: false
172
192
  requirements:
173
193
  - - ~>
174
194
  - !ruby/object:Gem::Version
@@ -176,6 +196,7 @@ dependencies:
176
196
  type: :development
177
197
  prerelease: false
178
198
  version_requirements: !ruby/object:Gem::Requirement
199
+ none: false
179
200
  requirements:
180
201
  - - ~>
181
202
  - !ruby/object:Gem::Version
@@ -224,14 +245,11 @@ files:
224
245
  - lib/td/command/export.rb
225
246
  - lib/td/command/help.rb
226
247
  - lib/td/command/import.rb
227
- - lib/td/command/ip_limit.rb
228
248
  - lib/td/command/job.rb
229
249
  - lib/td/command/list.rb
230
- - lib/td/command/org.rb
231
250
  - lib/td/command/password.rb
232
251
  - lib/td/command/query.rb
233
252
  - lib/td/command/result.rb
234
- - lib/td/command/role.rb
235
253
  - lib/td/command/runner.rb
236
254
  - lib/td/command/sample.rb
237
255
  - lib/td/command/sched.rb
@@ -261,26 +279,33 @@ files:
261
279
  - td.gemspec
262
280
  homepage: http://treasure-data.com/
263
281
  licenses: []
264
- metadata: {}
265
282
  post_install_message:
266
283
  rdoc_options: []
267
284
  require_paths:
268
285
  - lib
269
286
  required_ruby_version: !ruby/object:Gem::Requirement
287
+ none: false
270
288
  requirements:
271
- - - '>='
289
+ - - ! '>='
272
290
  - !ruby/object:Gem::Version
273
291
  version: '0'
292
+ segments:
293
+ - 0
294
+ hash: 2341272974152018852
274
295
  required_rubygems_version: !ruby/object:Gem::Requirement
296
+ none: false
275
297
  requirements:
276
- - - '>='
298
+ - - ! '>='
277
299
  - !ruby/object:Gem::Version
278
300
  version: '0'
301
+ segments:
302
+ - 0
303
+ hash: 2341272974152018852
279
304
  requirements: []
280
305
  rubyforge_project:
281
- rubygems_version: 2.0.3
306
+ rubygems_version: 1.8.23
282
307
  signing_key:
283
- specification_version: 4
308
+ specification_version: 3
284
309
  summary: CLI to manage data on Treasure Data, the Hadoop-based cloud data warehousing
285
310
  test_files:
286
311
  - spec/file_reader/filter_spec.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 54ab5db5f823601ee978f163a00352c436d0636a
4
- data.tar.gz: b3c3d90f2a273a47d97b904b96a5ba28a2c8ec1d
5
- SHA512:
6
- metadata.gz: ac9469809cba499a0d9148694bba56a8c732510716885e1d0c63db39e0fe32afdd8c01a001c945ac33e7e4af1701a8c424b54c28b093af4906241634eef28713
7
- data.tar.gz: 48d57829a410364a275be6863970293281aa28646be116eb98c425e6b2bc67329d06b5b2bf2a911ccc02a862dcccb7c679d51e05ec39d9b5088939daa598921c
@@ -1,53 +0,0 @@
1
-
2
- module TreasureData
3
- module Command
4
- def ip_limit_list(op)
5
- op.cmd_parse
6
-
7
- client = get_client
8
-
9
- ip_limits = client.ip_limits
10
- rows = ip_limits.map { |ip_limit|
11
- {:Organization => ip_limit.org, 'IP Range' => ip_limit.ip_range}
12
- }
13
-
14
- puts cmd_render_table(rows, :fields => [:Organization, 'IP Range'])
15
-
16
- if rows.empty?
17
- $stderr.puts "There are no IP range limitations."
18
- $stderr.puts "Use '#{$prog} ip_limit:set <organization> <ip_range>' to create IP range limitation."
19
- end
20
- end
21
-
22
- def ip_limit_show(op)
23
- organization = op.cmd_parse
24
-
25
- client = get_client
26
-
27
- ip_limits = client.ip_limits
28
- rows = ip_limits.select { |ip_limit|
29
- ip_limit.org == organization
30
- }.map { |ip_limit| {'IP Range' => ip_limit.ip_range} }
31
-
32
- puts cmd_render_table(rows, :fields => ['IP Range'])
33
- end
34
-
35
- def ip_limit_set(op)
36
- organization, *ip_ranges = op.cmd_parse
37
-
38
- client = get_client
39
- client.set_ip_limit(organization, ip_ranges)
40
-
41
- $stderr.puts "IP range limitations [#{ip_ranges.join(' ')}] are set to #{organization}"
42
- end
43
-
44
- def ip_limit_delete(op)
45
- organization = op.cmd_parse
46
-
47
- client = get_client
48
- client.delete_ip_limit(organization)
49
-
50
- $stderr.puts "All IP range limitations are deleted from #{organization}"
51
- end
52
- end
53
- end
@@ -1,63 +0,0 @@
1
-
2
- module TreasureData
3
- module Command
4
-
5
- def org_show(op)
6
- name = op.cmd_parse
7
-
8
- client = get_client
9
-
10
- orgs = client.organizations
11
- org = orgs.find {|org| name == org.name }
12
- unless org
13
- $stderr.puts "Organization '#{name}' does not exist."
14
- $stderr.puts "Use '#{$prog} org:create <name>' to create an organization."
15
- exit 1
16
- end
17
-
18
- $stderr.puts "Name : #{org.name}"
19
- end
20
-
21
- def org_list(op)
22
- op.cmd_parse
23
-
24
- client = get_client
25
-
26
- orgs = client.organizations
27
-
28
- rows = []
29
- orgs.each {|org|
30
- rows << {:Name => org.name}
31
- }
32
-
33
- puts cmd_render_table(rows, :fields => [:Name])
34
-
35
- if rows.empty?
36
- $stderr.puts "There are no organizations."
37
- $stderr.puts "Use '#{$prog} org:create <name>' to create an organization."
38
- end
39
- end
40
-
41
- def org_create(op)
42
- name = op.cmd_parse
43
-
44
- client = get_client
45
-
46
- client.create_organization(name)
47
-
48
- $stderr.puts "Organization '#{name}' is created."
49
- end
50
-
51
- def org_delete(op)
52
- name = op.cmd_parse
53
-
54
- client = get_client
55
-
56
- client.delete_organization(name)
57
-
58
- $stderr.puts "Organization '#{name}' is deleted."
59
- end
60
-
61
- end
62
- end
63
-
@@ -1,91 +0,0 @@
1
-
2
- module TreasureData
3
- module Command
4
-
5
- def role_show(op)
6
- name = op.cmd_parse
7
-
8
- client = get_client
9
-
10
- roles = client.roles
11
- role = roles.find {|role| name == role.name }
12
- unless role
13
- $stderr.puts "Role '#{name}' does not exist."
14
- $stderr.puts "Use '#{$prog} role:create <name>' to create a role."
15
- exit 1
16
- end
17
-
18
- $stderr.puts "Organization : #{role.org_name}"
19
- $stderr.puts "Name : #{role.name}"
20
- $stderr.puts "Users : #{role.user_names.join(', ')}"
21
- end
22
-
23
- def role_list(op)
24
- op.cmd_parse
25
-
26
- client = get_client
27
-
28
- roles = client.roles
29
-
30
- rows = []
31
- roles.each {|role|
32
- rows << {:Name => role.name, :Organization => role.org_name, :Users => role.user_names.join(',')}
33
- }
34
-
35
- puts cmd_render_table(rows, :fields => [:Name, :Organization, :Users])
36
-
37
- if rows.empty?
38
- $stderr.puts "There are no roles."
39
- $stderr.puts "Use '#{$prog} org:create <name>' to create a role."
40
- end
41
- end
42
-
43
- def role_create(op)
44
- org = nil
45
-
46
- op.on('-g', '--org ORGANIZATION', "create the role under this organization") {|s|
47
- org = s
48
- }
49
-
50
- name = op.cmd_parse
51
-
52
- client = get_client
53
-
54
- client.create_role(name, org)
55
-
56
- $stderr.puts "Role '#{name}' is created."
57
- end
58
-
59
- def role_delete(op)
60
- name = op.cmd_parse
61
-
62
- client = get_client
63
-
64
- client.delete_role(name)
65
-
66
- $stderr.puts "Role '#{name}' is deleted."
67
- end
68
-
69
- def role_grant(op)
70
- name, user = op.cmd_parse
71
-
72
- client = get_client
73
-
74
- client.grant_role(name, user)
75
-
76
- $stderr.puts "Role '#{name}' is granted to user '#{user}'."
77
- end
78
-
79
- def role_revoke(op)
80
- name, user = op.cmd_parse
81
-
82
- client = get_client
83
-
84
- client.revoke_role(name, user)
85
-
86
- $stderr.puts "Role '#{name}' is revoked from user '#{user}'."
87
- end
88
-
89
- end
90
- end
91
-