td-client 0.8.27 → 0.8.28

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,4 +1,10 @@
1
1
 
2
+ == 2012-09-17 version 0.8.28
3
+
4
+ * Added Client#core_utilization method
5
+ * Added Account#guaranteed_cores and #maximum_cores methods
6
+
7
+
2
8
  == 2012-09-17 version 0.8.27
3
9
 
4
10
  * Added Table#estimated_storage_size_string
data/lib/td/client.rb CHANGED
@@ -43,10 +43,15 @@ class Client
43
43
 
44
44
  # => Account
45
45
  def account
46
- plan, storage = @api.show_account
46
+ plan, storage, guaranteed_cores, maximum_cores = @api.show_account
47
47
  return Account.new(self, plan, storage)
48
48
  end
49
49
 
50
+ def core_utilization(from, to)
51
+ from, to, interval, history = @api.account_core_utilization(from, to)
52
+ return from, to, interval, history
53
+ end
54
+
50
55
  # => [Database]
51
56
  def databases
52
57
  m = @api.list_databases
data/lib/td/client/api.rb CHANGED
@@ -159,7 +159,25 @@ class API
159
159
  a = js["account"]
160
160
  plan = a['plan'].to_i
161
161
  storage_size = a['storage_size'].to_i
162
- return [plan, storage_size]
162
+ guaranteed_cores = a['guaranteed_cores'].to_i
163
+ maximum_cores = a['maximum_cores'].to_i
164
+ return [plan, storage_size, guaranteed_cores, maximum_cores]
165
+ end
166
+
167
+ def account_core_utilization(from, to)
168
+ params = { }
169
+ params['from'] = from.to_s if from
170
+ params['to'] = to.to_s if to
171
+ code, body, res = get("/v3/account/core_utilization", params)
172
+ if code != "200"
173
+ raise_error("Show account failed", res)
174
+ end
175
+ js = checked_json(body, %w[from to interval history])
176
+ from = Time.parse(js['from']).utc
177
+ to = Time.parse(js['to']).utc
178
+ interval = js['interval'].to_i
179
+ history = js['history']
180
+ return [from, to, interval, history]
163
181
  end
164
182
 
165
183
 
@@ -11,13 +11,15 @@ class Model
11
11
  end
12
12
 
13
13
  class Account < Model
14
- def initialize(client, plan, storage_size=nil)
14
+ def initialize(client, plan, storage_size=nil, guaranteed_cores=nil, maximum_cores=nil)
15
15
  super(client)
16
16
  @plan = plan
17
17
  @storage_size = storage_size
18
+ @guaranteed_cores = guaranteed_cores
19
+ @maximum_cores = maximum_cores
18
20
  end
19
21
 
20
- attr_reader :plan, :storage_size
22
+ attr_reader :plan, :storage_size, :guaranteed_cores, :maximum_cores
21
23
 
22
24
  def storage_size_string
23
25
  if @storage_size <= 1024*1024
@@ -1,5 +1,5 @@
1
1
  module TreasureData
2
2
 
3
- VERSION = '0.8.27'
3
+ VERSION = '0.8.28'
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.27
4
+ version: 0.8.28
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: 2012-09-17 00:00:00.000000000 Z
12
+ date: 2012-09-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: msgpack