td 0.10.97 → 0.10.98
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 +7 -0
- data/lib/td/command/bulk_import.rb +1 -2
- data/lib/td/command/import.rb +1 -1
- data/lib/td/command/list.rb +1 -13
- data/lib/td/command/table.rb +1 -1
- data/lib/td/version.rb +1 -1
- data/td.gemspec +1 -1
- metadata +5 -11
- data/lib/td/command/aggr.rb +0 -208
    
        data/ChangeLog
    CHANGED
    
    
| @@ -58,8 +58,7 @@ module Command | |
| 58 58 |  | 
| 59 59 | 
             
                client = get_client
         | 
| 60 60 |  | 
| 61 | 
            -
                 | 
| 62 | 
            -
                bi = bis.find {|bi| name == bi.name }
         | 
| 61 | 
            +
                bi = client.bulk_import(name)
         | 
| 63 62 | 
             
                unless bi
         | 
| 64 63 | 
             
                  $stderr.puts "Bulk import session '#{name}' does not exist."
         | 
| 65 64 | 
             
                  $stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "bulk_import:create <name> <db> <table>' to create a session."
         | 
    
        data/lib/td/command/import.rb
    CHANGED
    
    
    
        data/lib/td/command/list.rb
    CHANGED
    
    | @@ -127,7 +127,7 @@ module List | |
| 127 127 | 
             
              LIST = []
         | 
| 128 128 | 
             
              COMMAND = {}
         | 
| 129 129 | 
             
              GUESS = {}
         | 
| 130 | 
            -
              HELP_EXCLUDE = [/^help/, /^account/, /^ | 
| 130 | 
            +
              HELP_EXCLUDE = [/^help/, /^account/, /^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)
         | 
| @@ -308,15 +308,6 @@ module List | |
| 308 308 | 
             
              add_list 'acl:revoke', %w[subject action scope], 'Revoke an access control'
         | 
| 309 309 | 
             
              # TODO acl:test
         | 
| 310 310 |  | 
| 311 | 
            -
              add_list 'aggr:list', %w[], 'Show list of aggregation schemas'
         | 
| 312 | 
            -
              add_list 'aggr:show', %w[name], 'Describe a aggregation schema'
         | 
| 313 | 
            -
              add_list 'aggr:create', %w[name relation_key], 'Create a aggregation schema'
         | 
| 314 | 
            -
              add_list 'aggr:delete', %w[name], 'Delete a aggregation schema'
         | 
| 315 | 
            -
              add_list 'aggr:add-log', %w[name db table entry_name o1_key? o2_key? o3_key?], 'Add a log aggregation entry'
         | 
| 316 | 
            -
              add_list 'aggr:add-attr', %w[name db table entry_name method_name parameters_?], 'Add an attribute aggregation entry'
         | 
| 317 | 
            -
              add_list 'aggr:del-log', %w[name entry_name], 'Delete a log aggregation entry'
         | 
| 318 | 
            -
              add_list 'aggr:del-attr', %w[name entry_name], 'Delete an attribute aggregation entry'
         | 
| 319 | 
            -
             | 
| 320 311 | 
             
              add_list 'server:status', %w[], 'Show status of the Treasure Data server'
         | 
| 321 312 |  | 
| 322 313 | 
             
              add_list 'sample:apache', %w[path.json], 'Create a sample log file'
         | 
| @@ -375,9 +366,6 @@ module List | |
| 375 366 | 
             
              add_alias 'acl', 'acl:list'
         | 
| 376 367 | 
             
              add_alias 'acls', 'acl:list'
         | 
| 377 368 |  | 
| 378 | 
            -
              add_alias 'aggr', 'aggr:show'
         | 
| 379 | 
            -
              add_alias 'aggrs', 'aggr:list'
         | 
| 380 | 
            -
             | 
| 381 369 | 
             
              add_alias 'apikey', 'apikey:show'
         | 
| 382 370 | 
             
              add_alias 'server', 'server:status'
         | 
| 383 371 | 
             
              add_alias 'sample', 'sample:apache'
         | 
    
        data/lib/td/command/table.rb
    CHANGED
    
    | @@ -23,7 +23,7 @@ module Command | |
| 23 23 | 
             
                  end
         | 
| 24 24 | 
             
                  type = s.to_sym
         | 
| 25 25 | 
             
                }
         | 
| 26 | 
            -
                op.on('--primary-key PRIMARY_KEY_AND_TYPE', '[primary key]:[primary key type]') {|s|
         | 
| 26 | 
            +
                op.on('--primary-key PRIMARY_KEY_AND_TYPE', '[primary key]:[primary key type(int or string)]') {|s|
         | 
| 27 27 | 
             
                  unless /\A[\w]+:(string|int)\z/ =~ s
         | 
| 28 28 | 
             
                    $stderr.puts "--primary-key PRIMARY_KEY_AND_TYPE is required, and should be in the format [primary key]:[primary key type]"
         | 
| 29 29 | 
             
                    exit 1
         | 
    
        data/lib/td/version.rb
    CHANGED
    
    
    
        data/td.gemspec
    CHANGED
    
    | @@ -20,7 +20,7 @@ Gem::Specification.new do |gem| | |
| 20 20 | 
             
              gem.add_dependency "yajl-ruby", "~> 1.1.0"
         | 
| 21 21 | 
             
              gem.add_dependency "hirb", ">= 0.4.5"
         | 
| 22 22 | 
             
              gem.add_dependency "parallel", "~> 0.6.1"
         | 
| 23 | 
            -
              gem.add_dependency "td-client", "~> 0.8. | 
| 23 | 
            +
              gem.add_dependency "td-client", "~> 0.8.57"
         | 
| 24 24 | 
             
              gem.add_dependency "td-logger", "~> 0.3.21"
         | 
| 25 25 | 
             
              gem.add_dependency "rubyzip", "~> 0.9.9"
         | 
| 26 26 | 
             
              gem.add_development_dependency "rake", "~> 0.9"
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: td
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.10. | 
| 4 | 
            +
              version: 0.10.98
         | 
| 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:  | 
| 12 | 
            +
            date: 2014-02-22 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: msgpack
         | 
| @@ -112,7 +112,7 @@ dependencies: | |
| 112 112 | 
             
                requirements:
         | 
| 113 113 | 
             
                - - ~>
         | 
| 114 114 | 
             
                  - !ruby/object:Gem::Version
         | 
| 115 | 
            -
                    version: 0.8. | 
| 115 | 
            +
                    version: 0.8.57
         | 
| 116 116 | 
             
              type: :runtime
         | 
| 117 117 | 
             
              prerelease: false
         | 
| 118 118 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| @@ -120,7 +120,7 @@ dependencies: | |
| 120 120 | 
             
                requirements:
         | 
| 121 121 | 
             
                - - ~>
         | 
| 122 122 | 
             
                  - !ruby/object:Gem::Version
         | 
| 123 | 
            -
                    version: 0.8. | 
| 123 | 
            +
                    version: 0.8.57
         | 
| 124 124 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 125 125 | 
             
              name: td-logger
         | 
| 126 126 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -237,7 +237,6 @@ files: | |
| 237 237 | 
             
            - lib/td.rb
         | 
| 238 238 | 
             
            - lib/td/command/account.rb
         | 
| 239 239 | 
             
            - lib/td/command/acl.rb
         | 
| 240 | 
            -
            - lib/td/command/aggr.rb
         | 
| 241 240 | 
             
            - lib/td/command/apikey.rb
         | 
| 242 241 | 
             
            - lib/td/command/bulk_import.rb
         | 
| 243 242 | 
             
            - lib/td/command/common.rb
         | 
| @@ -289,18 +288,12 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 289 288 | 
             
              - - ! '>='
         | 
| 290 289 | 
             
                - !ruby/object:Gem::Version
         | 
| 291 290 | 
             
                  version: '0'
         | 
| 292 | 
            -
                  segments:
         | 
| 293 | 
            -
                  - 0
         | 
| 294 | 
            -
                  hash: -1410145252245092295
         | 
| 295 291 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 296 292 | 
             
              none: false
         | 
| 297 293 | 
             
              requirements:
         | 
| 298 294 | 
             
              - - ! '>='
         | 
| 299 295 | 
             
                - !ruby/object:Gem::Version
         | 
| 300 296 | 
             
                  version: '0'
         | 
| 301 | 
            -
                  segments:
         | 
| 302 | 
            -
                  - 0
         | 
| 303 | 
            -
                  hash: -1410145252245092295
         | 
| 304 297 | 
             
            requirements: []
         | 
| 305 298 | 
             
            rubyforge_project: 
         | 
| 306 299 | 
             
            rubygems_version: 1.8.23
         | 
| @@ -317,3 +310,4 @@ test_files: | |
| 317 310 | 
             
            - spec/spec_helper.rb
         | 
| 318 311 | 
             
            - spec/td/helpers_spec.rb
         | 
| 319 312 | 
             
            - spec/td/version_spec.rb
         | 
| 313 | 
            +
            has_rdoc: false
         | 
    
        data/lib/td/command/aggr.rb
    DELETED
    
    | @@ -1,208 +0,0 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
            module TreasureData
         | 
| 3 | 
            -
            module Command
         | 
| 4 | 
            -
             | 
| 5 | 
            -
              def aggr_list(op)
         | 
| 6 | 
            -
                op.cmd_parse
         | 
| 7 | 
            -
             | 
| 8 | 
            -
                client = get_client
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                ass = client.aggregation_schemas
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                rows = []
         | 
| 13 | 
            -
                ass.each {|as|
         | 
| 14 | 
            -
                  rows << {:Name=>as.name, :Relation=>as.relation_key, :Timezone=>as.timezone}
         | 
| 15 | 
            -
                }
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                puts cmd_render_table(rows, :fields => [:Name, :Relation, :Timezone])
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                if rows.empty?
         | 
| 20 | 
            -
                  $stderr.puts "There are no aggregation schemas."
         | 
| 21 | 
            -
                  $stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "aggr:create <name>' to create a aggregation schema."
         | 
| 22 | 
            -
                end
         | 
| 23 | 
            -
              end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
              def aggr_show(op)
         | 
| 26 | 
            -
                name = op.cmd_parse
         | 
| 27 | 
            -
             | 
| 28 | 
            -
                client = get_client
         | 
| 29 | 
            -
             | 
| 30 | 
            -
                begin
         | 
| 31 | 
            -
                  as = client.aggregation_schema(name)
         | 
| 32 | 
            -
                rescue
         | 
| 33 | 
            -
                  cmd_debug_error $!
         | 
| 34 | 
            -
                  $stderr.puts "Aggregation '#{name}' does not exist."
         | 
| 35 | 
            -
                  exit 1
         | 
| 36 | 
            -
                end
         | 
| 37 | 
            -
             | 
| 38 | 
            -
                log_rows = []
         | 
| 39 | 
            -
                as.logs.each {|las|
         | 
| 40 | 
            -
                  log_rows << {
         | 
| 41 | 
            -
                    :Table=>las.table.identifier,
         | 
| 42 | 
            -
                    :Name=>las.name,
         | 
| 43 | 
            -
                    :o1_key=>las.okeys[0].to_s,
         | 
| 44 | 
            -
                    :o2_key=>las.okeys[1].to_s,
         | 
| 45 | 
            -
                    :o3_key=>las.okeys[2].to_s,
         | 
| 46 | 
            -
                    :value_key=>las.value_key.to_s,
         | 
| 47 | 
            -
                    :count_key=>las.count_key.to_s,
         | 
| 48 | 
            -
                    :Comment=>las.comment.to_s
         | 
| 49 | 
            -
                  }
         | 
| 50 | 
            -
                }
         | 
| 51 | 
            -
             | 
| 52 | 
            -
                attr_rows = []
         | 
| 53 | 
            -
                as.attributes.each {|aas|
         | 
| 54 | 
            -
                  params = aas.parameters.to_a.map {|k,v| "#{k}=#{v}" }.join(' ')
         | 
| 55 | 
            -
                  attr_rows << {
         | 
| 56 | 
            -
                    :Table=>aas.table.identifier,
         | 
| 57 | 
            -
                    :Name=>aas.name,
         | 
| 58 | 
            -
                    :Method=>aas.method_name,
         | 
| 59 | 
            -
                    :Parameters=>params,
         | 
| 60 | 
            -
                    :Comment=>aas.comment.to_s,
         | 
| 61 | 
            -
                  }
         | 
| 62 | 
            -
                }
         | 
| 63 | 
            -
             | 
| 64 | 
            -
                puts "Log entries:"
         | 
| 65 | 
            -
                puts cmd_render_table(log_rows, :fields => [:Table, :Name, :o1_key, :o2_key, :o3_key, :value_key, :count_key, :Comment], :max_width=>400)
         | 
| 66 | 
            -
             | 
| 67 | 
            -
                puts ''
         | 
| 68 | 
            -
             | 
| 69 | 
            -
                puts "Attribute entries:"
         | 
| 70 | 
            -
                puts cmd_render_table(attr_rows, :fields => [:Table, :Name, :Method, :Parameters, :Comment], :max_width=>400)
         | 
| 71 | 
            -
              end
         | 
| 72 | 
            -
             | 
| 73 | 
            -
              def aggr_create(op)
         | 
| 74 | 
            -
                timezone = nil
         | 
| 75 | 
            -
             | 
| 76 | 
            -
                op.on('-t', '--timezone TZ', 'name of the timezone (like Asia/Tokyo)') {|s|
         | 
| 77 | 
            -
                  timezone = s
         | 
| 78 | 
            -
                }
         | 
| 79 | 
            -
             | 
| 80 | 
            -
                name, relation_key = op.cmd_parse
         | 
| 81 | 
            -
             | 
| 82 | 
            -
                client = get_client
         | 
| 83 | 
            -
             | 
| 84 | 
            -
                begin
         | 
| 85 | 
            -
                  client.create_aggregation_schema(name, relation_key, {'timezone'=>timezone})
         | 
| 86 | 
            -
                rescue AlreadyExistsError
         | 
| 87 | 
            -
                  cmd_debug_error $!
         | 
| 88 | 
            -
                  $stderr.puts "Aggregation '#{name}' already exists."
         | 
| 89 | 
            -
                  exit 1
         | 
| 90 | 
            -
                end
         | 
| 91 | 
            -
             | 
| 92 | 
            -
                $stderr.puts "Aggregation schema '#{name}' is created."
         | 
| 93 | 
            -
              end
         | 
| 94 | 
            -
             | 
| 95 | 
            -
              def aggr_delete(op)
         | 
| 96 | 
            -
                name = op.cmd_parse
         | 
| 97 | 
            -
             | 
| 98 | 
            -
                client = get_client
         | 
| 99 | 
            -
             | 
| 100 | 
            -
                client.delete_aggregation_schema(name)
         | 
| 101 | 
            -
             | 
| 102 | 
            -
                $stderr.puts "Aggregation schema '#{name}' is deleted."
         | 
| 103 | 
            -
              end
         | 
| 104 | 
            -
             | 
| 105 | 
            -
              def aggr_add_log(op)
         | 
| 106 | 
            -
                comment = nil
         | 
| 107 | 
            -
                value_key = nil
         | 
| 108 | 
            -
                count_key = nil
         | 
| 109 | 
            -
             | 
| 110 | 
            -
                op.on('-m', '--comment COMMENT', 'comment of this entry') {|s|
         | 
| 111 | 
            -
                  comment = s
         | 
| 112 | 
            -
                }
         | 
| 113 | 
            -
                op.on('-v', '--value KEY_NAME', 'key name of value field') {|s|
         | 
| 114 | 
            -
                  value_key = s
         | 
| 115 | 
            -
                }
         | 
| 116 | 
            -
                op.on('-c', '--count KEY_NAME', 'key name of count field') {|s|
         | 
| 117 | 
            -
                  count_key = s
         | 
| 118 | 
            -
                }
         | 
| 119 | 
            -
             | 
| 120 | 
            -
                name, db_name, table_name, entry_name, o1_key, o2_key, o3_key = op.cmd_parse
         | 
| 121 | 
            -
             | 
| 122 | 
            -
                okeys = [o1_key, o2_key, o3_key].compact
         | 
| 123 | 
            -
             | 
| 124 | 
            -
                client = get_client
         | 
| 125 | 
            -
             | 
| 126 | 
            -
                get_table(client, db_name, table_name)
         | 
| 127 | 
            -
             | 
| 128 | 
            -
                begin
         | 
| 129 | 
            -
                  client.create_aggregation_log_entry(name, entry_name, comment, db_name, table_name, okeys, value_key, count_key)
         | 
| 130 | 
            -
                rescue NotFoundError
         | 
| 131 | 
            -
                  cmd_debug_error $!
         | 
| 132 | 
            -
                  $stderr.puts "Aggregation schema '#{name}' does not exist."
         | 
| 133 | 
            -
                  $stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "aggr:create #{name}' to create the aggregation schema."
         | 
| 134 | 
            -
                  exit 1
         | 
| 135 | 
            -
                rescue AlreadyExistsError
         | 
| 136 | 
            -
                  $stderr.puts "Aggregation log entry '#{entry_name}' already exists."
         | 
| 137 | 
            -
                  exit 1
         | 
| 138 | 
            -
                end
         | 
| 139 | 
            -
             | 
| 140 | 
            -
                $stderr.puts "Aggregation log entry '#{entry_name}' is created."
         | 
| 141 | 
            -
              end
         | 
| 142 | 
            -
             | 
| 143 | 
            -
              def aggr_add_attr(op)
         | 
| 144 | 
            -
                comment = nil
         | 
| 145 | 
            -
             | 
| 146 | 
            -
                op.on('-m', '--comment COMMENT', 'comment of this entry') {|s|
         | 
| 147 | 
            -
                  comment = s
         | 
| 148 | 
            -
                }
         | 
| 149 | 
            -
             | 
| 150 | 
            -
                name, db_name, table_name, entry_name, method_name, *parameters = op.cmd_parse
         | 
| 151 | 
            -
             | 
| 152 | 
            -
                params = {}
         | 
| 153 | 
            -
                parameters.each {|pa|
         | 
| 154 | 
            -
                  k, v = pa.split('=')
         | 
| 155 | 
            -
                  params[k] = v
         | 
| 156 | 
            -
                }
         | 
| 157 | 
            -
             | 
| 158 | 
            -
                client = get_client
         | 
| 159 | 
            -
             | 
| 160 | 
            -
                get_table(client, db_name, table_name)
         | 
| 161 | 
            -
             | 
| 162 | 
            -
                begin
         | 
| 163 | 
            -
                  client.create_aggregation_attr_entry(name, entry_name, comment, db_name, table_name, method_name, params)
         | 
| 164 | 
            -
                rescue NotFoundError
         | 
| 165 | 
            -
                  cmd_debug_error $!
         | 
| 166 | 
            -
                  $stderr.puts "Aggregation schema '#{name}' does not exist."
         | 
| 167 | 
            -
                  $stderr.puts "Use '#{$prog} " + Config.cl_apikey_string + "aggr:create #{name}' to create the aggregation schema."
         | 
| 168 | 
            -
                  exit 1
         | 
| 169 | 
            -
                rescue AlreadyExistsError
         | 
| 170 | 
            -
                  $stderr.puts "Aggregation attribute entry '#{entry_name}' already exists."
         | 
| 171 | 
            -
                  exit 1
         | 
| 172 | 
            -
                end
         | 
| 173 | 
            -
             | 
| 174 | 
            -
                $stderr.puts "Aggregation attribute entry '#{entry_name}' is created."
         | 
| 175 | 
            -
              end
         | 
| 176 | 
            -
             | 
| 177 | 
            -
              def aggr_del_log(op)
         | 
| 178 | 
            -
                name, entry_name = op.cmd_parse
         | 
| 179 | 
            -
             | 
| 180 | 
            -
                client = get_client
         | 
| 181 | 
            -
             | 
| 182 | 
            -
                begin
         | 
| 183 | 
            -
                  client.delete_aggregation_log_entry(name, entry_name)
         | 
| 184 | 
            -
                rescue NotFoundError
         | 
| 185 | 
            -
                  $stderr.puts "Aggregation log entry '#{entry_name}' does not exist."
         | 
| 186 | 
            -
                  exit 1
         | 
| 187 | 
            -
                end
         | 
| 188 | 
            -
             | 
| 189 | 
            -
                $stderr.puts "Aggregation log entry '#{entry_name}' is deleted."
         | 
| 190 | 
            -
              end
         | 
| 191 | 
            -
             | 
| 192 | 
            -
              def aggr_del_attr(op)
         | 
| 193 | 
            -
                name, entry_name = op.cmd_parse
         | 
| 194 | 
            -
             | 
| 195 | 
            -
                client = get_client
         | 
| 196 | 
            -
             | 
| 197 | 
            -
                begin
         | 
| 198 | 
            -
                  client.delete_aggregation_attr_entry(name, entry_name)
         | 
| 199 | 
            -
                rescue NotFoundError
         | 
| 200 | 
            -
                  $stderr.puts "Aggregation log entry '#{entry_name}' does not exist."
         | 
| 201 | 
            -
                  exit 1
         | 
| 202 | 
            -
                end
         | 
| 203 | 
            -
             | 
| 204 | 
            -
                $stderr.puts "Aggregation log entry '#{entry_name}' is deleted."
         | 
| 205 | 
            -
              end
         | 
| 206 | 
            -
             | 
| 207 | 
            -
            end
         | 
| 208 | 
            -
            end
         |