td-client 0.8.45 → 0.8.46

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-03-29 version 0.8.46
2
+
3
+ * Add IP limitation API
4
+
5
+
1
6
  == 2012-01-25 version 0.8.45
2
7
 
3
8
  * Re-implement Client#job_status using /v3/job/status/job_id
data/lib/td/client.rb CHANGED
@@ -418,6 +418,21 @@ class Client
418
418
  @api.test_access_control(user, action, scope)
419
419
  end
420
420
 
421
+ def ip_limits
422
+ ips = @api.list_ip_limits
423
+ ips.map { |org, ipaddr, mask|
424
+ IpLimit.new(self, org, ipaddr, mask)
425
+ }
426
+ end
427
+
428
+ def set_ip_limit(org, ip_ranges)
429
+ @api.set_ip_limit(org, ip_ranges.to_json)
430
+ end
431
+
432
+ def delete_ip_limit(org)
433
+ @api.delete_ip_limit(org)
434
+ end
435
+
421
436
  # => [AggregationSchema]
422
437
  def aggregation_schemas
423
438
  list = @api.list_aggregation_schema
data/lib/td/client/api.rb CHANGED
@@ -1218,6 +1218,42 @@ class API
1218
1218
  return acl
1219
1219
  end
1220
1220
 
1221
+ ####
1222
+ ## IP Range Limit API
1223
+ ##
1224
+
1225
+ def list_ip_limits
1226
+ code, body, res = get("/v3/ip_limit/list")
1227
+ if code != "200"
1228
+ raise_error("Listing IP limitations failed", res)
1229
+ end
1230
+ js = checked_json(body, %w[ip_limits])
1231
+ lists = js["ip_limits"].map { |ip_limit|
1232
+ organization = ip_limit['organization']
1233
+ address = ip_limit['address']
1234
+ mask = ip_limit['mask']
1235
+ [organization, address, mask]
1236
+ }
1237
+ return lists
1238
+ end
1239
+
1240
+ def set_ip_limit(organization, ip_ranges)
1241
+ params = {'organization' => organization, 'ip_ranges' => ip_ranges}
1242
+ code, body, res = post("/v3/ip_limit/set", params)
1243
+ if code != "200"
1244
+ raise_error("Setting IP limitation failed", res)
1245
+ end
1246
+ return true
1247
+ end
1248
+
1249
+ def delete_ip_limit(organization)
1250
+ params = {'organization' => organization}
1251
+ code, body, res = post("/v3/ip_limit/delete", params)
1252
+ if code != "200"
1253
+ raise_error("Deleting IP range limitation failed", res)
1254
+ end
1255
+ return true
1256
+ end
1221
1257
 
1222
1258
  ####
1223
1259
  ## Server Status API
@@ -491,6 +491,22 @@ class AccessControl < Model
491
491
  end
492
492
 
493
493
 
494
+ class IpLimit < Model
495
+ def initialize(client, org, address, mask)
496
+ super(client)
497
+ @org = org
498
+ @address = address
499
+ @mask = mask
500
+ end
501
+
502
+ def ip_range
503
+ "#{address}/#{mask}"
504
+ end
505
+
506
+ attr_reader :org, :address, :mask
507
+ end
508
+
509
+
494
510
  class AggregationSchema < Model
495
511
  def initialize(client, name, relation_key, logs=nil, attributes=nil, timezone=nil)
496
512
  super(client)
@@ -1,5 +1,5 @@
1
1
  module TreasureData
2
2
 
3
- VERSION = '0.8.45'
3
+ VERSION = '0.8.46'
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.45
4
+ version: 0.8.46
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-01-25 00:00:00.000000000 Z
12
+ date: 2013-03-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: msgpack