td-client 0.8.53 → 0.8.54

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ == 2012-08-23 version 0.8.54
2
+
3
+ * Support table's expire_days API
4
+
5
+
1
6
  == 2012-07-22 version 0.8.53
2
7
 
3
8
  * Add normalized_msgpack method to serialize Bignum type
data/lib/td/client.rb CHANGED
@@ -91,6 +91,11 @@ class Client
91
91
  @api.update_schema(db_name, table_name, schema.to_json)
92
92
  end
93
93
 
94
+ # => true
95
+ def update_expire(db_name, table_name, expire_days)
96
+ @api.update_expire(db_name, table_name, expire_days)
97
+ end
98
+
94
99
  # => type:Symbol
95
100
  def delete_table(db_name, table_name)
96
101
  @api.delete_table(db_name, table_name)
@@ -99,10 +104,10 @@ class Client
99
104
  # => [Table]
100
105
  def tables(db_name)
101
106
  m = @api.list_tables(db_name)
102
- m.map {|table_name,(type,schema,count,created_at,updated_at,estimated_storage_size, last_import, last_log_timestamp)|
107
+ m.map {|table_name,(type,schema,count,created_at,updated_at,estimated_storage_size, last_import, last_log_timestamp, expire_days)|
103
108
  schema = Schema.new.from_json(schema)
104
109
  Table.new(self, db_name, table_name, type, schema, count, created_at, updated_at,
105
- estimated_storage_size, last_import, last_log_timestamp)
110
+ estimated_storage_size, last_import, last_log_timestamp, expire_days)
106
111
  }
107
112
  end
108
113
 
data/lib/td/client/api.rb CHANGED
@@ -264,7 +264,8 @@ class API
264
264
  last_log_timestamp = m['last_log_timestamp']
265
265
  estimated_storage_size = m['estimated_storage_size'].to_i
266
266
  schema = JSON.parse(m['schema'] || '[]')
267
- result[name] = [type, schema, count, created_at, updated_at, estimated_storage_size, last_import, last_log_timestamp]
267
+ expire_days = m['expire_days']
268
+ result[name] = [type, schema, count, created_at, updated_at, estimated_storage_size, last_import, last_log_timestamp, expire_days]
268
269
  }
269
270
  return result
270
271
  end
@@ -316,6 +317,14 @@ class API
316
317
  return true
317
318
  end
318
319
 
320
+ def update_expire(db, table, expire_days)
321
+ code, body, res = post("/v3/table/update/#{e db}/#{e table}", {'expire_days'=>expire_days})
322
+ if code != "200"
323
+ raise_error("Update table expiration failed", res)
324
+ end
325
+ return true
326
+ end
327
+
319
328
  # => type:Symbol
320
329
  def delete_table(db, table)
321
330
  code, body, res = post("/v3/table/delete/#{e db}/#{e table}")
@@ -98,7 +98,7 @@ class Database < Model
98
98
  end
99
99
 
100
100
  class Table < Model
101
- def initialize(client, db_name, table_name, type, schema, count, created_at=nil, updated_at=nil, estimated_storage_size=nil, last_import=nil, last_log_timestamp=nil)
101
+ def initialize(client, db_name, table_name, type, schema, count, created_at=nil, updated_at=nil, estimated_storage_size=nil, last_import=nil, last_log_timestamp=nil, expire_days=nil)
102
102
  super(client)
103
103
  @db_name = db_name
104
104
  @table_name = table_name
@@ -110,6 +110,7 @@ class Table < Model
110
110
  @estimated_storage_size = estimated_storage_size
111
111
  @last_import = last_import
112
112
  @last_log_timestamp = last_log_timestamp
113
+ @expire_days = expire_days
113
114
  end
114
115
 
115
116
  attr_reader :type, :db_name, :table_name, :schema, :count, :estimated_storage_size
@@ -133,6 +134,10 @@ class Table < Model
133
134
  @last_log_timestamp && !@last_log_timestamp.empty? ? Time.parse(@last_log_timestamp) : nil
134
135
  end
135
136
 
137
+ def expire_days
138
+ @expire_days ? @expire_days.to_i : nil
139
+ end
140
+
136
141
  def database
137
142
  @client.database(@db_name)
138
143
  end
@@ -1,5 +1,5 @@
1
1
  module TreasureData
2
2
  class Client
3
- VERSION = '0.8.53'
3
+ VERSION = '0.8.54'
4
4
  end
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.53
4
+ version: 0.8.54
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-07-22 00:00:00.000000000 Z
12
+ date: 2013-08-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: msgpack